Connect mavlink (on RPi) with QGroundControl

2.4k views Asked by At

I am trying to connect Mavlink (installed on RPi) with QGroundControl via 3DR Radio Telemetry as to transmit telemetry data from RPi without dependency of Ardupilot/Px4 flightcontrollers. I want to achieve transmitting data such as GPS or Postion using the message format of mavlink without dependency of ardupilot/PX4.

So far, I have taken the example code from mavlink git and have built the code as per instructions. I start the QGroundControl and was able receive the System ID and component ID from QGC. I modified the code to transmit a heartbeat from RPI-mavlink to QGroundControl.

mavlink_msg_heartbeat_pack(system_id, 200, &msg, MAV_TYPE_HELICOPTER, MAV_AUTOPILOT_GENERIC, MAV_MODE_GUIDED_ARMED, 0, MAV_STATE_ACTIVE);

int len_hb = write_message(msg);

After building and executing this code, I was expecting the QGroundControl to connect/show received message, but nothing was available at the QGroundControl.

I need to understand if what I am doing is the right way to do or if there is predefined method to establish such kind of communication. Kindly, help me out with documentations (if any) available to accomplish message transmission without ardupilot/Px4. If someone could guide me on this issue, it would be really helpful.

Thanks

2

There are 2 answers

1
Michael On

If you use RPi you not need the 3DR Radio Telemetry. You can connect RPi by WiFi or LTE to send/receive the Mavlink data. You need:

  1. Wire the RPi to the flight controller;
  2. Setup the Mavlink port in the QGroundControl, let the flight controller send the data to a telemetry port;
  3. Install the mavlink-router to RPI;
  4. Setup the mavlink-router send data to groundstation;
  5. When you can receive mavlink data in the groundstation, you use pymavlink to send mavlink message. There is a sample code
0
Joshi Vatsal On

If I have understood the question correctly, then what you are trying to do is to develop your own flight controller using raspberry pi. And, you want it to be detected as a vehicle in the QGC.

The example code that you are referring to from mavlink repository is used on the ground station to receive messages from a flight controller and send command messages to it. However, you are trying to send message from flight controller to the ground station.

What you will first have to do is to keep sending a heartbeat message at the rate of 1Hz as described in heartbeat microservice on mavlink documentation page. QGroundControl will detect a vehicle if it receives heartbeats from a vehicle I guess for about 5 seconds continuously. You have to keep sending the heartbeat at 1Hz after that as well, otherwise the QGC will state communication loss even if you are sending other mavlink messages to it.

On top of that, there are many mavlink messages which can have different interpretation for different flight controller. So, at some point you either will have to match your code to a certain extent to an existing flight controller or you will have to modify QGC to work with how you implement your flight controller.