From 00ca493860ead25b6e9c2629f133fdfaf16f5cec Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 27 May 2015 18:22:27 +1000 Subject: [PATCH] AP_AHRS: prevent a floating exception in update_trig --- libraries/AP_AHRS/AP_AHRS.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/AP_AHRS/AP_AHRS.cpp b/libraries/AP_AHRS/AP_AHRS.cpp index d86d93dbe7..aab7dee011 100644 --- a/libraries/AP_AHRS/AP_AHRS.cpp +++ b/libraries/AP_AHRS/AP_AHRS.cpp @@ -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()) {