rate limit most parameter_update subscriptions

- parameter updates can be quite expensive because they trigger nearly all modules to reload all of their parameters immediately
 - limit modules from updating faster than once per second
This commit is contained in:
Daniel Agar
2021-01-10 21:09:15 -05:00
committed by GitHub
parent 70e503cb91
commit 967d35a6b6
73 changed files with 212 additions and 122 deletions
@@ -241,7 +241,7 @@ void BlockLocalPositionEstimator::Run()
_lastArmedState = armedState;
// see which updates are available
bool paramsUpdated = _sub_param_update.update();
const bool paramsUpdated = _parameter_update_sub.updated();
_baroUpdated = false;
if ((_param_lpe_fusion.get() & FUSE_BARO) && _sub_airdata.update()) {
@@ -266,6 +266,10 @@ void BlockLocalPositionEstimator::Run()
// update parameters
if (paramsUpdated) {
// clear update
parameter_update_s pupdate;
_parameter_update_sub.copy(&pupdate);
SuperBlock::updateParams();
ModuleParams::updateParams();
updateSSParams();
@@ -263,12 +263,13 @@ private:
// subscriptions
uORB::SubscriptionCallbackWorkItem _sensors_sub{this, ORB_ID(sensor_combined)};
uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s};
uORB::SubscriptionData<actuator_armed_s> _sub_armed{ORB_ID(actuator_armed)};
uORB::SubscriptionData<vehicle_land_detected_s> _sub_land{ORB_ID(vehicle_land_detected)};
uORB::SubscriptionData<vehicle_attitude_s> _sub_att{ORB_ID(vehicle_attitude)};
uORB::SubscriptionData<vehicle_angular_velocity_s> _sub_angular_velocity{ORB_ID(vehicle_angular_velocity)};
uORB::SubscriptionData<optical_flow_s> _sub_flow{ORB_ID(optical_flow)};
uORB::SubscriptionData<parameter_update_s> _sub_param_update{ORB_ID(parameter_update)};
uORB::SubscriptionData<vehicle_gps_position_s> _sub_gps{ORB_ID(vehicle_gps_position)};
uORB::SubscriptionData<vehicle_odometry_s> _sub_visual_odom{ORB_ID(vehicle_visual_odometry)};
uORB::SubscriptionData<vehicle_odometry_s> _sub_mocap_odom{ORB_ID(vehicle_mocap_odometry)};