Hi, I am currently using pymavlink on a Raspberry Pi and all is going well.
I am requesting the current compass heading or the lat/lon using the
“msg = vehicle.recv_match(type=b’VFR_HUD’, blocking=True, timeout = 2 ) command.
It works well, but it seems to be wasting time, since the autopilot is sending out allot of data that I do not need. Can I request only one current status value like “VFR_HUD” or only the current compass heading?
If I continuously loop and read the compass heading, then it takes between 200-250ms. I do understand that I can increase the update time.
Thanks for any suggestions.
Yes, you can request only the mavlink messages you want at the intervals that you want.
google for “request_message_interval mavlink” it will get you:
I just figured it out. Posting the code here:
vehicle.mav.command_long_send(vehicle.target_system, vehicle.target_component, mavutil.mavlink.MAV_CMD_REQUEST_MESSAGE,
0, # confirmation - always 0
74, # mode_id VFR_HUD=74 GPS=33
0, # Param 2
0, # Param 3
0, # Param 4
0, # Param 5
0, # Param 6
0) # Param 7
ack_msg = vehicle.recv_match(type='COMMAND_ACK', blocking=True, timeout=3)
#### COMMAND_ACK has a message id of 512.
msg = vehicle.recv_match(blocking=True)
if msg.name == 'VFR_HUD':
elif msg.name == 'HEARTBEAT':
Not request message.
Request message interval.