# MAVSDK Server Plugins: How To Connect?

**URL:** <https://discuss.px4.io/t/mavsdk-server-plugins-how-to-connect/26073>\
**Category:** MAVSDK\
**Created:** [February 6, 2022, 8:05pm UTC](https://discuss.px4.io/t/mavsdk-server-plugins-how-to-connect/26073 "2022-02-06T20:05:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![WaldoPepper](https://discuss.px4.io/letter_avatar_proxy/v4/letter/w/41988e/32.png) [@WaldoPepper](https://discuss.px4.io/u/WaldoPepper)\
**Post date:** [February 6, 2022, 8:05pm UTC](https://discuss.px4.io/t/mavsdk-server-plugins-how-to-connect/26073/1 "2022-02-06T20:05:09Z")

</div>

Hi,

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:

![image](https://discuss.px4.io/uploads/default/original/2X/0/08dab2fd0677ba1e236fba082e21ed6938c48b16.png)

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

```auto
mavsdk::Mavsdk mavsdkConnection;
...
auto result = mavsdkConnection.add_any_connection("udp://192.168.0.155:14551");
if (mavsdkConnection.systems().size()) {
   auto system = mavsdkConnection.systems().back();
   ...
}

```

The other approach is:

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

![image](https://discuss.px4.io/uploads/default/original/2X/6/6a676b5c9a438fd5a56e1800d1bdc6bcd1bd9120.png)

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

```auto
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 = mavsdkConnection.systems().back();
    prom.set_value(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…

Kai
