mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 03:03:33 +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:
@@ -52,7 +52,6 @@
|
||||
#include <lib/mathlib/mathlib.h>
|
||||
#include <lib/systemlib/mavlink_log.h>
|
||||
#include <lib/version/version.h>
|
||||
#include <uORB/Publication.hpp>
|
||||
|
||||
#include "mavlink_receiver.h"
|
||||
#include "mavlink_main.h"
|
||||
@@ -2136,8 +2135,6 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
pthread_mutex_init(&_message_buffer_mutex, nullptr);
|
||||
}
|
||||
|
||||
uORB::Subscription parameter_update_sub{ORB_ID(parameter_update)};
|
||||
|
||||
uORB::Subscription cmd_sub{ORB_ID(vehicle_command)};
|
||||
// ensure topic exists, otherwise we might lose first queued commands (leading to printf error's below)
|
||||
orb_advertise_queue(ORB_ID(vehicle_command), nullptr, vehicle_command_s::ORB_QUEUE_LENGTH);
|
||||
@@ -2247,10 +2244,10 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
update_rate_mult();
|
||||
|
||||
// check for parameter updates
|
||||
if (parameter_update_sub.updated()) {
|
||||
if (_parameter_update_sub.updated()) {
|
||||
// clear update
|
||||
parameter_update_s pupdate;
|
||||
parameter_update_sub.copy(&pupdate);
|
||||
_parameter_update_sub.copy(&pupdate);
|
||||
|
||||
// update parameters from storage
|
||||
mavlink_update_parameters();
|
||||
|
||||
@@ -69,8 +69,10 @@
|
||||
#include <px4_platform_common/module_params.h>
|
||||
#include <px4_platform_common/posix.h>
|
||||
#include <systemlib/uthash/utlist.h>
|
||||
#include <uORB/Publication.hpp>
|
||||
#include <uORB/PublicationMulti.hpp>
|
||||
#include <uORB/topics/mission_result.h>
|
||||
#include <uORB/SubscriptionInterval.hpp>
|
||||
#include <uORB/topics/parameter_update.h>
|
||||
#include <uORB/topics/radio_status.h>
|
||||
#include <uORB/topics/telemetry_status.h>
|
||||
|
||||
@@ -530,6 +532,8 @@ private:
|
||||
|
||||
uORB::PublicationMulti<telemetry_status_s> _telem_status_pub{ORB_ID(telemetry_status)};
|
||||
|
||||
uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s};
|
||||
|
||||
bool _task_running{true};
|
||||
static bool _boot_complete;
|
||||
static constexpr int MAVLINK_MAX_INSTANCES{4};
|
||||
|
||||
@@ -354,14 +354,14 @@ MavlinkParametersManager::send_untransmitted()
|
||||
{
|
||||
bool sent_one = false;
|
||||
|
||||
if (_mavlink_parameter_sub.updated()) {
|
||||
// Clear the ready flag
|
||||
parameter_update_s value;
|
||||
_mavlink_parameter_sub.update(&value);
|
||||
if (_parameter_update_sub.updated()) {
|
||||
// clear the update
|
||||
parameter_update_s pupdate;
|
||||
_parameter_update_sub.copy(&pupdate);
|
||||
|
||||
// Schedule an update if not already the case
|
||||
if (_param_update_time == 0) {
|
||||
_param_update_time = value.timestamp;
|
||||
_param_update_time = pupdate.timestamp;
|
||||
_param_update_index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,12 +47,15 @@
|
||||
#include "mavlink_bridge_header.h"
|
||||
#include <uORB/Publication.hpp>
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/SubscriptionInterval.hpp>
|
||||
#include <uORB/topics/rc_parameter_map.h>
|
||||
#include <uORB/topics/uavcan_parameter_request.h>
|
||||
#include <uORB/topics/uavcan_parameter_value.h>
|
||||
#include <uORB/topics/parameter_update.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
|
||||
using namespace time_literals;
|
||||
|
||||
class Mavlink;
|
||||
|
||||
class MavlinkParametersManager
|
||||
@@ -147,7 +150,7 @@ protected:
|
||||
|
||||
uORB::Subscription _uavcan_parameter_value_sub{ORB_ID(uavcan_parameter_value)};
|
||||
|
||||
uORB::Subscription _mavlink_parameter_sub{ORB_ID(parameter_update)};
|
||||
uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s};
|
||||
hrt_abstime _param_update_time{0};
|
||||
int _param_update_index{0};
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#include <px4_platform_common/module_params.h>
|
||||
#include <uORB/Publication.hpp>
|
||||
#include <uORB/PublicationMulti.hpp>
|
||||
#include <uORB/SubscriptionInterval.hpp>
|
||||
#include <uORB/topics/actuator_armed.h>
|
||||
#include <uORB/topics/actuator_controls.h>
|
||||
#include <uORB/topics/actuator_outputs.h>
|
||||
@@ -107,6 +108,8 @@
|
||||
# include <uORB/topics/debug_vect.h>
|
||||
#endif // !CONSTRAINED_FLASH
|
||||
|
||||
using namespace time_literals;
|
||||
|
||||
class Mavlink;
|
||||
|
||||
class MavlinkReceiver : public ModuleParams
|
||||
@@ -304,11 +307,12 @@ private:
|
||||
// ORB subscriptions
|
||||
uORB::Subscription _actuator_armed_sub{ORB_ID(actuator_armed)};
|
||||
uORB::Subscription _control_mode_sub{ORB_ID(vehicle_control_mode)};
|
||||
uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)};
|
||||
uORB::Subscription _vehicle_attitude_sub{ORB_ID(vehicle_attitude)};
|
||||
uORB::Subscription _vehicle_local_position_sub{ORB_ID(vehicle_local_position)};
|
||||
uORB::Subscription _vehicle_status_sub{ORB_ID(vehicle_status)};
|
||||
|
||||
uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s};
|
||||
|
||||
// hil_sensor and hil_state_quaternion
|
||||
enum SensorSource {
|
||||
ACCEL = 0b111,
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <uORB/topics/estimator_selector_status.h>
|
||||
#include <uORB/topics/estimator_status.h>
|
||||
#include <uORB/topics/geofence_result.h>
|
||||
#include <uORB/topics/mission_result.h>
|
||||
#include <uORB/topics/position_controller_status.h>
|
||||
#include <uORB/topics/tecs_status.h>
|
||||
#include <uORB/topics/wind_estimate.h>
|
||||
|
||||
Reference in New Issue
Block a user