Skip to content

Commit d62f112

Browse files
committed
ekf2: prevent false mag fault detection
A false positive could be triggered if velocity fusion started, then stopped after takeoff and only position fusion started again (because velocity fusion timed out and had a timestamp > time_last_on_ground). We now also check if the fusion timeout is due to the innovation being rejected (and not just a temporary check failure or data interruption).
1 parent 14186cf commit d62f112

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/modules/ekf2/EKF/aid_sources/gnss/gps_control.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,17 @@ void Ekf::controlGpsFusion(const imuSample &imu_delayed)
104104

105105
bool do_vel_pos_reset = false;
106106

107-
if (!_control_status.flags.gnss_fault && (_control_status.flags.gnss_vel || _control_status.flags.gnss_pos)) {
107+
if (!_control_status.flags.gnss_fault && _control_status.flags.in_air && isYawFailure()) {
108+
const bool velocity_fusion_failure = _aid_src_gnss_vel.innovation_rejected
109+
&& isTimedOut(_time_last_hor_vel_fuse, _params.EKFGSF_reset_delay)
110+
&& (_time_last_hor_vel_fuse > _time_last_on_ground_us);
108111

109-
if (_control_status.flags.in_air
110-
&& isYawFailure()
111-
&& isTimedOut(_time_last_hor_vel_fuse, _params.EKFGSF_reset_delay)
112-
&& (_time_last_hor_vel_fuse > _time_last_on_ground_us)) {
112+
const bool position_fusion_failure = _aid_src_gnss_pos.innovation_rejected
113+
&& isTimedOut(_time_last_hor_pos_fuse, _params.EKFGSF_reset_delay)
114+
&& (_time_last_hor_pos_fuse > _time_last_on_ground_us);
115+
116+
if ((_control_status.flags.gnss_vel && velocity_fusion_failure)
117+
|| (_control_status.flags.gnss_pos && position_fusion_failure)) {
113118
do_vel_pos_reset = tryYawEmergencyReset();
114119
}
115120
}

0 commit comments

Comments
 (0)