Migrating from Pixhawk Pilot Support Package to UAV Toolbox Support Package for PX4 Autopilots
Till R2018a, MathWorks® provided support for the Pixhawk® Pilot Support Package that has been used for developing Simulink® models for the Pixhawk FMU using the PX4® toolchain. From R2018b, the official hardware support packages – Embedded Coder® Support Package for PX4 Autopilots (till R2020a) and UAV Toolbox Support Package for PX4 Autopilots (from R2020b) – are available for download.
After you download UAV Toolbox Support Package for PX4 Autopilots, you can migrate Simulink models that you developed using Pixhawk Pilot Support Package to the new support package.
Note
The UAV Toolbox Support Package for PX4 Autopilots contains blocks that are not backward compatible with the blocks of the Pixhawk Pilot Support Package. However, you can replace the blocks in older models with the newer blocks and deploy the model using UAV Toolbox Support Package for PX4 Autopilots.
Note
Before proceeding with the migration procedure, it is highly recommended that you take a backup of the existing Simulink model that you created using Pixhawk PSP.
The migration process involves the following steps:
Complete the setup and configuration activities of UAV Toolbox Support Package for PX4 Autopilots using the Hardware Setup screens (see Setup and Configuration).
The new support package supports PX4 firmware version v1.14 whereas the Pixhawk PSP supports PX4 firmware version 1.6.5. Therefore, you also need to clone PX4 firmware v1.14 by following the steps mentioned in the Hardware Setup screens.
Launch Simulink and create a new model.
Open the Configuration Parameters dialog box and select the hardware (go to the
Hardware Implementation
pane and use the Hardware board drop-down list to select the Pixhawk board that you will be using to deploy the Simulink model). The new support package provides support for Pixhawk 1, Pixhawk 2.1, Pixracer, and Pixhawk 4 flight controllers.If you are using a board that is not officially supported, select the
PX4 Pixhawk Series
option.Copy the contents of the entire Simulink model from Pixhawk PSP to the new Simulink model that you created.
Replace the Simulink blocks for Pixhawk Pilot Support Package with the new Simulink blocks that are available in the new support package.
Use the following table to migrate the Simulink blocks to the new UAV Toolbox Support Package for PX4 Autopilots, in R2018b and later releases.
Mapping of Simulink blocks in Pixhawk Pilot Support Package to UAV Toolbox Support Package for PX4 Autopilots
Pixhawk Pilot Support Package Block New Block in UAV Toolbox Support Package for PX4 Autopilots Documentation Links uORB Write / uORB Write Advanced PX4 uORB Write and PX4 uORB Message PX4 uORB Write and PX4 uORB Message uORB Read PX4 uORB Read PX4 uORB Read Read uORB Function Trigger <Not supported> ADC PX4 Analog Input PX4 Analog Input Serial Serial Transmit and Serial Receive Serial Transmit and Serial Receive PWM PX4 PWM Output PX4 PWM Output ParamUpdate Read Parameter Read Parameter Sensor_Combined Accelerometer
Gyroscope
Magnetometer
Input_RC Radio Control Transmitter Radio Control Transmitter Speaker Tune This block can be modelled using uORB Write block and tune_control uORB topic. Refer to px4demo_LEDBuzzer
Simulink model.LED This block can be modelled using uORB Write block and led_control uORB topic. Refer to px4demo_LEDBuzzer
Simulink model.Battery Battery Battery Vehicle Attitude Vehicle Attitude Vehicle Attitude Vehicle GPS This block can be modelled using uORB Read block and vehicle_gps uORB topic. Refer to px4_readGPS
Simulink model.Reading GPS Data from PX4 Autopilot Binary Logger Refer to px4demo_log
Simulink model.MAT-file Logging on SD Card for PX4 Autopilots Print <Not supported>