@ -989,35 +989,16 @@ void EKF2::Run()
@@ -989,35 +989,16 @@ void EKF2::Run()
}
}
{
// publish all corrected sensor readings and bias estimates after mag calibration is updated above
bias . timestamp = now ;
// take device ids from sensor_selection_s if not using specific vehicle_imu_s
if ( _imu_sub_index < 0 ) {
bias . gyro_device_id = _sensor_selection . gyro_device_id ;
bias . accel_device_id = _sensor_selection . accel_device_id ;
}
bias . mag_device_id = _param_ekf2_magbias_id . get ( ) ;
// In-run bias estimates
_ekf . getGyroBias ( ) . copyTo ( bias . gyro_bias ) ;
_ekf . getAccelBias ( ) . copyTo ( bias . accel_bias ) ;
bias . mag_bias [ 0 ] = _last_valid_mag_cal [ 0 ] ;
bias . mag_bias [ 1 ] = _last_valid_mag_cal [ 1 ] ;
bias . mag_bias [ 2 ] = _last_valid_mag_cal [ 2 ] ;
_estimator_sensor_bias_pub . publish ( bias ) ;
}
// publish estimator states
estimator_states_s states ;
states . n_states = 24 ;
_ekf . getStateAtFusionHorizonAsVector ( ) . copyTo ( states . states ) ;
_ekf . covariances_diagonal ( ) . copyTo ( states . covariances ) ;
states . timestamp = _replay_mode ? now : hrt_absolute_time ( ) ;
_estimator_states_pub . publish ( states ) ;
// publish estimator status
estimator_status_s status ;
status . timestamp = now ;
_ekf . getStateAtFusionHorizonAsVector ( ) . copyTo ( status . states ) ;
status . n_states = 24 ;
_ekf . covariances_diagonal ( ) . copyTo ( status . covariances ) ;
estimator_status_s status { } ;
_ekf . getOutputTrackingError ( ) . copyTo ( status . output_tracking_error ) ;
_ekf . get_gps_check_status ( & status . gps_check_fail_flags ) ;
// only report enabled GPS check failures (the param indexes are shifted by 1 bit, because they don't include
@ -1035,8 +1016,6 @@ void EKF2::Run()
@@ -1035,8 +1016,6 @@ void EKF2::Run()
_ekf . get_ekf_soln_status ( & status . solution_status_flags ) ;
_ekf . getImuVibrationMetrics ( ) . copyTo ( status . vibe ) ;
status . time_slip = _last_time_slip_us * 1e-6 f ;
status . health_flags = 0.0f ; // unused
status . timeout_flags = 0.0f ; // unused
status . pre_flt_fail_innov_heading = _preflt_checker . hasHeadingFailed ( ) ;
status . pre_flt_fail_innov_vel_horiz = _preflt_checker . hasHorizVelFailed ( ) ;
status . pre_flt_fail_innov_vel_vert = _preflt_checker . hasVertVelFailed ( ) ;
@ -1045,6 +1024,29 @@ void EKF2::Run()
@@ -1045,6 +1024,29 @@ void EKF2::Run()
_estimator_status_pub . publish ( status ) ;
{
// publish all corrected sensor readings and bias estimates after mag calibration is updated above
bias . timestamp = now ;
// take device ids from sensor_selection_s if not using specific vehicle_imu_s
if ( _imu_sub_index < 0 ) {
bias . gyro_device_id = _sensor_selection . gyro_device_id ;
bias . accel_device_id = _sensor_selection . accel_device_id ;
}
bias . mag_device_id = _param_ekf2_magbias_id . get ( ) ;
// In-run bias estimates
_ekf . getGyroBias ( ) . copyTo ( bias . gyro_bias ) ;
_ekf . getAccelBias ( ) . copyTo ( bias . accel_bias ) ;
bias . mag_bias [ 0 ] = _last_valid_mag_cal [ 0 ] ;
bias . mag_bias [ 1 ] = _last_valid_mag_cal [ 1 ] ;
bias . mag_bias [ 2 ] = _last_valid_mag_cal [ 2 ] ;
_estimator_sensor_bias_pub . publish ( bias ) ;
}
// publish GPS drift data only when updated to minimise overhead
float gps_drift [ 3 ] ;
bool blocked ;
@ -1103,8 +1105,8 @@ void EKF2::Run()
@@ -1103,8 +1105,8 @@ void EKF2::Run()
bool all_estimates_invalid = false ;
for ( uint8_t axis_index = 0 ; axis_index < = 2 ; axis_index + + ) {
if ( statu s . covariances [ axis_index + 19 ] < min_var_allowed
| | statu s . covariances [ axis_index + 19 ] > max_var_allowed ) {
if ( state s . covariances [ axis_index + 19 ] < min_var_allowed
| | state s . covariances [ axis_index + 19 ] > max_var_allowed ) {
all_estimates_invalid = true ;
}
}
@ -1112,9 +1114,9 @@ void EKF2::Run()
@@ -1112,9 +1114,9 @@ void EKF2::Run()
// Store valid estimates and their associated variances
if ( ! all_estimates_invalid ) {
for ( uint8_t axis_index = 0 ; axis_index < = 2 ; axis_index + + ) {
_last_valid_mag_cal [ axis_index ] = statu s . states [ axis_index + 19 ] ;
_last_valid_mag_cal [ axis_index ] = state s . states [ axis_index + 19 ] ;
_valid_cal_available [ axis_index ] = true ;
_last_valid_variance [ axis_index ] = statu s . covariances [ axis_index + 19 ] ;
_last_valid_variance [ axis_index ] = state s . covariances [ axis_index + 19 ] ;
}
}
}