mechanical-engineering-skills

Tutorial: LinkD (target curve → planar linkage)

Skill: linkage-synthesis · Paper: LinkD: Autoregressive diffusion for mechanical linkage synthesis, Barati Farimani Lab, arXiv:2601.04054

LinkD designs one-degree-of-freedom planar linkages whose end-effector traces a target curve.

How it represents a mechanism:

How each proposal is checked:

Success rates in the paper:

Retry strategy Success rate
One-shot 29.4%
Graph-level retry 96.7%
Node-level retry 99.6%

The paper does not release the trained weights. The skill therefore keeps the representation, the validation, the node-by-node construction with bounded retries, and the Chamfer metric exactly as published. In place of the diffusion sampler, an optimizer proposes nodes: differential evolution, then Nelder–Mead. It also adds practicality limits (link ratio, pivot spacing, overall size), so a fit cannot come from a mechanism nobody could build.

Use cases

Setup

npx skills add BaratiLab/mechanical-engineering-skills --skill linkage-synthesis
pip install numpy scipy matplotlib
cd skills/linkage-synthesis

1. Check that it can recover a known mechanism

Simulate the example four-bar, then ask the synthesizer to find a mechanism for that curve without being told the answer:

python scripts/linkage.py validate examples/fourbar.json
python scripts/linkage.py simulate examples/fourbar.json --out fourbar_curve.csv
python scripts/synth.py fourbar_curve.csv --out recovered.json --max-nodes 5

The second four-bar attempt reached CD = 0.0002, meaning the recovered mechanism traces the same curve. Run this check whenever you change the code.

2. Synthesize for a shape a four-bar can’t follow

python scripts/synth.py --preset bean --out bean.json --max-nodes 7
python scripts/linkage.py plot bean.json --target bean_target.csv --out bean.png

The log shows the paper’s construction loop at work:

[four-bar] attempt 2: CD = 0.0526
[grow] 7 nodes: CD = 0.0497
[grow] no proposal improved the fit after 25 retries; stopping at 7 nodes

Bean six-bar

Result:

The fit is good everywhere except the convex lobe on the right. That lobe is what the next dyad would have had to fix, and none of the 25 proposals improved it by more than 2%.

3. Read the numbers correctly

4. Make it real

Cite: LinkD, arXiv:2601.04054.