From 9fd66216c100a76adc013686c07e2dc26a140918 Mon Sep 17 00:00:00 2001 From: Richard Unger Date: Wed, 8 Nov 2023 00:19:26 +0100 Subject: [PATCH] check returned sensor angle is non-negative --- src/common/base_classes/Sensor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/base_classes/Sensor.cpp b/src/common/base_classes/Sensor.cpp index a80fa438..b0a8f4db 100644 --- a/src/common/base_classes/Sensor.cpp +++ b/src/common/base_classes/Sensor.cpp @@ -6,6 +6,8 @@ void Sensor::update() { float val = getSensorAngle(); + if (val<0) // sensor angles are strictly non-negative. Negative values are used to signal errors. + return; // TODO signal error, e.g. via a flag and counter angle_prev_ts = _micros(); float d_angle = val - angle_prev; // if overflow happened track it as full rotation