frompymavlinkimportmavutil# cast helpersfromtypingimportcastfrompymavlink.dialects.v20.commonimportMAVLink_messagefrompymavlink.mavutilimportmavtcpconn=mavutil.mavlink_connection('tcp:127.0.0.1:5760')conn=cast(mavtcp,conn)# Make sure the connection is validconn.wait_heartbeat()# Get some information !whileTrue:try:msg=conn.recv_match(blocking=True)msg=cast(MAVLink_message,msg)ifmsg:print(msg.get_type(),msg.to_dict())exceptExceptionas_:pass
frompymavlinkimportmavutil# cast helpersfromtypingimportcastfrompymavlink.dialects.v20.commonimportMAVLink_messagefrompymavlink.dialects.v20.ardupilotmegaimportMAVLinkfrompymavlink.dialects.v20importcommonfrompymavlink.mavutilimportmavtcpconn=mavutil.mavlink_connection('tcp:127.0.0.1:5760')conn=cast(mavtcp,conn)defrequest_message_interval(conn:mavtcp,message_id:int,frequency_hz:float):""" Request MAVLink message in a desired frequency, documentation for SET_MESSAGE_INTERVAL: https://mavlink.io/en/messages/common.html#MAV_CMD_SET_MESSAGE_INTERVAL Args: message_id (int): MAVLink message ID frequency_hz (float): Desired frequency in Hz """conn.mav.command_long_send(conn.target_system,conn.target_component,common.MAV_CMD_SET_MESSAGE_INTERVAL,0,message_id,# The MAVLink message ID1e6/frequency_hz,# The interval between two messages in microseconds. Set to -1 to disable and 0 to request default rate.0,0,0,0,# Unused parameters0,# Target address of message stream (if message has target address fields). 0: Flight-stack default (recommended), 1: address of requestor, 2: broadcast.)# Make sure the connection is validconn.wait_heartbeat()request_message_interval(conn,common.MAVLINK_MSG_ID_GPS_RAW_INT,1)# Get some information !whileTrue:try:msg=conn.recv_match(blocking=True)msg=cast(MAVLink_message,msg)ifmsg:print(msg.get_type(),msg.to_dict())exceptExceptionas_:pass
frompymavlinkimportmavutilimporttimefrompymavlink.dialects.v20importcommon# Create the connection to the top-side computer as companion computer/autopilotmaster=mavutil.mavlink_connection("udpout:localhost:14550",source_system=1,source_component=190)whileTrue:master.mav.statustext_send(common.MAV_SEVERITY_INFO,"QGC will read this".encode())time.sleep(1)
udpout
Send mavlink stream over udp
Send other location using ADSB
Send other location information using ADSB check mavlink message ADSB_VEHICLE (246)