Skip to main content

Command Palette

Search for a command to run...

QGroundControl and AirSim Integration Guide - Setting Up Ground Station Control for Virtual Aircraft

Updated
5 min read

Article Series

A total of two articles

Catalogue

QGroundControl and AirSim Integration Guide - Establishing STIL (Software-In-The-Loop)

QGroundControl and AirSim Integration Guide - Setting Up Ground Station Control for Virtual Aircraft


Tip:AirSim、SITL、QGroundControl、PX4、Ardupilot


Introduction

[AirSim] ←→ (TCP) ←→ [PX4 SITL(Software-In-The-Loop)] ←→ (UDP) ←→ [QGroundControl(QGC)]

This article explores how to achieve data transmission and control between AirSim, PX4 SITL, and QGroundControl. This architecture is designed for drone simulation environments, allowing developers to test flight control algorithms, navigation strategies, and automated flight plans in a virtual setting. It enables development and validation without requiring physical hardware.

TermDefinition
AirSimA drone simulation environment responsible for rendering the virtual world and providing physics simulation
PX4 SITLThe core of the flight control system, exchanging sensor data and control commands with AirSim via TCP
QGCThe ground station, communicating with PX4 SITL via UDP, providing a UI interface to monitor the drone's status and send control commands

AirSim ↔ PX4 SITL AirSim simulates the physical environment of the drone and connects to PX4 SITL via TCP, while PX4 SITL is used to simulate the PX4 flight controller.

PX4 SITL ↔ QGroundControll Through UDP communication, PX4 SITL sends MAVLink messages to QGroundControl for monitoring, while PX4 SITL allows QGroundControl to send flight commands (such as takeoff, landing, and navigation).

This architecture allows developers to simulate complete drone missions within a software environment, and further integrate AI, autonomous navigation, and image processing technologies to enhance the intelligence capabilities of drones. This article will provide a detailed guide on how to set up this system.


Tips:Here is the main content of this article. The following examples are provided for reference.

一、Install Unreal Engine

You need to log in and create an account before installing Unreal Engine. In UE5, the PhysX physics engine has been replaced with the Chaos physics engine. However, AirSim still relies on the PhysXVehicles plugin, meaning that AirSim is not officially supported in UE5. The best-supported version of AirSim is UE4.27. If you want to develop with UE5, you need to:

  1. Remove PhysXVehicles-related code in AirSim/Source/AirSim.cpp.
  2. Modify AirSimGameMode to support Chaos physics. UE4_27 Set Environment Variables
    setx Path "%Path%;C:\Program Files\Epic Games\UE_4.27\Engine\Binaries\Win64"
    

二、Install Visual Studio 2022

You can try searching in the "Start Menu" :

x64 Native Tools Command Prompt for VS 2022

Unreal Engine officially supports only Microsoft Visual C++ (MSVC) as the compiler for the Windows platform, so AirSim must also be compiled using MSVC. The x64 Native Tools Command Prompt for VS 2022 ensures that AirSim is compiled with MSVC, preventing mismatches with the UE toolchain.

三、Download and Compile AirSim

If you need to modify or further develop AirSim, download the source code:

git clone https://github.com/PX4/PX4-Autopilot.git --recursive

Relevant PX4 Resources:

If an error occurs, you need to Clean before Build. Use the x64 Native Tools Command Prompt.

cd C:\Project Location\AirSim\  
C:\Project Location\AirSim> clean.cmd  
C:\Project Location\AirSim> build.cmd

After the Build process is completed, an Unreal Engine project file will be generated. AirSim Build AirSim UE4

四、AirSim Parameter Configuration

Modify the settings.json file to enable QGroundControl (QGC) to connect with AirSim.

Modify the configuration file: C:\Users\xxx\Documents\AirSim\settings.json

{  
    "SettingsVersion": 1.2,  
    "SimMode": "Multirotor",  
    "ClockType": "SteppableClock",  
    "Vehicles": {  
        "PX4": {  
            "VehicleType": "PX4Multirotor",  
            "UseSerial": false,  
            "LockStep": true,  
            "UseTcp": true,  
            "TcpPort": 4560,  
            "ControlIp": "remote",  
            "ControlPortLocal": 14540,  
            "ControlPortRemote": 14580,  
            "LocalHostIp": "172.17.144.1",  
            "Sensors":{  
                "Barometer":{  
                    "SensorType": 1,  
                    "Enabled": true,  
                    "PressureFactorSigma": 0.0001825  
                }  
            },  
            "Parameters": {  
                "NAV_RCL_ACT": 0,  
                "NAV_DLL_ACT": 0,  
                "COM_OBL_ACT": 1,  
                "LPE_LAT": 47.641468,  
                "LPE_LON": -122.140165  
            }  
        }  
    }  
}

In WSL, enter "ip addr show eth0" to check the IP address: WSL address In Windows, enter "ipconfig" in Command Prompt (cmd) to check the IP configuration: CMD Address

五、Connect to Mission Planner

The connection IP that Mission Planner needs to configure is the IP of WSL. The connection between Mission Planner and SITL should be set to UDP to monitor the status of the AirSim simulated aircraft.

The port to configure will be displayed in the information shown when SITL is running in WSL. MAVlink SITL Port QGC UDP Configuration Screen QGC UDP setting Once connected successfully, you will be able to see the UAV settings in AirSim. AirSim Vehicle


Summary

This guide explains how to integrate QGroundControl (QGC) with AirSim, enabling the ground station to control the virtual drone. Through this integration, developers can monitor the drone's status, plan flight routes, and control flights manually or autonomously in a simulated environment, without requiring physical hardware to test the operation of the PX4 flight control system.