@ -167,10 +167,15 @@ void VehicleAngularVelocity::ResetFilters(const hrt_abstime &time_now_us)
@@ -167,10 +167,15 @@ void VehicleAngularVelocity::ResetFilters(const hrt_abstime &time_now_us)
_lp_filter_velocity [ axis ] . set_cutoff_frequency ( _filter_sample_rate_hz , _param_imu_gyro_cutoff . get ( ) ) ;
_lp_filter_velocity [ axis ] . reset ( angular_velocity_uncalibrated ( axis ) ) ;
// angular velocity notch
_notch_filter_velocity [ axis ] . setParameters ( _filter_sample_rate_hz , _param_imu_gyro_nf_freq . get ( ) ,
_param_imu_gyro_nf_bw . get ( ) ) ;
_notch_filter_velocity [ axis ] . reset ( ) ;
// angular velocity notch 0
_notch_filter0_velocity [ axis ] . setParameters ( _filter_sample_rate_hz , _param_imu_gyro_nf0_frq . get ( ) ,
_param_imu_gyro_nf0_bw . get ( ) ) ;
_notch_filter0_velocity [ axis ] . reset ( ) ;
// angular velocity notch 1
_notch_filter1_velocity [ axis ] . setParameters ( _filter_sample_rate_hz , _param_imu_gyro_nf1_frq . get ( ) ,
_param_imu_gyro_nf1_bw . get ( ) ) ;
_notch_filter1_velocity [ axis ] . reset ( ) ;
// angular acceleration low pass
if ( ( _param_imu_dgyro_cutoff . get ( ) > 0.f )
@ -360,11 +365,13 @@ void VehicleAngularVelocity::ParametersUpdate(bool force)
@@ -360,11 +365,13 @@ void VehicleAngularVelocity::ParametersUpdate(bool force)
parameter_update_s param_update ;
_parameter_update_sub . copy ( & param_update ) ;
const bool nf_enabled_prev = ( _param_imu_gyro_nf_freq . get ( ) > 0.f ) & & ( _param_imu_gyro_nf_bw . get ( ) > 0.f ) ;
const bool nf0_enabled_prev = ( _param_imu_gyro_nf0_frq . get ( ) > 0.f ) & & ( _param_imu_gyro_nf0_bw . get ( ) > 0.f ) ;
const bool nf1_enabled_prev = ( _param_imu_gyro_nf1_frq . get ( ) > 0.f ) & & ( _param_imu_gyro_nf1_bw . get ( ) > 0.f ) ;
updateParams ( ) ;
const bool nf_enabled = ( _param_imu_gyro_nf_freq . get ( ) > 0.f ) & & ( _param_imu_gyro_nf_bw . get ( ) > 0.f ) ;
const bool nf0_enabled = ( _param_imu_gyro_nf0_frq . get ( ) > 0.f ) & & ( _param_imu_gyro_nf0_bw . get ( ) > 0.f ) ;
const bool nf1_enabled = ( _param_imu_gyro_nf1_frq . get ( ) > 0.f ) & & ( _param_imu_gyro_nf1_bw . get ( ) > 0.f ) ;
_calibration . ParametersUpdate ( ) ;
@ -376,12 +383,23 @@ void VehicleAngularVelocity::ParametersUpdate(bool force)
@@ -376,12 +383,23 @@ void VehicleAngularVelocity::ParametersUpdate(bool force)
}
}
// gyro notch filter frequency or bandwidth changed
for ( auto & nf : _notch_filter_velocity ) {
const bool nf_freq_changed = ( fabsf ( nf . getNotchFreq ( ) - _param_imu_gyro_nf_fre q . get ( ) ) > 0.01f ) ;
const bool nf_bw_changed = ( fabsf ( nf . getBandwidth ( ) - _param_imu_gyro_nf_bw . get ( ) ) > 0.01f ) ;
// gyro notch filter 0 frequency or bandwidth changed
for ( auto & nf : _notch_filter0 _velocity ) {
const bool nf_freq_changed = ( fabsf ( nf . getNotchFreq ( ) - _param_imu_gyro_nf0 _frq . get ( ) ) > 0.01f ) ;
const bool nf_bw_changed = ( fabsf ( nf . getBandwidth ( ) - _param_imu_gyro_nf0 _bw . get ( ) ) > 0.01f ) ;
if ( ( nf_enabled_prev ! = nf_enabled ) | | ( nf_enabled & & ( nf_freq_changed | | nf_bw_changed ) ) ) {
if ( ( nf0_enabled_prev ! = nf0_enabled ) | | ( nf0_enabled & & ( nf_freq_changed | | nf_bw_changed ) ) ) {
_reset_filters = true ;
break ;
}
}
// gyro notch filter 1 frequency or bandwidth changed
for ( auto & nf : _notch_filter1_velocity ) {
const bool nf_freq_changed = ( fabsf ( nf . getNotchFreq ( ) - _param_imu_gyro_nf1_frq . get ( ) ) > 0.01f ) ;
const bool nf_bw_changed = ( fabsf ( nf . getBandwidth ( ) - _param_imu_gyro_nf1_bw . get ( ) ) > 0.01f ) ;
if ( ( nf1_enabled_prev ! = nf1_enabled ) | | ( nf1_enabled & & ( nf_freq_changed | | nf_bw_changed ) ) ) {
_reset_filters = true ;
break ;
}
@ -695,9 +713,14 @@ float VehicleAngularVelocity::FilterAngularVelocity(int axis, float data[], int
@@ -695,9 +713,14 @@ float VehicleAngularVelocity::FilterAngularVelocity(int axis, float data[], int
# endif // !CONSTRAINED_FLASH
// Apply general notch filter (IMU_GYRO_NF_FREQ)
if ( _notch_filter_velocity [ axis ] . getNotchFreq ( ) > 0.f ) {
_notch_filter_velocity [ axis ] . applyArray ( data , N ) ;
// Apply general notch filter 0 (IMU_GYRO_NF0_FRQ)
if ( _notch_filter0_velocity [ axis ] . getNotchFreq ( ) > 0.f ) {
_notch_filter0_velocity [ axis ] . applyArray ( data , N ) ;
}
// Apply general notch filter 1 (IMU_GYRO_NF1_FRQ)
if ( _notch_filter1_velocity [ axis ] . getNotchFreq ( ) > 0.f ) {
_notch_filter1_velocity [ axis ] . applyArray ( data , N ) ;
}
// Apply general low-pass filter (IMU_GYRO_CUTOFF)