mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-18 06:40:36 +08:00
fix mavlink: ensure vehicle_command topic exists
If the first publisher publishes multiple commands right after each other (e.g. on 'commander takeoff'), mavlink would miss the first and print an error like 'vehicle_command lost, generation 0 -> 2'. This is due to a recent uORB behavior change.
This commit is contained in:
@@ -2146,6 +2146,9 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
uORB::Subscription parameter_update_sub{ORB_ID(parameter_update)};
|
||||
|
||||
uORB::Subscription cmd_sub{ORB_ID(vehicle_command)};
|
||||
// ensure topic exists, otherwise we might lose first queued commands (leading to printf error's below)
|
||||
orb_advertise_queue(ORB_ID(vehicle_command), nullptr, vehicle_command_s::ORB_QUEUE_LENGTH);
|
||||
cmd_sub.subscribe();
|
||||
uORB::Subscription status_sub{ORB_ID(vehicle_status)};
|
||||
uORB::Subscription ack_sub{ORB_ID(vehicle_command_ack)};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user