Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Collapse
Brand Logo

ModalAI Forum

  1. ModalAI Support Forum
  2. Ask your questions right here!
  3. How can I use MAVLINK to obtain odometry values

How can I use MAVLINK to obtain odometry values

Scheduled Pinned Locked Moved Ask your questions right here!
2 Posts 1 Posters 572 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • José QuintanillaJ Offline
    José QuintanillaJ Offline
    José Quintanilla
    Regular
    wrote on last edited by
    #1

    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())
    
    

    Screenshot from 2023-06-26 14-46-59.png
    Screenshot from 2023-06-26 14-47-27.png
    Screenshot from 2023-06-26 14-47-45.png Screenshot from 2023-06-26 14-47-56.png

    José QuintanillaJ 1 Reply Last reply
    0
    • José QuintanillaJ José Quintanilla

      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())
      
      

      Screenshot from 2023-06-26 14-46-59.png
      Screenshot from 2023-06-26 14-47-27.png
      Screenshot from 2023-06-26 14-47-45.png Screenshot from 2023-06-26 14-47-56.png

      José QuintanillaJ Offline
      José QuintanillaJ Offline
      José Quintanilla
      Regular
      wrote on last edited by
      #2

      @tom @Chad-Sweet

      1 Reply Last reply
      0

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      ModalAI
      Categories Recent Tags ModalAI.com Docs
      © 2026 ModalAI® · Accelerating autonomy for smaller, smarter, safer drones · Powered by NodeBB
      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups