# williamcheong0616/drl-drone-navigation-ir-sim architecture

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

- Interactive diagram: https://gitdiagram.com/williamcheong0616/drl-drone-navigation-ir-sim
- Repository: https://github.com/williamcheong0616/drl-drone-navigation-ir-sim

## Overview

##### Main Components Identification
- Simulator & Environment:
- IR-SIM is the simulation engine for the navigation environment.
- Configuration files (e.g., robot_world.yaml, eval_world.yaml) and assets directory indicate environment definitions and sensor data setups.
- RL Agent & Models:
- The robot_nav/models directory contains multiple RL algorithm implementations (e.g., TD3, PPO, SAC, DDPG, CNNTD3, RCPG, HCM). Each subdirectory represents a distinct agent model.
- Checkpoint files inside each model subdirectory show that models are being saved and restored.
- Training & Evaluation:
- The train.py and train_rnn.py scripts are the training interfaces.
- Test scripts (like test.py, test_rnn.py) and logs under the runs/ directory indicate evaluation and debugging.
- The replay_buffer.py manages experience replay which is common in DRL.
- Utilities & Configuration:
- Utility functions (utils.py) and YAML configuration files (e.g., eval_points.yaml, eval_world.yaml, test data/config files) provide support for data preprocessing and simulation parameter settings.
- The pyproject.toml and use of Poetry manage package dependencies and versioning.

##### Relationship and Interaction between Components
- Data Flow:
- Sensor data (from 2D laser sensors) is fed into the Environment Simulator (IR-SIM), which in turn generates state data used by the RL agent.
- The RL agent uses one of the algorithms (picked from the models available) to decide on navigation action.
- The training scripts orchestrate the interaction between the simulation (environment) and the RL agent through a loop (state → action → reward → state).
- Model Management:
- Different algorithm branches are available; the system likely selects an algorithm based on training needs. Each branch saves checkpoints (model weights) used for testing and further training.
- Logging & Evaluation:

##### Architectural Patterns & Design Principles
- Modular Architecture:
- The separation of models (RL algorithms), simulation (IR-SIM calls and configuration), and training utilities shows a modular approach promoting extensibility.
- Separation of Concerns:
- Environment definitions, sensor data configuration, training execution, and model processing are all isolated—allowing independent updates.
- Plug-and-play Model Integration:
- The design of separate directories for each RL algorithm allows for easy switching or integration of new models.

##### Relevant Technologies, Frameworks, and Libraries
- Python is the main programming language.
- Poetry is used for package dependency management.
- Deep learning frameworks (likely PyTorch, considering .pth checkpoint files).
- TensorBoard for monitoring training progress.
- YAML for configuration management.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Simulator & Environment
    subgraph "Simulator & Environment"
        SIM["IR-SIM Engine"]:::sim
        CONFIG1["robot_world.yaml"]:::sim
        CONFIG2["eval_world.yaml"]:::sim
        CONFIG3["eval_points.yaml"]:::sim
        ASSETS["Assets Directory"]:::sim
        SIM --> CONFIG1
        SIM --> CONFIG2
        SIM --> CONFIG3
        SIM --> ASSETS
    end

    %% RL Agent & Models
    subgraph "RL Agent & Models"
        POLICY["Policy Learners"]:::rl
        TD3["TD3"]:::rl
        PPO["PPO"]:::rl
        SAC["SAC"]:::rl
        DDPG["DDPG"]:::rl
        CNNTD3["CNNTD3"]:::rl
        RCPG["RCPG"]:::rl
        HCM["HCM"]:::rl
        POLICY --> TD3
        POLICY --> PPO
        POLICY --> SAC
        POLICY --> DDPG
        POLICY --> CNNTD3
        POLICY --> RCPG
        POLICY --> HCM
    end

    %% Training & Evaluation
    subgraph "Training & Evaluation"
        TRAIN["Training Scripts"]:::train
        TEST["Testing Scripts"]:::train
        REPLAY["Replay Buffer"]:::train
        LOGS["TensorBoard Logs (runs/)"]:::train
        TRAIN --> REPLAY
        REPLAY --> TEST
        TRAIN --> LOGS
    end

    %% Utilities & Configuration
    subgraph "Utilities & Configurations"
        UTILS["Utility Functions"]:::util
        DEP["Dependency Management"]:::util
        TESTCONF["Test Config Files"]:::util
        UTILS --- DEP
        DEP --- TESTCONF
    end

    %% Interactions
    SIM -->|"sensorData"| POLICY
    POLICY -->|"navigationAction"| SIM
    TRAIN -->|"orchestrates"| POLICY
    UTILS -->|"utilitySupport"| TRAIN

    %% Click Events
    click SIM "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/blob/master/robot_nav/sim.py"
    click CONFIG1 "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/blob/master/robot_nav/robot_world.yaml"
    click CONFIG2 "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/blob/master/robot_nav/eval_world.yaml"
    click CONFIG3 "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/blob/master/robot_nav/eval_points.yaml"
    click ASSETS "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/tree/master/robot_nav/assets"
    click TD3 "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/tree/master/robot_nav/models/TD3"
    click PPO "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/tree/master/robot_nav/models/PPO"
    click SAC "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/tree/master/robot_nav/models/SAC"
    click DDPG "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/tree/master/robot_nav/models/DDPG"
    click CNNTD3 "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/tree/master/robot_nav/models/CNNTD3"
    click RCPG "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/tree/master/robot_nav/models/RCPG"
    click HCM "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/tree/master/robot_nav/models/HCM"
    click TRAIN "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/blob/master/robot_nav/train.py"
    click TRAIN "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/blob/master/robot_nav/train_rnn.py"
    click TEST "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/blob/master/robot_nav/test.py"
    click TEST "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/blob/master/robot_nav/test_rnn.py"
    click REPLAY "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/blob/master/robot_nav/replay_buffer.py"
    click LOGS "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/tree/master/runs/"
    click UTILS "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/blob/master/robot_nav/utils.py"
    click DEP "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/blob/master/pyproject.toml"
    click TESTCONF "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/blob/master/tests/test_world.yaml"
    click TESTCONF "https://github.com/williamcheong0616/drl-drone-navigation-ir-sim/blob/master/tests/test_data.yml"

    %% Styles
    classDef sim fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef rl fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef train fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef util fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
