mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 00:43:35 +08:00
parameter_update use uORB::Subscription consistently
This commit is contained in:
@@ -110,7 +110,6 @@ void Sih::run()
|
||||
_actuator_out_sub = orb_subscribe(ORB_ID(actuator_outputs));
|
||||
|
||||
// initialize parameters
|
||||
_parameter_update_sub = orb_subscribe(ORB_ID(parameter_update));
|
||||
parameters_update_poll();
|
||||
|
||||
init_variables();
|
||||
@@ -143,7 +142,6 @@ void Sih::run()
|
||||
hrt_cancel(&_timer_call); // close the periodic timer interruption
|
||||
px4_sem_destroy(&_data_semaphore);
|
||||
orb_unsubscribe(_actuator_out_sub);
|
||||
orb_unsubscribe(_parameter_update_sub);
|
||||
}
|
||||
|
||||
// timer_callback() is used as a real time callback to post the semaphore
|
||||
@@ -186,13 +184,13 @@ void Sih::inner_loop()
|
||||
|
||||
void Sih::parameters_update_poll()
|
||||
{
|
||||
bool updated = false;
|
||||
struct parameter_update_s param_upd;
|
||||
// check for parameter updates
|
||||
if (_parameter_update_sub.updated()) {
|
||||
// clear update
|
||||
parameter_update_s pupdate;
|
||||
_parameter_update_sub.copy(&pupdate);
|
||||
|
||||
orb_check(_parameter_update_sub, &updated);
|
||||
|
||||
if (updated) {
|
||||
orb_copy(ORB_ID(parameter_update), _parameter_update_sub, ¶m_upd);
|
||||
// update parameters from storage
|
||||
updateParams();
|
||||
parameters_updated();
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <lib/drivers/gyroscope/PX4Gyroscope.hpp>
|
||||
#include <lib/drivers/magnetometer/PX4Magnetometer.hpp>
|
||||
#include <perf/perf_counter.h>
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/parameter_update.h>
|
||||
#include <uORB/topics/vehicle_angular_velocity.h> // to publish groundtruth
|
||||
#include <uORB/topics/vehicle_attitude.h> // to publish groundtruth
|
||||
@@ -119,7 +120,7 @@ private:
|
||||
vehicle_global_position_s _gpos_gt{};
|
||||
orb_advert_t _gpos_gt_pub{nullptr};
|
||||
|
||||
int _parameter_update_sub {-1};
|
||||
uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)};
|
||||
int _actuator_out_sub {-1};
|
||||
|
||||
// hard constants
|
||||
|
||||
Reference in New Issue
Block a user