Skip to content

MissionRawError unknown when starting a mission #731

@Ziaad03

Description

@Ziaad03

I am encountering a MissionRawError unknown when attempting to start a mission using MAVSDK. Additionally, I don't know if it is gonna help solve this problem, but I see a related message in the drone console that states: "AP: Mode change to AUTO failed: init failed."

here is the script

#!/usr/bin/env python3

import asyncio
from mavsdk import System
from mavsdk import mission_raw
from mavsdk.action_server import FlightMode



async def px4_connect_drone():
   drone = System()
   await drone.connect(system_address="udp://:14540")

   print("Waiting for drone to connect...")
   async for state in drone.core.connection_state():
       if state.is_connected:
           print("-- Connected to drone!")
           return drone


async def run():
   drone = await px4_connect_drone()
   await run_drone(drone)


async def run_drone(drone):

   #clear previous missions
   print("-- Clearing previous missions")
   await drone.mission_raw.clear_mission()

   print("-- Downloading Previous mission")
   downloaded_items = await drone.mission_raw.download_mission()
   print("-- Done")

   mission_items = []

   
  
   # Fly to the first waypoint
   mission_items.append(mission_raw.MissionItem(
       0,  # Sequence number
       3,  # MAV_FRAME_GLOBAL_RELATIVE_ALT
       16,  # MAV_CMD_NAV_WAYPOINT
       1,  # Set current command
       1,  # Auto-continue
       0.0,  # Minimum pitch
       0.0,  # Empty param
       0.0,  # Empty param
       0,  # Yaw angle
       int(47.398039859999997 * 1e7),  # Latitude
       int(8.5455725400000002 * 1e7),  # Longitude
       25.0,  # Altitude
       0  # Mission type
   ))

   
   

   #upload mission
   print("-- Uploading mission")
   await drone.mission_raw.upload_mission(mission_items)
   print("-- Done")

   # Download Mission
   print("-- Downloading mission")
   downloaded_items = await drone.mission_raw.download_mission()
   print("-- Done")
   print(f"Mission size: {len(downloaded_items)}")
   print(downloaded_items)
   
   #Arm drone
   print("-- Arming")
   await drone.action.arm()

   

   #Takeoff
   print("-- Taking off")
   await drone.action.takeoff()

   await asyncio.sleep(10)

   
   #start mission
   print("-- Starting mission")
   await drone.mission_raw.start_mission()

   

if __name__ == "__main__":
   # Run the asyncio loop
   asyncio.run(run())

I don't know if this issue I am having because Mavsdk is not 100% compatible with ardupilot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions