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:
Beat Küng
2020-11-27 08:48:29 +01:00
committed by Daniel Agar
parent 05a3492174
commit a63e8cc149
+3
View File
@@ -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)};