SITL, short for software in the loop, is a testing method in which the unmodified autopilot firmware of a drone runs as an ordinary program on a desktop computer while a physics simulator replaces the real aircraft, its sensors and its environment. In drone software & autonomy, SITL is the standard way to develop, debug and rehearse flight code before any hardware leaves the ground.
Both major open-source autopilots, ArduPilot and PX4, ship with built-in SITL targets, and ground control stations such as Mission Planner and QGroundControl connect to a simulated vehicle exactly as they would to a real one. For teams building products around Drones, SITL turns risky field trials into repeatable, zero-cost experiments.
How software in the loop closes the control loop
SITL works by closing the control loop in software: the autopilot computes motor or servo outputs, the simulator applies them to a mathematical model of the aircraft, and the simulator returns new sensor readings to the autopilot. This cycle repeats hundreds of times per second, so the flight code behaves as if it were flying.
The firmware is compiled for the host processor instead of the flight controller, typically x86 or ARM on Linux, macOS or Windows. A thin hardware abstraction layer swaps real drivers for simulated ones, which means the estimator, the attitude controller, the mission logic and the failsafes are the same code that flies. Communication with the outside world uses MAVLink over UDP or TCP, usually on well-known local ports.
The following table lists the main components of a typical SITL setup and the role each one plays.
| Component | Role in the loop | Common examples |
|---|---|---|
| Autopilot binary | Runs estimation, control and mission logic | ArduCopter, PX4 multicopter build |
| Physics model | Computes motion from forces and torques | Built-in JSBSim, Gazebo, jMAVSim |
| Sensor emulation | Produces IMU, GPS, barometer and compass data | Noise and bias models in the simulator |
| MAVLink link | Connects ground software and scripts | UDP ports on localhost |
| Ground control station | Plans missions and displays telemetry | Mission Planner, QGroundControl |
| Automation layer | Drives repeatable test scenarios | MAVSDK scripts, pymavlink, ROS 2 nodes |
Simulation fidelity and lockstep timing
The value of SITL depends on simulation fidelity, meaning how closely the modeled aircraft, sensors and environment match reality. A simple built-in multicopter model is adequate for mission logic, while tuning work demands accurate inertia, motor and propeller data and realistic wind.
Most modern setups run in lockstep mode, where the autopilot and the simulator advance in fixed time steps and wait for each other. Lockstep makes runs deterministic and reproducible, and it allows simulation faster than real time, which is useful for running hundreds of regression missions overnight. Without lockstep, a busy host computer can introduce timing jitter that looks like a control problem but is only a scheduling artifact.
The table below compares the fidelity levels that teams typically choose and what each level is good for.
| Fidelity level | What is modeled | Best suited for |
|---|---|---|
| Basic kinematic model | Simple dynamics, ideal sensors | Mission logic, waypoint scripts |
| Rigid-body physics | Mass, inertia, thrust curves, drag | Controller behavior, failsafe testing |
| Full 3D environment | Terrain, obstacles, cameras, lidar | Computer vision, obstacle avoidance |
| Multi-vehicle world | Several vehicles sharing airspace | Swarm coordination, fleet software |
SITL compared with HITL and flight testing
SITL is the first rung of a verification ladder that continues with hardware in the loop (HITL) and ends with real flight. In HITL, the firmware runs on the actual flight controller while the simulator still provides sensor data, so it exposes processor load, timing and driver issues that SITL cannot see.
This comparison shows how the three approaches differ in cost, risk and what they can reveal.
| Approach | Where firmware runs | Main strength | Main blind spot |
|---|---|---|---|
| SITL | Desktop computer | Fast, cheap, fully repeatable | Real hardware timing and sensors |
| HITL | Real flight controller | Exposes CPU load and driver faults | Real aerodynamics and vibration |
| Flight test | Real aircraft in the air | Ground truth for everything | Cost, risk and limited repeatability |
Companion computer software and offboard control code also benefit from SITL. A companion computer program using MAVSDK or MAVROS can connect to the simulated autopilot through the same interface it will use on the aircraft, so integration bugs surface on the desk rather than at the field.
Practical uses in drone development
Engineers use SITL whenever a change could endanger the aircraft or people if it misbehaved. Typical cases include new flight modes, geofence rules, battery failsafes and complex waypoint missions. Firmware projects also run SITL in continuous integration, so every code change triggers automated test flights.
- Mission rehearsal: an operator loads a survey plan and checks turns, altitudes and landing behavior before the real job.
- Failsafe verification: a script cuts the simulated GPS or radio link and confirms the vehicle returns or lands as configured.
- Parameter experiments: a developer compares controller gains safely before trying them on hardware.
- Training: new pilots learn ground control station workflows without risking an aircraft.
- Swarm and fleet software: several SITL instances run in parallel to test coordination logic.
The following decision table helps choose the right SITL configuration for common goals.
| Goal | Recommended setup | Reason |
|---|---|---|
| Check a waypoint mission | Built-in simulator with default model | Quick start, adequate for navigation logic |
| Test obstacle avoidance | Gazebo with depth camera plugins | Needs rendered sensors and geometry |
| Validate a new failsafe | Scripted SITL in continuous integration | Repeatable fault injection on every change |
| Tune attitude gains | Custom model with measured inertia | Generic models give misleading responses |
Limitations and common mistakes
The central limitation is that a simulation is only as good as its model. A controller that looks perfect in SITL can oscillate on a real frame because of vibration, flexible arms, propeller wash or sensor noise that the simulator ignores. SITL also cannot reveal faulty wiring, overheating electronics or radio interference.
- Trusting tuned gains blindly: treat SITL tuning as a starting point and confirm with careful hover tests.
- Ignoring wind and noise: enable realistic disturbances, or failsafe tests will pass too easily.
- Mismatched parameters: load the same parameter file in SITL that the real aircraft uses.
- Skipping HITL: timing problems on the flight controller appear only on real hardware.
In everyday language
SITL is a flight simulator for the drone’s brain. The real autopilot program runs on a normal computer. A simulator pretends to be the aircraft and the sky around it. The program believes it is flying and reacts the same way it would in the air.
This lets engineers try new ideas safely. If a mission plan has a mistake, the virtual drone crashes and nothing breaks. The key point is simple: SITL catches software mistakes early, but a real test flight is still needed before trusting the drone.
Seen in the real world
A small team building an inspection drone for wind turbines writes a new flight mode that circles a tower at a fixed distance of 15 meters. Before touching hardware, the team runs the mode in ArduPilot SITL with a Gazebo world that contains a turbine model and gusty wind of about 8 meters per second.
The simulated runs reveal that the drone drifts toward the tower when GPS accuracy drops, because the distance check relies only on position estimates. The team adds a rangefinder check, reruns 200 automated scenarios overnight in lockstep mode, and confirms the fix. The first real flight then completes the full orbit without incident, and the scenarios remain in the continuous integration suite to guard against future regressions.