Test out the PX4 Simulink SIL Simulation!

Hey guys,
I work with a team of aerospace engineers who like to do fun projects on the side. We’ve recently released an open-source PX4 Simulink Software In The Loop (SIL) Simulation, and we’re looking for people to try it out and leave some feedback on how to improve it (either on GitHub or via email). Here’s a ChatGPT generated snippet of information about the sim. A preview video is also on the GitHub page.
:small_blue_diamond: What It Does:

:white_check_mark: Simulates an aircraft using the PX4 autopilot (V1.14.0)

:white_check_mark: Provides a Simulink plant model with physics, sensors, and environment simulation

:white_check_mark: Supports QGroundControl for ground station integration

:white_check_mark: Connects with FlightGear for 3D visualizations

:white_check_mark: Includes a default F-16 aircraft model, with options to add custom vehicles

:light_bulb: Why You Should Try It:

:check_mark: Provides an environment to experiment with the PX4 firmware or your custom version of the PX4 firmware

:check_mark: Improve your understanding of PX4 flight controller modes using realistic aircraft physics

:check_mark: Tune controller gains and test vehicle parameters without risking damage to an actual vehicle

:check_mark: Open source method of getting started on your own UAS project

:wrench: Help improve the simulation by contributing to the repository or simply by providing feedback via email or GitHub

:wrench: Get Started Today! Check out the PX4 Simulink SIL GitHub repository and start exploring:

1 Like

Dear Jepps,

I am an aerospace engineer currently working on integrating a custom controller within the PX4 flight control system. For this purpose, I have developed a Flight Dynamics model of my aircraft in Simulink and am utilizing the connector block provided by Avium Technologies (https://github.com/aviumtechnologies/pixhawk-sil-connector), which employs an S-function, to establish communication with PX4 Software-In-The-Loop (SITL).

I placed my custom controller module has been placed in the src/modules directory and appropriately included in the CMakeLists.txt file to ensure it is built during the make px4_sitl process.

Currently, I am encountering an issue where the PWM commands generated by my custom controller in PX4 are not being transmitted to the Simulink environment. Through detailed debugging and assistance from AI, I have identified a potential root cause: PX4 SITL appears to be failing to successfully receive or parse the simulated sensor data being transmitted from my Simulink model.

This lack of proper sensor data reception is leading to persistent pre-flight failures when I initiate SITL. For your reference, the following output is observed when starting the simulation:

pxh> INFO  [mavlink] partner IP: 127.0.0.1

INFO  [lockstep_scheduler] setting initial absolute time to 4000 us

pxh> commander arm -f

pxh> INFO  [commander] Armed by internal command

WARN  [failsafe] Failsafe activated

INFO  [tone_alarm] arming warning

INFO  [commander] Takeoff detected

pxh> custom_control start

pxh> listener hil_sensor -n 20INFO  [tone_alarm] battery warning (fast)


Topic hil_sensor did not match any known topics

Command 'listener' failed, returned -1.

pxh> WARN  [health_and_arming_checks] Preflight Fail: system power unavailable

WARN  [health_and_arming_checks] Preflight Fail: Flight termination active

WARN  [health_and_arming_checks] Preflight Fail: No connection to the ground control station

WARN  [custom_control] Failed to get missile position/velocity.

WARN  [custom_control] Failed to get missile position/velocity.

WARN  [health_and_arming_checks] Preflight Fail: system power unavailable

WARN  [health_and_arming_checks] Preflight Fail: Flight termination active

WARN  [health_and_arming_checks] Preflight Fail: No connection to the ground control station

WARN  [custom_control] Failed to get missile position/velocity.

WARN  [custom_control] Failed to get missile position/velocity.

INFO  [commander] Disarmed by lockdown

INFO  [tone_alarm] notify neutral

WARN  [health_and_arming_checks] Preflight Fail: Airspeed too high - check airspeed calibration

WARN  [health_and_arming_checks] Preflight Fail: High Gyro Bias

WARN  [health_and_arming_checks] Preflight Fail: system power unavailable

WARN  [health_and_arming_checks] Preflight Fail: Flight termination active

As I do not have access to the PX4 support package for Simulink, I cannot use your specific communication model.

Any insights or suggestions you might have regarding the potential causes of this issue and how to ensure the simulated sensor data from my Simulink model is correctly received and parsed by PX4 SITL would be greatly appreciated.

Thanks.

Hello aero-Sapphire,

Do you have your code on a github somewhere? I may be able to provide you with better assistance if I’m able to see your repository. Also, is your aircraft a fixed-wing or rotorcraft?

You may be able to use the optimAero SITL without the UAV support package. Take a look at step 6 on our repository. There’s a bash file that you can run to set up the PX4 build toolchain. Feel free to shoot an email to info@optim.aero if I’m slow to respond on this forum.