mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-29 17:00:34 +08:00
introduce uORB::PublicationQueued and transition most orb_advertise_queue usage
This commit is contained in:
@@ -55,6 +55,7 @@
|
||||
#include <parameters/param.h>
|
||||
#include <systemlib/mavlink_log.h>
|
||||
|
||||
#include <uORB/PublicationQueued.hpp>
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/camera_trigger.h>
|
||||
#include <uORB/topics/camera_capture.h>
|
||||
@@ -174,7 +175,8 @@ private:
|
||||
uORB::Subscription _lpos_sub{ORB_ID(vehicle_local_position)};
|
||||
|
||||
orb_advert_t _trigger_pub;
|
||||
orb_advert_t _cmd_ack_pub;
|
||||
|
||||
uORB::PublicationQueued<vehicle_command_ack_s> _cmd_ack_pub{ORB_ID(vehicle_command_ack)};
|
||||
|
||||
param_t _p_mode;
|
||||
param_t _p_activation_time;
|
||||
@@ -192,7 +194,7 @@ private:
|
||||
/**
|
||||
* Vehicle command handler
|
||||
*/
|
||||
void Run();
|
||||
void Run() override;
|
||||
|
||||
/**
|
||||
* Fires trigger
|
||||
@@ -250,7 +252,6 @@ CameraTrigger::CameraTrigger() :
|
||||
_last_shoot_position(0.0f, 0.0f),
|
||||
_valid_position(false),
|
||||
_trigger_pub(nullptr),
|
||||
_cmd_ack_pub(nullptr),
|
||||
_trigger_mode(TRIGGER_MODE_NONE),
|
||||
_cam_cap_fback(0),
|
||||
_camera_interface_mode(CAMERA_INTERFACE_MODE_GPIO),
|
||||
@@ -477,12 +478,13 @@ CameraTrigger::stop()
|
||||
void
|
||||
CameraTrigger::test()
|
||||
{
|
||||
vehicle_command_s vcmd = {};
|
||||
vehicle_command_s vcmd{};
|
||||
vcmd.timestamp = hrt_absolute_time();
|
||||
vcmd.param5 = 1.0;
|
||||
vcmd.command = vehicle_command_s::VEHICLE_CMD_DO_DIGICAM_CONTROL;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -682,20 +684,15 @@ CameraTrigger::Run()
|
||||
|
||||
// Command ACK handling
|
||||
if (updated && need_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)cmd_result;
|
||||
command_ack.target_system = cmd.source_system;
|
||||
command_ack.target_component = cmd.source_component;
|
||||
|
||||
if (_cmd_ack_pub == nullptr) {
|
||||
_cmd_ack_pub = orb_advertise_queue(ORB_ID(vehicle_command_ack), &command_ack,
|
||||
vehicle_command_ack_s::ORB_QUEUE_LENGTH);
|
||||
|
||||
} else {
|
||||
orb_publish(ORB_ID(vehicle_command_ack), _cmd_ack_pub, &command_ack);
|
||||
}
|
||||
_cmd_ack_pub.publish(command_ack);
|
||||
}
|
||||
|
||||
ScheduleDelayed(poll_interval_usec);
|
||||
|
||||
Reference in New Issue
Block a user