Imported from CoopperChen/layout_design (
AGENTS.md). Install upstream withnpx skills add CoopperChen/layout_design. Copyright stays with the author.
Agent instructions (layout_design)
Goal
Generate wire path layouts per subject. Preset in this repo means terminal assignment only (electrode → LEFT/RIGHT), not path transfer from a reference head.
Working directory
Repository root layout_design/. Paths via app.paths.
Pipeline
- A Preprocess target subject (STL mesh, align textured OBJ, fiducials with TERMINAL_*, electrodes)
- B
synthesize— create paths from assignment map + target geometry (default) - C Polish optional (paths only, not hub discovery)
- D Smooth → export-bundle → convert-gcode → simulate-gcode
Entry-order swap rule: When two same-hub traces cross, swap their strip slots and replan those two. Primary goal: drive same-hub odd-mutual pair count to 0 (slot parity); while odd pairs remain, accept only swaps that reduce #odd_pairs (total crossings may rise). After #odd_pairs == 0, accept count↓ or even-mutual residuals only if odd stays 0 (never accept odd↑). Tried-pair memory clears on odd↓. After swap, synthesize runs an even-mutual uncross pass (fixed-end bends) before generic detour uncross: single-wire straight/knee/double-knee/S-curve, then coordinated both-wire shapes; bends must not raise #odd_pairs. Crossing counts use the densified terminal-tail metric (same as full layout analysis).
Do not treat export-v4 / chord replay / --inherit-preset-terminals as the primary workflow.
Commands
python -m app build-assignments --reference 1 --id s1_assignments
python -m app synthesize --assignments s1_assignments --target 2
python -m app polish --applied data/output/layouts/synth_s2.json --mode gentle
python -m app smooth --applied data/output/layouts/synth_s2.json
python -m app export-bundle --input data/output/smooth/smooth_s2_final.json
python -m app convert-gcode --bundle data/output/bundles/subject_2
python -m app simulate-gcode --gcode data/output/gcode/subject_2_post/allinterconnects.txt --bundle data/output/bundles/subject_2
--preset is an alias for --assignments. --inherit-preset-terminals is legacy hub map only.
Simulator: app/simulator/ — forward FK (X,Y,Z = C pivot), mesh in machine frame. Kinematics: docs/MACHINE_KINEMATICS.md.
Key docs
- docs/GOAL.md
- docs/CLI.md
- docs/MACHINE_KINEMATICS.md
- docs/DATA_LAYOUT.md
.cursor/skills/layout-synth-pipeline/SKILL.md