# linchangyi1/9dtact architecture

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

- Interactive diagram: https://gitdiagram.com/linchangyi1/9dtact
- Repository: https://github.com/linchangyi1/9dtact

## Overview

##### Project Type and Purpose
- It spans mechanical design (SOLIDWORKS assemblies, PCB Gerbers), data‐collection utilities, offline data processing & ML model training, and live inference in ROS.

##### File Structure
- Top‐level “9DTact_Design” holds all mechanical/CAD and PCB design files, split into Perception, Diffusion, Contact modules, LED PCB layout, molds and fabrication exports.
- Python packages/modules:
- data/ (dataset definition)
- data_collection/ (scripts to acquire raw sensor + force readings)
- shape_reconstruction/ (camera/sensor calibration + 3D surface reconstruction)
- force_estimation/ (config, training, inference, visualization)
- model/ (CNN, ViT model definitions)
- Auxiliary files: requirements.txt, setup.py, saved_models/, README.md.

##### Essential Detail
- 3 calibration steps as sub‐blocks under shape_reconstruction.
- ML block with supported architectures (Densenet-169, ViT, etc.).
- Saved_models directory feeding into inference nodes.
- Optionally, note external dependencies (BOTA driver, wandb).

## Diagram (Mermaid)

```mermaid
flowchart TD
    classDef hardware fill:#cfe2f3,stroke:#6d9eeb
    classDef ros fill:#d9ead3,stroke:#6aa84f
    classDef data fill:#f9cb9c,stroke:#e69138
    classDef ml fill:#ffd966,stroke:#bf9000
    classDef infer fill:#d5a6bd,stroke:#8e7cc3

    subgraph "Hardware Layer"
        H1["Perception Module"]:::hardware
        H2["Diffusion Module"]:::hardware
        H3["Contact Module"]:::hardware
        H4["LED PCB Layout"]:::hardware
        H5["Calibration Board"]:::hardware
    end

    subgraph "ROS Driver Layer"
        R1["Sensor_ros node"]:::ros
        R2["Shape_Reconstruction_ros node"]:::ros
        R3["Force_Estimation_ros node"]:::ros
        R4["Shape_Force_ros (SSAF) node"]:::ros
    end

    subgraph "Data Collection & Processing"
        D1["collect_data.py"]:::data
        D2["wrench_normalization.py"]:::data
        D3["split_train_test.py"]:::data
        D4["dtact_dataset.py"]:::data
    end

    subgraph "Calibration & Reconstruction"
        C1["Camera Calibration"]:::data
        C2["Sensor Calibration"]:::data
        C3["3D Shape Reconstruction"]:::data
        C4["Calibration Assets"]:::data
        C5["Reconstruction Visualizer"]:::data
    end

    subgraph "Machine Learning Training"
        M1["cnn.py"]:::ml
        M2a["vit.py"]:::ml
        M2b["vit_resnet_v2.py"]:::ml
        M3["train.py"]:::ml
        M4["force_config.yaml"]:::ml
        M5["estimator.py"]:::ml
        SM["saved_models/"]:::ml
    end

    subgraph "Live Inference & Visualization"
        V1["sf_visualizer.py"]:::infer
        V2["shape_visualizer.py"]:::infer
        V3["force_visualizer.py"]:::infer
    end

    %% Data Flows
    H1 --> R1
    H2 --> R1
    H3 --> R1
    H4 --> R1
    H5 --> C1

    R1 -->|"ROS image topics"| R2
    R2 --> R4
    R4 --> V1
    R4 --> V2
    R4 --> V3
    R1 -->|"image+BOTA"| D1 -.-> D2 -.-> D3 -.-> SM
    D1 --> D4
    C1 --> C3
    C2 --> C3
    C4 --> C3
    C3 --> C5
    D4 --> M3
    M1 --> M3
    M2a --> M3
    M2b --> M3
    M4 --> M3
    M5 --> M3
    M3 --> SM
    SM --> R3
    R1 --> R3
    R3 --> R4

    %% Click Events
    click H1 "https://github.com/linchangyi1/9dtact/tree/main/9DTact_Design/1_Perception_Module"
    click H2 "https://github.com/linchangyi1/9dtact/tree/main/9DTact_Design/2_Diffusion_Module"
    click H3 "https://github.com/linchangyi1/9dtact/tree/main/9DTact_Design/3_Contact_Module"
    click H4 "https://github.com/linchangyi1/9dtact/tree/main/9DTact_Design/LED_PCB"
    click H5 "https://github.com/linchangyi1/9dtact/blob/main/9DTact_Design/fabrication/calibration_board.SLDPRT"
    click R1 "https://github.com/linchangyi1/9dtact/blob/main/shape‐force_ros/_1_Sensor_ros.py"
    click R2 "https://github.com/linchangyi1/9dtact/blob/main/shape‐force_ros/_2_Shape_Reconstruction_ros.py"
    click R3 "https://github.com/linchangyi1/9dtact/blob/main/shape‐force_ros/_3_Force_Estimation_ros.py"
    click R4 "https://github.com/linchangyi1/9dtact/blob/main/shape‐force_ros/_4_Shape_Force_ros.py"
    click D1 "https://github.com/linchangyi1/9dtact/blob/main/data_collection/collect_data.py"
    click D2 "https://github.com/linchangyi1/9dtact/blob/main/data_collection/wrench_normalization.py"
    click D3 "https://github.com/linchangyi1/9dtact/blob/main/data_collection/split_train_test.py"
    click D4 "https://github.com/linchangyi1/9dtact/blob/main/data/dtact_dataset.py"
    click C1 "https://github.com/linchangyi1/9dtact/blob/main/shape_reconstruction/_1_Camera_Calibration.py"
    click C2 "https://github.com/linchangyi1/9dtact/blob/main/shape_reconstruction/_2_Sensor_Calibration.py"
    click C3 "https://github.com/linchangyi1/9dtact/blob/main/shape_reconstruction/_3_Shape_Reconstruction.py"
    click C4 "https://github.com/linchangyi1/9dtact/tree/main/shape_reconstruction/calibration/"
    click C5 "https://github.com/linchangyi1/9dtact/blob/main/shape_reconstruction/visualizer.py"
    click M1 "https://github.com/linchangyi1/9dtact/blob/main/model/cnn.py"
    click M2a "https://github.com/linchangyi1/9dtact/blob/main/model/vit.py"
    click M2b "https://github.com/linchangyi1/9dtact/blob/main/model/vit_resnet_v2.py"
    click M3 "https://github.com/linchangyi1/9dtact/blob/main/force_estimation/train.py"
    click M4 "https://github.com/linchangyi1/9dtact/blob/main/force_estimation/force_config.yaml"
    click M5 "https://github.com/linchangyi1/9dtact/blob/main/force_estimation/estimator.py"
    click SM "https://github.com/linchangyi1/9dtact/tree/main/saved_models/"
    click V1 "https://github.com/linchangyi1/9dtact/blob/main/shape‐force_ros/sf_visualizer.py"
    click V2 "https://github.com/linchangyi1/9dtact/blob/main/shape‐force_ros/shape_visualizer.py"
    click V3 "https://github.com/linchangyi1/9dtact/blob/main/force_estimation/force_visualizer.py"
```
