From 854c43dde8c6ed0e52400a866eb1b7047b9d8f68 Mon Sep 17 00:00:00 2001 From: Marco Hauswirth Date: Wed, 15 Apr 2026 14:32:51 +0200 Subject: [PATCH] fix(ekf2): dont adjust inactive height bias estimators on altitude reset --- src/modules/ekf2/EKF/position_fusion.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/modules/ekf2/EKF/position_fusion.cpp b/src/modules/ekf2/EKF/position_fusion.cpp index cd11355578b..7e88ad46445 100644 --- a/src/modules/ekf2/EKF/position_fusion.cpp +++ b/src/modules/ekf2/EKF/position_fusion.cpp @@ -201,13 +201,25 @@ void Ekf::resetAltitudeTo(const float new_altitude, float new_vert_pos_var) updateVerticalPositionResetStatus(delta_z); #if defined(CONFIG_EKF2_BAROMETER) - _baro_b_est.setBias(_baro_b_est.getBias() + delta_z); + + if (_control_status.flags.baro_hgt) { + _baro_b_est.setBias(_baro_b_est.getBias() + delta_z); + } + #endif // CONFIG_EKF2_BAROMETER #if defined(CONFIG_EKF2_EXTERNAL_VISION) - _ev_hgt_b_est.setBias(_ev_hgt_b_est.getBias() - delta_z); + + if (_control_status.flags.ev_hgt) { + _ev_hgt_b_est.setBias(_ev_hgt_b_est.getBias() - delta_z); + } + #endif // CONFIG_EKF2_EXTERNAL_VISION #if defined(CONFIG_EKF2_GNSS) - _gps_hgt_b_est.setBias(_gps_hgt_b_est.getBias() + delta_z); + + if (_control_status.flags.gps_hgt) { + _gps_hgt_b_est.setBias(_gps_hgt_b_est.getBias() + delta_z); + } + #endif // CONFIG_EKF2_GNSS #if defined(CONFIG_EKF2_TERRAIN)