PX4 supports two simulation approaches that let you develop and test flight software without risking hardware. Software-In-The-Loop (SITL) runs the entire PX4 flight stack as a process on your computer, paired with an external physics simulator. Hardware-In-The-Loop (HITL) runs real PX4 firmware on a flight controller board but feeds it simulated sensor data instead of live hardware inputs. Both modes let you interact with PX4 through QGroundControl, offboard APIs like MAVSDK or MAVROS, and joysticks or gamepads — exactly as you would with a real vehicle.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/PX4/PX4-Autopilot/llms.txt
Use this file to discover all available pages before exploring further.
SITL vs HITL
Software-In-The-Loop (SITL)
The full PX4 flight stack runs as a native process on your development machine. A separate simulator process provides physics, sensor data, and rendering. No flight controller hardware required. Best for rapid development, algorithm testing, and CI pipelines.
Hardware-In-The-Loop (HITL)
Real PX4 firmware runs on your flight controller board. Simulated sensor data is injected over USB/serial. Tests real hardware timing and driver behavior without spinning motors. Best for pre-flight integration testing.
HITL simulation requires a supported flight controller running standard PX4 firmware. Flash your board with a HITL-enabled build, enable
SYS_HITL=1, and connect it via USB before launching the simulator.Supported simulators
The PX4 core team actively maintains two simulators. Choose based on your workflow.Gazebo
The recommended simulator for new projects on Ubuntu 22.04 and later. Offers photorealistic 3D rendering, a rich sensor library (cameras, LiDAR, depth sensors), custom worlds and model plugins, and documented multi-vehicle support. Communicates with PX4 directly via Gazebo Transport — no MAVLink required.Supported vehicles: Quadrotor (x500), Plane, Standard VTOL, Tailsitter, Tiltrotor, Rovers
SIH (Simulation-In-Hardware)
A lightweight, zero-dependency simulator that runs physics entirely inside PX4 as a C++ module. Headless by default for maximum iteration speed. Works on macOS Apple Silicon. Can also run on flight controller hardware (
SYS_HITL=2). Communicates via uORB — no MAVLink or external process required.Supported vehicles: Quad, Hex, Plane, Tailsitter, Standard VTOL, RoverSimulator comparison
| Feature | Gazebo | SIH |
|---|---|---|
| Default mode | GUI with 3D rendering | Headless (fastest iteration) |
| Physics engine | External (gz-physics) | Internal C++ module via uORB |
| External dependencies | Gazebo packages, rendering libs | None |
| Sensor simulation | Camera, LiDAR, depth, IMU, GPS, baro, mag | IMU, GPS, baro, mag, airspeed |
| Multi-vehicle | Yes | Yes |
| ROS 2 integration | Yes (uXRCE-DDS) | Yes (uXRCE-DDS) |
| Runs on FC hardware | No | Yes (SYS_HITL=2) |
| macOS Apple Silicon | Unstable | Works natively |
| Faster-than-realtime | Yes | Yes |
Choosing a simulator
- Full 3D rendering, custom worlds, camera/LiDAR sensors, or ROS integration: Use Gazebo. Largest ecosystem, photorealistic rendering, extensive sensor library.
- Fast headless iteration, controls research, zero-dependency setup, or macOS: Use SIH. Runs entirely inside PX4 with no external dependencies; physics parameters are directly tunable via
SIH_*parameters. - Hardware integration testing without propellers: Use SIH on flight controller hardware with
SYS_HITL=2.
Network architecture and MAVLink UDP ports
SITL instances communicate over UDP. PX4 uses fixed default ports so that QGroundControl and offboard APIs connect automatically.| Port | Direction | Purpose |
|---|---|---|
| 14550 | PX4 → GCS | QGroundControl and other ground stations listen here by default |
| 14540 | PX4 → Offboard API | MAVSDK, MAVROS, and other developer APIs listen here |
| 4560 | Simulator → PX4 | PX4 opens a TCP connection to the simulator on this port (MAVLink-based sims only) |
Multi-vehicle simulations allocate a separate offboard API port per instance, sequentially from 14540 to 14549. Additional instances beyond ten all share port 14549.
-p flag in the mavlink module, or set up an SSH tunnel.
Connecting QGroundControl
QGroundControl connects to SITL automatically when it detects a MAVLink heartbeat on UDP port 14550. No manual configuration is needed when running PX4 SITL on the same machine as QGroundControl.Start the simulation
Launch PX4 SITL with your chosen simulator. The flight stack will begin broadcasting MAVLink heartbeats on port 14550.
Open QGroundControl
Launch QGroundControl. It listens on UDP port 14550 by default and will detect the simulated vehicle within a few seconds.
Running simulation faster than real time
SITL supports faster-than-realtime execution for all supported simulators. Set thePX4_SIM_SPEED_FACTOR environment variable before launching:
Simulating failsafes
You can trigger safety failsafes such as GPS failure, battery drain, and RC signal loss inside the simulation to test your vehicle’s behavior before flying for real. To simulate GPS failure, set theSENS_GPS_MASK parameter or use the MAVLink shell:
failure battery off), RC signal loss (failure rc off), and barometer failure (failure baro off).