Yes, port 9000 is set up in mavproxy as a udp input, which is useful for things like sending a sensor reading to it for it to pass to the autopilot or up to QGC. If you want to get readings from it repeatedly then you’ll need to send it regular updates, e.g.
import time
import math
from pymavlink import mavutil
def wait_conn():
"""
Sends a ping to stabilish the UDP communication and awaits for a response
"""
msg = None
while not msg:
master.mav.ping_send(
int(time.time() * 1e6),
0,
0, # Request ping of all systems
0 # Request ping of all components
)
msg = master.recv_match()
time.sleep(0.5)
def send_heartbeat():
"""
Sends a heartbeat message to continue getting telemetry updates.
"""
master.mav.heartbeat_send(
mavutil.mavlink.MAV_TYPE_ANTENNA_TRACKER, # something that just listens
mavutil.mavlink.MAV_AUTOPILOT_INVALID, # not an autopilot
0, 0, 0
)
def get_attitude(timeout=0.1):
return master.recv_match(type='ATTITUDE', blocking=True, timeout=timeout)
master = mavutil.mavlink_connection('udpout:0.0.0.0:9000')
wait_conn()
print("connection successful")
t=0
while True:
# get the latest attitude data
message = get_attitude()
while message is None:
send_heartbeat()
message = get_attitude()
message = message.to_dict()
# do something with it
print("{:>5} -- pitch:{:.1f}, roll:{:.1f}, yaw:{:.1f}, pitchspeed:{:.3f}, rollspeed:{:.3f}, yawspeed:{:.3f}".format(
t,
math.degrees(message['pitch']),
math.degrees(message['roll']),
math.degrees(message['yaw']),
message['pitchspeed'],
message['rollspeed'],
message['yawspeed'])
)
# track progress
t += 1
time.sleep(0.1)