How sairisan123/projectairsim works
Purpose and execution model
Project AirSim is a C++ simulation platform for autonomous drones, rovers, robots, sensors, controllers, and custom physics, hosted primarily by Unreal Engine 5; Unity support is also present. The root build entry points are build.sh, build.cmd, and CMakeLists.txt. A standalone native simulator sample starts at samples/standalone_sim/main.cpp; the principal graphical host is the Unreal Blocks project at unreal/Blocks/Blocks.uproject.
Core simulation libraries
core_sim defines the engine-independent simulation model and tick-time orchestration: simulator, scene, actors/robots, transforms, clock, environment, runtime components, and service/topic abstractions.
• core_sim/include/core_sim/simulator.hpp
• core_sim/src/simulator.cpp
• core_sim/src/scene.cpp
Configured scenes instantiate robot and environment actors; the simulation advances clock/state, transforms, actuators, physics, and sensors. This is the core boundary that rendering hosts and network APIs integrate against.
Robot structure, actuation, and sensing
Robots are composed from links, joints, geometry/inertial definitions, actuators, and sensors. Actuator commands are mapped to rotors, wheels, gimbals, tilt mechanisms, or control surfaces; sensors generate typed simulation messages for camera, lidar, radar, GPS, IMU, battery, and related modalities.
• core_sim/src/actor/robot.cpp
• core_sim/src/actuators/control_mapper.cpp
• core_sim/src/sensors/sensor.cpp
Transform-tree and message types separate internal simulation state from published observation/control payloads.
Physics and vehicle-control boundary
Physics implementations are independently selectable: fast native physics, Unreal-backed physics, and MATLAB integration. Vehicle APIs provide controller-facing behavior for multirotors, VTOL/fixed-wing variants, and Ackermann rovers, including built-in simple-flight/simple-drive and MAVLink/ArduCopter adapters.
• physics/src/physics_world.cpp
• physics/src/fast_physics.cpp
• vehicle_apis/multirotor_api/src/mavlink_api.cpp
Control flow is controller/setpoint → vehicle API → actuator outputs → physics state → sensor/state messages. MATLAB S-functions enable external control or physics models.
Host rendering and engine integration
The Unreal ProjectAirSim plugin loads configuration, creates and synchronizes scene/robot representations, supplies engine-rendered sensor implementations, and bridges host-thread/render-thread concerns to native simulation libraries.
• unreal/Blocks/Plugins/ProjectAirSim/Source/ProjectAirSim/Private/UnrealSimLoader.cpp
• unreal/Blocks/Plugins/ProjectAirSim/Source/ProjectAirSim/Private/UnrealScene.cpp
• unreal/Blocks/Plugins/ProjectAirSim/Source/ProjectAirSim/Private/Sensors/UnrealCamera.cpp
Unity has an analogous C# host plus native wrapper:
• unity/BlocksUnity/Assets/ProjectAirSimAssets/Scripts/UnitySimLoader.cs
• unity/sim_unity_wrapper/src/sim_unity_wrapper.cpp
GIS/tiled scene rendering is a separate subsystem, with glTF and Bing-map utilities:
• rendering/scene/src/tile_manager.cpp
• rendering/scene/src/gltf_data_provider.cpp
Network APIs and clients
The simulator exposes services/topics and request/response messages; Python clients are the primary end-user automation layer. The Python package provides client, drone, rover, world, mission, and environment-actor APIs, while a Windows C++ DLL supplies another client surface.
• client/python/projectairsim/src/projectairsim/client.py
• client/python/projectairsim/src/projectairsim/drone.py
• client/cpp/AirSimClientDLL/src/Client.cpp
The service/topic layer is the key process/network boundary:
• core_sim/src/service_manager.cpp
• core_sim/src/topic_manager.cpp
Integrations and higher-level workloads
MAVLink networking supports external autopilots over TCP/UDP/serial, including PX4 and ArduPilot workflows.
• mavlinkcom/src/MavLinkConnection.cpp
• mavlinkcom/src/MavLinkVehicle.cpp
ROS 1, ROS 2, and rosbridge nodes translate simulation data and commands for robotics ecosystems. Python tooling adds synthetic data collection, augmentation, trajectory generation, validation, Gym environments, and ONNX-based perception/serving.
• ros/node/projectairsim-ros2/src/projectairsim_ros2/ros2_node.py
• client/python/projectairsim/src/projectairsim/datacollection/data_generator.py
• client/python/projectairsim/src/projectairsim/autonomy/serving/serve_onnx.py
Material infrastructure includes CMake/Visual Studio builds, Unreal Engine 5.2/5.7, Windows 11 and Ubuntu 22, optional Docker headless rendering, Azure CI/deployment pipelines, and optional Azure Blob data collection.
Main entry points: simulator.cpp Core simulator · service_manager.cpp Services and topics · UnrealSimLoader.cpp Unreal host plugin · robot.cpp Robot composition
Components 20
Native simulation
- Native build entry points · CMake and platform scripts build the native platform.
CMakeLists.txt - Core simulator · Engine-independent tick orchestration, scene state, and runtime components.
core_sim/src/simulator.cpp - Scene and actors · Configured environments and robot actors populate the simulation.
core_sim/src/scene.cpp - Robot composition · Links, joints, geometry, actuators, and sensors form robots.
core_sim/src/actor/robot.cpp - Control mapper · Maps commands to vehicle mechanisms.
core_sim/src/actuators/control_mapper.cpp - Simulated sensors · Produces typed camera, lidar, radar, GPS, IMU, and battery messages.
core_sim/src/sensors/sensor.cpp - Services and topics · Publishes simulation observations and accepts requests and commands.
core_sim/src/service_manager.cpp
Simulation hosts
- Unreal host plugin · Loads and synchronizes native simulation with Unreal scenes and rendering.
unreal/Blocks/Plugins/ProjectAirSim/Source/ProjectAirSim/Private/UnrealSimLoader.cpp - Unreal camera sensor · Engine-rendered camera implementation.
unreal/Blocks/Plugins/ProjectAirSim/Source/ProjectAirSim/Private/Sensors/UnrealCamera.cpp - Unity host and wrapper · C# host integrates through a native simulation wrapper.
unity/BlocksUnity/Assets/ProjectAirSimAssets/Scripts/UnitySimLoader.cs - Tiled GIS renderer · Loads glTF and Bing-map tile content.
rendering/scene/src/tile_manager.cpp - Standalone simulator sample
samples/standalone_sim/main.cpp
Control and physics
- Selectable physics · Supports fast native, Unreal-backed, and MATLAB physics implementations.
physics/src/physics_world.cpp - Vehicle APIs · Multirotor, VTOL, and rover control interfaces including MAVLink adapters.
vehicle_apis/multirotor_api/src/mavlink_api.cpp - MAVLink bridge · Connects PX4 and ArduPilot over TCP, UDP, or serial.
mavlinkcom/src/MavLinkConnection.cpp
APIs and integrations
- Python client APIs · Client, drone, rover, world, mission, and environment APIs.
client/python/projectairsim/src/projectairsim/client.py - C++ client DLL
client/cpp/AirSimClientDLL/src/Client.cpp - ROS 2 node · Translates ROS commands and simulation data.
ros/node/projectairsim-ros2/src/projectairsim_ros2/ros2_node.py
Data and autonomy
- Data collection · Generates and augments simulation datasets.
client/python/projectairsim/src/projectairsim/datacollection/data_generator.py - ONNX autonomy serving · Runs ONNX-based perception and serving.
client/python/projectairsim/src/projectairsim/autonomy/serving/serve_onnx.py
Connections 21
- Native build entry points → Core simulator: builds
- Standalone simulator sample → Core simulator: hosts
- Unreal host plugin → Core simulator: integrates
- Unity host and wrapper → Core simulator: wraps
- Core simulator → Scene and actors: advances
- Scene and actors → Robot composition: instantiates
- Robot composition → Control mapper: contains
- Robot composition → Simulated sensors: contains
- Control mapper → Selectable physics: applies outputs to
- Selectable physics → Core simulator: returns state
- Simulated sensors → Services and topics: publishes messages
- Services and topics → Vehicle APIs: receives control
- Vehicle APIs → Control mapper: produces commands
- MAVLink bridge → Vehicle APIs: external autopilot
- Unreal host plugin → Unreal camera sensor: implements
- Unreal host plugin → Tiled GIS renderer: renders scene tiles
- Python client APIs → Services and topics: service/topic client
- C++ client DLL → Services and topics: service/topic client
- ROS 2 node → Services and topics: translates ROS
- Data collection → Python client APIs: automates
- ONNX autonomy serving → Python client APIs: drives simulation