mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 15:18:54 +08:00
ekf2-mag: do not use yaw emergency estimator to reset mag states
On slowly moving vehicles (e.g.: boats, rovers), the yaw estimator has worse convergence than the main EKF. Resetting the mag states using the yaw estimator as reference can lead to poor heading. Also, the EKF can recover really well from initially incorrect mag states.
This commit is contained in:
@@ -349,23 +349,7 @@ void Ekf::resetMagStates(const Vector3f &mag, bool reset_heading)
|
||||
* Vector3f(_mag_strength_gps, 0, 0);
|
||||
|
||||
// mag_B: reset
|
||||
#if defined(CONFIG_EKF2_GNSS)
|
||||
|
||||
if (isYawEmergencyEstimateAvailable()) {
|
||||
|
||||
const Dcmf R_to_earth = updateYawInRotMat(_yawEstimator.getYaw(), _R_to_earth);
|
||||
const Dcmf R_to_body = R_to_earth.transpose();
|
||||
|
||||
// mag_B: reset using WMM and yaw estimator
|
||||
_state.mag_B = mag - (R_to_body * mag_earth_pred);
|
||||
|
||||
ECL_INFO("resetMagStates using yaw estimator");
|
||||
|
||||
} else if (!reset_heading && _control_status.flags.yaw_align) {
|
||||
#else
|
||||
|
||||
if (!reset_heading && _control_status.flags.yaw_align) {
|
||||
#endif
|
||||
// mag_B: reset using WMM
|
||||
const Dcmf R_to_body = quatToInverseRotMat(_state.quat_nominal);
|
||||
_state.mag_B = mag - (R_to_body * mag_earth_pred);
|
||||
|
||||
Reference in New Issue
Block a user