Skip to content

Commit

Permalink
AP_InertialSensor: allow backend filters to be updated independently …
Browse files Browse the repository at this point in the history
…from a separate thread
  • Loading branch information
andyp1per committed Aug 22, 2024
1 parent ecd9694 commit 2864465
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 18 additions & 1 deletion libraries/AP_InertialSensor/AP_InertialSensor_Backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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());
Expand Down
2 changes: 2 additions & 0 deletions libraries/AP_InertialSensor/AP_InertialSensor_Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,11 @@ class AP_InertialSensor_Backend

// 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;
Expand Down

0 comments on commit 2864465

Please sign in to comment.