HITL Testing for Linux

HITL Testing for Linux

About HITL

It is possible to test the SDK in hardware in the loop mode (HITL).

In HITL, the drone is connected over USB to a host computer. A physics simulation runs on the computer and simulates sensor data which is given to the microcontroller on the drone. The drone acts given the fake sensor data and generates motor outputs which are fed back to the simulation.

Note: In HITL, the camera and gimbal is used normally and will take boring pictures of your desk. Also, the ST16 or ST10C can be used in HITL. It actually has to be used, otherwise the autopilot will complain about the fact that RC is missing.


Set H520 into HITL mode

Use DataPilot app to enable HITL mode in H520. Goto third tab(hamburger menu) in the main screen->Advanced Settings->Parameters and enable SYS_HITL. Please restart the drone once you enable HITL. 

Note: To see Advanced Settings, you have to click multiple times on the third tab(hamburger menu).

Set up HITL

  1. Make sure to have Java 8 installed:
    sudo apt-get install openjdk-8-jdk ant

    For Fedora:
    sudo dnf install java-1.8.0-openjdk ant
  2. Install Apache Ant (instructions).
  3. Download jMAVSim:
    git clone https://github.com/PX4/jMAVSim.git
    cd jMAVSim
    git submodule update --init --recursive
  4. Build the simulator:
    cd jMAVSim
    ant create_run_jar copy_res


  1. Connect USB cable to H520. Use a Micro USB cable and plug it into the drone's body.
  2. Switch the H520 on.
  3. Find the USB device:
    ls /dev | grep ttyACM
    Usually it's `/dev/ttyACM0` on Linux.
  4. Build and start the simulator (use the port from above):
    cd jMAVSim
    ant create_run_jar copy_res && java -Djava.ext.dirs= -jar ./out/production/jmavsim_run.jar -serial /dev/ttyACM0 921600 -qgc -r 100



  1. The simulator FPS (shown in the bottom left corner) suddenly goes from 60 Hz to around 5 Hz.
    -> Restart the simulator and drone.
  2. The FPS immediately and consistently drops to 10-20 Hz.
    -> Try another USB port. If using a USB hub, try plugging it straight into the computer.