Main Content

getMATFilesFromPixhawk

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

    Description

    example

    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.

    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 Pair Arguments

    Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

    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.

    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,'COMPort','COM15')

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

    Data Types: char | string

    Introduced in R2020b