Heading & Depth data to surface?

If you want to get the data from your surface computer or in the Rpi, you can use this simple pymalink example:

# Float division
from __future__ import division
 
# Import mavutil
from pymavlink import mavutil
 
# Create the connection
# From topside computer
master = mavutil.mavlink_connection('udp:192.168.2.1:14550')
 
def update():
    # Get all messages
    msgs = []
    while True:
        msg = master.recv_match()
        if msg == None:
            break
        msgs.append(msg)
 
    # Create dict
    data = {}
    for msg in msgs:
        data[msg.get_type()] = msg.to_dict()
    # Return dict
    return data
 
while True:
    data = update()
    if 'RAW_IMU' in data:
        print('IMU [x,y,z] [mg]: ',data['RAW_IMU']['xacc'], data['RAW_IMU']['yacc'], data['RAW_IMU']['zacc'])
    if 'ATTITUDE' in data:
        print('ATTITUDE [r,p,y] [rad]: ', data['ATTITUDE']['roll'], data['ATTITUDE']['pitch'], data['ATTITUDE']['yaw'])

To allow your program to run parallel with QGC you will need to create a second output in mavproxy, like this: --out udp:192.168.2.1:14550 --out udp:192.168.2.1:14777.

1 Like