Hello world.

I'm running Pi3 with Px4

I have a custom mavproxy_ins.py module. Could you please explain how to access m.lat, m.lon and other variables in mavproxy.py 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 "mavproxy.py  --master=/dev/ttyS0 --baudrate 115200 --load ins" command. Should I "import mavproxy_ins"? in mavproxy.py 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 mavproxy.py) 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: ', m.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)

Views: 196

Attachments:

Reply to This

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service