Simulink PX4 Support Package Applications

Hi. We want to share our study on PX4 Support Package in simulink. As I see there is too few work about this topic.So I hope this example encourage the community to use this method more. MATLAB/Simulink is very flexible tool. When used with PX4 I think it is highly promising.
We made two applications on Fixed Wing airframe these are Kamikaze and pursuing another plane in air.
I’m sharing flight videos.

We used this methods in a national competition. In kamikaze mission there is a QR code in area and you should dive-read and recovery the vehicle.

In pursuing mission other competitors planes publishing 1Hz location data you should follow them by using these datas and image processing methods.

First we defined required parameters for the missions like kamikaze dive altitude,recovery altitude,approach angle(to dive into wind) etc.

In simulink model we are using these parameters and defined custom uorb topics. Basically in kamikaze mode according to QR location model calculating a loiter point by using defined parameters and loitering for a while(hardcoded loiter counter) and approaching to the target with desired heading. When achieve to the calculated dive point diving and recovering phases working respectively finally its return to waiting point again defined by parameter.
Complete model is here

And the state flow part is here

In “following” mission there is incoming data from image processing as x,y location of target on image. According to this value plane switching to image processing based following from telemetry based following. We hope to share more detailed explanation about the architecture coming soon. Thanks to MathWorks and PX4 community for this collaboration.

https://www.linkedin.com/in/burak-yildirim-navigation
https://www.linkedin.com/in/alparslan-uçan-350066249

4 Likes

Hi @Alp_Ucan
I have discovered that the Simulink PX4 packages is updated to 1.14v with Matlab 2024a/b but I noticed that it doesn’t support Gazebo simulation.
Have you find a way to use the Gazebo simulation? Have you used the gazebo simulation in your experiments?

Hi @fc250. Yes we actively used HITL simulation with standart plane in gazebo. Actually after code generation there is no relation between simulink and gazebo. What did you try, if you can explain more clear I would be happy to help.

1 Like

Hello Alper,

I’ve been trying to upload my own controller to PX4, and I’ve succeeded with that. However, before testing it on my quadrotor, I tested it on QGC as HITL with MATLAB, but I received random results that don’t make sense. My question is: how do you upload the state flow part to PX4? Also, have you uploaded your controller for the airplane, or are you just using the stock version of PX4?

Thank you!