Hardware-in-the-loop (HIL) testing puts the real controller board on a bench and makes it believe it is flying, driving or running in a plant. The firmware is the build you will ship. Only the world around it is simulated: sensor readings go in, actuator commands come out, and a model closes the loop. You run it to find the faults that only show up when real code meets real hardware, and to see what the system does when something fails.
What is hardware-in-the-loop testing?
A HIL setup has four parts. NI’s description of a HIL system lists the same ones:
- The device under test. The controller with its production firmware, for example a flight controller, a companion computer or a motor drive.
- Interfaces. The buses and I/O the device normally uses: UART, CAN, SPI, PWM, Ethernet, USB.
- A real-time simulator. It runs a model of the vehicle or plant and the sensors, reads the device’s outputs and answers within the device’s timing budget.
- Test software. It sets up scenarios, injects faults, records everything and decides pass or fail.

The loop is the point. When the controller commands more thrust, the model’s altitude changes and the next barometer reading reflects it. A test that only replays recorded data cannot do that.
How is HIL different from SITL?
Software-in-the-loop (SITL) compiles the same code for a development computer and runs it against a simulator with no target hardware at all. ArduPilot’s documentation describes SITL as a build of the autopilot made with an ordinary C++ compiler. It gives developers debuggers and analysis tools that are not available on the board.
PX4’s documentation makes a useful distinction. In SITL, more of the standard system code runs, because only the sensor drivers are replaced. In HITL, the normal firmware runs on the normal flight controller, and the simulator’s data enters at a different point.

In practice the two do different jobs:
| SITL | HIL | |
|---|---|---|
| Runs on | Development computer | The real controller board |
| Good for | Control logic, mission logic, regressions on every commit | Timing, drivers, interfaces, CPU and memory load, boot and update behaviour |
| Cost per run | Seconds, can run in parallel in CI | Bench time on a limited number of boards |
| Misses | Anything that depends on the hardware | Physics and failures that were not modelled |
Test most logic in SITL, then move what depends on the board to HIL. Flight or field trials come last.
What should you test on the HIL bench first?
Nominal missions are worth running, but they rarely find much. The value of a bench is in the failures you would not dare to provoke in the air. These are the ones we would start with.

Sensor faults. A gyro that stops updating, a barometer that freezes on one value, a magnetometer that reads wrong. PX4’s failure-injection module can make a sensor go off, stuck, wrong, garbage or drift, both in simulation and on real hardware. It is disabled by default and enabled with the SYS_FAILURE_EN parameter. Check that each fault is detected, that the estimator rejects the bad source and that the failsafe you designed is the one that triggers.
Satellite navigation loss and drift. Cut the GNSS fix, then try a position that drifts slowly. The second case is harder, because nothing looks broken at first. The test shows whether the system notices and how far it travels before it does.
Power. Drop the battery reading below the warning threshold and confirm the low-battery behaviour. Then test brown-outs and restarts on the real board, which a desktop simulation cannot reproduce. A board that reboots in flight has to come back to a known state.
Links. Drop the telemetry or command link, add latency, lose packets. Decide in advance what the vehicle should do after one second, ten seconds and a minute without a link, then check that it does exactly that.
Load and timing. Run the companion computer’s vision pipeline, logging and telemetry together and watch loop rates and latency on the flight controller. Many integration faults only appear when everything runs at once.
Updates. Interrupt a firmware update halfway through, then power-cycle the board. The device should boot the previous image or a recovery mode, never nothing.
Where does HIL fall short?
A simulator only knows what someone put into it. Aerodynamics at the edge of the envelope, vibration, temperature, electromagnetic interference from the vehicle’s own wiring, real radio propagation: these are hard to model and are often simplified. PX4’s own simulation pages are candid about this. HITL is marked as community supported, and in SIH only the quadrotor model is stable, with the other vehicle types listed as experimental.
The Ariane 5 inquiry is a reminder of what an incomplete loop can hide. On 4 June 1996 the first Ariane 5 launch failed about 37 seconds into flight, after both inertial reference systems failed. In the closed-loop simulations run before the flight, many pieces of equipment were physically present, but the two inertial reference units were replaced by software models. The board’s second recommendation asked for a test facility with as much real equipment as technically feasible, realistic input data and complete closed-loop system testing.
The lesson for a drone or an industrial controller is the same. Any unit that is simulated instead of connected deserves a written reason and a check that earlier tests covered it.
How does HIL fit into the development process?
- On every commit: SITL regression tests, in parallel, in CI.
- Nightly or before a release: the HIL suite on real boards, including the failure cases above, with logs kept for every run.
- Before field trials: a short HIL run with the exact firmware, parameters and companion software that will fly.
- After a field incident: reproduce the incident on the HIL bench, fix it, and keep the scenario as a permanent test.
The last step matters most. Each problem found in the field becomes a bench test, so the same fault does not reach the field twice.
What to ask a supplier about their HIL testing
- Which units run as real hardware on the bench, and which are simulated?
- Which failures are injected, and how is the expected reaction defined?
- Does the bench run the exact release build, or a special test build?
- Are HIL runs automated and logged, and can you see the results for the release you receive?
- How are field incidents turned into new tests?
At Perfsol, hardware-in-the-loop and field testing are part of our verification and hardening work, together with load, soak and failure-injection testing and tests under radio interference and satellite-navigation disturbance. If you are building on a flight stack and a companion computer, our Drone Platform and onEDGE pages describe what we build on.
Questions we are asked
What is the difference between HIL and SITL?
SITL runs the flight or device code on a development computer with simulated sensors and no target hardware. HIL runs the normal firmware on the actual controller board and connects it to the simulator, so board timing, drivers and interfaces are part of the test.
Does PX4 support hardware-in-the-loop?
Yes, for multicopters and standard VTOL with Gazebo Classic, though the PX4 documentation marks HITL as community supported. PX4 also offers SIH, which runs a lightweight physics model inside PX4 on the flight controller itself.
Can HIL replace flight testing?
No. A simulator only knows the physics and failures you modelled. HIL removes most software and integration faults before the first flight, and field testing finds what the model left out.
Sources
- Hardware in the Loop Simulation (HITL), PX4 Autopilot documentation
- SIH Simulation, PX4 Autopilot documentation
- System Failure Injection, PX4 Autopilot documentation
- SITL Simulator (Software in the Loop), ArduPilot developer documentation
- What Is Hardware-in-the-Loop (HIL)?, NI
- Ariane 5 Flight 501 Failure: Report by the Inquiry Board, ESA / CNES Inquiry Board, July 1996