Issue with Setting MAVLink Message Rates using MAV_CMD_SET_MESSAGE_INTERVAL

Hi all,

I am currently working on a project using a Pixhawk flight controller and communicating with it using MAVLink through a Raspberry Pi. I’ve been attempting to control the rate of specific MAVLink messages using the MAV_CMD_SET_MESSAGE_INTERVAL command. However, I’ve encountered an issue that I hope to get some assistance with.

Here’s a brief overview of what I’m trying to achieve and the problem I’m facing:


  • Increase the rate of message ID 30 (ATTITUDE) to 10Hz.
  • Add message ID 31 (GLOBAL_POSITION_INT) with a rate of 4Hz.
  • Disable or reduce the rate of message ID 193.

Issue: When I send the MAV_CMD_SET_MESSAGE_INTERVAL command, I receive a positive acknowledgment (MAV_RESULT_ACCEPTED). However, when I check the message rates using MAVLink Inspector, I do not observe the expected changes in the message rates, except for the addition of message ID 31.

Steps Taken:

  1. Established a MAVLink connection using pymavlink on a Raspberry Pi.
  2. Sent MAV_CMD_SET_MESSAGE_INTERVAL commands to set the desired message rates.
  3. Checked the rates using MAVLink Inspector and found inconsistencies with expected results.

Code Snippet: I have been using a Python script with pymavlink to establish the connection and send the commands. Here’s a snippet of the code I use to send the MAV_CMD_SET_MESSAGE_INTERVAL command:

message = master.mav.command_long_send(
    master.target_system,  # Target system ID
    master.target_component,  # Target component ID
    mavutil.mavlink.MAV_CMD_SET_MESSAGE_INTERVAL,  # ID of command to send
    0,  # Confirmation
    message_id,  # param1: Message ID to be streamed
    int(1e6 / rate_hz),  # param2: Interval in microseconds
    0,  # param3 (unused)
    0,  # param4 (unused)
    0,  # param5 (unused)
    0,  # param6 (unused)
    0   # param7 (unused)

Has anyone faced a similar issue or is there something I might be missing? Any help or guidance would be immensely appreciated. Thank you in advance!

Best Regards,

Probably your respective SRx_ parameters are not 0 like they should be .
Have you started mavproxy with --stream_rates=-1?

Thank you for your prompt response, amilcarlucas.

Indeed, I initially did not start MAVProxy with the --streamrate=-1 option. Having adjusted that, I now observe in the Mavlink Inspector that all messages are received approximately at the desired rate (around 10Hz). However, I’m encountering an issue with the SRx_ parameters: I am unable to set them to 0 as they seem to be updated each time the autopilot boots. Do you have any advice on how to maintain them at 0 or work around this automatic update?

Mission planner sets those parameters.
You need to always use mavproxy with --streamrate=-1 or configure the rates in the mission planner advanced settings.

1 Like

Done, it works, thank you so much!!