From 59fa794818af2d2b9d6f2ae0e2b57a22bc0e3e6e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 1 Jan 2021 19:24:01 +1100 Subject: [PATCH] AP_NavEKF3: constrain vertical error this prevents a floating point exception with external AHRS --- libraries/AP_NavEKF3/AP_NavEKF3_core.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/AP_NavEKF3/AP_NavEKF3_core.cpp b/libraries/AP_NavEKF3/AP_NavEKF3_core.cpp index 4f14aee997..c5f92206d0 100644 --- a/libraries/AP_NavEKF3/AP_NavEKF3_core.cpp +++ b/libraries/AP_NavEKF3/AP_NavEKF3_core.cpp @@ -824,7 +824,7 @@ void NavEKF3_core::calcOutputStates() // Coefficients selected to place all three filter poles at omega const float CompFiltOmega = M_2PI * constrain_float(frontend->_hrt_filt_freq, 0.1f, 30.0f); float omega2 = CompFiltOmega * CompFiltOmega; - float pos_err = outputDataNew.position.z - vertCompFiltState.pos; + float pos_err = constrain_float(outputDataNew.position.z - vertCompFiltState.pos, -1e5, 1e5); float integ1_input = pos_err * omega2 * CompFiltOmega * imuDataNew.delVelDT; vertCompFiltState.acc += integ1_input; float integ2_input = delVelNav.z + (vertCompFiltState.acc + pos_err * omega2 * 3.0f) * imuDataNew.delVelDT;