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

This commit is contained in:
Wang Jiayue
2026-06-02 14:14:20 +08:00
committed by Ramon Roche
parent cac770e333
commit 48bc4a8576

View File

@@ -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