mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 01:33:33 +08:00
EKF: Rework use of fuseDeclination()
Simplify calling so that it is only called in two ways: 1) Immediately before 3-axis mag fusion if not called since the last earth field covariance reset so that the earth field declination information can be formed. 2) Immediately after 3-axis mag fusion otherwise.
This commit is contained in:
committed by
Daniel Agar
parent
d52f53635b
commit
bd1647a7fb
+2
-3
@@ -847,6 +847,7 @@ void Ekf::fixCovarianceErrors()
|
||||
if (!_control_status.flags.mag_3D) {
|
||||
zeroRows(P, 16, 21);
|
||||
zeroCols(P, 16, 21);
|
||||
_mag_decl_cov_reset = false;
|
||||
|
||||
} else {
|
||||
// constrain variances
|
||||
@@ -887,15 +888,13 @@ void Ekf::resetMagCovariance()
|
||||
// set the magnetic field covariance terms to zero
|
||||
zeroRows(P, 16, 21);
|
||||
zeroCols(P, 16, 21);
|
||||
_mag_decl_cov_reset = false;
|
||||
|
||||
// set the field state variance to the observation variance
|
||||
for (uint8_t rc_index = 16; rc_index <= 21; rc_index ++) {
|
||||
P[rc_index][rc_index] = sq(_params.mag_noise);
|
||||
}
|
||||
|
||||
// Fuse the declination angle to prevent rapid rotation of earth field vector estimates
|
||||
fuseDeclination(0.02f);
|
||||
|
||||
// save covariance data for re-use when auto-switching between heading and 3-axis fusion
|
||||
save_mag_cov_data();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user