Servers by jDrones

MAVLink REQUEST_DATA_STREAM parameters?

(Matt) #1

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
(iseries) #2

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

(Francisco Ferreira) #3

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).

(Matt) #4

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!

(Soubhi Hadri) #5

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

(yepzhang) #6

Hi!
Did you get the methods?