MAVSDK Server Plugins: How To Connect?


I am working on a robot of the rover kind (in fact a robotic harbor tug PoC based on an R/C boat) which I would like to “mesh” later with some Px4 based aerial drones.

The tug runs on some CAN-bus connected MCU’s and a RaspberryPi with a PiCAN hat. I would like to use QGroundcontrol as a means of planning tug missions and receiving a camera stream later.

I use the MAVSDK server plugins on the tug’s RasPi and am not sure if I fully understood the connection process between vehicle and QGC.

Based on the autopilot_server example from MAVSDK I tried two approaches:

1.1) create a generic UDP MAVLink Comm Link in QGC:


1.2) connect to the GCS IP adress from the vehicle:

mavsdk::Mavsdk mavsdkConnection;
auto result = mavsdkConnection.add_any_connection("udp://");
if ( {
   auto system =;

The other approach is:

2.1) create a dedicated UDP MAVLink Comm Link in QGC with the vehicle as a server:


2.2) subscribe the vehicle to connection attempts from the GCS:

mavsdk::Mavsdk mavsdkConnection;
auto result = mavsdkConnection.add_any_connection("udp://:14551");
auto prom = std::promise < std::shared_ptr < mavsdk::System >> {};
auto fut = prom.get_future();

mavsdkConnection.subscribe_on_new_system([&mavsdkConnection, &prom]() {
    auto system =;

auto system = fut.get();

Both approaches seem to work, but I wonder if one of them can be considered the “preferred” one? I tend to like the second approach better, since the vehicle does not have to know the GCS address.

Thanks in advance for your input…