How can I use MAVLINK to obtain odometry values
-
I already have the code working with a SITL but I want to be able to connect my laptop to the drone and obtain the data, im able to connect through QGC but not through the code
from pymavlink import mavutil import asyncio async def run(): while True: # Start a connection listening on a UDP port the_connection = mavutil.mavlink_connection('udpin:localhost:14550') # Wait for the first heartbeat # This sets the system and component ID of remote system for the link the_connection.wait_heartbeat() print("Heartbeat from system (system %u component %u)" % (the_connection.target_system, the_connection.target_component)) asyncio.sleep(2) # Once connected, use 'the_connection' to get and send messages msg = the_connection.recv_match(type ='ODOMETRY',blocking=True) msg = str(msg) msg = msg.split(',') print(msg[17]) #print(msg) asyncio.sleep(2) if __name__ == "__main__": loop = asyncio.get_event_loop() loop.run_until_complete(run())


-
I already have the code working with a SITL but I want to be able to connect my laptop to the drone and obtain the data, im able to connect through QGC but not through the code
from pymavlink import mavutil import asyncio async def run(): while True: # Start a connection listening on a UDP port the_connection = mavutil.mavlink_connection('udpin:localhost:14550') # Wait for the first heartbeat # This sets the system and component ID of remote system for the link the_connection.wait_heartbeat() print("Heartbeat from system (system %u component %u)" % (the_connection.target_system, the_connection.target_component)) asyncio.sleep(2) # Once connected, use 'the_connection' to get and send messages msg = the_connection.recv_match(type ='ODOMETRY',blocking=True) msg = str(msg) msg = msg.split(',') print(msg[17]) #print(msg) asyncio.sleep(2) if __name__ == "__main__": loop = asyncio.get_event_loop() loop.run_until_complete(run())


Reading along? Create a free ModalAI Forum account to join in.
With an account you can reply, ask your own question, get an email when a ModalAI engineer answers, and mark the reply that solved it. Your place in each thread is saved between visits.
Questions about VOXL, Flight Core, ESCs and ModalAI drones are answered here by the engineers who build them.
Register Login