forbes fe41fa3b00 feat(models): implement GNN model layer for assembly constraint analysis
Add complete model layer with GIN and GAT encoders, 5 task-specific
prediction heads, uncertainty-weighted multi-task loss (Kendall et al.
2018), and config-driven factory functions.

New modules:
- graph_conv.py: datagen dict -> PyG Data conversion (22D node/edge features)
- encoder.py: GINEncoder (3-layer, 128D) and GATEncoder (4-layer, 256D, 8-head)
- heads.py: edge classification, graph classification, joint type,
  DOF regression, per-body DOF tracking heads
- assembly_gnn.py: AssemblyGNN wiring encoder + configurable heads
- losses.py: MultiTaskLoss with learnable log-variance per task
- factory.py: build_model() and build_loss() from YAML configs

Supporting changes:
- generator.py: serialize anchor_a, anchor_b, pitch in joint dicts
- configs: fix joint_type num_classes 12 -> 11 (matches JointType enum)

92 tests covering shapes, gradients, edge cases, and end-to-end
datagen-to-model pipeline.
2026-02-07 10:14:19 -06:00
2024-08-15 09:06:53 -06:00
2026-02-02 13:26:38 -06:00
2026-02-02 13:26:38 -06:00
2025-08-07 21:43:45 -05:00
2024-09-09 13:48:07 -06:00
2024-08-30 15:19:30 -06:00
2024-01-04 17:58:44 -06:00
2026-02-02 13:26:38 -06:00
2023-10-17 09:56:26 -05:00
2026-02-02 13:26:38 -06:00
2025-10-09 09:13:17 -05:00

Kindred Solver

Assembly constraint solver for Kindred Create. Combines a numerical multibody dynamics engine (OndselSolver) with a GNN-based constraint prediction layer.

Components

OndselSolver (C++)

Numerical assembly constraint solver using multibody dynamics. Solves joint constraints between rigid bodies using a Newton-Raphson iterative approach. Used by FreeCAD's Assembly workbench as the backend solver.

  • Source: OndselSolver/
  • Entry point: OndselSolverMain/
  • Tests: tests/, testapp/
  • Build: CMake

Theory: MbDTheory

Building

cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build

ML Solver Layer (Python)

Graph neural network that predicts constraint independence and per-body degrees of freedom. Trained on synthetic assembly data generated via the pebble game algorithm, with the goal of augmenting or replacing the numerical solver for common assembly patterns.

  • Core library: solver/
  • Data generation: solver/datagen/ (pebble game, synthetic assemblies, labeling)
  • Model architectures: solver/models/ (GIN, GAT, NNConv)
  • Training: solver/training/
  • Inference: solver/inference/
  • FreeCAD integration: freecad/
  • Configuration: configs/ (Hydra)

Setup

pip install -e ".[train,dev]"
pre-commit install

Usage

make help          # show all targets
make dev           # install all deps + pre-commit hooks
make test          # run tests
make lint          # run ruff linter
make check         # lint + type-check + test
make data-gen      # generate synthetic data
make train         # run training
make export        # export model

Docker is also supported:

docker compose up train       # GPU training
docker compose up test        # run tests
docker compose up data-gen    # generate synthetic data

Repository structure

kindred-solver/
├── OndselSolver/       # C++ numerical solver library
├── OndselSolverMain/   # C++ solver CLI entry point
├── tests/              # C++ unit tests + Python tests
├── testapp/            # C++ test application
├── solver/             # Python ML solver library
│   ├── datagen/        # Synthetic data generation (pebble game)
│   ├── datasets/       # PyG dataset adapters
│   ├── models/         # GNN architectures
│   ├── training/       # Training loops
│   ├── evaluation/     # Metrics and visualization
│   └── inference/      # Runtime prediction API
├── freecad/            # FreeCAD workbench integration
├── configs/            # Hydra configs (dataset, model, training, export)
├── scripts/            # CLI utilities
├── data/               # Datasets (not committed)
├── export/             # Model packaging
└── docs/               # Documentation

License

OndselSolver: LGPL-2.1-or-later (see LICENSE) ML Solver Layer: Apache-2.0

Description
An assembly solving stack for Kindred Create based on a trained GNN layer between placement actions in the UI and actual constraints applied.
Readme LGPL-2.1 17 MiB
Languages
C++ 66.2%
Python 32.5%
CMake 1.1%