From 6899767d28817b87beb3c71fee4efef3e7351509 Mon Sep 17 00:00:00 2001 From: Paul Riseborough Date: Sat, 17 Oct 2015 19:17:30 +1100 Subject: [PATCH] AP_NavEKF2: Disable magnetic field learning if we have no absolute position reference --- libraries/AP_NavEKF2/AP_NavEKF2_Control.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/AP_NavEKF2/AP_NavEKF2_Control.cpp b/libraries/AP_NavEKF2/AP_NavEKF2_Control.cpp index 1c95337af4..502856d3eb 100644 --- a/libraries/AP_NavEKF2/AP_NavEKF2_Control.cpp +++ b/libraries/AP_NavEKF2/AP_NavEKF2_Control.cpp @@ -70,8 +70,9 @@ void NavEKF2_core::setWindMagStateLearningMode() ((frontend._magCal == 3) && firstMagYawInit) || // when initial in-air yaw and field reset has completed (frontend._magCal == 4); // all the time - // Deny mag calibration request if we aren't using the compass or it has been inhibited by the user - bool magCalDenied = !use_compass() || (frontend._magCal == 2); + // Deny mag calibration request if we aren't using the compass, it has been inhibited by the user, or we do not have an absolute position reference + // If we do nto have absolute position (eg GPS) then the earth field states cannot be learned + bool magCalDenied = !use_compass() || (frontend._magCal == 2) || (PV_AidingMode != AID_ABSOLUTE); // Inhibit the magnetic field calibration if not requested or denied inhibitMagStates = (!magCalRequested || magCalDenied);