AP_InertialSensor: allow backend filters to be updated independently from a separate thread

This commit is contained in:
Andy Piper 2024-06-03 18:38:08 +01:00 committed by Peter Barker
parent 62e3c6a6a9
commit 98f3a4b7d5
2 changed files with 20 additions and 1 deletions

View File

@ -781,6 +781,14 @@ void AP_InertialSensor_Backend::update_gyro(uint8_t instance) /* front end */
_imu._new_gyro_data[instance] = false;
}
update_gyro_filters(instance);
}
/*
propagate filter changes from front end to backend
*/
void AP_InertialSensor_Backend::update_gyro_filters(uint8_t instance) /* front end */
{
// possibly update filter frequency
const float gyro_rate = _gyro_raw_sample_rate(instance);
@ -815,7 +823,16 @@ void AP_InertialSensor_Backend::update_accel(uint8_t instance) /* front end */
_publish_accel(instance, _imu._accel_filtered[instance]);
_imu._new_accel_data[instance] = false;
}
update_accel_filters(instance);
}
/*
propagate filter changes from front end to backend
*/
void AP_InertialSensor_Backend::update_accel_filters(uint8_t instance) /* front end */
{
// possibly update filter frequency
if (_last_accel_filter_hz != _accel_filter_cutoff()) {
_imu._accel_filter[instance].set_cutoff_frequency(_accel_raw_sample_rate(instance), _accel_filter_cutoff());

View File

@ -276,9 +276,11 @@ protected:
// common gyro update function for all backends
void update_gyro(uint8_t instance) __RAMFUNC__; /* front end */
void update_gyro_filters(uint8_t instance) __RAMFUNC__; /* front end */
// common accel update function for all backends
void update_accel(uint8_t instance) __RAMFUNC__; /* front end */
void update_accel_filters(uint8_t instance) __RAMFUNC__; /* front end */
// support for updating filter at runtime
uint16_t _last_accel_filter_hz;