From 2d09a5f3aca36391c9498113b1133c106c4404e6 Mon Sep 17 00:00:00 2001 From: Paul Riseborough Date: Wed, 24 Feb 2016 20:13:42 +1100 Subject: [PATCH] EKF: Don't reset yaw and mag field states when not necessary --- EKF/control.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/EKF/control.cpp b/EKF/control.cpp index d010b77552..7674d66d46 100644 --- a/EKF/control.cpp +++ b/EKF/control.cpp @@ -57,8 +57,10 @@ void Ekf::controlFusionModes() if (!_control_status.flags.gps) { if (_control_status.flags.tilt_align && (_time_last_imu - _time_last_gps) < 5e5 && _NED_origin_initialised && (_time_last_imu - _last_gps_fail_us > 5e6)) { - // Reset the yaw and magnetic field states - _control_status.flags.yaw_align = resetMagHeading(_mag_sample_delayed.mag); + // If the heading is not aligned, reset the yaw and magnetic field states + if (!_control_status.flags.yaw_align) { + _control_status.flags.yaw_align = resetMagHeading(_mag_sample_delayed.mag); + } // If the heading is valid, reset the positon and velocity and start using gps aiding if (_control_status.flags.yaw_align) {