# michaelbosello/f1tenth-rl architecture

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

- Interactive diagram: https://gitdiagram.com/michaelbosello/f1tenth-rl
- Repository: https://github.com/michaelbosello/f1tenth-rl

## Overview

##### Main Components

a) Core System Components:
- DQN Agent Module
- Car Environment Interface
- ROS Integration Layer
- Sensor Processing System
- Control System
- Monitor/GUI System

b) Data Flow Components:
- State Management
- Replay Buffer
- Logger System
- Training Pipeline

##### Component Relationships

- Bidirectional data flow between Car Environment (car_env.py) and DQN Agent
- Sensor data flow from LIDAR to State Processor
- Control signals from DQN Agent to Car Control System
- Safety override signals from Safety Control to Car Control
- Training data flow between DQN Agent and Replay Buffer
- Monitoring data flow to GUI components

##### Technical Details

Annotations for:
- ROS topic interfaces
- Neural network architecture (1D CNN, 2D CNN options)
- State representation formats
- Action space definition
- Safety threshold parameters

##### Specific Implementation Notes

- Tensorflow 2.x integration
- ROS Melodic dependencies
- Hardware compatibility (F1tenth car vs simulator)
- LIDAR data preprocessing options

- The modular nature of the system
- Clear separation between real hardware and simulator interfaces
- Safety-critical paths and override mechanisms
- Training pipeline flow
- Data processing pipeline for LIDAR inputs

This system design should reflect both the training and inference modes of operation, as well as the ability to switch between real hardware and simulator environments.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Interface_Layer
        GUI["Monitor GUI System"]:::monitoring
        GP["Gamepad Interface"]:::interface
        ROS["ROS Communication Layer"]:::interface
    end

    subgraph Core_Processing
        DQN["DQN Agent"]:::core
        SP["State Processor"]:::core
        RB["Replay Buffer"]:::core
        LOG["Logger"]:::monitoring
    end

    subgraph Hardware_Interface
        CC["Car Control System"]:::hardware
        SC["Safety Control"]:::safety
        SI["Sensor Interface"]:::hardware
    end

    subgraph Environment
        CE["Car Environment"]:::env
        LIDAR["LIDAR Processing"]:::hardware
    end

    %% Connections
    DQN <--> CE
    CE --> SP
    LIDAR --> SP
    DQN --> CC
    SC --> CC
    DQN <--> RB
    SP --> GUI
    CC --> GUI
    GP --> CC
    SI --> SP
    LOG --> GUI
    ROS --> CE
    
    %% Click Events
    click DQN "https://github.com/MichaelBosello/f1tenth-RL/blob/master/f1tenth-rl/dqn.py"
    click CE "https://github.com/MichaelBosello/f1tenth-RL/blob/master/f1tenth-rl/car_env.py"
    click SI "https://github.com/MichaelBosello/f1tenth-RL/blob/master/f1tenth-rl/car/sensors.py"
    click CC "https://github.com/MichaelBosello/f1tenth-RL/blob/master/f1tenth-rl/car/car_control.py"
    click GUI "https://github.com/MichaelBosello/f1tenth-RL/blob/master/f1tenth-rl/monitor/monitor_gui.py"
    click SC "https://github.com/MichaelBosello/f1tenth-RL/blob/master/f1tenth-rl/car/safety_control.py"
    click SP "https://github.com/MichaelBosello/f1tenth-RL/blob/master/f1tenth-rl/state.py"
    click RB "https://github.com/MichaelBosello/f1tenth-RL/blob/master/f1tenth-rl/replay.py"
    click LOG "https://github.com/MichaelBosello/f1tenth-RL/blob/master/f1tenth-rl/logger.py"
    click GP "https://github.com/MichaelBosello/f1tenth-RL/blob/master/f1tenth-rl/car/gamepad.py"

    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef hardware fill:#2ecc71,stroke:#27ae60,color:white
    classDef safety fill:#f1c40f,stroke:#f39c12,color:black
    classDef monitoring fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef interface fill:#e74c3c,stroke:#c0392b,color:white
    classDef env fill:#9b59b6,stroke:#8e44ad,color:white

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Hardware Interface"]:::hardware
        L3["Safety Critical"]:::safety
        L4["Monitoring"]:::monitoring
        L5["Interface"]:::interface
        L6["Environment"]:::env
    end
```
