Skip to content

Commit

Permalink
Fix a bug in RoundAngle.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tao Du committed Aug 3, 2018
1 parent bfae716 commit 19fcbdd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion projects/copter_simulation/src/inertia_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ const double RoundAngle(const double radian) {
// round_radian is in (-2pi, 2pi) now.
if (round_radian < -M_PI) round_radian += period;
else if (round_radian > M_PI) round_radian -= period;
assert(radian >= -M_PI && radian <= M_PI);
// Clamp in case we have numerical errors.
if (round_radian > M_PI) round_radian = M_PI;
if (round_radian < -M_PI) round_radian = -M_PI;
return round_radian;
}

Expand Down

0 comments on commit 19fcbdd

Please sign in to comment.