mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 00:53:34 +08:00
parameter_update use uORB::Subscription consistently
This commit is contained in:
@@ -292,9 +292,13 @@ float Heater::temperature_setpoint(char *argv[])
|
||||
|
||||
void Heater::update_params(const bool force)
|
||||
{
|
||||
parameter_update_s param_update;
|
||||
// check for parameter updates
|
||||
if (_parameter_update_sub.updated() || force) {
|
||||
// clear update
|
||||
parameter_update_s pupdate;
|
||||
_parameter_update_sub.copy(&pupdate);
|
||||
|
||||
if (_params_sub.update(¶m_update) || force) {
|
||||
// update parameters from storage
|
||||
ModuleParams::updateParams();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ private:
|
||||
|
||||
float _integrator_value = 0.0f;
|
||||
|
||||
uORB::Subscription _params_sub{ORB_ID(parameter_update)};
|
||||
uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)};
|
||||
|
||||
float _proportional_value = 0.0f;
|
||||
|
||||
|
||||
@@ -80,7 +80,8 @@ private:
|
||||
volatile bool _running{false};
|
||||
volatile bool _should_run{true};
|
||||
bool _leds_enabled{true};
|
||||
uORB::Subscription _param_sub{ORB_ID(parameter_update)};
|
||||
|
||||
uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)};
|
||||
|
||||
LedController _led_controller;
|
||||
|
||||
@@ -202,11 +203,13 @@ RGBLED::Run()
|
||||
return;
|
||||
}
|
||||
|
||||
if (_param_sub.updated()) {
|
||||
// check for parameter updates
|
||||
if (_parameter_update_sub.updated()) {
|
||||
// clear update
|
||||
parameter_update_s pupdate;
|
||||
_param_sub.copy(&pupdate);
|
||||
_parameter_update_sub.copy(&pupdate);
|
||||
|
||||
// update parameters from storage
|
||||
update_params();
|
||||
|
||||
// Immediately update to change brightness
|
||||
|
||||
@@ -80,7 +80,8 @@ private:
|
||||
volatile bool _running{false};
|
||||
volatile bool _should_run{true};
|
||||
bool _leds_enabled{true};
|
||||
uORB::Subscription _param_sub{ORB_ID(parameter_update)};
|
||||
|
||||
uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)};
|
||||
|
||||
LedController _led_controller;
|
||||
|
||||
@@ -166,11 +167,13 @@ RGBLED_NPC5623C::Run()
|
||||
return;
|
||||
}
|
||||
|
||||
if (_param_sub.updated()) {
|
||||
// check for parameter updates
|
||||
if (_parameter_update_sub.updated()) {
|
||||
// clear update
|
||||
parameter_update_s pupdate;
|
||||
_param_sub.copy(&pupdate);
|
||||
_parameter_update_sub.copy(&pupdate);
|
||||
|
||||
// update parameters from storage
|
||||
update_params();
|
||||
|
||||
// Immediately update to change brightness
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#include <px4_getopt.h>
|
||||
#include <px4_posix.h>
|
||||
|
||||
#include <uORB/uORB.h>
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/actuator_controls.h>
|
||||
#include <uORB/topics/actuator_outputs.h>
|
||||
#include <uORB/topics/actuator_armed.h>
|
||||
@@ -260,7 +260,7 @@ void task_main(int argc, char *argv[])
|
||||
|
||||
Mixer::Airmode airmode = Mixer::Airmode::disabled;
|
||||
update_params(airmode);
|
||||
int params_sub = orb_subscribe(ORB_ID(parameter_update));
|
||||
uORB::Subscription parameter_update_sub{ORB_ID(parameter_update)};
|
||||
|
||||
int rc_channels_sub = -1;
|
||||
|
||||
@@ -418,16 +418,15 @@ void task_main(int argc, char *argv[])
|
||||
_task_should_exit = true;
|
||||
}
|
||||
|
||||
/* check for parameter updates */
|
||||
bool param_updated = false;
|
||||
orb_check(params_sub, ¶m_updated);
|
||||
// check for parameter updates
|
||||
if (parameter_update_sub.updated()) {
|
||||
// clear update
|
||||
parameter_update_s pupdate;
|
||||
parameter_update_sub.copy(&pupdate);
|
||||
|
||||
if (param_updated) {
|
||||
struct parameter_update_s update;
|
||||
orb_copy(ORB_ID(parameter_update), params_sub, &update);
|
||||
// update parameters from storage
|
||||
update_params(airmode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
delete pwm_out;
|
||||
@@ -447,10 +446,6 @@ void task_main(int argc, char *argv[])
|
||||
orb_unsubscribe(rc_channels_sub);
|
||||
}
|
||||
|
||||
if (params_sub != -1) {
|
||||
orb_unsubscribe(params_sub);
|
||||
}
|
||||
|
||||
perf_free(_perf_control_latency);
|
||||
|
||||
_is_running = false;
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
#include <px4_time.h>
|
||||
#include <mathlib/mathlib.h>
|
||||
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/parameter_update.h>
|
||||
#include <uORB/topics/multirotor_motor_limits.h>
|
||||
|
||||
PWMSim::PWMSim() :
|
||||
@@ -162,7 +164,7 @@ PWMSim::run()
|
||||
_armed_sub = orb_subscribe(ORB_ID(actuator_armed));
|
||||
|
||||
update_params();
|
||||
int params_sub = orb_subscribe(ORB_ID(parameter_update));
|
||||
uORB::Subscription parameter_update_sub{ORB_ID(parameter_update)};
|
||||
|
||||
/* loop until killed */
|
||||
while (!should_exit()) {
|
||||
@@ -323,13 +325,13 @@ PWMSim::run()
|
||||
}
|
||||
}
|
||||
|
||||
/* check for parameter updates */
|
||||
bool param_updated = false;
|
||||
orb_check(params_sub, ¶m_updated);
|
||||
// check for parameter updates
|
||||
if (parameter_update_sub.updated()) {
|
||||
// clear update
|
||||
parameter_update_s pupdate;
|
||||
parameter_update_sub.copy(&pupdate);
|
||||
|
||||
if (param_updated) {
|
||||
struct parameter_update_s update;
|
||||
orb_copy(ORB_ID(parameter_update), params_sub, &update);
|
||||
// update parameters from storage
|
||||
update_params();
|
||||
}
|
||||
}
|
||||
@@ -341,7 +343,6 @@ PWMSim::run()
|
||||
}
|
||||
|
||||
orb_unsubscribe(_armed_sub);
|
||||
orb_unsubscribe(params_sub);
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -177,7 +177,7 @@ private:
|
||||
|
||||
unsigned _current_update_rate{0};
|
||||
|
||||
uORB::Subscription _param_sub{ORB_ID(parameter_update)};
|
||||
uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)};
|
||||
|
||||
|
||||
unsigned _num_outputs{0};
|
||||
@@ -767,7 +767,13 @@ PX4FMU::Run()
|
||||
update_pwm_out_state(pwm_on);
|
||||
}
|
||||
|
||||
if (_param_sub.updated()) {
|
||||
// check for parameter updates
|
||||
if (_parameter_update_sub.updated()) {
|
||||
// clear update
|
||||
parameter_update_s pupdate;
|
||||
_parameter_update_sub.copy(&pupdate);
|
||||
|
||||
// update parameters from storage
|
||||
update_params();
|
||||
}
|
||||
|
||||
@@ -783,16 +789,12 @@ PX4FMU::Run()
|
||||
|
||||
void PX4FMU::update_params()
|
||||
{
|
||||
parameter_update_s pupdate;
|
||||
_param_sub.update(&pupdate);
|
||||
|
||||
update_pwm_rev_mask();
|
||||
update_pwm_trims();
|
||||
|
||||
updateParams();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
PX4FMU::ioctl(file *filp, int cmd, unsigned long arg)
|
||||
{
|
||||
|
||||
@@ -256,7 +256,7 @@ private:
|
||||
uORB::Subscription _t_actuator_controls_3{ORB_ID(actuator_controls_3)};; ///< actuator controls group 3 topic
|
||||
uORB::Subscription _t_actuator_armed{ORB_ID(actuator_armed)}; ///< system armed control topic
|
||||
uORB::Subscription _t_vehicle_control_mode{ORB_ID(vehicle_control_mode)}; ///< vehicle control mode topic
|
||||
uORB::Subscription _t_param{ORB_ID(parameter_update)}; ///< parameter update topic
|
||||
uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)}; ///< parameter update topic
|
||||
uORB::Subscription _t_vehicle_command{ORB_ID(vehicle_command)}; ///< vehicle command topic
|
||||
|
||||
bool _param_update_force; ///< force a parameter update
|
||||
@@ -997,10 +997,14 @@ PX4IO::task_main()
|
||||
*
|
||||
* XXX this may be a bit spammy
|
||||
*/
|
||||
if (_t_param.updated() || _param_update_force) {
|
||||
_param_update_force = false;
|
||||
|
||||
// check for parameter updates
|
||||
if (_parameter_update_sub.updated() || _param_update_force) {
|
||||
// clear update
|
||||
parameter_update_s pupdate;
|
||||
_t_param.copy(&pupdate);
|
||||
_parameter_update_sub.copy(&pupdate);
|
||||
|
||||
_param_update_force = false;
|
||||
|
||||
if (!_rc_handling_disabled) {
|
||||
/* re-upload RC input config as it may have changed */
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include <cmath> // NAN
|
||||
#include <string.h>
|
||||
|
||||
#include <uORB/uORB.h>
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/actuator_controls.h>
|
||||
#include <uORB/topics/actuator_outputs.h>
|
||||
#include <uORB/topics/actuator_armed.h>
|
||||
@@ -357,7 +357,7 @@ void task_main(int argc, char *argv[])
|
||||
|
||||
Mixer::Airmode airmode = Mixer::Airmode::disabled;
|
||||
update_params(airmode);
|
||||
int params_sub = orb_subscribe(ORB_ID(parameter_update));
|
||||
uORB::Subscription parameter_update_sub{ORB_ID(parameter_update)};
|
||||
|
||||
// Start disarmed
|
||||
_armed.armed = false;
|
||||
@@ -471,13 +471,13 @@ void task_main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
/* check for parameter updates */
|
||||
bool param_updated = false;
|
||||
orb_check(params_sub, ¶m_updated);
|
||||
// check for parameter updates
|
||||
if (parameter_update_sub.updated()) {
|
||||
// clear update
|
||||
parameter_update_s pupdate;
|
||||
parameter_update_sub.copy(&pupdate);
|
||||
|
||||
if (param_updated) {
|
||||
struct parameter_update_s update;
|
||||
orb_copy(ORB_ID(parameter_update), params_sub, &update);
|
||||
// update parameters from storage
|
||||
update_params(airmode);
|
||||
}
|
||||
}
|
||||
@@ -491,7 +491,6 @@ void task_main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
orb_unsubscribe(_armed_sub);
|
||||
orb_unsubscribe(params_sub);
|
||||
|
||||
perf_free(_perf_control_latency);
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
#include <lib/cdev/CDev.hpp>
|
||||
#include <perf/perf_counter.h>
|
||||
#include <px4_module_params.h>
|
||||
#include <uORB/uORB.h>
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/actuator_controls.h>
|
||||
#include <uORB/topics/actuator_outputs.h>
|
||||
#include <uORB/topics/actuator_armed.h>
|
||||
@@ -114,7 +114,9 @@ private:
|
||||
bool _is_armed = false;
|
||||
int _armed_sub = -1;
|
||||
int _test_motor_sub = -1;
|
||||
int _params_sub = -1;
|
||||
|
||||
uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)};
|
||||
|
||||
orb_advert_t _outputs_pub = nullptr;
|
||||
actuator_outputs_s _outputs = {};
|
||||
actuator_armed_s _armed = {};
|
||||
@@ -191,7 +193,6 @@ TAP_ESC::~TAP_ESC()
|
||||
|
||||
orb_unsubscribe(_armed_sub);
|
||||
orb_unsubscribe(_test_motor_sub);
|
||||
orb_unsubscribe(_params_sub);
|
||||
|
||||
orb_unadvertise(_outputs_pub);
|
||||
orb_unadvertise(_esc_feedback_pub);
|
||||
@@ -336,7 +337,6 @@ int TAP_ESC::init()
|
||||
|
||||
_armed_sub = orb_subscribe(ORB_ID(actuator_armed));
|
||||
_test_motor_sub = orb_subscribe(ORB_ID(test_motor));
|
||||
_params_sub = orb_subscribe(ORB_ID(parameter_update));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -609,13 +609,13 @@ void TAP_ESC::cycle()
|
||||
|
||||
}
|
||||
|
||||
/* check for parameter updates */
|
||||
bool param_updated = false;
|
||||
orb_check(_params_sub, ¶m_updated);
|
||||
// check for parameter updates
|
||||
if (_parameter_update_sub.updated()) {
|
||||
// clear update
|
||||
parameter_update_s pupdate;
|
||||
_parameter_update_sub.copy(&pupdate);
|
||||
|
||||
if (param_updated) {
|
||||
struct parameter_update_s update;
|
||||
orb_copy(ORB_ID(parameter_update), _params_sub, &update);
|
||||
// update parameters from storage
|
||||
updateParams();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#include <arch/board/board.h>
|
||||
#include <arch/chip/chip.h>
|
||||
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/esc_status.h>
|
||||
#include <uORB/topics/parameter_update.h>
|
||||
|
||||
@@ -810,17 +811,17 @@ int UavcanNode::run()
|
||||
|
||||
update_params();
|
||||
|
||||
int params_sub = orb_subscribe(ORB_ID(parameter_update));
|
||||
uORB::Subscription parameter_update_sub{ORB_ID(parameter_update)};
|
||||
|
||||
while (!_task_should_exit) {
|
||||
|
||||
/* check for parameter updates */
|
||||
bool param_updated = false;
|
||||
orb_check(params_sub, ¶m_updated);
|
||||
// check for parameter updates
|
||||
if (parameter_update_sub.updated()) {
|
||||
// clear update
|
||||
parameter_update_s pupdate;
|
||||
parameter_update_sub.copy(&pupdate);
|
||||
|
||||
if (param_updated) {
|
||||
struct parameter_update_s update;
|
||||
orb_copy(ORB_ID(parameter_update), params_sub, &update);
|
||||
// update parameters from storage
|
||||
update_params();
|
||||
}
|
||||
|
||||
@@ -995,8 +996,6 @@ int UavcanNode::run()
|
||||
}
|
||||
}
|
||||
|
||||
orb_unsubscribe(params_sub);
|
||||
|
||||
(void)::close(busevent_fd);
|
||||
|
||||
teardown();
|
||||
|
||||
Reference in New Issue
Block a user