# teketesfaye/speed-control-based-on-detection-result architecture

> Architecture diagram of the GitHub repository teketesfaye/speed-control-based-on-detection-result, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/teketesfaye/speed-control-based-on-detection-result
- Repository: https://github.com/teketesfaye/speed-control-based-on-detection-result

## Overview

##### Project Type and Purpose
- This is a ROS2‐based C++ package (“speed_controller_cpp”) that implements an autonomous safety system.
- It subscribes to object detections from one or two YOLOX vision nodes, merges/fuses detections, analyzes whether any object lies in the planned trajectory, then publishes speed commands (including emergency stop) to the vehicle’s controller via Autoware.

##### File Structure
Top‐level:
– scripts/            (setup script)
– speed_controller_cpp/  (ROS2 package)
Inside speed_controller_cpp:
– CMakeLists.txt, package.xml          (ROS2 build & metadata)
– include/speed_controller_cpp/        (public headers: speed_controller, core logic)
– src/                                 (node entrypoint + core implementation)
– config/stop_line.param.yaml          (tunable behavior parameters)
– launch/speed_controller.launch.py    (launch file defining ROS nodes & parameters)

##### README for Additional Insights
- Dual‐camera safety system using YOLOX for object detection
- Real‐time detection fusion via IoU overlap logic
- Publishes ROS2 topics: detection inputs, fused detection outputs, speed_command outputs
- Integrates with Autoware trajectory planning
- Architecture line: Camera(s) → YOLOX Detection → Object Analysis → Speed Control → Autoware Trajectory

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Sensors
    subgraph "Sensors"
        direction TB
        FLCam["FL Camera"]:::sensor
        FRCam["FR Camera"]:::sensor
    end

    %% Detection Nodes
    subgraph "YOLOX Detection Nodes"
        direction TB
        YOLOX0["speed_controller_cpp:yolox_node0"]:::detection
        YOLOX1["speed_controller_cpp:yolox_node1"]:::detection
    end

    %% Speed Controller
    subgraph "Speed Controller Node"
        direction TB
        SpeedControllerNode["speed_controller_cpp:speed_controller_node"]:::control
        CoreLogic["Fusion & Decision Logic"]:::control
        Interface["Controller Interface"]:::control
    end

    %% Autoware & Actuation
    subgraph "Planning & Actuation"
        direction TB
        Planner["Autoware.universe:Trajectory Planner"]:::planning
        VehicleInterface["Vehicle Hardware Interface"]:::planning
        ManualOverride["Manual Override"]:::planning
    end

    %% Support Components
    subgraph "Support Components"
        direction TB
        ConfigStore["stop_line.param.yaml"]:::config
        LaunchFile["speed_controller.launch.py"]:::config
        BuildConfig["CMakeLists.txt"]:::config
        PackageXML["package.xml"]:::config
        SetupScript["setup.sh"]:::config
        OverviewImage["System Overview Diagram"]:::config
    end

    %% Connections
    FLCam -->|"/camera0/image_raw\nsensor_msgs/Image"| YOLOX0
    FRCam -->|"/camera1/image_raw\nsensor_msgs/Image"| YOLOX1

    YOLOX0 -->|"/rois0\nFloat32MultiArray"| SpeedControllerNode
    YOLOX1 -->|"/rois1\nFloat32MultiArray"| SpeedControllerNode

    Planner -.->|"/planned_trajectory\nTrajectory"| SpeedControllerNode
    ManualOverride -.->|"/speed_command\nFloat64"| SpeedControllerNode

    SpeedControllerNode -->|"publishes /speed_command\nFloat64"| Planner
    SpeedControllerNode -->|"publishes /speed_command\nFloat64"| VehicleInterface

    ConfigStore -.-> SpeedControllerNode
    LaunchFile -.-> YOLOX0
    LaunchFile -.-> YOLOX1
    LaunchFile -.-> SpeedControllerNode
    BuildConfig -.-> LaunchFile
    PackageXML -.-> LaunchFile
    SetupScript -.-> BuildConfig

    %% Internal component connections
    SpeedControllerNode --> CoreLogic
    SpeedControllerNode --> Interface

    %% Click Events
    click SpeedControllerNode "https://github.com/teketesfaye/speed-control-based-on-detection-result/blob/main/speed_controller_cpp/src/speed_controller_node.cpp"
    click CoreLogic "https://github.com/teketesfaye/speed-control-based-on-detection-result/blob/main/speed_controller_cpp/src/speed_controller_core.cpp"
    click CoreLogic "https://github.com/teketesfaye/speed-control-based-on-detection-result/blob/main/speed_controller_cpp/include/speed_controller_cpp/speed_controller_core.hpp"
    click Interface "https://github.com/teketesfaye/speed-control-based-on-detection-result/blob/main/speed_controller_cpp/src/speed_controller.cpp"
    click Interface "https://github.com/teketesfaye/speed-control-based-on-detection-result/blob/main/speed_controller_cpp/include/speed_controller_cpp/speed_controller.hpp"
    click ConfigStore "https://github.com/teketesfaye/speed-control-based-on-detection-result/blob/main/speed_controller_cpp/config/stop_line.param.yaml"
    click LaunchFile "https://github.com/teketesfaye/speed-control-based-on-detection-result/blob/main/speed_controller_cpp/launch/speed_controller.launch.py"
    click BuildConfig "https://github.com/teketesfaye/speed-control-based-on-detection-result/blob/main/speed_controller_cpp/CMakeLists.txt"
    click PackageXML "https://github.com/teketesfaye/speed-control-based-on-detection-result/blob/main/speed_controller_cpp/package.xml"
    click SetupScript "https://github.com/teketesfaye/speed-control-based-on-detection-result/blob/main/scripts/setup.sh"
    click OverviewImage "https://github.com/teketesfaye/speed-control-based-on-detection-result/tree/main/images/"

    %% Styles
    classDef sensor fill:#e0f7da,stroke:#2e7d32,color:#2e7d32
    classDef detection fill:#e3f2fd,stroke:#1976d2,color:#1976d2
    classDef control fill:#fff3e0,stroke:#ef6c00,color:#e65100
    classDef planning fill:#f3e5f5,stroke:#8e24aa,color:#6a1b9a
    classDef config fill:#eeeeee,stroke:#757575,color:#424242
```
