UAV Toolbox Support Package for PX4 Autopilots - px4_simulink_app module
19 views (last 30 days)
I have successfully built and deployed the px4 controller on pixhawk4 via simulink. Also added rc.txt to SD Card's etc folder.
When I tried to connect Pixhawk4 to QGroundControl without any additional work, it was disconnected and unable to connect.
For reference, I added the following two lines to the end of rc.txt, so I was able to connect Pixhawk4 to QGroundControl.
mavlink start -d /dev/ttyACM0 -m config –x
At this point, I had my doubts. I know that if the rc.txt file is added to the SD card and the Simulink controller is built and deployed, the px4_simulink_app module, not the mc_attitude_control and mc_position_control modules, is executed without any additional work. But how can I make sure that it activates px4_simulink_app when linked to QGroundControl?
Ankur Bose on 3 Feb 2023
Edited: Ankur Bose on 3 Feb 2023
Before I answer your question, let me clarify that the "PX4 default startup script rcS" is the recommended option for booting up modules compared to custom startup script rc.txt option from R2020b release. The custom startup script option is difficult to scale for functionalities with other modules.
Now coming to your question, I guess your question is how to ensure Pixhawk connects to QGC after deploying to Simulink. You dont need to add any mavlink specific line in rc.txt like you did. You can follow the below documentation to enable MAVLink communication before deploying the controller.
Basically, the selection "Enable MAVLink over USB" ensures that px4_simulink_app is generated with MAVLink communication enabled and hence it will connect to QGC after deployment.
Note that this option will not work with External Mode simulation as both are trying to connect over "/dev/tyACM0". If you need External Mode option, you need to disable this checkbox
More Answers (2)
Arun Mathamkode on 3 Feb 2023
The modules you are adding to the rc.txt will be started after the board bootup, irrespective of whether you have connected QGroundControl or not. So if you have the px4_simulink_app start command added in the rc.txt, px4_simulink_app will be started after the bootup. It is not very clear to me what you meant by 'activates', if you are referring to making sure the module is running you can verify it through the System Console or MAVLink NSH Console in QgroundControl. Use the px4_simulink_app status command for this.