Requesting Data From The Autopilot

The ground station or companion computer can request the data it wants (and the rate) using one of the following methods:

  • Set the SRx_ parameters to cause the autopilot to pro-actively send groups of messages on start-up. This method is easy to set-up for a small number of drones but is not recommended for most applications
  • Send REQUEST_DATA_STREAM messages to set the rate for groups of messages
  • Send a SET_MESSAGE_INTERVAL command (within a COMMAND_LONG message) to precisely control the rate of an individual message. Note this is only supported on ArduPilot 4.0 and higher
  • Send a REQUEST_MESSAGE command (within a COMMAND_LONG message) to request a single instance of a message. Note this is only supported on ArduPilot 4.0 and higher

More details of these methods can be found below.

Using SRx Parameters

Setting the SRx_ parameters (and then rebooting the autopilot) will cause the autopilot to pro-actively send groups of messages to the ground station. This is not the recommended method because the ground station has no way to determine what “x” should be.

Using REQUEST_DATA_STREAM

Most ground stations including the Mission Planner use this method. See “Setting the datarate” section of the Telemetry Logs wiki page.

Send a REQUEST_DATA_STREAM message with the following fields

  • target_system : the mavlink system id of the vehicle (normally “1”)
  • target_components : normally “0”
  • req_stream_id : 0 to 12 corresponding to the group of messages (see MAV_DATA_STREAM). See the “Using SRx Parameters” section above to determine exactly which messages are in each group
  • req_message_rate : the rate (in hz) of the message
  • start_stop : “1” to start sending, “0” to stop

Using SET_MESSAGE_INTERVAL

This method provides the most precise control and reduces bandwidth requirements (because unnecessary messages are not sent) but requires knowing exactly which messages you require

Send a COMMAND_LONG with the following fields

  • target_system : the mavlink system id of the vehicle (normally “1”)
  • target_components : normally “0”
  • command: 511 (for MAV_CMD_SET_MESSAGE_INTERVAL)
  • confirmation: 0
  • param1: desired mavlink message’s id (i.e. 33 for GLOBAL_POSITION_INT)
  • param2: time interval between messages in microseconds (i.e. 100000 for 10hz, 1000000 for 1hz)
  • param3 to param7: 0 (not used)

Warning

If the telemetry link is shared (i.e. multiple GCSs or a GCS and a companion computer) there can be conflicting requests. The most common example is the Mission Planner using the REQUEST_DATA_STREAM method while a companion copmuter uses SET_MESSAGE_INTERVAL method. Mission Planner at least allows turning off the REQUEST_DATA_STREAM requests by setting the rates to “-1” (see Setting the datarate here). MAVProxy users can set messagerate -1.

Using REQUEST_MESSAGE

A GCS can poll for a single instance of a message from the autopilot.

Send a COMMAND_LONG with the following fields

  • target_system : the mavlink system id of the vehicle (normally “1”)
  • target_components : normally “0”
  • command: 512 (for MAV_CMD_REQUEST_MESSAGE)
  • confirmation: 0
  • param1: desired mavlink message’s id (i.e. 33 for GLOBAL_POSITION_INT)
  • param2: depends on message requested; see that message’s definition for details.
  • param3 to param7: 0 (not used)

Checking The Message Rates

Some ground stations including Mission Planner and QGC include a “MAVLink Inspector” which is useful when checking the update rate of specific messages.

If using Mission Planner:

  • Press Ctrl-F
  • Push the “MAVLink Inspector” button
  • Expand the vehicle and component IDs to see individual messages and their update rate
../_images/mavlink-mp-mavlink-inspector.png

If using MAVProxy:

  • module load messagerate
  • messagerate status