# tomasvr/turtlebot3_drlnav architecture

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

- Interactive diagram: https://gitdiagram.com/tomasvr/turtlebot3_drlnav
- Repository: https://github.com/tomasvr/turtlebot3_drlnav

## Overview

##### Main Components Identification

The system consists of four major components that should be represented as distinct blocks:

a) Simulation Environment:
- Gazebo Simulator (turtlebot3_gazebo)
- Robot Model (TurtleBot3)
- World Models (stages 1-10)
- Obstacle Plugins

b) DRL Framework:
- Training Agents (DQN, DDPG, TD3)
- Neural Network Models
- Replay Buffer
- Training/Testing Logic

c) ROS2 Infrastructure:
- Environment Node
- Agent Node
- Goal Management Node
- Message Communication

d) Physical Robot Integration:
- Real Robot Interface
- Sensor Processing
- Command Execution

##### Component Relationships

a) Simulation → ROS2:
- LiDAR Scans
- Odometry Data
- Robot State

b) ROS2 → Simulation:
- Velocity Commands
- Goal Positions
- Reset Commands

c) DRL Framework ↔ ROS2:
- State Observations
- Action Commands
- Reward Signals

##### Detailed Elements

Specific components with appropriate symbols:

a) Nodes (rectangles):
- /gazebo
- /environment
- /train_agent or /test_agent
- /gazebo_goals

b) Topics (ovals):
- /scan
- /odom
- /cmd_vel
- /goal

c) Services (hexagons):
- /drl_step
- /goal
- /ring_goal

##### Data Flow Specifications

Message types on connections:
- LaserScan
- Odometry
- Twist
- Custom DRL messages

##### Implementation Details

Small annotations for:
- Neural Network Architecture
- Reward Function
- State Space
- Action Space

##### Additional Elements

- Configuration parameters
- Model storage
- Visualization tools
- Utility scripts

##### DRL Intelligence Layer (top)

This will create a comprehensive visualization that captures both the high-level architecture and the important implementation details of the system.

Remember to maintain clarity by using appropriate spacing and grouping related components together, while still showing all critical interactions between the different parts of the system.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style Definitions
    classDef simulation fill:#a8d1f0,stroke:#333
    classDef drl fill:#f8a8a8,stroke:#333
    classDef ros fill:#a8f0b8,stroke:#333
    classDef physical fill:#f0e5a8,stroke:#333
    
    subgraph DRL_Layer
        DRLAgents["DRL Agents\n(DQN, DDPG, TD3)"]
        NNModels["Neural Network Models"]
        ReplayBuffer["Replay Buffer"]
        TrainingLogic["Training/Testing Logic"]
    end

    subgraph ROS2_Layer
        EnvNode["Environment Node"]
        AgentNode["Agent Node"]
        GoalNode["Goal Management Node"]
        CustomMsgs["Custom Messages/Services"]
    end

    subgraph Simulation_Layer
        GazeboSim["Gazebo Simulator"]
        WorldModels["World Models\n(Stages 1-10)"]
        RobotModel["TurtleBot3 Model"]
        ObstaclePlugins["Obstacle Plugins"]
    end

    subgraph Physical_Layer
        RobotInterface["Real Robot Interface"]
        SensorProc["Sensor Processing"]
        CmdExec["Command Execution"]
        RobotConfig["Robot Configuration"]
    end

    %% Connections
    GazeboSim --> EnvNode
    WorldModels --> GazeboSim
    RobotModel --> GazeboSim
    ObstaclePlugins --> GazeboSim
    
    EnvNode <--> AgentNode
    AgentNode <--> GoalNode
    CustomMsgs --> EnvNode
    CustomMsgs --> AgentNode
    
    DRLAgents --> AgentNode
    NNModels --> DRLAgents
    ReplayBuffer --> DRLAgents
    TrainingLogic --> DRLAgents
    
    RobotInterface --> EnvNode
    SensorProc --> RobotInterface
    CmdExec --> RobotInterface
    RobotConfig --> RobotInterface

    %% Click Events
    click GazeboSim "https://github.com/tomasvr/turtlebot3_drlnav/tree/main/src/turtlebot3_simulations/turtlebot3_gazebo/"
    click WorldModels "https://github.com/tomasvr/turtlebot3_drlnav/tree/main/src/turtlebot3_simulations/turtlebot3_gazebo/worlds/"
    click RobotModel "https://github.com/tomasvr/turtlebot3_drlnav/tree/main/src/turtlebot3_simulations/turtlebot3_gazebo/models/"
    click ObstaclePlugins "https://github.com/tomasvr/turtlebot3_drlnav/tree/main/src/turtlebot3_simulations/turtlebot3_gazebo/models/turtlebot3_drl_world/obstacle_plugin/"
    click DRLAgents "https://github.com/tomasvr/turtlebot3_drlnav/tree/main/src/turtlebot3_drl/turtlebot3_drl/drl_agent/"
    click NNModels "https://github.com/tomasvr/turtlebot3_drlnav/tree/main/src/turtlebot3_drl/model/"
    click ReplayBuffer "https://github.com/tomasvr/turtlebot3_drlnav/blob/main/src/turtlebot3_drl/turtlebot3_drl/common/replaybuffer.py"
    click TrainingLogic "https://github.com/tomasvr/turtlebot3_drlnav/blob/main/src/turtlebot3_drl/turtlebot3_drl/drl_environment/drl_environment.py"
    click EnvNode "https://github.com/tomasvr/turtlebot3_drlnav/tree/main/src/turtlebot3_drl/turtlebot3_drl/drl_environment/"
    click CustomMsgs "https://github.com/tomasvr/turtlebot3_drlnav/tree/main/src/turtlebot3_msgs/"
    click RobotInterface "https://github.com/tomasvr/turtlebot3_drlnav/blob/main/src/turtlebot3_drl/turtlebot3_drl/drl_environment/drl_environment_real.py"
    click RobotConfig "https://github.com/tomasvr/turtlebot3_drlnav/tree/main/src/turtlebot3_simulations/turtlebot3_fake_node/param/"

    %% Class Assignments
    class GazeboSim,WorldModels,RobotModel,ObstaclePlugins simulation
    class DRLAgents,NNModels,ReplayBuffer,TrainingLogic drl
    class EnvNode,AgentNode,GoalNode,CustomMsgs ros
    class RobotInterface,SensorProc,CmdExec,RobotConfig physical
```
