Hardware-in-the-loop Simulation in Airsim Environment

Note: This tutorial is part of our Kerloud DASA service

Background

../_images/airsim_background.png

Airsim is an open source project created by Microsoft in 2017, and it serves as a simulation platform that supports autonomous drones and cars. The platform is built on Unreal Engine with superior 3D visualization effect and high fidelity physics engine. So it offers high-end users an alternative solution to existing tools like Gazebo and jMAVsim, and enables fantastic simulation scenarios that are comparable with those in games and movies.

The hardware-in-the-loop (HIL) simulation is another simulation mode supported by PX4 firmware. Different with the SITL simulation mentioned in Offboard Control with Mavros (C++), the flight control firmware is run on the real autopilot, hence all code can be tested onboard. The simulation method can accelerate greatly our software development and reduce experiment risks.

This tutorial provides a starting point for interested users to familiarize the Airsim environment and interface with our Kerloud autopilots in the hardware level.

Prerequisites

Necessary tools are listed as below with full test:

  • Kerloud autopilot : firmware version >= v1.10.0

  • A RC receiver and a transmitter

  • A powerful personal computer

The recommended PC hardware requirement can be referred here. In our case, the hardware details are: CPU (Intel i7-13700KF), video card (Nvidia Geforce RTX 3060), hard drive (1TB SSD) and 32GB RAM memory. The PC is installed with Ubuntu 18.04 and Unreal Engine 4.27 plus.

Experiment Setup

Autopilot Setup

The HIL mode of the Kerloud autopilot can be set up following the instruction in https://docs.px4.io/main/en/simulation/hitl.html. For short, the HIL mode is enabled, and the QGroundcontrol station should be configured with UDP communication only. The autopilot will communicate mavlink messages with the airsim platform via its USB port.

Airsim Software

The airsim platform is built from source in our PC following the guide. Here we use the source code from the latest main branch (commit date: 2022-7-21). Users are suggested to play with the Block environment for initial test. We use a customized environment using the landscape mountain content from the marketplace in Epic Games, and the details can be referred in https://microsoft.github.io/AirSim/unreal_custenv/. The environment view is shown as below:

../_images/airsim_landscape.png

After copying the Airsim plugin folder to the customized project, we can start the simulation with simply a click on the “Play” button. The default quadrotor vehicle can show up just like real.

../_images/sceneview.png

Demonstration

The demonstration of remote manual control in the airsim platform can be viewed in the video below: