mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 11:33:35 +08:00
introduce uORB::PublicationQueued and transition most orb_advertise_queue usage
This commit is contained in:
@@ -195,20 +195,15 @@ void SendEvent::process_commands()
|
||||
void SendEvent::answer_command(const vehicle_command_s &cmd, unsigned result)
|
||||
{
|
||||
/* publish ACK */
|
||||
vehicle_command_ack_s command_ack = {};
|
||||
vehicle_command_ack_s command_ack{};
|
||||
command_ack.timestamp = hrt_absolute_time();
|
||||
command_ack.command = cmd.command;
|
||||
command_ack.result = (uint8_t)result;
|
||||
command_ack.target_system = cmd.source_system;
|
||||
command_ack.target_component = cmd.source_component;
|
||||
|
||||
if (_command_ack_pub != nullptr) {
|
||||
orb_publish(ORB_ID(vehicle_command_ack), _command_ack_pub, &command_ack);
|
||||
|
||||
} else {
|
||||
_command_ack_pub = orb_advertise_queue(ORB_ID(vehicle_command_ack), &command_ack,
|
||||
vehicle_command_ack_s::ORB_QUEUE_LENGTH);
|
||||
}
|
||||
uORB::PublicationQueued<vehicle_command_ack_s> command_ack_pub{ORB_ID(vehicle_command_ack)};
|
||||
command_ack_pub.publish(command_ack);
|
||||
}
|
||||
|
||||
int SendEvent::print_usage(const char *reason)
|
||||
@@ -275,7 +270,7 @@ int SendEvent::custom_command(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
vehicle_command_s vcmd = {};
|
||||
vehicle_command_s vcmd{};
|
||||
vcmd.timestamp = hrt_absolute_time();
|
||||
vcmd.param1 = (float)((gyro_calib || calib_all) ? vehicle_command_s::PREFLIGHT_CALIBRATION_TEMPERATURE_CALIBRATION : NAN);
|
||||
vcmd.param2 = NAN;
|
||||
@@ -286,7 +281,8 @@ int SendEvent::custom_command(int argc, char *argv[])
|
||||
vcmd.param7 = (float)((baro_calib || calib_all) ? vehicle_command_s::PREFLIGHT_CALIBRATION_TEMPERATURE_CALIBRATION : NAN);
|
||||
vcmd.command = vehicle_command_s::VEHICLE_CMD_PREFLIGHT_CALIBRATION;
|
||||
|
||||
orb_advertise_queue(ORB_ID(vehicle_command), &vcmd, vehicle_command_s::ORB_QUEUE_LENGTH);
|
||||
uORB::PublicationQueued<vehicle_command_s> vcmd_pub{ORB_ID(vehicle_command)};
|
||||
vcmd_pub.publish(vcmd);
|
||||
|
||||
} else {
|
||||
print_usage("unrecognized command");
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <px4_workqueue.h>
|
||||
#include <px4_module.h>
|
||||
#include <px4_module_params.h>
|
||||
#include <uORB/PublicationQueued.hpp>
|
||||
#include <uORB/topics/vehicle_command.h>
|
||||
#include <uORB/topics/vehicle_command_ack.h>
|
||||
|
||||
@@ -132,9 +133,6 @@ private:
|
||||
/** @var _rc_loss_alarm Pointer to the RC loss alarm object. */
|
||||
rc_loss::RC_Loss_Alarm *_rc_loss_alarm = nullptr;
|
||||
|
||||
/** @var _command_ack_pub The command ackowledgement topic. */
|
||||
orb_advert_t _command_ack_pub = nullptr;
|
||||
|
||||
/** @note Declare local parameters using defined parameters. */
|
||||
DEFINE_PARAMETERS(
|
||||
/** @var _param_status_display Parameter to enable/disable the LED status display. */
|
||||
|
||||
@@ -102,12 +102,7 @@ void StatusDisplay::publish()
|
||||
{
|
||||
_led_control.timestamp = hrt_absolute_time();
|
||||
|
||||
if (_led_control_pub != nullptr) {
|
||||
orb_publish(ORB_ID(led_control), _led_control_pub, &_led_control);
|
||||
|
||||
} else {
|
||||
_led_control_pub = orb_advertise_queue(ORB_ID(led_control), &_led_control, LED_UORB_QUEUE_LENGTH);
|
||||
}
|
||||
_led_control_pub.publish(_led_control);
|
||||
}
|
||||
|
||||
} /* namespace status */
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
#include <drivers/drv_hrt.h>
|
||||
|
||||
#include <uORB/uORB.h>
|
||||
#include <uORB/PublicationQueued.hpp>
|
||||
#include <uORB/topics/battery_status.h>
|
||||
#include <uORB/topics/cpuload.h>
|
||||
#include <uORB/topics/led_control.h>
|
||||
@@ -96,7 +96,9 @@ private:
|
||||
bool _critical_battery = false;
|
||||
int _old_nav_state = -1;
|
||||
int _old_battery_status_warning = -1;
|
||||
orb_advert_t _led_control_pub = nullptr;
|
||||
|
||||
uORB::PublicationQueued<led_control_s> _led_control_pub{ORB_ID(led_control)};
|
||||
|
||||
const events::SubscriberHandler &_subscriber_handler;
|
||||
};
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
* @author Beat Küng <beat-kueng@gmx.net>
|
||||
*/
|
||||
|
||||
#include <uORB/PublicationQueued.hpp>
|
||||
#include <uORB/topics/sensor_gyro.h>
|
||||
#include <mathlib/mathlib.h>
|
||||
#include <px4_log.h>
|
||||
@@ -92,7 +93,7 @@ public:
|
||||
private:
|
||||
void publish_led_control(led_control_s &led_control);
|
||||
|
||||
orb_advert_t _led_control_pub = nullptr;
|
||||
uORB::PublicationQueued<led_control_s> _led_control_pub{ORB_ID(led_control)};
|
||||
|
||||
bool _force_task_exit = false;
|
||||
int _control_task = -1; // task handle for task
|
||||
@@ -349,13 +350,7 @@ int TemperatureCalibration::start()
|
||||
void TemperatureCalibration::publish_led_control(led_control_s &led_control)
|
||||
{
|
||||
led_control.timestamp = hrt_absolute_time();
|
||||
|
||||
if (_led_control_pub == nullptr) {
|
||||
_led_control_pub = orb_advertise_queue(ORB_ID(led_control), &led_control, LED_UORB_QUEUE_LENGTH);
|
||||
|
||||
} else {
|
||||
orb_publish(ORB_ID(led_control), _led_control_pub, &led_control);
|
||||
}
|
||||
_led_control_pub.publish(led_control);
|
||||
}
|
||||
|
||||
int run_temperature_calibration(bool accel, bool baro, bool gyro)
|
||||
|
||||
Reference in New Issue
Block a user