This is an "upgrade" package for PX4 Firmware that defines a certain I/O structure for control system development and integration through SIMULINK. The focus here is to provide an integration layer for the SIMULINK-generated control system, re-enable stock PX4 features, and simplify communication-related tasks. The major focus of this work was to enable PWM servo and ESC control using a CAN protocol for PX4 v1.12.3 and circumvent some of the limitations of the R2023a UAV Toolbox Support Package for PX4 Autopilots.
Check out my tutorials on installing and configuring this framework on YouTube!
Important notes before you start:
- Everything below assumes you are compiling for Pixhawk Cube Orange (although other configurations may also work if you adjust the source code accordingly).
- When configuring "UAV Toolbox Support Package for PX4 Autopilots", you should select:
- Design Flight Controller in Simulink (which is the default option for "Simulink application").
- PX4 Cube Orange as your PX4 Autopilot board (this is not by default).
- cubepilot_cubeorange_default as your "Build Target" (should be the default).
- Keep the default startup script (I recommend completely erasing the SD card if you have it).
- Prepare your hardware now:
- Remove the SD card, and format it (FAT32). You can keep it unplugged until you have completed all the installation steps below (an SD card is not needed until you start configuring the firmware through QGC).
- Do a factory reset for your Pixhawk Cube Orange and flush it with the default PX4 firmware (you should use the most recent stable release, which is the default in QGC).
You should follow standard MATLAB R2023a documentation for all installation steps, unless stated otherwise. A quick recap is given below:
- Install MATLAB R2023a (R2023b might work, but was not tested)
- Install MinGW
- Install UAV Toolbox Support Package for PX4 Autopilots:
- Install Python 3.8.2.
- Install Cygwin toolchain v0.8.
- (Optional) I recommend cloning PX4 into a separate, top-level directory, for example, into D:/PX4/v1.12.3/Firmware.
You must clone stock PX4 v1.12.3, and go through all of the default installation steps, before attempting anything further. Follow the documentation and make sure all of the stock functionality of the R2023a Matlab/Simulink has been installed and configured correctly (run examples!). I can't help you if you can't install/configure MATLAB/toolboxes or follow step-by-step MATHWORKS documentation.
- Locate the Firmware installation directory - this is where you have already installed PX4 v1.12.3, let's say D:/PX4/v1.12.3/Firmware.
- Go to D:/PX4/v1.12.3/Firmware/src/drivers/ and delete these folders:
- uavcan
- uavcan_v1
- uavcannode
- Locate the Firmware upgrade folder - this is the folder provided in this repository, called "Firmware"
- Install the upgrade by copying the contents of the Firmware upgrade folder into D:/PX4/v1.12.3/Firmware, replacing all files.
- Recompile upgraded PX4 firmware. You need to re-run the setup app for "UAV Toolbox Support Package for PX4 Autopilots".
- In Matlab, click on the "home" tab and use the dropdown menu under the "Add-Ons" icon to select "Manage Add-Ons"
- In the Add-On Manager, locate "UAV Toolbox Support Package for PX4 Autopilots"
- Click the gear icon on the far right of the tab
- Re-do UAV Toolbox Support Package for PX4 Autopilots setup every time you need to re-compile the PX4 firmware.
At this point, you should be able to compile the Simulink model and upload firmware to the board. You can also upload the firmware before compiling anything through Simulink to check the status of everything without the control system deployed. You should also be able to check the status of the sm_ctrl_mod through the MAVLINK shell in QGC. There should be no further action required on the firmware side, besides configuration.
Simulink integration is very application-dependent. This specific package was written to be used with the RRTV Tilt-Wing configuration and Quadrotor_with_FF_Control.
You may also find KGroundControl useful for your communication-related tasks.
If you have any questions, please feel free to contact me, Yevhenii (Jack) Kovryzhenko, at yzk0058@auburn.edu.
This work started during my Ph.D. at ACELAB at Auburn University, under the supervision of Dr. Ehsan Taheri. Part of this work has been used during my participation in the STTR Phase II project with Transcend Air Co. to support the control system deployment and related activities. For more details, check out my KGroundControl and RRTV TiltWing repositories that were all part of this project.
I am still in the process of publishing journal papers that have directly used this work, so I will keep this section actively updated. Feel free to credit me by citing any of my relevant works. Some of the articles that directly used this work:
- Kovryzhenko, Y., Li, N., and Taheri, E., “A Control System Design and Implementation for Autonomous Quadrotors with Real-Time Re-Planning Capability,” Robotics, Vol. 13, No. 9, 2024, p. 136. https://doi.org/10.3390/robotics13090136
@article{kovryzhenko_control_2024, title = {A Control System Design and Implementation for Autonomous Quadrotors with Real-Time Re-Planning Capability}, volume = {13}, copyright = {http://creativecommons.org/licenses/by/3.0/}, issn = {2218-6581}, url = {https://www.mdpi.com/2218-6581/13/9/136}, doi = {10.3390/robotics13090136}, language = {en}, number = {9}, urldate = {2024-09-09}, journal = {Robotics}, author = {Kovryzhenko, Yevhenii and Li, Nan and Taheri, Ehsan}, month = sep, year = {2024}, keywords = {autopilot development, embedded computing, hardware pipeline, online re-planning, PX4, real-time control, UAS}, pages = {136}, }
- Comer, A., Chakraborty, I., Kovryzhenko, Y., Taheri, E., Bhandari, R., Kunwar, B., and Putra, S., “Flight Testing of Explicit Model-Following Trajectory Control System for Lift-Plus-Cruise and Tilt-Wing Configurations,” presented at the VFS 80 Forum, Montreal, Canada, 2024. https://doi.org/10.4050/F-0080-2024-1306
@inproceedings{comer_flight_2024, address = {Montreal, Canada}, title = {Flight Testing of Explicit Model-Following Trajectory Control System for Lift-Plus-Cruise and Tilt-Wing Configurations}, copyright = {All rights reserved}, url = {https://doi.org/10.4050/F-0080-2024-1306}, doi = {10.4050/F-0080-2024-1306}, booktitle = {VFS 80 Forum}, author = {Comer, Anthony and Chakraborty, Imon and Kovryzhenko, Yevhenii and Taheri, Ehsan and Bhandari, Rajan and Kunwar, Bikash and Putra, Stefanus}, month = may, year = {2024}, }