Where are the MAVLink stream rates specified?

Hi all,

I have a python script which sets up a stream of certain MAVLink parameters and uses those. The problem is now that the data rate is not what I specified and also somehow not predictable.
My setup is as follows: A Raspberry Pi is connected to the Pixhawk as companion computer. It runs Mavproxy. Further I use a python script which connects to MAVProxy over UDP. The python script starts a data stream by REQUEST_DATA_STREAM with a specified stream rate. To prevent MAVProxy from setting another stream rate I start the application with the --streamrate=-1 option.
What I experience is that the stream rate is sometimes close to what I set, e.g. when I set 3 Hz I get 4Hz, setting 23 Hz results in either 20 Hz or 25 Hz and setting 35 Hz in about 50 Hz. Does someone have an idea where this behaviour comes from?

And also does someone know what the stream rate parameters exactly do. I read somewhere that SR0 is realted to USB, but what are the others? And how do they behave when setting the stream rate by REQUEST_DATA_STREAM?

I hope someone can help. Thanks in advance.
-Fabian

I think I am doing the same thing you are. I am using the REQUEST_DATA_STREAM like this:
master.mav.request_data_stream_send(master.target_system, master.target_component,
mavutil.mavlink.MAV_DATA_STREAM_RAW_SENSORS, 50, 1)
I cant really say why you get varying results when you set the data rate but I have the same problem. I am just living with it now.
I have found the stream rate parameters are actually set when we use request_data_stream.
SRO is the usb
SR1 is the telem1 port
SR2 is the telem2 port
SR3 is the GPS port
SR4 is serial 4/5 port
SR5 is serial 4/5 port

On another note when I try and connect to mavproxy with my python script and use request_data_stream i don’t get anything out faster then 4Hz of data. Did you get more?

Hi @Brian_Duvall,
I still have no solution for this problem. Would be really good to find one.

The point with mavproxy is solved. There is a flag in the mavproxy commands that resets the datarate to 4 Hz. Therefore, you have to start mavproxy with the --streamrate=-1 flag. This disables the default behaviour and does not change the datarate anymore.

yea if we plot the time between each mavlink message we see the rate is changing instantaneously. The top plot shows diffrence in mavlink messages for RAW_IMU, second RC_CHANNELS, thrid AIRSPEED_VFR. This would explain why the set rate is close to what we get. I still dont know about that set 25 and get 50? I am afraid this is something we have to live with.