forbes-0023 533ca91774 feat(solver): full constraint vocabulary — all 24 BaseJointKind types (phase 2)
Add 18 new constraint classes covering all BaseJointKind types from Types.h:
- Point: PointOnLine (2r), PointInPlane (1r)
- Orientation: Parallel (2r), Perpendicular (1r), Angle (1r)
- Surface: Concentric (4r), Tangent (1r), Planar (3r), LineInPlane (2r)
- Kinematic: Ball (3r), Revolute (5r), Cylindrical (4r), Slider (5r),
  Screw (5r), Universal (4r)
- Mechanical: Gear (1r), RackPinion (1r)
- Stubs: Cam, Slot, DistanceCylSph

New modules:
- geometry.py: marker axis extraction, vector ops (dot3, cross3, sub3),
  geometric primitives (point_plane_distance, point_line_perp_components)
- bfgs.py: L-BFGS-B fallback solver via scipy for when Newton fails

solver.py changes:
- Wire all 20 supported types in _build_constraint()
- BFGS fallback after Newton-Raphson in solve()

183 tests passing (up from 82), including:
- DOF counting for every joint type
- Solve convergence from displaced initial conditions
- Multi-body mechanisms (four-bar linkage, slider-crank, revolute chain)
2026-02-20 21:15:15 -06:00
2023-10-17 09:56:26 -05:00

Kindred Solver

Assembly constraint solver addon for Kindred Create. Implements the IKCSolver interface via kcsolve.register_solver().

Components

Kindred Solver (Phase 1)

Expression-based Newton-Raphson constraint solver. Pure Python, registered as a Create addon.

  • Expression DAG with eval, symbolic differentiation, simplification: kindred_solver/expr.py
  • Parameter table with fixed/free tracking: kindred_solver/params.py
  • Quaternion rotation as polynomial Expr trees: kindred_solver/quat.py
  • RigidBody entity (7 params: position + unit quaternion): kindred_solver/entities.py
  • Constraint residual generators (Coincident, DistancePointPoint, Fixed): kindred_solver/constraints.py
  • Newton-Raphson solver with symbolic Jacobian: kindred_solver/newton.py
  • Pre-solve passes (substitution, single-equation): kindred_solver/prepass.py
  • DOF counting via Jacobian rank: kindred_solver/dof.py
  • KCSolve IKCSolver bridge: kindred_solver/solver.py

GNN (future phases)

Graph neural network constraint prediction layer. OndselSolver C++ engine and ML training infrastructure. Moved to GNN/ — will be integrated in later phases.

Create Addon Integration

This repo is a git submodule at mods/solver/ in the Create repository. The addon loader discovers package.xml and executes Init.py, which registers the solver:

import kcsolve
from kindred_solver import KindredSolver
kcsolve.register_solver("kindred", KindredSolver)

Testing

python3 -m venv .venv && . .venv/bin/activate
pip install pytest numpy
PYTHONPATH=. pytest tests/ -v

Repository Structure

├── package.xml            # Create addon manifest
├── Init.py                # Solver registration entry point
├── kindred_solver/        # Phase 1: expression-based Newton solver
│   ├── expr.py            # Expression DAG
│   ├── params.py          # Parameter table
│   ├── quat.py            # Quaternion math as Expr trees
│   ├── entities.py        # RigidBody entity
│   ├── constraints.py     # Constraint residual generators
│   ├── newton.py          # Newton-Raphson solver
│   ├── prepass.py         # Pre-solve passes
│   ├── dof.py             # DOF counting
│   └── solver.py          # IKCSolver bridge
├── tests/                 # Unit tests (82 tests)
└── GNN/                   # GNN solver layer (future phases)

License

LGPL-2.1-or-later (see LICENSE)

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%