Main Content

getMATFilesFromPixhawk

Retrieve MAT-files from SD card inserted on Pixhawk hardware board

Since R2020b

    Add-On Required: This feature requires the UAV Toolbox Support Package for PX4 Autopilots add-on.

    Description

    getMATFilesFromPixhawk(modelname) retrieves MAT-files corresponding to the model name, specified as an argument, from the SD card inserted on the Pixhawk® hardware board.

    Note

    To work with this function, you need to enable MAVLink in the Simulink® model for which the MAT-files are generated. For details, see Enable MAVLink.

    example

    getMATFilesFromPixhawk(modelname,Name,Value) retrieves MAT-files from the SD card based on the options specified by one or more Name,Value pair arguments.

    example

    Examples

    collapse all

    Retrieve all MAT-files that are generated as part of the latest run (the MAT-files that are generated after you last clicked Build, Deploy & Start in Simulink).

    Consider that the file name of the Simulink model that is configured for MAT-file logging is px4_squarepath_sdcard. This Simulink model is deployed to the Pixhawk hardware three times, and you want to retrieve files only from the latest run.

    To do this, enter the following command at the MATLAB® command prompt after the model has successfully run on the hardware:

    getMATFilesFromPixhawk(px4_squarepath_sdcard)

    After the above function is run, only the files from the latest (third) run are copied to the current folder in MATLAB. For example, the file names of the retrieved files in the current folder look like this:

    px4_squarepath_sdcard_3_1.mat
    px4_squarepath_sdcard_3_2.mat
    px4_squarepath_sdcard_3_3.mat

    The suffix 3 just after the model name represents the run number.

    Retrieve MAT-files by specifying options as name-value pairs.

    Consider that the file name of the Simulink model that is configured for MAT-file logging is px4_squarepath_sdcard. This Simulink model is deployed to the Pixhawk hardware three times, and you want to retrieve all files from all the successful runs, and also delete all the files from SD card after retrieving the files.

    To do this, enter the following command at the MATLAB command prompt:

    getMATFilesFromPixhawk(px4_squarepath_sdcard,'ExtractFilesFromAllRuns',true,'DeleteAfterRetrieval',true)

    After the above function is run, all the files from all the successful runs are copied to the current folder in MATLAB, and they are also deleted from the SD card. For example, the file names of the retrieved files in the current folder look like this:

    px4_squarepath_sdcard_1_1.mat
    px4_squarepath_sdcard_1_2.mat
    px4_squarepath_sdcard_1_3.mat
    px4_squarepath_sdcard_2_1.mat
    px4_squarepath_sdcard_2_2.mat
    px4_squarepath_sdcard_2_3.mat
    px4_squarepath_sdcard_3_1.mat
    px4_squarepath_sdcard_3_2.mat
    px4_squarepath_sdcard_3_3.mat

    Input Arguments

    collapse all

    File name of the Simulink model that is configured for MAT-file logging and deployed on the Pixhawk hardware board with SD card inserted.

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

    Example:

    Extract all the MAT-files from the SD card inserted on the Pixhawk hardware, for all runs (for all successful Build, Deploy & Start actions)

    Example: getMATFilesFromPixhawk(px4_squarepath_sdcard,'ExtractFilesFromAllRuns',true)

    Data Types: logical

    Delete the MAT-files that are retrieved from the SD card inserted on the Pixhawk hardware, after successful retrieval of the files.

    Tip

    Set the value of DeleteAfterRetrieval to true always because this will reduce the time taken to retrieve the MAT-Files from SD card next time.

    Example: getMATFilesFromPixhawk(px4_squarepath_sdcard,'DeleteAfterRetrieval',true)

    Data Types: logical

    The COM Port of the host computer to which the Pixhawk hardware board is connected to retrieve the MAT-files, specified as a character vector or string.

    Note

    This name-value pair is generally used if you select PX4 Pixhawk Series as the Hardware board. For all other boards such as PX4 Pixhawk 1, the COM port is determined automatically unless you specify the COM port as part of this name-value pair.

    Example: getMATFilesFromPixhawk(px4_squarepath_sdcard,'DeleteAfterRetrieval',true,'COMPort','COM15')

    Data Types: char | string

    Version History

    Introduced in R2020b