Connection only works after opening QGC

I’m trying to get the default MAVSDK take_off_and_land c++ example running. I have a Herelink connected on the same WiFi network, that is connected to my drone. The connection fails every time, unless I first connect and disconnect QGC. Then it works.

Step by step:

I’m running the default example:

./takeoff_and_land udp://:14552

Results in:

[09:14:30|Info ] MAVSDK version: v0.29.0 (mavsdk_impl.cpp:27)
[09:14:30|Debug] New: System ID: 0 Comp ID: 0 (mavsdk_impl.cpp:404)
Waiting to discover system...
No system found, exiting.

Here is the weird thing. Now I open QGC, and create a comlink to udp://<my_ip>:14552, and that works. Now I disconnect QGC and run the same command again.

./takeoff_and_land udp://:14552

Now it works. How is this possible? What does QGC do that it manages to establish a connection.

1 Like

I’m having a similar problem when trying to use MAVSDK to connect to a pixhawk. Were you able to solve this? Or do you have any tips? Thanks

I solved my problem by running the script and closing the shell, instead of opening and closing QGC(QGroundControl). So in a way the problem remains, but now you only have to run a python script, which is much more doable than having to run QGC.

The answer to what does this script does in order to enable connection after it is closed is, for certain, inside the script itself; you just have to study it, understand it and replicate in your own code.

Hope it helps!