PX4 SITL with MATLAB Simulink model

Hi

I will run SITL for PX4 with my own simulink model. can anyone write instruction for this?

I saw this code but it’s document is unclear.

can i run sitl in windows or i must install ubuntu ?

Hello,
I managed to connect my Simulink plant model with PX4 SITL using this interface. You don’t need a Ubuntu machine to set this up. Though you need to tinker with the C code of the interface to make it work using localhost. I would be happy to help.

hello , Thank you
can you send an example project or write step by step instruction to me ?

Hello,
Can you inform me about your progress? Did you manage to arrange sensor data to be sent to PX4? What’s your infrastructure like? Then we can go from there.

I will receive actuator’s pwm and send sensor data (imu,gps,compass and …) to px4 SITL. currently i have simulink blocks for calculating sensor data but i don’t know how can i send this outputs .

You will need to create busses to arrange your sensor outputs to conform with the following protocols:
https://mavlink.io/en/messages/common.html#HIL_SENSOR
https://mavlink.io/en/messages/common.html#HIL_GPS
https://mavlink.io/en/messages/common.html#RC_CHANNELS

Then you will feed these data to the s-function block provided by the github repo. Check out the simulink model named ‘PX4.slx’, ‘PX4Main.c’ and the ‘User Guide.docx’ files for more information on this. The comments in the ‘PX4Main.c’ file may be of help.