Main Content

Prepare Model for Simulation and Deployment

After you configure the Simulink model by including the necessary To Workspace blocks, you need to complete the prerequisites for simulation and deployment.

Use px4PrepareModelForMATFileLogging to Optimize Memory

The px4PrepareModelForMATFileLogging function needs to be run in the MATLAB command prompt to optimize the memory. The function checks the Limit data points to last parameter in the various To Workspace blocks and adjusts its value for memory optimization.

You can use the px4PrepareModelForMATFileLogging function by specifying the model name either as character or string:

  • px4PrepareModelForMATFileLogging(bdroot)

  • px4PrepareModelForMATFileLogging('modelname')

    Here, modelname is the file name of the Simulink model.

After you run this function, a dialog box opens requesting your permission to fix the values for memory optimization. Click Fix it to optimize the memory.

Error message

After you click Fix it, the value for Limit data points to last corresponding to all 'To Workspace' blocks is changed.

It is recommended that you run the function px4PrepareModelForMATFileLogging every time you make changes in the model.

Enable MAVLink

MAVLink needs to be enabled to retrieve the log files from SD card inserted on the Pixhawk hardware board (for details about retrieving files, see getMATFilesFromPixhawk). To enable MAVLink, open the Configuration Parameters dialog box, go to Hardware Implementation > Target hardware resources > MAVLink, and select Enable MAVLink on /dev/ttyACM0.

Enable MAVLink