メインコンテンツ

download

R2026b

Download mission from remote MAVLink client

Since R2026b

    Description

    [status,missionData] = download(mission,mavlinkclient) downloads mission data from the remote MAVLink client.

    example

    Examples

    collapse all

    Download a mission from a Pixhawk® 4 board running PX4® firmware by using the mission microservice.

    Create a mavlinkdialect object using the common.xml file.

    dialect = mavlinkdialect("common.xml");

    Create a local MAVLink client by using the mavlinkio object.

    gcs = mavlinkio(dialect);

    Store the remote MAVLink client information by using the mavlinkclient object. This Pixhawk board has a system ID of 1 and a component ID of 1.

    uav = mavlinkclient(gcs,1,1);

    Connect the local MAVLink client to the same serial port as the Pixhawk board by using the connect function. This Pixhawk board uses the COM5 port.

    connect(gcs,"Serial",SerialPort="COM5");

    Create a heartbeat microservice object.

    heartbeat = mavlinkmicroservice(gcs,"heartbeat");

    Start sending the HEARTBEAT messages to the Pixhawk board by using the start function.

    start(heartbeat,uav,"Serial",SerialPort="COM5")

    If the Pixhawk board replies with HEARTBEAT messages, a connection is established.

    Verify that the connection has been established by using the listClients function.

    listClients(gcs)
    ans = 2×4 table
        SystemID    ComponentID       ComponentType             AutopilotType     
        ________    ___________    ____________________    _______________________
    
          255            1            "MAV_TYPE_GCS"        "MAV_AUTOPILOT_INVALID"
           1             1         "MAV_TYPE_QUADROTOR"       "MAV_AUTOPILOT_PX4"

    Create a mission microservice object.

    mission = mavlinkmicroservice(gcs,"mission");

    Download the mission stored in the Pixhawk board by using the download function. This mission contains four waypoints.

    [status,missionData] = download(mission,uav)
    status = true
    missionData = 4×15 table
      param1  param2  param3  param4      x           y      z   seq  command  target_system  target_component  frame  current  autocontinue  mission_type
      ______  ______  ______  ______  _________  __________  __  ___  _______  _____________  ________________  _____  _______  ____________  ____________
        0       0       0       NaN   422315437  -717016359  10   0      16         255              1            6      0           1             0      
        0       0       0       NaN   422327909  -716999085  10   1      16         255              1            6      0           1             0      
        0       0       0       NaN   422324334  -716981812  10   2      16         255              1            6      0           1             0      
        0       0       0       NaN   422309320  -716974302  10   3      16         255              1            6      0           1             0      

    Input Arguments

    collapse all

    Mission microservice, specified as a missionMicroservice object.

    Remote MAVLink client information, specified as a mavlinkclient object.

    Output Arguments

    collapse all

    Mission download status, returned as a 1 or 0 of data type logical. The value is 1 (true) when the local MAVLink client receives the acknowledgement message without exceeding the maximum time and number of retries.

    Data Types: logical

    Mission data, returned as a table with these columns:

    • param1 to param4 — Mission parameters that correspond to command‑specific arguments defined by the MAV_CMD enum in the command field.

    • x — X‑coordinate, returned as an integer. If frame specifies a local frame, this value is the local x position in units of 1e4 meters. If frame specifies a global frame, this value is the latitude in units of 1e7 degrees.

    • y — Y‑coordinate, returned as an integer. If frame specifies a local frame, this value is the local y position in units of 1e4 meters. If frame specifies a global frame, this value is the longitude in units of 1e7 degrees.

    • z — Z‑coordinate, returned as an integer. If frame specifies a relative altitude frame, this value represents altitude relative to the home position. If frame specifies a global altitude frame, this value represents altitude relative to mean sea level.

    • seq — Waypoint sequence, returned as a nonnegative integer.

    • command — Waypoint action, returned as a nonnegative integer that corresponds to a value of the MAV_CMD enum.

    • target_system — Local MAVLink system ID, returned as an integer in the range [1, 255].

    • target_component — Local MAVLink component ID, returned as an integer in the range [0, 255].

    • frame — Waypoint coordinate system, returned as a nonnegative integer that corresponds to a value of the MAV_FRAME enum.

    • current — Logical value indicating whether the waypoint is the current active waypoint, returned as 1 (true) or 0 (false).

    • autocontinue — Logical value indicating whether the remote MAVLink client automatically proceeds to the next waypoint, returned as 1 (true) or 0 (false).

    • mission_type — Mission type, returned as a nonnegative integer that corresponds to a value of the MAV_MISSION_TYPE enum.

    Tip

    To view the available MAV_MISSION_TYPE enum values, use the enuminfo function. For example, to find the values of the MAV_MISSION_TYPE enum:

    info = enuminfo(dialect,"MAV_MISSION_TYPE");
    info.Entries{:}
    where dialect is the MAVLink dialect object that you specify when you create the local MAVLink client.

    Version History

    Introduced in R2026b