AP_AHRS: prevent a floating exception in update_trig

This commit is contained in:
Andrew Tridgell 2015-05-27 18:22:27 +10:00
parent b121d83beb
commit 00ca493860

View File

@ -255,7 +255,11 @@ void AP_AHRS::update_trig(void)
// sin_roll, sin_pitch
_sin_pitch = -temp.c.x;
_sin_roll = temp.c.y / _cos_pitch;
if (is_zero(_cos_pitch)) {
_sin_roll = sinf(roll);
} else {
_sin_roll = temp.c.y / _cos_pitch;
}
// sanity checks
if (yaw_vector.is_inf() || yaw_vector.is_nan()) {