Using data from mavproxy module

Hello world.

I'm running Pi3 with Px4

I have a custom module. Could you please explain how to access, m.lon and other variables in instead of just printing them? Should I use global variables? I'm relatively new to Python to know how to access a variable in function in class in module :)

I use "  --master=/dev/ttyS0 --baudrate 115200 --load ins" command. Should I "import mavproxy_ins"? in or is it redundant?

If you know any better and simpler way to access latitude, longitude, altitude, roll, pitch and yaw with minimal custom .py program (instead of fiddling with at least with 10Hz refresh rate, I would appreciate that too.

from MAVProxy.modules.lib import mp_module
from pymavlink import mavutil

class inertialData(mp_module.MPModule):
def __init__(self, mpstate):
super(inertialData, self).__init__(mpstate, "ins")
print("Module test loaded")

def mavlink_packet(self, m):
'''handle an incoming mavlink packet'''
if m.get_type() == "GLOBAL_POSITION_INT":
print ('lat: ',, 'lon: ', m.lon, 'alt: ', m.alt)
#if m.get_type() == "RAW_IMU":
# print m
if m.get_type() == "ATTITUDE":
print ('pitch: ', m.pitch, 'roll: ', m.roll, 'yaw: ', m.yaw)

def init(mpstate):
'''initialise module'''
return inertialData(mpstate)

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –


Hiroki Tanaka liked Hiroki Tanaka's profile
Oct 13
Derrick Davies liked lisa TDrones's profile
Sep 23