Deployment of Simulink designed controller to Pixhawk Cube Orange for a generic qadrotor UAV

Hello!
I wanted to implement my designed controller in PX4 so to understand the process, I was trying to implement this example provided by MATLAB. I was able to perform HITL simulations and was trying to implement the controller on an actual quadrotor. For that I followed a similar procedure and disabled 'Enable HITL Mode' in the Model Configuration paramters.
The controller model used in this MATLAB example reads the waypoints from QGround Control mission as shown in the figures. So I wanted to know if the simulink controller is used only in mission mode and not any other modes like manual or stabilised mode? Does pixhawk use the default PX4 control algorithm in Manual mode?

Answers (1)

When you run the hardware setup screens from MATLAB, the inbuilt controllers get removed from the build process (by default). They no longer run in PX4.
Simulink controller runs irrespective of the selected mode from QGC.
For stabilize functionality, you can try deleting the high level navigation control loops in that model. Use Radio Control Transmitter block to get the RC inputs and set the roll, pitch, yaw setpoints.

4 Comments

Thanks for the reply.
I tried to upload to the simulink controller in pixhawk and it wasn't behaving accordingly, not in manual mode at least. I haven't tested it in mission mode but I'll do that soon. But my doubt was if the Simulink controller successfully replaced the default PX4 controller shouldn't it work regardless of the mode I'm flying in?
If you have any suggestions regarding that it would be really helpful. Do you think there could be a problem of startup script because I was using the default startup script (rcS)?
Only the position, attitute and rate control loops are disabled in the PX4 stack. Still modules like navigator and flight mode manager run. This information can be seen in Firmware\ROMFS\px4fmu_common\init.d\rc.mc_apps file.
Some of those modules, validate the mission given by the QGC and provide active waypoint to the control loops. That may explain the differences that you see.
I understand that only the position, attitute and rate control loops are disabled in the PX4 stack. But I still could not understand that if the default controllers are disabled and replaced by simulink controllers then why is the UAV's responce still the same. If I'm flying in manual mode tusing a transmitter then QGC is not publishing any active waypoints.
We have validated the Simulink controller model in this example only for mission mode. That being said, the controller should work in manual mode as well. Can you elaborate on the changes you did on the Simulink model for manual mode and what is the behavior you see? What do you mean when you say QGC is not publishing any active waypoints? How are you seeing that?

Sign in to comment.

Products

Release

R2022b

Asked:

on 19 Dec 2022

Commented:

on 5 Jan 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!