Hi!
I am trying to get attitude messages from my speedybee 405v3 to companion PC using MAVLink2 lib, that was generated from ardupilotomega.xml using mavgen.py. Unfortunately, i can`t upload directly autogenerated lib, but here you can see it.
Code, that can get attitude messages:
def read_mavlink_message(serial_obj, mav_obj):
while True:
byte = serial_obj.read(1) # Read one byte at a time
if byte:
msg = mav_obj.parse_char(byte)
if msg:
return msg
serial_obj = serial.Serial('/dev/ttyS6', baudrate=921600, timeout=1)
mav_obj = mav_custom(file=serial_obj, srcSystem=1, srcComponent=0, use_native=True)
mav_obj.command_long_send(mav_obj.srcSystem, mav_obj.srcComponent, MAV_CMD_SET_MESSAGE_INTERVAL, 0, MAVLINK_MSG_ID_ATTITUDE, 10000, 0, 0, 0, 0, 0)
print(mav_obj)
attitude_count = 0
start_time = perf_counter()
duration = 1
while True:
incom_data = read_mavlink_message(serial_obj, mav_obj)
print(incom_data.get_type())
if incom_data and incom_data.get_type() == "ATTITUDE":
print(incom_data)
This code sample gave me 100Hz for attitude messages. But when i trying to wrap it in class (that inherit from class MAVLink(object) from Mavlink2.py) or in procedure style wrap that sample - i am getting only HEARTBEAT messages or TIMESYNC.
Here you can see procedure wrapping for that code sample. For handling serial connection Im using this code.
Thank`s to anyone, who can help me or discuss that problem!