@ -879,10 +879,7 @@ void Ekf::resetMagBias()
@@ -879,10 +879,7 @@ void Ekf::resetMagBias()
P . uncorrelateCovarianceSetVariance < 3 > ( 19 , sq ( _params . mag_noise ) ) ;
// reset any saved covariance data for re-use when auto-switching between heading and 3-axis fusion
// _saved_mag_bf_variance[0] is the the D earth axis
_saved_mag_bf_variance [ 1 ] = 0 ;
_saved_mag_bf_variance [ 2 ] = 0 ;
_saved_mag_bf_variance [ 3 ] = 0 ;
_saved_mag_bf_variance . zero ( ) ;
}
// get EKF innovation consistency check status information comprising of:
@ -1487,24 +1484,30 @@ void Ekf::increaseQuatYawErrVariance(float yaw_variance)
@@ -1487,24 +1484,30 @@ void Ekf::increaseQuatYawErrVariance(float yaw_variance)
// save covariance data for re-use when auto-switching between heading and 3-axis fusion
void Ekf : : saveMagCovData ( )
{
// save variances for the D earth axis and XYZ body axis field
for ( uint8_t index = 0 ; index < = 3 ; index + + ) {
_saved_mag_bf_variance [ index ] = P ( index + 18 , index + 18 ) ;
}
// save variances for XYZ body axis field
_saved_mag_bf_variance ( 0 ) = P ( 19 , 19 ) ;
_saved_mag_bf_variance ( 1 ) = P ( 20 , 20 ) ;
_saved_mag_bf_variance ( 2 ) = P ( 21 , 21 ) ;
// save the NE axis covariance sub-matrix
_saved_mag_ef_covmat = P . slice < 2 , 2 > ( 16 , 16 ) ;
_saved_mag_ef_ne_covmat = P . slice < 2 , 2 > ( 16 , 16 ) ;
// save variance for the D earth axis
_saved_mag_ef_d_variance = P ( 18 , 18 ) ;
}
void Ekf : : loadMagCovData ( )
{
// re-instate variances for the D earth axis and XYZ body axis field
for ( uint8_t index = 0 ; index < = 3 ; index + + ) {
P ( index + 18 , index + 18 ) = _saved_mag_bf_variance [ index ] ;
}
// re-instate variances for the XYZ body axis field
P ( 19 , 19 ) = _saved_mag_bf_variance ( 0 ) ;
P ( 20 , 20 ) = _saved_mag_bf_variance ( 1 ) ;
P ( 21 , 21 ) = _saved_mag_bf_variance ( 2 ) ;
// re-instate the NE axis covariance sub-matrix
P . slice < 2 , 2 > ( 16 , 16 ) = _saved_mag_ef_covmat ;
P . slice < 2 , 2 > ( 16 , 16 ) = _saved_mag_ef_ne_covmat ;
// re-instate the D earth axis variance
P ( 18 , 18 ) = _saved_mag_ef_d_variance ;
}
void Ekf : : startAirspeedFusion ( )