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

ModalAI Forum

  1. ModalAI Support Forum
  2. VOXL Compute & Autopilot
  3. VOXL 2
  4. Help!!! When flying can't control speed

Help!!! When flying can't control speed

Scheduled Pinned Locked Moved VOXL 2
velocitynedyaw
2 Posts 2 Posters 294 Views 1 Watching
  • 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.
  • C Offline
    C Offline
    cy208183395
    Contributor
    wrote on last edited by
    #1

    VelocityNedYaw fails when it controls the code of flight distance and speed, no matter how to adjust the parameters, it will fly at the same speed. And the orientation of the header at initialization is random rather than fixed to the north.

    #!/usr/bin/env python3
    
    import asyncio
    from mavsdk import System
    from mavsdk.offboard import (PositionNedYaw, VelocityNedYaw, OffboardError)
    
    async def run():
    drone = System()
    await drone.connect(system_address="udp://:14551")
    
    print("Waiting for drone to connect...")
    async for state in drone.core.connection_state():
        if state.is_connected:
            print(f"-- Connected to drone!")
            break
    
    # print("Waiting for drone to have a global position estimate...")
    # async for health in drone.telemetry.health():
    #     if health.is_global_position_ok and health.is_home_position_ok:
    #         print("-- Global position estimate OK")
    #         break
    print("-- Arming")
    await drone.action.arm()
    # need delay!!
    await asyncio.sleep(5)
    
    print("-- Setting initial setpoint")
    await drone.offboard.set_position_ned(PositionNedYaw(0.0, 0.0, 0.0, 0.0))
    
    print("-- Starting offboard")
    try:
        await drone.offboard.start()
    except OffboardError as error:
        print(f"Starting offboard mode failed with error code: {error._result.result}")
        print("-- Disarming")
        await drone.action.disarm()
        return
    
    # async def print_z_velocity(drone):
    #     async for odom in drone.telemetry.position_velocity_ned():
    #         print(f"{odom.velocity.north_m_s} {odom.velocity.down_m_s}")
    
    # asyncio.ensure_future(print_z_velocity(drone))
    
    # print("-- Go 0m North, 0m East, -10m Down within local coordinate system")
    # await drone.offboard.set_position_velocity_ned(
    #     PositionNedYaw(0.0, 0.0, -10.0, 0.0),
    #     VelocityNedYaw(0.0, 0.0, -1.0, 0.0))
    # await asyncio.sleep(10)
    
    # print("-- Go 10m North, 0m East, 0m Down within local coordinate system")
    # await drone.offboard.set_position_velocity_ned(
    #     PositionNedYaw(50.0, 0.0, -10.0, 0.0),
    #     VelocityNedYaw(1.0, 0.0, 0.0, 0.0))
    # await asyncio.sleep(20)
    
    print("-- Go 0m North, 0m East, -0.5m Down within local coordinate system")
    await drone.offboard.set_position_velocity_ned(
        PositionNedYaw(0.0, 0.0, -0.5, 0.0),
        VelocityNedYaw(0.0, 0.0, -1.0, 0.0))
    await asyncio.sleep(5)
    
    print("-- Go 0.5m North, 0m East, -0.5m Down within local coordinate system")
    await drone.offboard.set_position_velocity_ned(
        PositionNedYaw(0.5, 0.0, -0.5, 90.0),
        VelocityNedYaw(0.2, 0.0, 0.0, 90.0)
        )
    await asyncio.sleep(5)
    
    # print("-- Go 0.5m North, 0m East, -0.5m Down within local coordinate system")
    # await drone.offboard.set_position_velocity_ned(
    #     PositionNedYaw(0.3, 0.3, -0.5, 90.0),
    #     VelocityNedYaw(0.0, 0.2, 0, 0.0))
    # await asyncio.sleep(5)
    
    
    
    
    
    
    # await drone.action.land()
    
    
    try:
        await drone.action.land()
    except:
        print("Failed to land")
    
    print("-- Disarming")
    try:
        await drone.action.disarm()
    except:
        print("Disarming failed")
    
    
    
    # print("-- Stopping offboard")
    # try:
    #     await drone.offboard.stop()
    # except OffboardError as error:
    #     print(f"Stopping offboard mode failed with \
    #             error code: {error._result.result}")
    if __name__ == "__main__":
        # Run the asyncio loop
        # asyncio.run(run())
        loop = asyncio.get_event_loop()
        loop.run_until_complete(run())
    
    Eric KatzfeyE 1 Reply Last reply
    0
    • C cy208183395

      VelocityNedYaw fails when it controls the code of flight distance and speed, no matter how to adjust the parameters, it will fly at the same speed. And the orientation of the header at initialization is random rather than fixed to the north.

      #!/usr/bin/env python3
      
      import asyncio
      from mavsdk import System
      from mavsdk.offboard import (PositionNedYaw, VelocityNedYaw, OffboardError)
      
      async def run():
      drone = System()
      await drone.connect(system_address="udp://:14551")
      
      print("Waiting for drone to connect...")
      async for state in drone.core.connection_state():
          if state.is_connected:
              print(f"-- Connected to drone!")
              break
      
      # print("Waiting for drone to have a global position estimate...")
      # async for health in drone.telemetry.health():
      #     if health.is_global_position_ok and health.is_home_position_ok:
      #         print("-- Global position estimate OK")
      #         break
      print("-- Arming")
      await drone.action.arm()
      # need delay!!
      await asyncio.sleep(5)
      
      print("-- Setting initial setpoint")
      await drone.offboard.set_position_ned(PositionNedYaw(0.0, 0.0, 0.0, 0.0))
      
      print("-- Starting offboard")
      try:
          await drone.offboard.start()
      except OffboardError as error:
          print(f"Starting offboard mode failed with error code: {error._result.result}")
          print("-- Disarming")
          await drone.action.disarm()
          return
      
      # async def print_z_velocity(drone):
      #     async for odom in drone.telemetry.position_velocity_ned():
      #         print(f"{odom.velocity.north_m_s} {odom.velocity.down_m_s}")
      
      # asyncio.ensure_future(print_z_velocity(drone))
      
      # print("-- Go 0m North, 0m East, -10m Down within local coordinate system")
      # await drone.offboard.set_position_velocity_ned(
      #     PositionNedYaw(0.0, 0.0, -10.0, 0.0),
      #     VelocityNedYaw(0.0, 0.0, -1.0, 0.0))
      # await asyncio.sleep(10)
      
      # print("-- Go 10m North, 0m East, 0m Down within local coordinate system")
      # await drone.offboard.set_position_velocity_ned(
      #     PositionNedYaw(50.0, 0.0, -10.0, 0.0),
      #     VelocityNedYaw(1.0, 0.0, 0.0, 0.0))
      # await asyncio.sleep(20)
      
      print("-- Go 0m North, 0m East, -0.5m Down within local coordinate system")
      await drone.offboard.set_position_velocity_ned(
          PositionNedYaw(0.0, 0.0, -0.5, 0.0),
          VelocityNedYaw(0.0, 0.0, -1.0, 0.0))
      await asyncio.sleep(5)
      
      print("-- Go 0.5m North, 0m East, -0.5m Down within local coordinate system")
      await drone.offboard.set_position_velocity_ned(
          PositionNedYaw(0.5, 0.0, -0.5, 90.0),
          VelocityNedYaw(0.2, 0.0, 0.0, 90.0)
          )
      await asyncio.sleep(5)
      
      # print("-- Go 0.5m North, 0m East, -0.5m Down within local coordinate system")
      # await drone.offboard.set_position_velocity_ned(
      #     PositionNedYaw(0.3, 0.3, -0.5, 90.0),
      #     VelocityNedYaw(0.0, 0.2, 0, 0.0))
      # await asyncio.sleep(5)
      
      
      
      
      
      
      # await drone.action.land()
      
      
      try:
          await drone.action.land()
      except:
          print("Failed to land")
      
      print("-- Disarming")
      try:
          await drone.action.disarm()
      except:
          print("Disarming failed")
      
      
      
      # print("-- Stopping offboard")
      # try:
      #     await drone.offboard.stop()
      # except OffboardError as error:
      #     print(f"Stopping offboard mode failed with \
      #             error code: {error._result.result}")
      if __name__ == "__main__":
          # Run the asyncio loop
          # asyncio.run(run())
          loop = asyncio.get_event_loop()
          loop.run_until_complete(run())
      
      Eric KatzfeyE Offline
      Eric KatzfeyE Offline
      Eric Katzfey
      ModalAI Team
      wrote on last edited by
      #2

      @cy208183395 Can you test this with SITL? Does it work fine there but not on VOXL 2?

      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