Establishing a MAVLINK connection to VOXL 2
-
Hi everyone, I am trying to read mavlink messages like the pressure and altitude from the VOXL 2 sensors using python. I wanted to make sure that the udpin to the mavlink connection is correct? Would setting the udpin to localhost work or is there another udpin address to use for connecting the VOXL 2 board to the mavlink server? I set the port number to 14557 based on the first diagram in this page: (https://docs.modalai.com/mavlink/).
# MAVLINK Common Message Set: https://mavlink.io/en/messages/common.html from pymavlink import mavutil the_connection = mavutil.mavlink_connection('udpin:localhost:14557') the_connection.wait_heartbeat() print("Heartbeat from system (system %u component %u)" % (the_connection.target_system, the_connection.target_component)) while True: try: # local xyz position msg_pos = the_connection.recv_match(type='LOCAL_POSITION_NED', blocking=True) print(msg_pos.x, msg_pos.y, msg_pos.z) # altitude msg_altitude = the_connection.recv_match(type='ALTITUDE', blocking=True) print(msg_altitude.altitude_local, msg_altitude.altitude_relative) # pressure msg_pressure = the_connection.recv_match(type='SCALED_PRESSURE', blocking=True) print(msg_pressure.press_abs) except KeyboardInterrupt: print('Terminating mavlink...') break