mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-02 02:50:34 +08:00
parameter_update use uORB::Subscription consistently
This commit is contained in:
@@ -77,17 +77,13 @@ void Simulator::write_gps_data(void *buf)
|
||||
|
||||
void Simulator::parameters_update(bool force)
|
||||
{
|
||||
bool updated;
|
||||
struct parameter_update_s param_upd;
|
||||
// check for parameter updates
|
||||
if (_parameter_update_sub.updated() || force) {
|
||||
// clear update
|
||||
parameter_update_s pupdate;
|
||||
_parameter_update_sub.copy(&pupdate);
|
||||
|
||||
orb_check(_param_sub, &updated);
|
||||
|
||||
if (updated) {
|
||||
orb_copy(ORB_ID(parameter_update), _param_sub, ¶m_upd);
|
||||
}
|
||||
|
||||
if (updated || force) {
|
||||
// update C++ param system
|
||||
// update parameters from storage
|
||||
updateParams();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include <perf/perf_counter.h>
|
||||
#include <px4_module_params.h>
|
||||
#include <px4_posix.h>
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/actuator_outputs.h>
|
||||
#include <uORB/topics/battery_status.h>
|
||||
#include <uORB/topics/differential_pressure.h>
|
||||
@@ -181,8 +182,6 @@ private:
|
||||
|
||||
_gps.writeData(&gps_data);
|
||||
|
||||
_param_sub = orb_subscribe(ORB_ID(parameter_update));
|
||||
|
||||
_battery_status.timestamp = hrt_absolute_time();
|
||||
|
||||
_px4_accel.set_sample_rate(250);
|
||||
@@ -191,9 +190,6 @@ private:
|
||||
|
||||
~Simulator()
|
||||
{
|
||||
// Unsubscribe from uORB topics.
|
||||
orb_unsubscribe(_param_sub);
|
||||
|
||||
// free perf counters
|
||||
perf_free(_perf_gps);
|
||||
perf_free(_perf_sim_delay);
|
||||
@@ -230,7 +226,7 @@ private:
|
||||
orb_advert_t _irlock_report_pub{nullptr};
|
||||
orb_advert_t _visual_odometry_pub{nullptr};
|
||||
|
||||
int _param_sub{-1};
|
||||
uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)};
|
||||
|
||||
unsigned int _port{14560};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user