# radar-lab/mmfall architecture

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

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

## Overview

##### Project type and purpose
- This is neither a web nor a traditional full-stack app. It is a sensor data-processing + machine-learning system built around ROS (Robot Operating System) to detect human falls using a 4D mmWave radar and an RNN-autoencoder anomaly detector (the HVRAE).
- The README confirms: data collection via mmWave radar (and optionally a webcam), preprocessing, semi-supervised ML model training on normal activities, and real-time inference to flag falls.

##### File structure
- Top-level Python scripts:
- combine.py – merging or aggregating datasets
- data_pre.py – raw → cleaned/preprocessed data
- data_analyzer.py – statistical analysis or feature exploration
- data_visualizer.py – plotting / RViz configs
- data/ – raw and processed datasets (npy, csv) plus recorded ROS bag files
- saved_model/ – trained model files (HVRAE_SL_mdl.h5, HVRAE_mdl.h5, RAE_mdl.h5)
- src/mmfall.ipynb – notebook to reproduce experiments and ROC curves
- src/ros/ – ROS workspace with three packages:
- node1_radarinterface – C++ ROS node to interface mmWave radar and publish RadarScan messages
- serial – generic serial library, used by radarinterface
- usb_webcam – optional camera capture node

##### Insights from the README
- Confirms a two-stage system: (i) real-time sensor acquisition via ROS, (ii) anomaly detection via Hybrid Variational RNN AutoEncoder.
- The provided misc/mmfall.png hints at the high-level data flow.

##### Final recommendations
- Major directories/packages as distinct components
- Note on the bifurcation: “Offline training” vs. “Online detection”

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Hardware Layer"
        Radar["mmWave Radar"]:::hardware
        Webcam["USB Webcam (Optional)"]:::hardware
    end

    subgraph "ROS Middleware"
        node1["node1_radarinterface"]:::ros
        serial["serial lib"]:::ros
        usbnode["usb_webcam"]:::ros
        TopicRadar["/radar_scan (RadarScan msg)"]:::ros
        TopicCam["/camera_frame (Image msg)"]:::ros
        Rosbag["rosbag Recorder"]:::ros
    end

    subgraph "Offline Pipeline"
        dp["data_pre.py"]:::offline
        comb["combine.py"]:::offline
        da["data_analyzer.py"]:::offline
        dv["data_visualizer.py"]:::offline
        nb["mmfall.ipynb"]:::offline
        subgraph "Saved Models"
            m1["HVRAE_SL_mdl.h5"]:::offline
            m2["HVRAE_mdl.h5"]:::offline
            m3["RAE_mdl.h5"]:::offline
        end
    end

    subgraph "Real-time Inference"
        rtinf["Inference Module"]:::realtime
        Detect["/fall_detected (Alert)"]:::realtime
    end

    Radar --> node1
    Webcam --> usbnode
    node1 --> TopicRadar
    usbnode --> TopicCam
    TopicRadar --> Rosbag
    TopicCam --> Rosbag

    Rosbag --> dp
    dp --> comb
    comb --> da
    da --> dv
    dv --> nb
    nb --> m1
    nb --> m2
    nb --> m3

    TopicRadar --> rtinf
    m1 --> rtinf
    m2 --> rtinf
    m3 --> rtinf
    rtinf --> Detect

    click node1 "https://github.com/radar-lab/mmfall/tree/master/src/ros/src/node1_radarinterface"
    click serial "https://github.com/radar-lab/mmfall/tree/master/src/ros/src/serial"
    click usbnode "https://github.com/radar-lab/mmfall/tree/master/src/ros/src/usb_webcam"
    click Rosbag "https://github.com/radar-lab/mmfall/tree/master/data/ros_bag_files"
    click dp "https://github.com/radar-lab/mmfall/blob/master/data_pre.py"
    click comb "https://github.com/radar-lab/mmfall/blob/master/combine.py"
    click da "https://github.com/radar-lab/mmfall/blob/master/data_analyzer.py"
    click dv "https://github.com/radar-lab/mmfall/blob/master/data_visualizer.py"
    click nb "https://github.com/radar-lab/mmfall/blob/master/src/mmfall.ipynb"
    click m1 "https://github.com/radar-lab/mmfall/blob/master/saved_model/HVRAE_SL_mdl.h5"
    click m2 "https://github.com/radar-lab/mmfall/blob/master/saved_model/HVRAE_mdl.h5"
    click m3 "https://github.com/radar-lab/mmfall/blob/master/saved_model/RAE_mdl.h5"

    classDef hardware fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef ros fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef offline fill:#FFA500,stroke:#000,stroke-width:1px;
    classDef realtime fill:#FF6347,stroke:#000,stroke-width:1px;
```
