Simulating a hexacopter in Simulink with FlightGear—need correct PX4 SITL build and sensor data connection. Preguntar a ChatGPT
15 views (last 30 days)
Show older comments
Hi everyone,
I'm working on a project that involves a Software-In-The-Loop (SITL) simulation of a hexacopter.
I have developed a dynamic model and navigation equations (lat, lon, alt) in Simulink, and I'm using FlightGear as the visual simulator. FlightGear is launched directly from Simulink via a script, so I don’t need PX4 to start any built-in GUI simulator (like jMAVSim or Gazebo).
I’ve followed the PX4 setup steps from the official PX4 + WSL documentation, and everything builds successfully. However, I'm confused about the correct build target for my use case. I’ve been using:
make px4_sitl_default none
But I’m unsure if this is the right choice, given that all simulation (dynamics + FlightGear connection) is handled externally by Simulink.
❓ My Questions:
1. Which build target should I use for PX4 SITL, considering that:
- I already simulate the vehicle’s dynamics in Simulink.
- I control and visualize the vehicle in FlightGear (also launched from Simulink).
- I do not use jMAVSim, Gazebo, or other internal PX4 simulators.
2. How should I connect my Simulink model to PX4 so that PX4 receives simulated sensor data (e.g., IMU, GPS, barometer)?
- Should I use MAVLink and send HIL_SENSOR, HIL_GPS, etc.?
- What parameters/modules do I need to configure inside PX4 to make this work?
Thanks in advance for any help or pointers!
0 Comments
Answers (1)
Sayan
on 23 Sep 2025
Edited: Sayan
on 23 Sep 2025
Hi Jon,
You can use the following build target.
make px4_sitl_default none_iris
Since you are developing a custom plant, I recommend referring to this example, which demonstrates a custom Simulink plant workflow: https://www.mathworks.com/help/uav/px4/ref/simulator-plant-model-example.html
This example features both a custom controller and a custom Simulink plant for use in SITL. You can update the 'Core plant' subsystem within the 'Quad_UAV_Dynamics' model to incorporate your own dynamics model. Sensor feedback handling is already included in the model.
If you are not working on Linux, you will need to set the following environment variable in WSL before running the build target to ensure TCP communication from the plant:
export PX4_SIM_HOST_ADDR="IP assigned to WSL. You can find it using ipconfig."
- Sayan
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!