Skip to content

Commit

Permalink
check returned sensor angle is non-negative
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Unger committed Nov 7, 2023
1 parent 7b336cf commit 9fd6621
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/common/base_classes/Sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9fd6621

Please sign in to comment.