mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 22:03:34 +08:00
EKF: Allow mag field estimates to stabilise before use
This commit is contained in:
@@ -1244,6 +1244,9 @@ void Ekf::controlMagFusion()
|
||||
_control_status.flags.update_mag_states_only = (_params.mag_fusion_type == MAG_FUSE_TYPE_AUTOFW)
|
||||
&& _control_status.flags.fixed_wing;
|
||||
|
||||
// For the first 10 seconds after switching to 3-axis fusion we allow the magnetic field state estimates to stabilise
|
||||
_flt_mag_align_converging = ((_imu_sample_delayed.time_us - _flt_mag_align_start_time) < (uint64_t)1e7);
|
||||
|
||||
if (!_control_status.flags.update_mag_states_only && _control_status_prev.flags.update_mag_states_only) {
|
||||
// When re-commencing use of magnetometer to correct vehicle states
|
||||
// set the field state variance to the observation variance and zero
|
||||
@@ -1293,6 +1296,12 @@ void Ekf::controlMagFusion()
|
||||
fuseDeclination();
|
||||
}
|
||||
|
||||
if (_flt_mag_align_converging) {
|
||||
_control_status.flags.mag_hdg = true;
|
||||
fuseHeading();
|
||||
_control_status.flags.mag_hdg = false;
|
||||
}
|
||||
|
||||
} else if (_control_status.flags.mag_hdg && _control_status.flags.yaw_align) {
|
||||
// fusion of an Euler yaw angle from either a 321 or 312 rotation sequence
|
||||
fuseHeading();
|
||||
|
||||
Reference in New Issue
Block a user