download
R2026bDescription
[
downloads mission data from the remote MAVLink client.status,missionData] = download(mission,mavlinkclient)
Examples
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
Mission microservice, specified as a missionMicroservice object.
Remote MAVLink client information, specified as a mavlinkclient object.
Output Arguments
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:
param1toparam4— Mission parameters that correspond to command‑specific arguments defined by theMAV_CMDenum in the command field.x— X‑coordinate, returned as an integer. Ifframespecifies a local frame, this value is the local x position in units of 1e4 meters. Ifframespecifies a global frame, this value is the latitude in units of 1e7 degrees.y— Y‑coordinate, returned as an integer. Ifframespecifies a local frame, this value is the local y position in units of 1e4 meters. Ifframespecifies a global frame, this value is the longitude in units of 1e7 degrees.z— Z‑coordinate, returned as an integer. Ifframespecifies a relative altitude frame, this value represents altitude relative to the home position. Ifframespecifies 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 theMAV_CMDenum.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 theMAV_FRAMEenum.current— Logical value indicating whether the waypoint is the current active waypoint, returned as1(true) or0(false).autocontinue— Logical value indicating whether the remote MAVLink client automatically proceeds to the next waypoint, returned as1(true) or0(false).mission_type— Mission type, returned as a nonnegative integer that corresponds to a value of 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
upload | 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)