Skip to content

Commit 9fd6621

Browse files
author
Richard Unger
committed
check returned sensor angle is non-negative
1 parent 7b336cf commit 9fd6621

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/common/base_classes/Sensor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
void Sensor::update() {
88
float val = getSensorAngle();
9+
if (val<0) // sensor angles are strictly non-negative. Negative values are used to signal errors.
10+
return; // TODO signal error, e.g. via a flag and counter
911
angle_prev_ts = _micros();
1012
float d_angle = val - angle_prev;
1113
// if overflow happened track it as full rotation

0 commit comments

Comments
 (0)