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
+4 -2
View File
@@ -55,6 +55,7 @@
#include <parameters/param.h>
#include <perf/perf_counter.h>
#include <uORB/Subscription.hpp>
#include <uORB/SubscriptionInterval.hpp>
#include <uORB/topics/actuator_controls.h>
#include <uORB/topics/manual_control_setpoint.h>
#include <uORB/topics/parameter_update.h>
@@ -65,7 +66,8 @@
#include <uORB/topics/vehicle_global_position.h>
#include <uORB/topics/vehicle_rates_setpoint.h>
#include <uORB/topics/vehicle_status.h>
#include <uORB/uORB.h>
using namespace time_literals;
/* Prototypes */
@@ -315,7 +317,7 @@ int fixedwing_control_thread_main(int argc, char *argv[])
int vstatus_sub = orb_subscribe(ORB_ID(vehicle_status));
int global_sp_sub = orb_subscribe(ORB_ID(position_setpoint_triplet));
uORB::Subscription parameter_update_sub{ORB_ID(parameter_update)};
uORB::SubscriptionInterval parameter_update_sub{ORB_ID(parameter_update), 1_s};
/* Setup of loop */
-1
View File
@@ -38,7 +38,6 @@
#include <mathlib/math/Functions.hpp>
using namespace matrix;
using namespace time_literals;
using math::radians;
GyroFFT::GyroFFT() :
+4 -1
View File
@@ -54,6 +54,8 @@
#include "arm_math.h"
#include "arm_const_structs.h"
using namespace time_literals;
class GyroFFT : public ModuleBase<GyroFFT>, public ModuleParams, public px4::ScheduledWorkItem
{
public:
@@ -86,7 +88,8 @@ private:
uORB::Publication<sensor_gyro_fft_s> _sensor_gyro_fft_pub{ORB_ID(sensor_gyro_fft)};
uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)};
uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s};
uORB::Subscription _sensor_selection_sub{ORB_ID(sensor_selection)};
uORB::Subscription _vehicle_imu_status_sub{ORB_ID(vehicle_imu_status)};
+8 -5
View File
@@ -52,6 +52,7 @@
#include <time.h>
#include <drivers/drv_hrt.h>
#include <uORB/Subscription.hpp>
#include <uORB/SubscriptionInterval.hpp>
#include <uORB/topics/vehicle_global_position.h>
#include <uORB/topics/position_setpoint_triplet.h>
#include <uORB/topics/vehicle_attitude.h>
@@ -70,6 +71,8 @@
/* process-specific header files */
#include "params.h"
using namespace time_literals;
/* Prototypes */
/**
@@ -101,7 +104,7 @@ int parameters_init(struct param_handles *h);
* Update all parameters
*
*/
int parameters_update(const struct param_handles *h, struct params *p);
int parameter_update(const struct param_handles *h, struct params *p);
/**
* Mainloop of daemon.
@@ -141,7 +144,7 @@ int parameters_init(struct param_handles *h)
return OK;
}
int parameters_update(const struct param_handles *h, struct params *p)
int parameter_update(const struct param_handles *h, struct params *p)
{
param_get(h->yaw_p, &(p->yaw_p));
@@ -201,7 +204,7 @@ int rover_steering_control_thread_main(int argc, char *argv[])
/* initialize parameters, first the handles, then the values */
parameters_init(&ph);
parameters_update(&ph, &pp);
parameter_update(&ph, &pp);
/*
@@ -271,7 +274,7 @@ int rover_steering_control_thread_main(int argc, char *argv[])
int att_sp_sub = orb_subscribe(ORB_ID(vehicle_attitude_setpoint));
uORB::Subscription parameter_update_sub{ORB_ID(parameter_update)};
uORB::SubscriptionInterval parameter_update_sub{ORB_ID(parameter_update), 1_s};
/* Setup of loop */
@@ -313,7 +316,7 @@ int rover_steering_control_thread_main(int argc, char *argv[])
parameter_update_sub.copy(&pupdate);
// if a param update occured, re-read our parameters
parameters_update(&ph, &pp);
parameter_update(&ph, &pp);
}
/* only run controller if attitude changed */