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

ModalAI Forum

  1. ModalAI Support Forum
  2. Software Development
  3. Offboard Mode - MAVSDK - Drone random movement

Offboard Mode - MAVSDK - Drone random movement

Scheduled Pinned Locked Moved Software Development
voxl2viomavsdkfcv2odometry
3 Posts 2 Posters 1.8k 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.
  • Jetson NanoJ Offline
    Jetson NanoJ Offline
    Jetson Nano
    Veteran
    wrote on last edited by
    #1

    I'm using a setup consisting of,

    Flight Controller: Flight Core V2
    Comapanion: VOXL2
    PX4 version: PX4 1.14.3 dev version (modalai fork)

    I'm able to connect and communicate between FC and Flight controller through the UART ports. Also initialise the mavlink stream from one of the ports on FC to initiate streaming of mavlink messages.

    mavlink stream -r 30 -s ODOMETRY -d /dev/ttyS6
    

    In voxl-vision-hub, I have defined the offboard mode to trajectory. When shifting to offboard, the drone stays at position since I'm streaming the mavlink message as stated above. The drone hovers stable in the same position(there are no visible drift or random motion which could be observed)

    I have built MAVSDK on VOXL2 and try to execute a python script consisting of a path.

    Below is the script,

    #!/usr/bin/env python3
    
    """
    Caveat when attempting to run the examples in non-gps environments:
    
    `drone.offboard.stop()` will return a `COMMAND_DENIED` result because it
    requires a mode switch to HOLD, something that is currently not supported in a
    non-gps environment.
    """
    
    import asyncio
    
    from mavsdk import System
    from mavsdk.offboard import (OffboardError, PositionNedYaw)
    
    
    async def run():
        """ Does Offboard control using position NED coordinates. """
    
        drone = System()
        await drone.connect(system_address="serial:///dev/ttyHS1:2000000")
    
        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("-- Arming")
        await drone.action.arm()
    
        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
    
        print("-- Go 0m North, 0m East, -1m Down \
                within local coordinate system")
        await drone.offboard.set_position_ned(
                PositionNedYaw(0.0, 0.0, -1.0, 0.0))
        await asyncio.sleep(3)
    
        print("-- Go 1m North, 0m East, -1m Down \
                within local coordinate system, turn to face East")
        await drone.offboard.set_position_ned(
                PositionNedYaw(4.4, 0.0, -1.0, 0.0))
        await asyncio.sleep(7)
    
        print("-- Go 1m North, 0m East, -1m Down \
                within local coordinate system, turn to face East")
        await drone.offboard.set_position_ned(
                PositionNedYaw(4.4, 0.0, -1.0, 90.0))
        await asyncio.sleep(4)
    
        print("-- Go 1m North, 1m East, -1m Down \
                within local coordinate system")
        await drone.offboard.set_position_ned(
                PositionNedYaw(4.45, 2.9, -1.0, 90.0))
        await asyncio.sleep(5)
    
        print("-- Go 0m North, 1m East, -1m Down \
                within local coordinate system, turn to face South")
        await drone.offboard.set_position_ned(
                PositionNedYaw(5.9, 5.0, -1.0, 30.0))
        await asyncio.sleep(8)
        
        print("-- Go 0m North, 0m East, -1m Down \
                within local coordinate system, turn to face South")
        await drone.offboard.set_position_ned(
                PositionNedYaw(10.1, 4.8, -1.0, 0))
        await asyncio.sleep(6)
        
        print("-- Go 0m North, 0m East, 0m Down \
                within local coordinate system, turn to face South")
        await drone.offboard.set_position_ned(
                PositionNedYaw(11.9, 6.6, -1.0, 45))
        await asyncio.sleep(4)
    
        print("-- Go 0m North, 0m East, 0m Down \
                within local coordinate system, turn to face South")
        await drone.offboard.set_position_ned(
                PositionNedYaw(11.9, 6.6, -1.0, 90))
        await asyncio.sleep(2)
    
        print("-- Go 0m North, 0m East, 0m Down \
                within local coordinate system, turn to face South")
        await drone.offboard.set_position_ned(
                PositionNedYaw(12.3, 10.0, -1.0, 90.0))
        await asyncio.sleep(5)
    
        print("-- Go 0m North, 0m East, 0m Down \
                within local coordinate system, turn to face South")
        await drone.offboard.set_position_ned(
                PositionNedYaw(12.7, 13.0, -1.0, 90.0))
        await asyncio.sleep(5)
    
        print("-- Go 0m North, 0m East, 0m Down \
                within local coordinate system, turn to face South")
        await drone.offboard.set_position_ned(
                PositionNedYaw(12.7, 13.0, 0.3, 90.0))
        await asyncio.sleep(1)
    
        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())
    

    Once the above script is initialised once the drone is the air and shifted to offboard mode, the script is supposed to make the drone pass through a set of defined waypoints in NED frame.

    When executing the above script I observe,

    1. there is a random jittery motion in movement of the drone passing trying to reach further waypoints.

    2. Visually I see that there is a resistance in the drone trying to move to next waypoints. Not sure if the drone is trying to come back to Home position.

    How can I make the drone move through the defined waypoints?

    1 Reply Last reply
    0
    • Zachary Lowell 0Z Offline
      Zachary Lowell 0Z Offline
      Zachary Lowell 0
      ModalAI Team
      wrote on last edited by
      #2

      Why do you have it set to trajectory? If you are commanding the drone via strictly offboard commands programmatically - vision-hub should have offboard set to "off" so it isnt conflicting offboard commands with what you are feeding in.

      Please do this and retest and post the results.

      Jetson NanoJ 1 Reply Last reply
      0
      • Zachary Lowell 0Z Zachary Lowell 0

        Why do you have it set to trajectory? If you are commanding the drone via strictly offboard commands programmatically - vision-hub should have offboard set to "off" so it isnt conflicting offboard commands with what you are feeding in.

        Please do this and retest and post the results.

        Jetson NanoJ Offline
        Jetson NanoJ Offline
        Jetson Nano
        Veteran
        wrote on last edited by
        #3

        @Zachary-Lowell-0 as mentioned I have set offboard-mode in voxl-vision-hub.conf to "off".

        I did a flight test shifting to offboard-mode,

        1. The drone was able to execute the script in a stable way without any jittery motions or trying to come back to home position.

        These are the flight logs,
        https://review.px4.io/plot_app?log=e32a28df-cbba-4765-8499-6fe46e2ff890

        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