fix(ekf2): use HAGL validity for range height ref

This commit is contained in:
Wang Jiayue authored and Ramon Roche committed 2026-07-06 11:36:43 -07:00
1 parent cac770e333
commit 48bc4a8576
1 file changed
+2 -1
@@ -380,7 +380,8 @@ bool Ekf::checkHaglYawResetReq() const
// Check if height has increased sufficiently to be away from ground magnetic anomalies
// and request a yaw reset if not already requested.
static constexpr float mag_anomalies_max_hagl = 1.5f;
return isHeightAboveGroundEstimateValid() && (getHagl() > mag_anomalies_max_hagl);
const bool above_mag_anomalies = (getTerrainVPos() + _gpos.altitude()) > mag_anomalies_max_hagl;
return above_mag_anomalies;
}
#endif // CONFIG_EKF2_TERRAIN