Simulation-in-Hardware (SIH) for PX4 SITL
R2026bSimulation-in-Hardware (SIH) is a PX4® simulation mode in which the PX4 firmware runs a built-in vehicle dynamics model on the autopilot hardware. Unlike Software-in-the-Loop (SITL), where PX4 firmware and the simulator run on the development computer, SIH executes the PX4 firmware on the target hardware and uses internally simulated vehicle states instead of physical sensor data.
Use SIH to test PX4 controller workflows on real autopilot hardware without using a physical vehicle, propellers, or an external simulator. SIH is useful for controller development, External Mode parameter tuning, and hardware-oriented verification before flight testing.
For a task-based example that shows how to deploy a controller, tune position and yaw setpoints in External Mode, and log flight data using PX4 uLOG, see Log Simulink Signals Using PX4 ULog.
When to Use SIH
Use SIH when you want to:
Run PX4 firmware on real autopilot hardware while using an internally simulated vehicle model.
Test controller behavior without connecting motors, propellers, or a physical airframe.
Avoid dependency on external simulators such as jMAVSim for basic controller verification.
Tune controller parameters in External Mode or Connected IO on hardware.
SIH can reduce issues caused by simulator maintenance, host-side simulator dependencies, and sporadic SITL failures. However, SIH does not replace final validation on a physical vehicle or in a high-fidelity simulation environment.
SIH and SITL
PX4 supports different simulation workflows. Each workflow differs in where the controller and plant run, and whether the plant model is a custom Simulink® model or the PX4 built-in plant. Choose the workflow that matches your development stage.
| Workflow | Controller | Plant | Execution Location | Typical Use |
|---|---|---|---|---|
| SITL with custom plant | Custom (Simulink) | Custom (Simulink) | Controller and plant both run on the host development computer | Early algorithm development: try out algorithms before deploying to hardware, find faults or errors in the model |
| SIH on hardware | Custom (Simulink, deployed) | PX4 built-in plant (not custom) | Controller and built-in plant both run on the autopilot hardware | Try out the controller model on hardware without a physical vehicle or external simulator |
| SIH in SITL (Host Target) | Custom (Simulink) | PX4 built-in plant (not custom) | Controller and PX4 built-in plant both run on the host development computer | Host-based simulation using the PX4 built-in dynamics model without hardware. For an example, see Design and Tune Quadcopter Position Controller for PX4 Autopilot. |
| HITL | Custom (Simulink, deployed) | Custom (Simulink) | Controller runs on the autopilot hardware; custom plant runs on the host development computer | Higher-fidelity simulation with custom controller and custom plant, both from Simulink |
In SIH on hardware, the PX4 firmware runs on the autopilot hardware. The firmware uses the PX4 built-in plant dynamics model to simulate the vehicle response, so you do not need a physical vehicle or an external custom plant simulator. The controller is your custom Simulink model deployed to the hardware, and the plant is the PX4 built-in model — not a custom Simulink plant.
In contrast, SITL with a custom plant runs both the custom controller and custom plant on the host machine, which is useful for early algorithm development and finding faults before deploying to hardware. HITL deploys the custom controller to hardware but keeps the custom plant on the host, providing higher-fidelity validation with both custom controller and custom plant from Simulink.
Supported SIH Workflows
PX4 SIH supports these types of workflows in Simulink:
Standalone SIH workflow — Run PX4 SIH on the autopilot hardware without an external visualizer.
SIH with QGroundControl — Connect QGroundControl to monitor PX4 status and vehicle behavior.
SIH with jMAVSim display — Use jMAVSim only for visualization, if supported by your workflow.
SIH with Simulink visualization — Use Simulink-based visualization blocks to display vehicle motion.
SIH with External Mode — Tune parameters while the controller runs on PX4 hardware using wireless External Mode with telemetry modules. Wireless External Mode supports only tuning. For signal logging, use PX4 uLOG.
SIH with Connected IO — Use Connected IO simulation mode with SIH for different airframes.
Airframe Support
You can use SIH with supported PX4 airframes such as:
Quadrotor
Fixed-wing
VTOL tailsitter
The available SIH airframes depend on the PX4 firmware, target hardware, and support package configuration. Select an airframe that is supported by your PX4 firmware and does not exceed the memory constraints of the target board.
Note
The built-in SIH dynamics model is not available on all PX4 hardware targets because some boards have limited flash memory. Verify that your PX4 hardware supports SIH before using this workflow. PX4 Pixhawk 6X and similar boards with sufficient flash memory support SIH.
Configure SIH in Simulink
To configure a model for PX4 SIH, open the model configuration parameters and select SIH as the plant simulator for the PX4 SITL workflow.
Open the Simulink model.
In the Simulink Toolstrip, on the Modeling tab, click Model Settings.
In the Configuration Parameters dialog box, select Hardware Implementation.
In Target hardware resources, select the PX4 simulation or simulator settings.
Set the simulator or plant simulator option to SIH.
Select the required vehicle type or airframe, if the configuration exposes vehicle type separately.
Select the visualization option for the workflow.
Click Apply.
Use the default SIH configuration unless your workflow requires a specific airframe, visualizer, or communication setup.
Note
Before building the firmware for SIH, ensure that the SIH module is enabled in the board configuration file for your hardware. Add this line to the default board file:
CONFIG_MODULES_SIMULATION_SIMULATOR_SIH=y
Then run the hardware setup screen with the multicopter variant of cmake to include the SIH dynamics model in the firmware build.
In QGroundControl, configure these parameters for the SIH workflow:
Set the airframe to
SIH Quadcopter X.Set
COM_RAM_MAXto-1.Set
COM_CPU_MAXto-1.
These settings disable resource monitoring alerts that can interfere with SIH operation.
Select Vehicle Visualization
For SIH workflows, you can select a visualization option based on the level of visual feedback required.
| Visualization Option | Description |
|---|---|
| No display | Runs SIH without a vehicle visualization display. Use this option for automated testing or workflows that do not require visualization. |
| QGroundControl | Displays vehicle state and PX4 status in QGroundControl. |
| jMAVSim | Uses jMAVSim as a display-only visualizer, if supported by the selected workflow. |
| UAV Animation | Uses a lightweight Simulink-based visualization block. |
| Simulation 3D UAV Vehicle | Uses a higher-fidelity Unreal Engine based vehicle visualization. |
Choose a visualization option based on the level of visual feedback required for your workflow.
Platform Support
SIH is supported on both Windows and Linux platforms.
Linux — SIH runs natively. No additional configuration is required for UDP communication.
Windows — PX4 workflows run through Windows Subsystem for Linux 2 (WSL2) and can require UDP communication between WSL2 and Windows.
If your workflow uses WSL2, install and configure the required UDP forwarding utility,
such as socat, before launching SIH.
socat is not available by default in some WSL2 environments.
Install it in the WSL2 Linux distribution before running workflows that require UDP
forwarding.
sudo apt update sudo apt install socat
After installing socat, configure UDP forwarding as required by
your PX4 and Simulink workflow.
Note
Commands that install or configure Linux packages in WSL2 require
sudo privileges.
Validate SIH Setup
Before launching SIH from Simulink, verify that:
WSL2 is installed and configured, if you use a Windows-based PX4 workflow.
Required Linux utilities such as
socatare installed in WSL2 (Windows) or in the native Linux environment.The selected PX4 hardware supports SIH.
The selected airframe is supported by the PX4 firmware.
The selected visualizer is compatible with the SIH workflow.
UDP ports required for PX4 communication are available.
Firewall, VPN, or network settings do not block required communication.
If validation fails, update the reported configuration and run the workflow again.
Use SIH with External Mode and Connected IO
You can use SIH with External Mode and Connected IO to tune parameters while generated code runs on PX4 hardware. In this workflow, PX4 runs the internal SIH dynamics model on the hardware, and Simulink communicates with the deployed model for parameter tuning. The attached example uses telemetry radio modules for wireless External Mode communication and logs flight data using PX4 uLOG.
Note
Wireless External Mode with telemetry modules supports only parameter tuning. Signal logging through External Mode can cause failures. For logging signals, use PX4 uLOG as described below.
Configure Telemetry Modules for Wireless External Mode
To establish wireless External Mode communication, configure a pair of telemetry radio modules (air and ground) with matching baud rates.
Connect the ground module to your development computer using a micro USB cable.
Connect the air module to the hardware board serial port (TELEM 1 or TELEM 2) and connect the hardware board to power.
Open Mission Planner and navigate to Setup > Optional Hardware > SiK Radio.
Select the correct COM port where the ground module is connected and set the baud rate to
57600(default) or115200. Ensure the Connect button is in a disconnected state.Click Load Settings. Both the Local and Remote areas fill in with values including the firmware version.
Set the baud rate to match your planned External Mode communication speed. Change the Net ID to a unique value if other telemetry radios are in range. The default Net ID is
25.Click Copy Required Items to Remote and then Save Settings.
Close Mission Planner.
Note
The baud rate must be identical across three points: the MATLAB External Mode
configuration, the ground telemetry module, and the air telemetry module. A mismatch
at any point prevents the External Mode connection from being established. Common
baud rate values are 57600 and
115200.
In QGroundControl, verify that the MAV_0_CONFIG parameter is set
to TELEM 1. This ensures that the MAVLink communication instance
uses the TELEM 1 serial port where the air module is connected.
Configure External Mode Communication in Simulink
After the telemetry modules are configured, set up the Simulink model to communicate over the serial link.
Open the Simulink model. On the Simulink Toolstrip, click Modeling > Model Settings.
In the Configuration Parameters dialog box, navigate to Hardware Implementation > Target hardware resources > External mode.
Select the Hardware board serial port to the serial port where the air module is connected. For the correct serial port name for your hardware board, see Serial Port Names and Corresponding Labels on PX4 Flight Controller Boards.
Set Baud rate (in bits/s) to the same value configured on the telemetry modules (for example,
57600).Uncheck Use the same host serial port for External mode as used for firmware upload.
Set Host Serial port to the COM port on the development computer where the ground telemetry module is connected (for example,
COM9).Click Apply and then OK.
Log Signals Using PX4 uLOG
To log controller signals during SIH, use the PX4 uLOG mechanism with the Simulink custom uORB message. This approach logs signals on the SD card without relying on External Mode communication.
Add the Simulink custom message name to the
logger.txtfile on the SD card. Open the file and add this entry:simulink_custom_message
This configures the PX4 logger to record the custom uORB message published by the deployed Simulink model.
Deploy and run the controller model on the PX4 hardware with SIH enabled.
After the run completes, extract the uLOG file from the SD card.
Parse the uLOG file and extract the logged fields from the
simulink_custom_messagetopic. The logged fields include:x_desiredx_actualy_desiredy_actual
Use these fields to analyze the controller response by comparing desired and actual position values.