Setting Up PX4 Autopilot in Hardware-in-the-Loop (HITL) Mode from QGroundControl
The PX4 Autopilot must be configured in Hardware-in-the-Loop (HITL) mode before setting it up for HITL Simulation. The workflow is based on Hardware in the Loop Simulation (HITL).
Setting up PX4 Autopilot in HITL Mode
Perform these steps to configure and setup QGroundControl (QGC).
Upload PX4® v1.10.2 released firmware to the Pixhawk® autopilot. Ensure that the
cmakefile is not modified to exclude PX4 controllers and the custom
rc.txtis not present. To download firmware for your PX4 board go to PX4 Firmware GitHub page. For example, download
The PX4 firmware version supported for R2021b is PX4 v1.10.2. However as v1.10.2 firmware image is not available for download in PX4 repository, use v1.10.1 for the setup process.
In the QGC, navigate to Vehicle Setup > Firmware. Select Advanced settings and choose
Custom firmware filefrom the drop-down list. In Firmware Setup option, click Ok and continue with the onscreen instructions to install the firmware.
Connect the autopilot to QGC via USB.
Enable HITL mode.
Navigate to Setup > Safety section.
Select Enabled from the HITL Enabled list.
Navigate to Setup > Airframes.
HIL QuadCopterand then click Apply and Restart on top-right of the Airframe Setup page.
In the General tab of the settings menu, clear all AutoConnect options except UDP.
This selection ceases the communication between QGC and PX4 Autopilot over USB. The QGC can now communicate only over UDP (this is usually taken care by a Simulator which acts as a bridge between QGC and Autopilot and routes MAVLink data between QGC and Autopilot over UDP).
This selection is done only for HITL mode. Later, if you want to connect to a non HITL hardware, return to this settings menu and select Pixhawk option also.
Select Virtual Joystick.
In the General tab, from Fly View of the settings menu, select Virtual Joystick option.
Configure Joystick and Failsafe. Set the following parameters to use a joystick instead of an RC remote control transmitter:
Joystick/No RC Checks. This allows joystick input and disables RC input checks.
Disabled. This ensures that no RC failsafe actions interfere when not running HITL with a radio control.
-1. This disables the timeout for auto-disarm when QGC detects a landing. This helps in avoiding a potential PX4 failsafe when drone motors stops at highest take-off point momentarily.
Ensure there are no warnings in the Vehicle Settings tab of QGC. Only the Power tab can be in red (with warning). If you see warnings for the Flight Modes tab, set it up by picking a mode for each of the channels. Sometimes, the Sensor Calibration tab can be in red. You can go ahead with it.
Ensure that SD card is inserted in the hardware for the mission upload from QGC to work.
Close the QGC.