mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 09:33:33 +08:00
EKF: Update yaw innovation calculation to match revised derivation
The new derivation does not use magnetic field measurements in the observation model and instead fuses in a heading measurement directly.
This commit is contained in:
+7
-4
@@ -532,12 +532,15 @@ void Ekf::fuseHeading()
|
|||||||
H_YAW[1] = t14 * (t15 * (q0 * q1 * 2.0f - q2 * q3 * 2.0f) + t9 * t10 * (q0 * q2 * 2.0f + q1 * q3 * 2.0f));
|
H_YAW[1] = t14 * (t15 * (q0 * q1 * 2.0f - q2 * q3 * 2.0f) + t9 * t10 * (q0 * q2 * 2.0f + q1 * q3 * 2.0f));
|
||||||
H_YAW[2] = t14 * (t15 * (t2 - t3 + t4 - t5) + t9 * t10 * (t7 - t8));
|
H_YAW[2] = t14 * (t15 * (t2 - t3 + t4 - t5) + t9 * t10 * (t7 - t8));
|
||||||
|
|
||||||
// calculate innovation
|
// rotate body field magnetic field measurement into earth frame and compare horizontal vector with published declination to get yaw measurement
|
||||||
// rotate body field magnetic field measurement into earth frame and compare to published declination to get heading measurement
|
// TODO - enable use of an off-board yaw measurement
|
||||||
// TODO - enable use of an off-board heading measurement
|
|
||||||
matrix::Dcm<float> R_to_earth(_state.quat_nominal);
|
matrix::Dcm<float> R_to_earth(_state.quat_nominal);
|
||||||
matrix::Vector3f mag_earth_pred = R_to_earth * _mag_sample_delayed.mag;
|
matrix::Vector3f mag_earth_pred = R_to_earth * _mag_sample_delayed.mag;
|
||||||
float innovation = atan2f(mag_earth_pred(1), mag_earth_pred(0)) - _mag_declination;
|
float measured_yaw = atan2f(mag_earth_pred(1), mag_earth_pred(0)) - _mag_declination;
|
||||||
|
|
||||||
|
// calculate the innovation
|
||||||
|
matrix::Euler<float> euler(_state.quat_nominal);
|
||||||
|
float innovation = euler(2) - measured_yaw;
|
||||||
|
|
||||||
// wrap the innovation to the interval between +-pi
|
// wrap the innovation to the interval between +-pi
|
||||||
innovation = matrix::wrap_pi(innovation);
|
innovation = matrix::wrap_pi(innovation);
|
||||||
|
|||||||
Reference in New Issue
Block a user