Main Content

upload

R2026b

Upload mission to remote MAVLink client

Since R2026b

    Description

    [status,ack] = upload(mission,mavlinkclient,missionData) uploads mission data to the remote MAVLink client mavlinkclient. The function returns the mission upload status and the acknowledgment message returned by the remote MAVLink client.

    example

    Examples

    collapse all

    Upload a mission to 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");

    Upload the mission SampleMission.plan to the Pixhawk board by using the upload function. The function returns the upload status and acknowledgement message.

    [status,ack] = upload(mission,uav,"SampleMission.plan")
    status = true
    ack = 
      struct with fields:
    
           target_system : 255
        target_component : 1
                    type : 0
            mission_type : 0
         

    Input Arguments

    collapse all

    Mission microservice, specified as a missionMicroservice object.

    Remote MAVLink client information, specified as a mavlinkclient object.

    Mission data to upload, specified as one of these options:

    • uavMission object

    • Path to a PX4 mission file (.plan), specified as a string scalar

    • Path to a MAVLink waypoints file (.waypoints), specified as a string scalar

    Example: "documents/SampleMission.plan"

    Output Arguments

    collapse all

    Mission upload 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 acknowledgement message, returned as a structure with these fields:

    • 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].

    • type — Result of mission operation, returned as an integer corresponding to a value from the MAV_MISSION_RESULT enum.

    • mission_type — Type of mission items sent in mission protocol, returned as an integer corresponding to a value from 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