DEV Community

WinterTurtle23
WinterTurtle23

Posted on

Using AirSim with Unreal Engine: A Guide to Drone & Autonomous Vehicle Simulation

As autonomous systems and robotics grow, developers need realistic, flexible environments to test algorithms safely. This is where AirSim, an open-source simulator developed by Microsoft, becomes incredibly valuable.

In this blog post, I’ll walk you through what AirSim is, how to integrate it with Unreal Engine, and how I used it in my project to simulate realistic drone physics for training and navigation systems.


🧠 What Is AirSim?

AirSim (Aerial Informatics and Robotics Simulation) is a plugin for Unreal Engine that provides realistic physics, sensor data, and environment simulation for drones, cars, and other autonomous systems.

  • Open-source (MIT license)
  • Supports drone and car simulations
  • Includes APIs for Python, C++, and ROS
  • Simulates RGB, depth, segmentation, lidar, IMU, GPS, and barometer
  • Ideal for AI, computer vision, reinforcement learning, and testing flight code

🔧 Getting Started with AirSim in Unreal Engine

🧱 Step 1: Clone and Build AirSim

git clone https://github.com/microsoft/AirSim.git
cd AirSim
./setup.sh    # or setup.bat for Windows
./build.sh    # or build.cmd for Windows
Enter fullscreen mode Exit fullscreen mode

This compiles the AirSim plugin and samples.


🛠 Step 2: Create or Use an Unreal Project

You can either:

  • Use the Blocks environment from AirSim samples
  • Or create your own custom Unreal map

📦 Step 3: Integrate AirSim Plugin into Your UE Project

  1. Copy the AirSim folder into your Unreal project under /Plugins/
  2. Regenerate project files (.uproject → right-click → Generate Visual Studio project)
  3. Open the project in Unreal Engine and enable the plugin if prompted

🧠 How AirSim Handles Drone Physics

AirSim uses a PX4-based physics model for multirotors. It mimics:

  • Pitch, roll, yaw control
  • Aerodynamic drag and lift
  • GPS drift and latency
  • Motor delay simulation

🧪 Using the API

AirSim offers a Python and C++ API. Here's a basic Python example to control the drone:

void ADroneController::BeginPlay()
{
    Super::BeginPlay();

    // Create and connect AirSim client
    msr::airlib::MultirotorRpcLibClient* DroneClient = new msr::airlib::MultirotorRpcLibClient();
    DroneClient->confirmConnection();

    // Enable control and arm the drone
    DroneClient->enableApiControl(true);
    DroneClient->armDisarm(true);

    // Take off
    DroneClient->takeoffAsync()->waitOnLastTask();

    // Fly to a target position
    DroneClient->moveToPositionAsync(0, 0, -10, 5)->waitOnLastTask();

    // Land after reaching destination
    DroneClient->landAsync()->waitOnLastTask();

    // Release control
    DroneClient->enableApiControl(false);
}

Enter fullscreen mode Exit fullscreen mode

You can automate missions, collect sensor data, or train AI models on top of this API.


🧰 Sensors Available in AirSim

  • RGB & Depth camera
  • Segmentation mask
  • Lidar (360° scan)
  • GPS
  • IMU
  • Magnetometer
  • Distance sensor (ultrasonic)
  • Barometer

These can be configured via the settings.json file in the AirSim root:

{
  "SettingsVersion": 1.2,
  "Vehicles": {
    "Drone1": {
      "VehicleType": "SimpleFlight",
      "X": 0, "Y": 0, "Z": 0
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

🌦️ Enhancing Simulation Realism with Unreal

In my project, I used Unreal features to elevate the realism:

  • Dynamic lighting and weather using Blueprint systems
  • Obstacles with collision meshes to test navigation
  • Post-processing effects to simulate camera noise

🧠 Use Cases of AirSim

  • Reinforcement Learning – Train agents to fly or drive using safe simulations
  • Robotics Research – Test autonomous code before deploying to hardware
  • Surveillance & Mapping – Simulate GPS + camera-based tracking
  • Logistics & Delivery – Prototype drone delivery systems
  • Education & Training – Create VR/PC training simulations for drones

🧩 Tips & Best Practices

  • Run AirSim in UE Editor → VR Preview / Standalone Mode for stability
  • Use SimMode Blueprint/C++ class to customize vehicle spawning
  • Check airsim.log and settings.json for API config issues
  • Use stat unit and stat fps to keep your simulation optimized

📦 Final Thoughts

AirSim + Unreal Engine is a powerhouse combo for anyone working in autonomous vehicles, AI, or simulation. Whether you're building a drone racing prototype or testing machine vision models, this toolset allows for real-world logic testing in safe, scalable virtual environments.

In my experience with Dronewood and simulation-based client projects, AirSim helped bridge the gap between Unreal’s visual power and robotics code realism.

If you're exploring AirSim for Unreal and need help setting it up, integrating APIs, or deploying to hardware — feel free to connect. I’d love to hear about your projects!

Top comments (0)