# Does MAVSDK supports visual inertial odometry?

**URL:** <https://discuss.px4.io/t/does-mavsdk-supports-visual-inertial-odometry/29281>\
**Category:** MAVSDK\
**Created:** [October 5, 2022, 7:04am UTC](https://discuss.px4.io/t/does-mavsdk-supports-visual-inertial-odometry/29281 "2022-10-05T07:04:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anubhav](https://discuss.px4.io/letter_avatar_proxy/v4/letter/a/5e9695/32.png) [@Anubhav](https://discuss.px4.io/u/Anubhav)\
**Post date:** [October 5, 2022, 7:04am UTC](https://discuss.px4.io/t/does-mavsdk-supports-visual-inertial-odometry/29281/1 "2022-10-05T07:04:57Z")

</div>

Hello Team,

Because of following two reasons I am asking the above question.

1. I am using MAVSDK to automate takeoff, pattern flight and land. I was doing HITL of following code

```auto
import asyncio

from mavsdk import System
from mavsdk.offboard import (OffboardError, PositionNedYaw)

async def run():
    """ Does Offboard control using position NED coordinates. """

    print("Using mavsdk server port 50051")
    drone = System(mavsdk_server_address="localhost", port=50051)
    print("Connecting to vehicle using port 14550")
    await drone.connect(system_address="udp://:14550")

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

    print("-- Go 1m North, 0m East, -1m Down within local coordinate system, turn to face East")
    await drone.offboard.set_position_ned(PositionNedYaw(1.0, 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(1.0, 1.0, -1.0, 90.0))
    await asyncio.sleep(4)

    print("-- Go 0m North, 1m East, -1m Down within local coordinate system, turn to face South")
    await drone.offboard.set_position_ned(PositionNedYaw(0.0, 1.0, -1.0, 180.0))
    await asyncio.sleep(4)

    try:
        await drone.action.land()
    except:
        print("Failed to land")

    print("-- Disarming")
    try:
        await drone.action.disarm()
    except:
        print("Disarming failed")

if __name__ == " __main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run())

```

here is the [video](https://drive.google.com/file/d/1ZZc6subJ8IrS2LLFk2EK8NzBabZy82tc/view?usp=sharing) of simulation, where drone is getting crashed just after taking-off.

1. When I tried the flying drone in real time with following MAVSDK code:

```auto
import asyncio

from mavsdk import System
from mavsdk.offboard import (OffboardError, PositionNedYaw)

async def run():
    """ Does Offboard control using position NED coordinates. """

    print("Using mavsdk server port 50051")
    drone = System(mavsdk_server_address="localhost", port=50051)
    print("Connecting to vehicle using port 14550")
    await drone.connect(system_address="udp://:14550")

    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.7, 0.0))
    await asyncio.sleep(4)
    
    print("-- Go 0.1m North, 0m East, -1m Down within local coordinate system, turn to face East")
    await drone.offboard.set_position_ned(PositionNedYaw(0.1, 0.0, -1.0, 90.0))
    await asyncio.sleep(4)
    
    try:
        await drone.action.land()
    except:
        print("Failed to land")

    print("-- Disarming")
    try:
        await drone.action.disarm()
    except:
        print("Disarming failed")

```

With the above code the drone is getting drifted from it’s takeoff position as shown here in [video](https://drive.google.com/file/d/16Z2d5WkDrGSleNUmcbnWxqePpFJWEco-/view?usp=sharing). According to the code it should takeoff, turn 90deg and land, but it drifted didn’t got crashed due to collision prevention and landed at it’s original pose due to tag detector.  
[here](https://review.px4.io/plot_app?log=5589a22b-cbfd-418d-bd36-827f2dece118) is log file analysis.

---

<div class="post-metadata">

**Author:** ![Artem\_Borisov](https://discuss.px4.io/user_avatar/discuss.px4.io/artem_borisov/32/9999_2.png) [@Artem\_Borisov](https://discuss.px4.io/u/Artem_Borisov)\
**Post date:** [October 5, 2022, 12:24pm UTC](https://discuss.px4.io/t/does-mavsdk-supports-visual-inertial-odometry/29281/2 "2022-10-05T12:24:41Z")

</div>

Hi!  
Did you make a mistake with the code that you showed in point 2? In the log file, you can see that in the offboard mode, the coordinates X = 1.2 Y = -1.15 were set.

And another question how do you pass EV\_POS + EV\_VEL + EV\_YAW?
