From 573b3210dd7202ba2e28956c275292511c17da3c Mon Sep 17 00:00:00 2001 From: Paul Riseborough Date: Sun, 2 Mar 2014 08:07:25 +1100 Subject: [PATCH] AP_NavEKF : Add div0 protection to the IMU1_weighting calc --- libraries/AP_NavEKF/AP_NavEKF.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/AP_NavEKF/AP_NavEKF.cpp b/libraries/AP_NavEKF/AP_NavEKF.cpp index 322ead78d1..5b6befe29e 100644 --- a/libraries/AP_NavEKF/AP_NavEKF.cpp +++ b/libraries/AP_NavEKF/AP_NavEKF.cpp @@ -1545,9 +1545,9 @@ void NavEKF::FuseVelPosNED() // observation error to normalise float R_hgt; if (i == 2) { - R_hgt = sq(_gpsVertVelNoise); + R_hgt = sq(constrain_float(_gpsVertVelNoise, 0.05f, 5.0f)); } else { - R_hgt = sq(_gpsHorizVelNoise); + R_hgt = sq(constrain_float(_gpsHorizVelNoise, 0.05f, 5.0f)); } K1 += R_hgt / (R_hgt + sq(velInnov1[i])); K2 += R_hgt / (R_hgt + sq(velInnov2[i]));