mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 14:33:35 +08:00
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:
@@ -41,7 +41,6 @@
|
||||
#include <systemlib/mavlink_log.h>
|
||||
|
||||
using namespace temperature_compensation;
|
||||
using namespace time_literals;
|
||||
|
||||
TemperatureCompensationModule::TemperatureCompensationModule() :
|
||||
ModuleParams(nullptr),
|
||||
@@ -233,10 +232,10 @@ void TemperatureCompensationModule::Run()
|
||||
}
|
||||
|
||||
// Check if any parameter has changed
|
||||
if (_params_sub.updated()) {
|
||||
if (_parameter_update_sub.updated()) {
|
||||
// Read from param to clear updated flag
|
||||
parameter_update_s update;
|
||||
_params_sub.copy(&update);
|
||||
_parameter_update_sub.copy(&update);
|
||||
|
||||
parameters_update();
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include <px4_platform_common/time.h>
|
||||
#include <uORB/Publication.hpp>
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/SubscriptionInterval.hpp>
|
||||
#include <uORB/topics/parameter_update.h>
|
||||
#include <uORB/topics/sensor_accel.h>
|
||||
#include <uORB/topics/sensor_baro.h>
|
||||
@@ -58,6 +59,8 @@
|
||||
|
||||
#include "TemperatureCompensation.h"
|
||||
|
||||
using namespace time_literals;
|
||||
|
||||
namespace temperature_compensation
|
||||
{
|
||||
|
||||
@@ -123,7 +126,8 @@ private:
|
||||
{ORB_ID(sensor_baro), 3},
|
||||
};
|
||||
|
||||
uORB::Subscription _params_sub{ORB_ID(parameter_update)};
|
||||
uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s};
|
||||
|
||||
uORB::Subscription _vehicle_command_sub{ORB_ID(vehicle_command)};
|
||||
|
||||
perf_counter_t _loop_perf; /**< loop performance counter */
|
||||
|
||||
Reference in New Issue
Block a user