Skip to content

feat(ui): registration wizard — fit the cut to the sticker from three jogged points - #54

Merged
BernardJen merged 1 commit into
mainfrom
change/svg-calibration-points
Sep 8, 2026
Merged

feat(ui): registration wizard — fit the cut to the sticker from three jogged points#54
BernardJen merged 1 commit into
mainfrom
change/svg-calibration-points

Conversation

@BernardJen

Copy link
Copy Markdown
Contributor

Why

1.1.0's registration (touch-mark each point, read the miss, shift work zero) could only correct a translation, and only by moving the origin. A sticker mounted a few degrees off — the normal case by hand — could not be cut. The operator asked for a wizard that measures where the sticker really is and moves the cut to it. OpenSpec change svg-calibration-points, revised.

What

  • Registration wizard (src/ui/RegistrationWizard.tsx), opened automatically after importing an SVG with ≥2 calibration points and via Register…: mount → per point jog onto the crosshair (arrow keys / arrows, step, pen up/down) and Set → result → Apply.
  • fitRegistration (src/plot/register.ts): 2-D rigid least squares (rotation + translation, scale fixed at 1:1) in the placePolylines convention, so the result is a Placement. Reports per-point residuals, RMS and the implied print scale; the wizard flags RMS > 0.3 mm or scale off > 1%.
  • Removed the 1.1.0 Run calibration / Apply correction UI, shiftWorkZero (controller, protocol, gateway, client) and generateCalibrationGcode. The streamProgram busy guard stays.
  • Shared button styles moved to src/ui/styles.ts. README section rewritten, changelog, v1.2.0.

Design notes

  • Scale is not solved for on purpose: the sticker is printed 1:1; stretching the cut to a mis-jogged point would be wrong. The implied scale is a warning.
  • The warning is on RMS, not on one residual: least squares shares a single point's error across all points, so the mis-set point is not reliably the largest residual. A unit test pins this down.

Verification

  • mise run ci green, 97 tests, coverage 55% statements.
  • fitRegistration round-trips known placements (translation, ±rotation incl. ≈180°), flags a 1.5 mm mis-set point via RMS, reports a 2% print scale without applying it, handles 2/1/0 points.
  • Chromium with a seeded session: Registration panel lists cal-P1..3 at page 15,15 / 195,15 / 15,282; Register… opens the wizard; mount and point steps render, Set disabled with the reason while disconnected.
  • Hardware (tasks 7.1–7.4): mount a sticker a few degrees off, run the wizard, confirm the fitted angle/offset and RMS < 0.3 mm, cut, confirm the contour follows the print.

🤖 Generated with Claude Code

… jogged points

The 1.1.0 approach (touch-mark each point, read the miss, shift work zero)
could only correct a translation, and only by moving the origin. A sticker
mounted a few degrees off — which is how stickers get mounted by hand — could
not be cut at all. Replace it with a wizard that adjusts the artwork instead.

Importing an SVG with calibration points opens the wizard: mount the sticker;
then, per point in file order, jog the pen tip onto the printed crosshair
(arrow keys or on-screen arrows, step size, pen up/down to sight the tip)
and Set records the live work position; finally fitRegistration finds the
rigid transform (rotation + translation, scale fixed at 1:1) that maps the
file's points onto the measurements — the 2-D Kabsch solution written in the
placePolylines convention so the result is a Placement — and Apply sets it
on the artwork. Rotation, offset, per-point residual and the implied print
scale are shown; RMS over 0.3 mm or scale off by more than 1% is flagged.

Scale is deliberately not solved for: the sticker is printed 1:1 and the cut
must match its real size, not stretch to a mis-jogged point. The warning
is on the RMS, not on any one residual: least squares shares a single
point's error across all points, so the mis-set point is not reliably the
one with the largest residual (a unit test pins that down).

Removed: Run calibration, Apply correction, the shiftWorkZero command and
generateCalibrationGcode. The streamProgram busy guard from 1.1.0 stays.

Verified in Chromium with a seeded session: the Registration panel lists the
points at page 15,15 / 195,15 / 15,282; Register… opens the wizard; the
mount step and the point step render with Set disabled and the reason while
disconnected. fitRegistration round-trips known placements (translation,
±rotation incl. ≈180°), reports a 2% print scale without applying it, and
handles 2/1/0 points. OpenSpec change svg-calibration-points revised; the
hardware group (7) stays unchecked until a real sticker is cut.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@BernardJen
BernardJen force-pushed the change/svg-calibration-points branch from f5cae72 to 552b92a Compare September 8, 2026 15:04
@BernardJen
BernardJen merged commit e757363 into main Sep 8, 2026
2 checks passed
@BernardJen
BernardJen deleted the change/svg-calibration-points branch September 8, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant