Skip to main content

MAVLink

The MAVLink plugin allows you to connect your MAVLink based robot to the DroneDeploy Robotics Portal; the plugin communicates as either a MAVLink TCP/UDP server or client.

The MAVLink plugin is bidirectional; it can both subscribe to MAVLink messages and send them upstream to the DroneDeploy Robotics Portal, as well as receive downstream message from the DroneDeploy Robotics Portal and publish them into the MAVLink network.

Configuration

To use the MAVLink plugin, your agent will need a section in its agent-settings.json file which enables the mavlink component, as shown below. For more information on how to configure the agent plugins, see Agent Configuration.

...
"components": [
...
{
"id": "mavlink",
"enabled": true,
"settings": {
"componentId": 1,
"dialectIncludePath": ".",
"dialectPath": "common.xml",
"endpoints": [
{
"address": "127.0.0.1:5760",
"type": "tcpClient"
},
{
"address": "0.0.0.0:14550",
"type": "udpServer"
}
],
"logLevel": 1,
"name": "mavlink",
"systemId": 1,
"streamRequestEnable": true,
"streamRequestFrequency": 10
}
},
...
]

The MAVLink plugin understands the following configuration parameters:

NameDescriptionDefaultUnit
enabledWhether to enable the MAVLink plugin or not.false
nameHow this instance of the MAVLink plugin should be named."mavlink"
logLevelThe logging verbosity: 1 - very quiet, 6 - very talkative.1
endpointsRequired. The structure containing each endpoint to/from which MAVLink messages are sent/received. Each endpoint has an address and a type. More than one endpoint can be specified, as shown in the JSON example above.
addressRequired. When in server mode, the ip:port on which the plugin should listen. When in client mode, the ip:port to which the plugin should attempt to connect.
typeRequired. Select "udpClient", "udpServer", "tcpClient", or "tcpServer" mode operation.-
dialectPathRequired. File pathway to the .xml file containing the MAVLink dialect you are using.-
dialectIncludePathRequired if 'include' .xml files are in a different location to the .xml file specified in dialectPath. Some MAVLink .xml dialect files have statements at the beginning showing that they 'include' other dialect .xml files. For example, ardupilotmega includes 'common.xml', 'icarous.xml', and 'uAvionix.xml'. This means the ardupilotmega dialect also uses the common, icarous, and uAvionix dialects. If the dialect you are using 'includes' other dialect .xml files, then specify their file directory here.
If include files are located in more than one directory, split each path address using a colon (:).
E.g. "dialectIncludePath": "include/dir/one:include/dir/two"
streamRequestEnableThis parameter is set to automatically request streams to detected ArduPilot devices that need an explicit request in order to emit a telemetry stream. This parameter is only required under those circumstances.false
streamRequestFrequencyThis parameter is used when the parameter 'streamRequestEnable' is required to be set to 'true'. It provides the requested stream frequency in Hz. It defaults to 4 if no value is provided.4Hz

Data Model

The data model for messages sent by this plugin are derived from the MAVLink specification, available here. For instructions on how to send MAVLink payloads to this plugin from the platform, see this documentation.

Examples

These are examples of the JSON objects to send from the platform in the control feature-set. All commands are derived directly from the MAVLink specification for sending commands.

/mavlink/SET_MODE - to change the mode of a vehicle.

For an ArduPilotMega vehicle, assuming a vehicle of type 'copter', to set the mode to guided send a payload formatted as such:

{
"custom_mode":4,
"target_system":1,
"base_mode":1
}

custom_mode is taken from this APM specific dialect in the MAVLink spec: https://mavlink.io/en/messages/ardupilotmega.html#COPTER_MODE - in this case it's 4 for 'guided' mode.

target_system is the system ID of the vehicle on which you're setting the mode.

base_mode is the base mode of the vehicle.

/mavlink/COMMAND_LONG - this message can be used to send a variety of commands, however in this example we use it to arm the vehicle:

{
"target_system": 1,
"target_component" : 1,
"command": 400,
"param1": 1
}

target_system is the system ID of the vehicle to which you're sending the command.

target_component is the component ID of the component to which you're sending the command.

command is the type of the command, in this case corresponding to MAV_CMD_COMPONENT_ARM_DISARM.

param1 this particular command expects one parameter. Set to 1 for arm and 0 to disarm.

Metadata

MetadataDescription
Message IDThis identifies which MAVLink message has been sent. A list of messages in the MAVLink common set can be seen here: https://mavlink.io/en/messages/common.html#messages
Component IDWithin a system/vehicle, different components can send messages. The Component ID provides an identifier for each component. For further information, see: https://mavlink.io/en/messages/common.html#MAV_COMPONENT
System IDID of the system/vehicle sending messages. This is useful, in particular, when there are multiple systems on the network. Determining which system the message has come from is possible with the System ID. Values from 1 - 255 are possible.
Sequence IDA incremented number identifier that gets added to messages sent to keep track of the order in which these messages are sent. This value is between 0 - 255, so after message 255 is sent, the Sequence ID is reset to 0.