# zmsbruce/rm_radar architecture

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

- Interactive diagram: https://gitdiagram.com/zmsbruce/rm_radar
- Repository: https://github.com/zmsbruce/rm_radar

## Overview

##### Project Type and Purpose
- This is a high-performance robotics perception pipeline written in C++20, built with CMake, running on Linux.
- It provides three core capabilities:
- Localization (point cloud + image ROI → field coordinates via PCL)
- Tracking (temporal filtering & data association via Kalman/Singer/Auction)

##### File Structure
- Top-level directories:
- src/ – implementation modules (detect, locate, track, robot orchestrator)
- models/ – ONNX model files for detection
- assets/ – sample point clouds & images
- samples/ – demo application using the library
- test/ – unit and integration tests per module
- cmake/ & CMakeLists.txt – build configuration
- doc/ – design & optimization docs
- Each src/<module>/CMakeLists.txt builds a self-contained library linked by src/robot/main

##### Extract Key Architecture from README
- Detection uses CUDA preprocessing + TensorRT inference
- Localization fuses LiDAR point clouds with camera detections and known extrinsics
- Tracking applies multiple filters (Kalman, Singer) and the auction algorithm for data association
- No UI, no I/O drivers—pure perception pipeline

##### Main Components
A. Input Sources
- Camera (image frames)
- LiDAR (point clouds)
B. Preprocessing
- CUDA kernels (in src/detect/detector.cu)
- TensorRT engine loader (src/detect/tensor.* & trt_logger.h)
C. Detection Module (src/detect)
- ONNX → TensorRT
D. Localization Module (src/locate)
- Coordinate transforms (camera ↔ LiDAR ↔ field)
- Outputs 2D/3D positions in field frame
E. Tracking Module (src/track)
- Feature extraction (features.h)
- Kalman & Singer filters + Auction association
- Outputs smooth target trajectories
F. Orchestrator / Robot Interface (src/robot)
- High-level pipeline that sequences detect→locate→track
- Exposes API for sample app
G. Sample Application (samples/main.cpp)
- Demonstrates end-to-end usage
H. Tests (test/)
- Unit tests per module
I. External Dependencies
- CUDA, TensorRT, OpenCV, PCL, Eigen, TBB, GTest

##### Relationships & Data Flow
- LiDAR → Localization (merge stream)
- The “robot” module orchestrates data movement between modules
- The sample app links the robot library and feeds it input assets

##### Important Architectural Patterns
- Modular libraries per concern (detect/locate/track)
- Pipeline/chain of responsibility for data processing
- GPU‐accelerated compute (CUDA + TensorRT) vs CPU compute (PCL, filters)
- CMake multi‐target build
- Unit testing per module

##### Essential Elements
- Clear component labels matching source folders
- Blue for GPU modules
- Green for CPU modules
- Grey for orchestration & samples

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Sources
    subgraph "Data Sources"
        Camera["Camera\n(Image Frames)"]:::input
        LiDAR["LiDAR\n(Point Clouds)"]:::input
        Assets["Sample Assets\nassets/"]:::artifact
    end

    %% GPU Processing
    subgraph "GPU Processing"
        Detect["Detect\n(CUDA + TensorRT)\nsrc/detect"]:::gpu
        Models["ONNX Models\nmodels/*.onnx"]:::artifact
    end

    %% CPU Processing
    subgraph "CPU Processing"
        Locate["Locate\n(PCL)\nsrc/locate"]:::cpu
        Track["Track\n(Kalman/Singer + Auction)\nsrc/track"]:::cpu
    end

    %% Orchestration & API
    subgraph "Orchestration & API"
        Robot["Orchestrator\n(src/robot)"]:::orch
    end

    %% Applications & Tests
    subgraph "Applications & Tests"
        SampleApp["Sample App\n(samples/main.cpp)"]:::orch
        Tests["Test Harness\n(test/)"]:::test
    end

    %% Build & Documentation
    subgraph "Build & Docs"
        CMake["Build Config\nCMakeLists.txt & cmake/"]:::build
        Docs["Documentation\ndoc/"]:::doc
    end

    %% Data Flow
    Camera -->|"image frames"| Detect
    Assets -->|uses samples| Camera
    Models -->|"model files"| Detect
    Detect -->|"bounding boxes"| Locate
    LiDAR -->|"point clouds"| Locate
    Locate -->|"2D/3D positions"| Track
    Track -->|"trajectories"| Robot
    Robot -->|"API"| SampleApp
    Robot -->|"invokes"| Tests
    CMake -.-> Detect
    CMake -.-> Locate
    CMake -.-> Track
    CMake -.-> Robot
    CMake -.-> SampleApp
    CMake -.-> Tests
    Docs -.-> Detect
    Docs -.-> Locate
    Docs -.-> Track

    %% Click Events
    click Detect "https://github.com/zmsbruce/rm_radar/tree/main/src/detect"
    click Models "https://github.com/zmsbruce/rm_radar/tree/main/models"
    click Locate "https://github.com/zmsbruce/rm_radar/tree/main/src/locate"
    click Track "https://github.com/zmsbruce/rm_radar/tree/main/src/track"
    click Robot "https://github.com/zmsbruce/rm_radar/tree/main/src/robot"
    click SampleApp "https://github.com/zmsbruce/rm_radar/blob/main/samples/main.cpp"
    click Tests "https://github.com/zmsbruce/rm_radar/tree/main/test"
    click Assets "https://github.com/zmsbruce/rm_radar/tree/main/assets"
    click CMake "https://github.com/zmsbruce/rm_radar/blob/main/CMakeLists.txt"
    click Docs "https://github.com/zmsbruce/rm_radar/tree/main/doc"

    %% Styles
    classDef input fill:#E0F7FA,stroke:#006064,color:#004D40;
    classDef gpu fill:#BBDEFB,stroke:#0D47A1,color:#0D47A1;
    classDef cpu fill:#C8E6C9,stroke:#1B5E20,color:#1B5E20;
    classDef orch fill:#ECEFF1,stroke:#37474F,color:#37474F;
    classDef test fill:#FFCDD2,stroke:#B71C1C,color:#B71C1C;
    classDef build fill:#FFF9C4,stroke:#F57F17,color:#F57F17;
    classDef doc fill:#E0F2F1,stroke:#004D40,color:#004D40;
    classDef artifact fill:#F3E5F5,stroke:#6A1B9A,color:#4A148C;
```
