Does MAVSDK supports visual inertial odometry?

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
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 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:
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. 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 is log file analysis.

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?

1 Like