Hi,
I am confused on how mavutil.messages work in pymavlink.
I have a orange cube ardupilot drone. And right after connection, I print out the field in mavutil.messages, it shows me “MAV” , “HOME” field, which I assume supposed to be default telemetry stream. And then, after I used the following code to loop receiving the msgs, I got some other fields from mavutil.messages like “ALTITUDE”, "GLOBAL_LOCATION_INT.
async def _message_listener(self):
logger.info("-- Starting message listener")
try:
while True:
msg = await asyncio.to_thread(self.vehicle.recv_match, blocking=True)
if msg:
message_type = msg.get_type()
logger.debug(f"Received message type: {message_type}")
except asyncio.CancelledError:
logger.info("-- Message listener stopped")
except Exception as e:
logger.error(f"-- Error in message listener: {e}")
However, i dont want to loop receiving the the msg all the time for saving my computation resource. And I find the quote from this post.
it seems like using this MAV_CMD_SET_MESSAGE_INTERVAL can make the autopilot to automatically send the nondefault message stream without requesting it. I tried it in my code without using the loop receiving mechanism. The mavutil.messages still shows only “MAV” and “HOME” field after the MAV_CMD_SET_MESSAGE_INTERVAL.
Can anyone explains this? is the communication model for pymavlink using request/reply or push/pull kind? when to properly use mavutil.messages? how does using recv_match() method affect the field stored in mavutil.messages?