How microsoft/airsim works
Main Components
• Simulation Engine Integration Layer:
– Unreal Engine (core simulation environment; see the “Unreal” directory and plugin code in Unreal/Plugins/AirSim).
– Experimental Unity plugin (found under the “Unity” folder).
• Core Simulation Library – AirLib:
– Organized into subcomponents such as “api”, “common”, “physics”, “sensors”, “safety”, and “vehicles”.
– Contains modules that implement vehicle-specific simulations, sensor modeling, physical computations, and safety (e.g., geofence checks).
• Communication and API Layer:
– RPC libraries (with base classes in AirLib/include/api) to expose simulation controls and sensor data.
– External API servers and clients (see AirLib/src/api and files like RpcLibServerBase.cpp and RpcLibClientBase.cpp).
• Client Interfaces and Tools:
– Python Client (PythonClient folder) for programmatic control.
– ROS and ROS2 integrations (directories “ros” and “ros2”) that include launch files, msg/srv definitions, and wrappers.
– Additional demo and utility projects such as DroneServer, DroneShell, and examples listed in the “Examples” directory.
• Auxiliary and Integration Components:
– MavLinkCom for communication with flight controllers.
– Azure and Docker folders for cloud/CI setup.
– LogViewer and additional UI components for visualization and debugging.
Establish Relationships and Data Flow
• A bidirectional connection between the Simulation Core and the Engine Integration Layer – they exchange commands and simulation state.
• The API layer (RPC servers, API adaptors) sits on top of AirLib connecting external clients (Python programs, ROS nodes, MavLink components, vehicle control consoles like DroneShell) with the simulation core.
• Clients send instructions (via API calls or RPC) to control vehicles or request sensor data; the simulation core processes these and responds back through the API layer.
• Relationships between the simulation’s modular components (e.g., sensors, physics engine, vehicle models, safety checks) that are combined to create the full simulation state.
• External connectivity for hardware-in-the-loop support (PX4 & ArduPilot integration) and customization through configuration files (settings in AirLib/include/common and docs).
Architectural Patterns and Design Principles
• Layered Architecture – separate the simulation engine integration, simulation core (AirLib), API/external communication, and client applications.
• Modular and Extensible Design – AirLib is organized into several directories (e.g., “sensors”, “vehicles”, “physics”) that clearly indicate separation of concerns.
• RPC Pattern – for programmatic control over simulation (via RPC libraries and APIs).
• Cross-platform and Multi-language Support – support for C++, Python, ROS, and C# clearly indicate heterogeneous client connections.
• Plugin-Based Integration – with Unreal and Unity, the system is built as a plugin that can be added to different environments.
Relevant Technologies, Frameworks, and Libraries
• Unreal Engine and Unity as simulation/rendering engines.
• C++ core libraries (AirLib, DroneServer, DroneShell, MavLinkCom).
• RPC frameworks (for example, the use of RPC adaptation via RpcLib libraries).
• ROS and ROS2 for integrating simulation with standard robotics middleware.
• Python for API-based control and reinforcement learning experiments.
• Docker and Azure elements for CI/CD and deployment.
• Build systems (CMake and Visual Studio) clearly present in the file tree.
Elements
• Use clear, descriptive labels for each component (e.g., “AirLib Simulation Core”, “Unreal Engine Plugin”, “RPC API Server”, “Python Client Interface”, “ROS Integration Layer”).
– From client interfaces (e.g., Python scripts, ROS nodes) to the API layer and then to the AirLib core.
– From simulation core back to UI components or logging systems.
• Notes on configuration files and build scripts (shown in directories like “cmake”, “docker”, “build.cmd/sh”) that hint at deployment and integration processes.