|
|
|
@ -51,13 +51,9 @@ void Ekf::controlFusionModes()
@@ -51,13 +51,9 @@ void Ekf::controlFusionModes()
|
|
|
|
|
// Get the magnetic declination
|
|
|
|
|
calcMagDeclination(); |
|
|
|
|
|
|
|
|
|
// Check for tilt convergence during initial alignment
|
|
|
|
|
// filter the tilt error vector using a 1 sec time constant LPF
|
|
|
|
|
float filt_coef = 1.0f * _imu_sample_delayed.delta_ang_dt; |
|
|
|
|
_tilt_err_length_filt = filt_coef * _tilt_err_vec.norm() + (1.0f - filt_coef) * _tilt_err_length_filt; |
|
|
|
|
|
|
|
|
|
// Once the tilt error has reduced sufficiently, initialise the yaw and magnetic field states
|
|
|
|
|
if (_tilt_err_length_filt < 0.005f && !_control_status.flags.tilt_align) { |
|
|
|
|
// Once the angular uncertainty has reduced sufficiently, initialise the yaw and magnetic field states
|
|
|
|
|
float total_angle_variance = P[0][0] + P[1][1] + P[2][2] + P[3][3]; |
|
|
|
|
if (total_angle_variance < 0.001f && !_control_status.flags.tilt_align) { |
|
|
|
|
_control_status.flags.tilt_align = true; |
|
|
|
|
_control_status.flags.yaw_align = resetMagHeading(_mag_sample_delayed.mag); |
|
|
|
|
} |
|
|
|
|