# khlann/miaa_sim architecture

> Architecture diagram of the GitHub repository khlann/miaa_sim, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/khlann/miaa_sim
- Repository: https://github.com/khlann/miaa_sim

## Overview

##### Main Components Identification
- Asset Repository: Represented by the “asset” folder, which holds 3D models, URDFs, descriptions, and pre-rendered parts for objects and multiple robot models. This acts as a resource library for simulation.
- Configuration Module: The “config” directory contains separate configuration files (e.g., camera_varant.py, object_varant.py, robot_varant.py) that parameterize and customize different simulation aspects.
- Simulation Core and Entry Point: The “main.py” acts as the central initiation script that ties together the simulation environment, assets, and robot instances.
- Robot Modules:
– The “robot” folder includes files like camera.py (for sensor simulation), controller.py (managing the simulation’s robot lifecycle), motion_planning.py (integrating the mplib’s planning logic), and visualization.py (for real-time rendering or UI aspects).
- External Libraries & Dependencies: These include the sapien library for simulation and mplib for motion planning as specified in the README.

##### Relationships and Data Flow
- The entry point in main.py will load configurations from the “config” files and initialize the simulation environment.
- The asset repository data (e.g., URDF files, textured models, and point samples) are used to construct the robot models and environmental objects within the simulation.
- The Controller (from robot/controller.py) integrates and manages different robot instances based on selected configurations (extracted from config/robot_varant.py, etc.). It serves as a mediator between higher-level commands and lower-level control logic.
- Motion planning logic (in robot/motion_planning.py) uses mplib to perform trajectory planning, translating user inputs (through two “demonstration” modes, move_to_pose and move_to_joints) into robot actuation commands.

##### Architectural Patterns & Design Principles
- Modular Design: The clear separation of asset management, configuration, simulation control, motion planning, and visualization reflects a modular design, making it easier to update or extend individual components.
- Separation of Concerns: By isolating configuration files from control logic and assets from simulation code, the project enhances maintainability.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Components
    Sim("Simulation Engine (main.py)"):::simulation
    Assets("Asset Repository"):::assets
    ConfigModule("Configuration Module (config)"):::config

    %% Configuration Files Subgraph
    subgraph "Configuration Files"
        CamConfig("Camera Config (config/camera_varant.py)"):::config
        ObjConfig("Object Config (config/object_varant.py)"):::config
        RbtConfig("Robot Config (config/robot_varant.py)"):::config
    end

    %% Robot Modules Subgraph
    subgraph "Robot Modules"
        RCam("Robot Camera (robot/camera.py)"):::controller
        RCtrl("Robot Controller (robot/controller.py)"):::controller
        RMP("Motion Planning (robot/motion_planning.py)"):::controller
        RViz("Robot Visualization (robot/visualization.py)"):::controller
    end

    SVis("Standalone Visualization (visualize.py)"):::controller

    %% External Dependencies Subgraph
    subgraph "External Dependencies"
        Sapien("sapien (Simulation Library)"):::external
        Mplib("mplib (Motion Planning Library)"):::external
    end

    %% Relationships and Data Flow
    Sim -->|"loads_assets"| Assets
    Sim -->|"loads_config"| ConfigModule
    ConfigModule -->|"provides"| CamConfig
    ConfigModule -->|"provides"| ObjConfig
    ConfigModule -->|"provides"| RbtConfig
    Sim -->|"initiates_sensor"| RCam
    Sim -->|"launches_control"| RCtrl
    RCtrl -->|"issues_planning"| RMP
    RCtrl -->|"updates_view"| RViz
    RCtrl -->|"sends_feedback"| SVis
    RMP -->|"uses"| Mplib
    Sim -->|"drives_simulation"| Sapien
    RViz -->|"feedback"| RCtrl
    SVis -->|"feedback"| RCtrl

    %% Styles
    classDef simulation fill:#FFE082,stroke:#333,stroke-width:2px;
    classDef config fill:#81D4FA,stroke:#333,stroke-width:2px;
    classDef assets fill:#A5D6A7,stroke:#333,stroke-width:2px;
    classDef controller fill:#CE93D8,stroke:#333,stroke-width:2px;
    classDef external fill:#EF9A9A,stroke:#333,stroke-width:2px;

    %% Click Events
    click Sim "https://github.com/khlann/miaa_sim/blob/miaa_sim/main.py"
    click Assets "https://github.com/khlann/miaa_sim/tree/miaa_sim/asset"
    click ConfigModule "https://github.com/khlann/miaa_sim/tree/miaa_sim/config"
    click CamConfig "https://github.com/khlann/miaa_sim/blob/miaa_sim/config/camera_varant.py"
    click ObjConfig "https://github.com/khlann/miaa_sim/blob/miaa_sim/config/object_varant.py"
    click RbtConfig "https://github.com/khlann/miaa_sim/blob/miaa_sim/config/robot_varant.py"
    click RCam "https://github.com/khlann/miaa_sim/blob/miaa_sim/robot/camera.py"
    click RCtrl "https://github.com/khlann/miaa_sim/blob/miaa_sim/robot/controller.py"
    click RMP "https://github.com/khlann/miaa_sim/blob/miaa_sim/robot/motion_planning.py"
    click RViz "https://github.com/khlann/miaa_sim/blob/miaa_sim/robot/visualization.py"
    click SVis "https://github.com/khlann/miaa_sim/blob/miaa_sim/visualize.py"
```
