Skip to content

Commit

Permalink
AP_NavEKF: Ensure in-flight yaw alignment is performed if over-written
Browse files Browse the repository at this point in the history
Landing on a surface with a magnetic anomaly large enough to require the EKF to reset its field states can result in poor heading and large EKF magnetometer and velocity innovations if the vehicle is re-armed and takes off. This happens because the flags indicating that completion of the in-air yaw and field states was not being reset if a ground reset had occurred.
This patch ensures that any reset of magnetic field states that occurs whilst disarmed causes the flags to be reset.
  • Loading branch information
priseborough committed Sep 21, 2016
1 parent 13d4329 commit 14268ad
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libraries/AP_NavEKF/AP_NavEKF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 14268ad

Please sign in to comment.