PX4 / PX4-Autopilot

PX4 Autopilot Software
https://px4.io
BSD 3-Clause "New" or "Revised" License
7.89k stars 13.25k forks source link

Add MAV_FRAME_LOCAL_NED as a valid MAV_FRAME for mission item #23036

Open vudala opened 2 months ago

vudala commented 2 months ago

Problem description and how to reproduce

I am trying to plan a mission that uses local NED coordinates as waypoints.

I am creating mission items with MAV_FRAME_LOCAL_NED as MAV_FRAME for the MISSION_ITEM_INT, as defined by the MAVLink protocol: https://mavlink.io/kr/messages/common.html#MISSION_ITEM_INT https://mavlink.io/kr/messages/common.html#MAV_FRAME

Relevant code

Here's the relavant part of the MAVSDK code that I'm using to create the mission:

from mavsdk import System

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(f"-- Connected to drone!")
        break

mission_items = []
mission_items.append(mission_raw.MissionItem(
       0,     # start seq at 0
       1,     # MAV_FRAME_LOCAL_NED enum value
       16,    # MAV_CMD_NAV_WAYPOINT enum value
       1,
       1,
       0, 10, 0, float('nan'),
       50, 50, -30.0, # N, E, D
       0
   ))

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

However when I try to upload the mission, I get an error indicating that I have invalid mission items.

mavsdk.mission_raw.MissionRawError: UNSUPPORTED: 'Unsupported'; origin: upload_mission(); params: ([<mavsdk.mission_raw.MissionItem object at 0x7b3ae853c5e0>],)

That happens because the mission item parser doesn't treat MAV_FRAME_LOCAL_NED as a supported frame.

Currently it's only possible to add waypoints to the mission using global coordinates, so it would be great to have the support for local coordinates during mission planning.

Solution

Add MAV_FRAME_LOCAL_NED as a supported frame for the mission items. The parser that doesn't recognize this frame as a valid one, is located in modules/mavlink/mavlink_mission.cpp named parse_mavlink_mission_item().

Possible alternatives

Add some other way of planning missions using local coordinates. Like adding MAV_FRAME_LOCAL_ENU or MAV_FRAME_LOCAL_OFFSET_NED as a supported frame.

mrpollo commented 1 month ago

@hamishwillee Is MAV_FRAME_LOCAL_NED a valid message? I couldn't find the reference in the mavlink docs

vudala commented 1 week ago

@hamishwillee Is MAV_FRAME_LOCAL_NED a valid message? I couldn't find the reference in the mavlink docs

It is referenced here: https://mavlink.io/kr/messages/common.html#MAV_FRAME_LOCAL_NED