# radar-lab/mmpose-nlp architecture

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

- Interactive diagram: https://gitdiagram.com/radar-lab/mmpose-nlp
- Repository: https://github.com/radar-lab/mmpose-nlp

## Overview

##### Project Type and Purpose
- This is a research‐grade, multi‐component toolchain—an “open‐source tool” rather than a monolithic application—designed for mmWave radar–aided skeletal pose estimation using a Seq2Seq (GRU) architecture.
- Key functions: real‐time data capture from TI AWR1843 radars via ROS, offline model training/inference in Python, and posthoc visualization/analysis in MATLAB.

##### Top‐Level Components
a. Hardware & Data Acquisition
- TI AWR1843 mmWave radar units (see “TI AWR1843 Datasheets”).
- Serial link (RS-232/USB) driving radar control & data packets.
- ROS package (“multiradar_mmpose_ROS”) with C++ nodelets for:
– Parameter parsing & radar configuration
– mmWaveCommSrv & mmWaveDataHdl for streaming raw frames
– Publishing `RadarScan.msg` on ROS topics
b. Data Storage & Preprocessing
- DataHandlerClass (C++) writes raw+preprocessed frames to disk.
- On‐disk artifacts under “Dataset and Predictions”: .mat logs, .npy ground truth/predictions, CSV features.
c. Python ML Pipeline
- master_train_mmpose_nlp_gru.py: orchestrates training Seq2Seq model (mmpose + NLP features + GRU) on stored CSV/.mat data.
- master_infer_mmpose_nlp_gru.py: uses trained weights to generate pose predictions (.npy).
d. MATLAB Analysis & Visualization
- Scripts in “MATLAB Files” generate tables, plots, and side‐by‐side ground‐truth vs. prediction videos (Figures 3–7).
e. Outputs
- Under “Dataset and Predictions”:
– Continuous Data Videos (.avi) comparing GT vs. predictions
– Metrics (MAE, inference time)
– CSV/.npy result files

##### Component Interactions and Data Flow
1. Radar hardware → serial driver → ROS nodelets
2. ROS nodelets → publish `RadarScan` → DataHandlerClass
3. DataHandlerClass → write raw and pre‐processed data (.mat, .npy, CSV)
4. Python training script → read CSV/.mat → train Seq2Seq model → save model weights
5. Python inference script → load model & CSV inputs → output predicted joint positions (.npy)
6. MATLAB scripts → ingest GT & prediction arrays → compute metrics, generate figures & videos

##### Architectural Patterns & Principles
- Pipeline Pattern: clear, uni‐directional data flow from capture → storage → ML → visualization
- Modularity: separate C++/ROS layer, Python ML layer, MATLAB layer
- Separation of Concerns:
- Real‐time capture (ROS/C++)
- Batch ML processing (Python)
- Posthoc analysis (MATLAB)

1. “MMW Radar Sensors” (hardware)
2. “ROS Nodelets & Serial Drivers” (C++ layer)
3. “Data Storage & Preprocessing” (DataHandlerClass → files)
4. “Python ML Pipeline” (train & inference scripts)
5. “MATLAB Analysis & Visualization”
- Hardware → ROS (serial/RS-232)
- ROS → Storage (ROS topic: RadarScan.msg → .mat/.csv)
- Storage → Python (CSV/.mat → model)
- Python → Storage (model weights → .npy predictions)
- Storage → MATLAB (npy/.csv → figures & videos)
c. Component with key technologies:
- ROS (C++), serial lib, CMakeLists, msg/srv
- Python (PyTorch or mmpose, Seq2Seq, GRU)
- MATLAB
- File formats (.mat, .npy, .csv, .avi)
d. Feedback loops (e.g., model evaluation metrics back into training if iterative)

- Blue for capture layer (C++/ROS)
- Green for storage
- Orange for Python ML
- Purple for MATLAB
- Rectangles for compute modules
- Trapezoids for hardware

## Diagram (Mermaid)

```mermaid
flowchart TD
    Hardware{{"MMW Radar Sensors"}}:::hardware

    subgraph "ROS Nodelets & Serial Drivers"
        direction TB
        Serial["Serial Driver Library"]:::backend
        Param["Parameter Parser"]:::backend
        CommSrv["mmWaveCommSrv"]:::backend
        DataHdlSrv["mmWaveDataHdl"]:::backend
        Msg["RadarScan.msg"]:::backend
    end

    subgraph "Data Storage & Preprocessing"
        direction TB
        DataHandler["DataHandlerClass"]:::storage
        Artifacts["Dataset & Predictions"]:::storage
        Raw["Raw/.mat/.csv files"]:::cylinder
        Predictions[".npy Predictions"]:::cylinder
        Videos[".avi Continuous Data Videos"]:::cylinder
        Metrics["Metrics (.csv)"]:::cylinder
    end

    subgraph "Python ML Pipeline"
        direction TB
        Train["master_train_mmpose_nlp_gru.py"]:::ml
        Infer["master_infer_mmpose_nlp_gru.py"]:::ml
    end

    subgraph "MATLAB Analysis & Visualization"
        direction TB
        Fig34["Fig_3_and_4.m"]:::matlab
        Fig6["Fig_6.m"]:::matlab
        TabAndFigs["Table_1_and_Figs_5and7.m"]:::matlab
        Analyze["analyze_pred.m"]:::matlab
    end

    Hardware -->|serial/RS-232| Serial
    Serial -->|"config & data packets"| Param
    Param --> CommSrv
    CommSrv --> DataHdlSrv
    DataHdlSrv --> Msg
    Msg -->|"ROS topic: RadarScan.msg"| DataHandler
    DataHandler --> Artifacts
    Artifacts --> Raw
    Raw --> Train
    Train -->|"model weights"| Artifacts
    Artifacts --> Predictions
    Predictions --> Infer
    Predictions --> Fig34
    Predictions --> Fig6
    Predictions --> TabAndFigs
    Artifacts --> Videos
    Metrics --> TabAndFigs
    Artifacts --> Metrics
    Videos --> TabAndFigs
    Analyze --> TabAndFigs

    click Hardware "https://github.com/radar-lab/mmpose-nlp/tree/main/TI AWR1843 Datasheets/"
    click Serial "https://github.com/radar-lab/mmpose-nlp/tree/main/Source Codes/ROS_Packages/multiradar_mmpose_ROS/src/serial/"
    click Param "https://github.com/radar-lab/mmpose-nlp/blob/main/Source Codes/ROS_Packages/multiradar_mmpose_ROS/src/multiradar_mmpose/include/parameter_parser.h"
    click CommSrv "https://github.com/radar-lab/mmpose-nlp/blob/main/Source Codes/ROS_Packages/multiradar_mmpose_ROS/src/multiradar_mmpose/include/mmWaveCommSrv.hpp"
    click DataHdlSrv "https://github.com/radar-lab/mmpose-nlp/blob/main/Source Codes/ROS_Packages/multiradar_mmpose_ROS/src/multiradar_mmpose/include/mmWaveDataHdl.hpp"
    click Msg "https://github.com/radar-lab/mmpose-nlp/blob/main/Source Codes/ROS_Packages/multiradar_mmpose_ROS/src/multiradar_mmpose/msg/RadarScan.msg"
    click DataHandler "https://github.com/radar-lab/mmpose-nlp/blob/main/Source Codes/ROS_Packages/multiradar_mmpose_ROS/src/multiradar_mmpose/include/DataHandlerClass.h"
    click DataHandler "https://github.com/radar-lab/mmpose-nlp/blob/main/Source Codes/ROS_Packages/multiradar_mmpose_ROS/src/multiradar_mmpose/src/DataHandlerClass.cpp"
    click Artifacts "https://github.com/radar-lab/mmpose-nlp/tree/main/Dataset and Predictions/"
    click Train "https://github.com/radar-lab/mmpose-nlp/blob/main/Source Codes/Python Files/master_train_mmpose_nlp_gru.py"
    click Infer "https://github.com/radar-lab/mmpose-nlp/blob/main/Source Codes/Python Files/master_infer_mmpose_nlp_gru.py"
    click Fig34 "https://github.com/radar-lab/mmpose-nlp/blob/main/Source Codes/MATLAB Files/Fig_3_and_4.m"
    click Fig6 "https://github.com/radar-lab/mmpose-nlp/blob/main/Source Codes/MATLAB Files/Fig_6.m"
    click TabAndFigs "https://github.com/radar-lab/mmpose-nlp/blob/main/Source Codes/MATLAB Files/Table_1_and_Figs_5and7.m"
    click Analyze "https://github.com/radar-lab/mmpose-nlp/blob/main/Source Codes/MATLAB Files/analyze_pred.m"
    click Videos "https://github.com/radar-lab/mmpose-nlp/tree/main/Dataset and Predictions/Continuous Data Videos/"
    click Metrics "https://github.com/radar-lab/mmpose-nlp/tree/main/Dataset and Predictions/Inference_Time/"

    classDef hardware fill:#f9f,stroke:#333,shape:trapezoid
    classDef backend fill:#bbf,stroke:#333
    classDef storage fill:#bfb,stroke:#333
    classDef ml fill:#f96,stroke:#333
    classDef matlab fill:#d9f,stroke:#333
    classDef cylinder fill:#afa,stroke:#333,shape:cylinder
```
