MAVLink REQUEST_DATA_STREAM parameters?

Hi I’m working on trying to send MAVLink commands to ArduCopter requesting it to send GPS data.

From what I understand, the newer MESSAGE_INTERVAL MAVLink command is not supported but REQUEST_DATA_STREAM is. However I am unsure about some of the parameters for the MAVLink packing function.

^ This is the documentation that my MAVLink library gives for the REQUEST_DATA_STREAM packing function. I said system_id to 32 (from what I understand this is an arbitrary number between 1 and 255, though I’ve also tried using 1 and 255 and nothing improved), for component_id I used 1, for target_system I used 1, for target_component I used 220 aka MAV_COMP_ID_GPS (GPS’s component ID), start_stop is set to 1.

I’m assuming that the req_stream_id is supposed to be the id # of the MAVLink message that I want ArduCopter to send. I’ve tried 24, 25, 63, etc.

req_message_rate is something that I am wary of. I’ve set it to 100, 1000, 100000, and 38400 (baud rate of GPS component) but nothing has improved.

No matter what I do, the only thing ArduCopter sends back is the same constant heartbeat messages as always. I’ve tried using PARAM_REQUEST and that actually worked so I don’t know what’s up with REQUEST_DATA_STREAM.

Any help would be greatly appreciated, this is driving me crazy.

1 Like

Here is a sample of what I did some time ago. The simple thing to do is set this on the Ardupilot so you don’t need to do this.

const int maxStreams = 6; const uint8_t MAVStreams[] = { MAV_DATA_STREAM_RAW_SENSORS, MAV_DATA_STREAM_EXTENDED_STATUS, MAV_DATA_STREAM_RC_CHANNELS, MAV_DATA_STREAM_POSITION, MAV_DATA_STREAM_EXTRA1, MAV_DATA_STREAM_EXTRA2}; const uint16_t MAVRates[] = { 0x02, 0x05, 0x02, 0x05, 0x02, 0x02}; for (i=0; i < maxStreams; i++) { t = mavlink_msg_request_data_stream_pack(mavlink_system.sysid, mavlink_system.compid, buf, Md.System, Md.Compent, MAVStreams[i], MAVRates[i], 1);

The rate is the number of times per second you want this type of data.
In Mission Planner they are listed as Serial Port_Item:
SR0_RAW_SENS

Mike

Hi Matt,

This might be working, but there is no reason why you are sending the message with that ID. You want to target the autopilot, not a GPS (and there’s no GPS that talks MAVLink that I’m aware). The system is the vehicle, the autopilot is one of the components, a MAVLink gimbal is another component, a companion computer another, etc.

No, you can’t select individual messages with REQUEST_DATA_STREAM, you can only select streams. The available streams are defined in the MAV_DATA_STREAM (http://mavlink.org/messages/common).

Thanks yeah I ended up figuring it out a bit after stumbling across the MAV_DATA_STREAM enum. For some reason I can only get it to send all of the statuses (stream id 0) and not just position (stream id 6).

More is better than nothing though so I’ve been able to get on with my work regardless, thank you all for the help!

Hi Matt,

Did you success with enable some types of data streaming and disable some types? I am getting too many packets and want just to get specific packets like MAV_DATA_STREAM_POSITION but I still get other types.
Do you keep sending heartbeats or not?
Can you help me with a complete example :slight_smile: ?
Thanks
@Matt_Kun

Hi!
Did you get the methods?

Hello, about REQUEST_DATA_STREAM (and mavlink1.0). I tried to send command as described here https://mavlink.io/en/messages/ardupilotmega.html#MEMINFO and https://ardupilot.org/dev/docs/mavlink-requesting-data.html. But in both links sequense of Request is wrong, and in first MAV_DATA_STREAM - have inaccurate description. Need to see the description “Using SRx Parameters” in second link, and number of parameter in MAV_DATA_STREAM.

My sequense of request to start:
0xFE 0x06 0x01 0x01 0x01 0x42 0x01 0x00 0x01 0x00 0x02 0x01 0x65 0x28
where
0xFE
0x06 0x01 0x01 0x01 0x42 - heading
0x01 0x00 0x01 0x00 0x02 0x01 -
0x01 0x00 - rate in Hz (lsb ) = 1Hz
01 - system id
00 - component id (don’t know why 0)
02 - number of stream in MAV_DATA_STREAM = MAV_DATA_STREAM_EXTENDED_STATUS
01 - start
0x65 0x28 - crc (lsb)

About numder of stream: I need [GPS_RAW_INT], in SRx params - stream is SRx_EXT_STAT, than look at the MAV_DATA_STREAM - value 2 fits (at first I tried value 1 - no data needed).

Answers:
FE 09 7D 01 01 00 00 00 00 00 02 03 51 03 03 4F 03 FD 09 00 00 6E FF BE 00 00 00 00 00 00 00 06 08 00 00 03 C8 9A - heartbit
FE 1F 7E 01 01 01 2F FC 60 03 2F 1C 60 00 2F 9C 50 01 C8 01 00 00 FF FF 00 00 00 00 00 00 00 00 00 00 00 00 FF 28 B1 - sys_stat
FE 06 7F 01 01 7D 05 13 3A 00 04 00 BD B4 - power_status
FE 04 80 01 01 98 00 00 FF FF 52 7F - Meminfo
FE 1A 81 01 01 3E 20 1A 86 B9 90 C3 A7 B9 10 AC 3A 40 00 00 00 00 00 00 00 00 17 00 00 00 00 00 FD 4F - nav_controller_output
FE 02 82 01 01 2A 00 00 3A 40 - mission_current
FE 1E 83 01 01 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 98 BD FF FF 0F 27 0F 27 00 00 00 00 01 00 BE A1 - gps_raw_int

My sequense to stop stream:
0xFE 0x06 0x02 0x01 0x01 0x42 0x01 0x00 0x01 0x00 0x02 0x00 0x0e 0xcf