upload
R2026bDescription
[
uploads mission data to the remote MAVLink client status,ack] = upload(mission,mavlinkclient,missionData)mavlinkclient. The
function returns the mission upload status and the acknowledgment message returned by the
remote MAVLink client.
Examples
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
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:
uavMissionobjectPath to a PX4 mission file (
.plan), specified as a string scalarPath to a MAVLink waypoints file (
.waypoints), specified as a string scalar
Example: "documents/SampleMission.plan"
Output Arguments
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 theMAV_MISSION_RESULTenum.mission_type— Type of mission items sent in mission protocol, returned as an integer corresponding to a value from theMAV_MISSION_TYPEenum.
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{:}dialect is the MAVLink dialect object
that you specify when you create the local MAVLink client.Version History
Introduced in R2026b
See Also
download | heartbeatMicroservice | parameterMicroservice | commandMicroservice | ftpMicroservice
External Websites
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)