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 mavlink_shell.py 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!

Hi both, I am having the same problem as you! I am using MAVSDK v1.4 (I find this by seeing which git branch I have checked out). I have tested this by using a Raspberry Pi4B+ connected by both the TX,RX pinouts to the TELEM2 port on the Orange Cube as well as via usb connection.

I have also determined that connecting the flight controller to QGroundControl through any machine, then disconnecting the Orange Cube (ensuring it still has power) and then reconnecting the usb cable to the RPi 4B+ will actually allow the autopilot connection when running any MAVSDK example script.

This means that the issue must come from the OrangeCube side (i.e. PX4 firmware) or that QGroundControl is initialising something which MAVSDK is not. I tried an earlier version of PX4 firmware and it did not have this problem. Perhaps there is a setting which QGroundControl changes when initialising a connection to the flight controller?

Hopefully someone can help with this issue!

Turns out the issue was relating to the versions of PX4 > 1.3 requiring a heartbeat message to be sent to the flight controller before transmitting telemetry back.

See MAVSDK Only Connects to PX4 Autopilot AFTER QGroundControl is Launched! · Issue #1967 · mavlink/MAVSDK · GitHub for the solution!

1 Like