Skip to content

SITL

SITL runs PX4 on the workstation with Gazebo simulating the aircraft and sensors.

How the parts connect

---
config:
  flowchart:
    useMaxWidth: true
    wrappingWidth: 180
    padding: 10
    rankSpacing: 22
    nodeSpacing: 24
---
flowchart TB
    G["Gazebo"] <--> P["PX4 SITL<br/>Native PX4 terminal"]
    P <-->|GCS MAVLink| M["MAVProxy or<br/>QGroundControl"]
    P <--> X["DDS agent<br/>UDP"]
    X <--> R["ROS 2<br/>Nodes + recorder"]

MAVLink serves the selected ground-control frontend; use the native px4 window for PX4 commands. uXRCE-DDS transports ROS state and setpoints. Tools identifies the command environments.

Start

After installation, in a repository-root shell:

./tools/sitl start

The default px4-sitl tmux session contains:

  • px4 — PX4 build/launch and Gazebo connection.
  • xrce-dds — DDS agent, if START_XRCE_AGENT=true.
  • mavproxy or qgroundcontrol — the configured ground-control frontend.

start attaches to the tmux session and reattaches if it is already running. Open another repository shell for ROS commands.

For headless Gazebo, use this command instead of the GUI start:

./tools/sitl start headless

Headless mode still runs Gazebo simulation, PX4, DDS, and the configured GCS; QGroundControl requires a display.

Inspect

In a second repository-root shell:

source ros2/runtime_env.sh
./tools/sitl status
./tools/topic_rates

status reports services and session windows. topic_rates measures ROS callback arrivals after a 1-second warmup, not controller execution frequency.

Land and reset

For GCS=mavproxy, land after PX4 has returned to Position mode.

In a repository-root shell in the running simulation environment (inside the container when using Docker), attach to the session:

tmux attach-session -t px4-sitl

Open the mavproxy window in that session. At the MAVProxy console, enter this command, not a Bash or PX4 command:

mode LAND

Confirm PX4 accepted LAND, monitor descent, and wait for ground contact before disarming.

In a second repository-root shell, verify PX4's landing state:

source ros2/runtime_env.sh
ros2 topic echo /fmu/out/vehicle_land_detected --qos-reliability best_effort --once
ros2 topic echo /fmu/out/vehicle_status_v1 --qos-reliability best_effort --once

Require landed: true. Check arming state as well: ARMING_STATE_DISARMED is 1 in the pinned message. PX4 may disarm automatically; if it remains armed after landed is confirmed, return to the MAVProxy console and enter:

disarm

Confirm disarmed state in /fmu/out/vehicle_status_v1 before starting another demonstration or stopping SITL. Never disarm in flight.

Stop

After the aircraft is landed and disarmed, in a repository-root shell:

./tools/sitl stop

The wrapper shuts down the tmux process trees, then searches for Gazebo processes associated with this repository. Use it instead of killing tmux alone.

Configuration

config/runtime/sitl.env selects the PX4 target, gz_f450 model, world, estimator overrides, UDP DDS endpoint, optional agent, GCS, and session. The checked-in estimator settings enable external-vision/Gazebo odometry aiding and disable the other listed aiding sources. Changing these settings is a vehicle/estimator decision, not controller tuning.

GCS accepts mavproxy or qgc. The staging and Position-mode examples use MAVProxy's virtual joystick. QGroundControl installation is covered in Native SITL.

For flight procedures, continue with First simulation, Onboard control, or Offboard control.