Table of Contents
MAVLink Ground Control Integration Tutorial
This tutorial covers the integration of new MAVLink packet formats. Assuming you successfully followed the MAVLink Onboard Integration Tutorial, you can now receive data from your MAV.
This is work in progress, please feel free to edit/extend it
Integrating your messages has two primary phases:
- Expose your custom messages to QGroundControl, which enables basic functionality like data logging, the MAVLink receive widget, and the MAVLink send widget
- Create a new UAS subclass that can appropriately handle the data coming in from your new messages.
Exposing custom messages to QGroundControl
Follow the instructions below to compile QGroundControl with your own custom messages. This provides a base set of functionality such as data logging, using the MAVLink Receive widget to view incoming messages, and using the MAVLink Transmit widget to manually transmit messages.
- Make a MAVLink message definition .xml file like the one shown below (reference the files in
/message_definitionsin the MAVLink project).
- Follow the MAVLink library generation instructions to generate a custom MAVLink library (this will involve using
mavgen.pyin the MAVLink project to create a custom 1.0 version of MAVLink for the C language).
- Copy the generated files into the
user_config.priand modify it so that the
MAVLINK_CONFvariable is set to the name of your custom messages: for example, if your file was called
MAVLINK_CONFshould be set to slugs.
- Optional: Follow the instructions in the section below about extending the UAS base class
- Follow the build instructions for QGC for your platform.
Creating a new UAS subclass
If additional functionality is required, you'll need to write some C++ code. QGroundControl represents each MAV with its own class, which derives from the base class of UAS. This is the default class for all MAVs, though that can be overridden by specifying the correct
AUTOPILOT_TYPE in heartbeat messages transmit from your autopilot. An example of an existing subclass of UAS, like what you will create, can be found in the PxQuadMAV class, which represents a PIXHAWK quadrotor.
To begin your integration:
- Create a new class (in
/src/uas) that derives from
UASInterface, and is a
Q_OBJECT(reference PxQuadMAV if necessary).
- The primary function of this class will be in the overridden
receiveMessage()function that processes all MAVLink messages as they're received.
/src/uas/QGCMAVLinkUASFactor.ccto add a switch for your Autopilot type and to instantiate the correct class.
- Choose an unused value for your AUTOPILOT_TYPE transmit in your heartbeat message and check for that value. If you're looking to push your code back into QGroundControl also modify the AUTOPILOT_TYPE_ENUM in
common.xmlwith a new value for your specific autopilot.
- If necessary, modify other code within QGroundControl by checking for the
%1is replaced with your autopilot name (which was specified in the
MAVLINK_CONFvariable. Use the standard C/C++
#endifto isolate your changes to only when QGroundControl is compiled for your autopilot.
- Modify the
qgroundcontrol.profile to include the header and source file for your new class when compiling.