diff --git a/libraries/AP_NavEKF/AP_NavEKF.cpp b/libraries/AP_NavEKF/AP_NavEKF.cpp index 0736e8bde8..a30ede5fd6 100644 --- a/libraries/AP_NavEKF/AP_NavEKF.cpp +++ b/libraries/AP_NavEKF/AP_NavEKF.cpp @@ -4529,6 +4529,12 @@ Quaternion NavEKF::calcQuatAndFieldStates(float roll, float pitch) yawAligned = false; } + if (!vehicleArmed) { + // The flags indicating that the in-air alignment has been completed need to be cleared + // because this alignment is on-ground and the yaw and field values could be incorrect. + secondMagYawInit = firstMagYawInit = false; + } + // return attitude quaternion return initQuat; }