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
+2 -1
View File
@@ -124,8 +124,9 @@ private:
{this, ORB_ID(vehicle_imu), 3}
};
uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s};
uORB::Subscription _diff_pres_sub{ORB_ID(differential_pressure)};
uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)};
uORB::Subscription _vcontrol_mode_sub{ORB_ID(vehicle_control_mode)};
uORB::Subscription _vehicle_air_data_sub{ORB_ID(vehicle_air_data)};
@@ -38,7 +38,6 @@
#include <uORB/topics/vehicle_imu_status.h>
using namespace matrix;
using namespace time_literals;
namespace sensors
{
@@ -190,10 +189,10 @@ bool VehicleAcceleration::SensorSelectionUpdate(bool force)
void VehicleAcceleration::ParametersUpdate(bool force)
{
// Check if parameters have changed
if (_params_sub.updated() || force) {
if (_parameter_update_sub.updated() || force) {
// clear update
parameter_update_s param_update;
_params_sub.copy(&param_update);
_parameter_update_sub.copy(&param_update);
updateParams();
@@ -51,6 +51,8 @@
#include <uORB/topics/sensor_selection.h>
#include <uORB/topics/vehicle_acceleration.h>
using namespace time_literals;
namespace sensors
{
@@ -79,7 +81,8 @@ private:
uORB::Subscription _estimator_selector_status_sub{ORB_ID(estimator_selector_status)};
uORB::Subscription _estimator_sensor_bias_sub{ORB_ID(estimator_sensor_bias)};
uORB::Subscription _params_sub{ORB_ID(parameter_update)};
uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s};
uORB::SubscriptionCallbackWorkItem _sensor_selection_sub{this, ORB_ID(sensor_selection)};
uORB::SubscriptionCallbackWorkItem _sensor_sub{this, ORB_ID(sensor_accel)};
@@ -40,7 +40,6 @@ namespace sensors
{
using namespace matrix;
using namespace time_literals;
static constexpr uint32_t SENSOR_TIMEOUT{300_ms};
@@ -114,10 +113,10 @@ void VehicleAirData::SensorCorrectionsUpdate(bool force)
void VehicleAirData::ParametersUpdate()
{
// Check if parameters have changed
if (_params_sub.updated()) {
if (_parameter_update_sub.updated()) {
// clear update
parameter_update_s param_update;
_params_sub.copy(&param_update);
_parameter_update_sub.copy(&param_update);
updateParams();
}
@@ -51,6 +51,8 @@
#include <uORB/topics/sensor_correction.h>
#include <uORB/topics/vehicle_air_data.h>
using namespace time_literals;
namespace sensors
{
class VehicleAirData : public ModuleParams, public px4::ScheduledWorkItem
@@ -75,7 +77,8 @@ private:
uORB::Publication<vehicle_air_data_s> _vehicle_air_data_pub{ORB_ID(vehicle_air_data)};
uORB::Subscription _params_sub{ORB_ID(parameter_update)};
uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s};
uORB::Subscription _sensor_correction_sub{ORB_ID(sensor_correction)};
uORB::SubscriptionCallbackWorkItem _sensor_sub[MAX_SENSOR_COUNT] {
@@ -38,7 +38,6 @@
#include <uORB/topics/vehicle_imu_status.h>
using namespace matrix;
using namespace time_literals;
namespace sensors
{
@@ -189,10 +188,10 @@ bool VehicleAngularVelocity::SensorSelectionUpdate(bool force)
void VehicleAngularVelocity::ParametersUpdate(bool force)
{
// Check if parameters have changed
if (_params_sub.updated() || force) {
if (_parameter_update_sub.updated() || force) {
// clear update
parameter_update_s param_update;
_params_sub.copy(&param_update);
_parameter_update_sub.copy(&param_update);
updateParams();
@@ -53,6 +53,8 @@
#include <uORB/topics/vehicle_angular_acceleration.h>
#include <uORB/topics/vehicle_angular_velocity.h>
using namespace time_literals;
namespace sensors
{
@@ -82,7 +84,8 @@ private:
uORB::Subscription _estimator_selector_status_sub{ORB_ID(estimator_selector_status)};
uORB::Subscription _estimator_sensor_bias_sub{ORB_ID(estimator_sensor_bias)};
uORB::Subscription _params_sub{ORB_ID(parameter_update)};
uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s};
uORB::SubscriptionCallbackWorkItem _sensor_selection_sub{this, ORB_ID(sensor_selection)};
uORB::SubscriptionCallbackWorkItem _sensor_sub{this, ORB_ID(sensor_gyro)};
@@ -77,10 +77,10 @@ void VehicleGPSPosition::Stop()
void VehicleGPSPosition::ParametersUpdate(bool force)
{
// Check if parameters have changed
if (_params_sub.updated() || force) {
if (_parameter_update_sub.updated() || force) {
// clear update
parameter_update_s param_update;
_params_sub.copy(&param_update);
_parameter_update_sub.copy(&param_update);
updateParams();
}
@@ -116,7 +116,7 @@ private:
uORB::Publication<vehicle_gps_position_s> _vehicle_gps_position_pub{ORB_ID(vehicle_gps_position)};
uORB::Subscription _params_sub{ORB_ID(parameter_update)}; /**< parameter updates subscription */
uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s};
uORB::SubscriptionCallbackWorkItem _sensor_gps_sub[GPS_MAX_RECEIVERS] { /**< sensor data subscription */
{this, ORB_ID(sensor_gps), 0},
@@ -38,7 +38,6 @@
#include <float.h>
using namespace matrix;
using namespace time_literals;
using math::constrain;
@@ -111,10 +110,10 @@ void VehicleIMU::Stop()
void VehicleIMU::ParametersUpdate(bool force)
{
// Check if parameters have changed
if (_params_sub.updated() || force) {
if (_parameter_update_sub.updated() || force) {
// clear update
parameter_update_s param_update;
_params_sub.copy(&param_update);
_parameter_update_sub.copy(&param_update);
const auto imu_integ_rate_prev = _param_imu_integ_rate.get();
@@ -53,6 +53,8 @@
#include <uORB/topics/vehicle_imu.h>
#include <uORB/topics/vehicle_imu_status.h>
using namespace time_literals;
namespace sensors
{
@@ -87,7 +89,9 @@ private:
uORB::PublicationMulti<vehicle_imu_s> _vehicle_imu_pub{ORB_ID(vehicle_imu)};
uORB::PublicationMulti<vehicle_imu_status_s> _vehicle_imu_status_pub{ORB_ID(vehicle_imu_status)};
uORB::Subscription _params_sub{ORB_ID(parameter_update)};
uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s};
uORB::SubscriptionCallbackWorkItem _sensor_accel_sub;
uORB::SubscriptionCallbackWorkItem _sensor_gyro_sub;
@@ -40,7 +40,6 @@ namespace sensors
{
using namespace matrix;
using namespace time_literals;
static constexpr uint32_t SENSOR_TIMEOUT{300_ms};
@@ -82,10 +81,10 @@ void VehicleMagnetometer::Stop()
void VehicleMagnetometer::ParametersUpdate(bool force)
{
// Check if parameters have changed
if (_params_sub.updated() || force) {
if (_parameter_update_sub.updated() || force) {
// clear update
parameter_update_s param_update;
_params_sub.copy(&param_update);
_parameter_update_sub.copy(&param_update);
updateParams();
@@ -59,6 +59,8 @@
#include <uORB/topics/vehicle_control_mode.h>
#include <uORB/topics/vehicle_magnetometer.h>
using namespace time_literals;
namespace sensors
{
class VehicleMagnetometer : public ModuleParams, public px4::ScheduledWorkItem
@@ -98,9 +100,10 @@ private:
{ORB_ID(vehicle_magnetometer)},
};
uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s};
uORB::Subscription _actuator_controls_0_sub{ORB_ID(actuator_controls_0)};
uORB::Subscription _battery_status_sub{ORB_ID(battery_status), 0};
uORB::Subscription _params_sub{ORB_ID(parameter_update)};
uORB::Subscription _vehicle_control_mode_sub{ORB_ID(vehicle_control_mode)};
// Used to check, save and use learned magnetometer biases