# dongchenyu165/dongdoctoralresearch architecture

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

- Interactive diagram: https://gitdiagram.com/dongchenyu165/dongdoctoralresearch
- Repository: https://github.com/dongchenyu165/dongdoctoralresearch

## Overview

##### Project type and purpose
- This is a C++-based research tool (with Python bindings) for evaluating robotic grasp poses in a bi-arm knife-cutting task.
- It implements a multi-stage pipeline that, given a knife trajectory and food surface mesh, generates candidate grasp positions, filters them geometrically, computes force and position scores, aggregates them, and outputs the best grasp.

##### File structure
- Top-level directories correspond to pipeline stages:
- 1_PrepareData
- 2_FilterByGeo
- 3_KnifeForceCalculator
- 4_ForceScore
- 4_PositionScore
- Supporting modules:
- SearchSpaceGenerator – produces the initial candidate set
- ScoreCalculator – orchestrates per-stage scoring and final aggregation
- Shared code:
- DataTypes – definitions for trajectory nodes, point sets, etc.
- Utilities – numerical routines (Eigen helper), EMST (CGAL), PCL helpers, JSON serialization, logging (spdlog)
- Entrypoints:
- main.cpp / main_grasping_pc.cpp – command-line applications
- pybind11 submodule – Python bindings
- Build and test:
- CMakeLists.txt at root and per-module
- Tests/ – unit tests for each module

##### README for insights
- The pipeline has six logical stages:
1. Input knife trajectory → extract pose Tj
2. PrepareData: compute contact surface Ωc and gripping surface Ωg, initial search space P_init
4. KnifeForceCalculator: compute forces from the knife on the food
5. ForceScore: compute finger force distribution score (uses CUDA optionally)
6. PositionScore: compute fingertip positional redundancy score
7. Aggregate scores over trajectory → pick best grasp
- Key dependencies: Eigen, nlohmann/json, spdlog, cppitertools, CGAL, PCL, VTK, pybind11

##### Elements
- Rectangles for modules (SearchSpaceGenerator, PrepareData, …)
- A “Shared Utilities” rectangle beneath them
- Utilities in another
- External dependencies in a third

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Input
    subgraph "Input Layer"
        trajectory["KnifeTrajectory"]:::data
        mesh["FoodMesh"]:::data
    end
    trajectory -->|"TrajectoryNodes"| SSG
    mesh -->|"MeshData"| SSG

    %% Pipeline Stages
    SSG["SearchSpaceGenerator"]:::pipeline
    SSG -->|"P_init (Candidates)"| prepare
    prepare["PrepareData"]:::pipeline
    prepare -->|"Filtered by Geo"| geo
    geo["GeometryFilter"]:::pipeline
    geo -->|"GeoFilteredCandidates"| kfc
    kfc["KnifeForceCalculator"]:::pipeline
    kfc -->|"ForceVectors"| fscore
    fscore["ForceScore"]:::pipeline
    fscore -->|"ForceScores"| scalc
    pos["PositionScore"]:::pipeline
    kfc --> pos
    pos -->|"PosScores"| scalc
    scalc["ScoreCalculator"]:::pipeline
    scalc -->|"BestGrasp"| cli

    %% Entry Points
    cli["CLI App"]:::entry
    py["Python API"]:::entry
    cli -->|invokes| scalc
    py -->|binds to| scalc

    %% Shared Utilities
    subgraph "Shared Utilities"
        utils["Utilities"]:::util
    end
    utils -.-> SSG
    utils -.-> prepare
    utils -.-> geo
    utils -.-> kfc
    utils -.-> fscore
    utils -.-> pos
    utils -.-> scalc

    %% External Libraries
    subgraph "External Dependencies"
        eig["Eigen"]:::external
        json["nlohmann/json"]:::external
        log["spdlog"]:::external
        cgal["CGAL"]:::external
        pcl["PCL/VTK"]:::external
        cuda["CUDA"]:::external
        pyb["pybind11"]:::external
    end
    eig --> utils
    json --> utils
    log --> utils
    cgal --> utils
    pcl --> utils
    cuda --> fscore
    pyb --> py

    %% Click Events
    click trajectory "https://github.com/dongchenyu165/dongdoctoralresearch/blob/dev/DataTypes/KnifeTrajectoryNode.hpp"
    click SSG "https://github.com/dongchenyu165/dongdoctoralresearch/blob/dev/SearchSpaceGenerator/SearchSpaceGenerator.hpp"
    click prepare "https://github.com/dongchenyu165/dongdoctoralresearch/blob/dev/1_PrepareData/CuttingFaceMaker/CuttingFaceMaker.hpp"
    click geo "https://github.com/dongchenyu165/dongdoctoralresearch/blob/dev/2_FilterByGeo/GeometryFilter.hpp"
    click kfc "https://github.com/dongchenyu165/dongdoctoralresearch/blob/dev/3_KnifeForceCalculator/KnifeForceCalculator.hpp"
    click fscore "https://github.com/dongchenyu165/dongdoctoralresearch/blob/dev/4_ForceScore/ForceScoreCalculator.hpp"
    click pos "https://github.com/dongchenyu165/dongdoctoralresearch/blob/dev/4_PositionScore/PositionScoreCalculator.hpp"
    click scalc "https://github.com/dongchenyu165/dongdoctoralresearch/blob/dev/ScoreCalculator/ScoreCalculatorBase.hpp"
    click cli "https://github.com/dongchenyu165/dongdoctoralresearch/blob/dev/main.cpp"
    click py "https://github.com/dongchenyu165/dongdoctoralresearch/tree/dev/pybind11/"
    click utils "https://github.com/dongchenyu165/dongdoctoralresearch/blob/dev/Utilities/Asserting.hpp"

    %% Styles
    classDef pipeline fill:#D6EAF8,stroke:#2980B9,color:#1B4F72;
    classDef util fill:#E8DAEF,stroke:#8E44AD,color:#512E5F;
    classDef external fill:#FDEBD0,stroke:#E67E22,color:#873600;
    classDef data fill:#D5F5E3,stroke:#27AE60,color:#145A32,shape:cylinder;
    classDef entry fill:#FADBD8,stroke:#C0392B,color:#641E16;
```
