Public: anyone can read this; the crew can change it.

Migrated from github.com/Trevato/SO-ARM100

/admin walks the owner through aligning each joint to its mechanical reference #492

Merged opened this

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

/admin now has an "Align joints" section, shown to the owner only. It lists all six joints, each with its reference angle, the pose to hold it in, its current offset, and a Record button. Record: the button posts to POST /settings/joint-zero.

Notes

shipped merged

opened this

/admin now has an "Align joints" section, shown to the owner only. It lists all six joints, each with its reference angle, the pose to hold it in, its current offset, and a Record button.

  • Record: the button posts to POST /settings/joint-zero.
  • Check: the server status now reports modelDeg for each joint, the angle the model reads with trims applied. After a record, the row compares that angle to the reference. It is marked done within 0.5° and otherwise says to record again.
  • Reference poses: src/joint-reference.ts holds the joints, reference angles and pose descriptions. The poses are described in one sentence each in Software/README.md. All six reference angles are 0°. I wrote the pose wording myself, so check it against the real arm's marks.
  • Tests: admin-page.test.ts renders the section for the owner and for a visitor. server.test.ts posts a record against a fake arm.
  • Test run: the suite had two failures. The first was an off-by-one in my new admin-page.test.ts assertion, now fixed. The second is "serves the model, its meshes and the vendored libraries", which gets a 404 for /vendor/three/build/three.module.js. It also fails with my changes stashed, and node_modules is missing here, so I think it's the environment. I did not rerun the full suite after the fix, only admin-page.test.ts, which passes.
  • Not run: the type check found no bun types in this clone (Cannot find type definition file for 'bun'), so tsc told me nothing. design-lint was not run.

Closes #446

2 earlier comments · 2 events
commented

I merged main into the branch and pushed it. The conflicts were in admin-page.ts and admin-page.test.ts, and in both files I kept both sides.

  • admin-page.ts: the Align joints section sits alongside the Versions section that came in from main.
  • admin-page.test.ts: I kept the Align test and the table-touch test from main. The table-touch test builds a fake document with only getElementById. The page script now also calls querySelectorAll, so I gave the fake one that returns an empty list. That is a change to a test that main wrote.

admin-page.test.ts passes (7 tests). I ran server.test.ts before that fix: it had two failures, the table-touch test and the vendored-libraries test. The vendored-libraries test also failed before the merge (here, node_modules is missing), so I think it's the environment. I did not rerun server.test.ts after the fix, and I did not run the whole suite.

Changes requested — before the latest push

Both-doors miss, plus one piece of dead code. The page work itself looks sound: owner-only, escaped, and the existing ADMIN_ONLY gate covers joint-zero. I did not inspect the preview or the screenshots.

Fix first: the terminal has no Align joints walk-through. /zero <joint> [deg] records an offset, but it knows nothing of the reference poses, shows no offset list, and gives no Done / record-again check against modelDeg. Add a terminal command in src/terminal.ts that lists the REFERENCES (joint, pose, current offset) and, after a record, reports the model-vs-reference verdict. It should be admin-gated like /zero, with a test. Then name it in the README Align joints bullet, which currently only describes the page.

Second: alignment() in joint-reference.ts is used only by the tests. The page re-implements the same maths inside ALIGN_SCRIPT, so the test proves a function production never calls. Have the terminal use alignment(), and for the page either inject its logic into the script or drop the helper, so one rule decides Done.

Smaller: the table-touch test was edited only to stub querySelectorAll. That is fine, but say so in the pull. Also the pose wording was written by the builder and not checked against the real arm; the owner should confirm it before merge.

commented

The terminal now has an Align joints walk-through, and the page and the terminal use one rule for Done. terminal.test.ts and admin-page.test.ts pass. I did not run the type check (it only resolved dependencies and printed no errors), design-lint, or the full suite.

  • Terminal: /align lists each joint's reference, pose and current offset. /align <joint> posts to /settings/joint-zero at that joint's reference, reads the next /status, and prints either "done: the model is X° from the reference" or "…; record again". It goes through the same endpoints as /zero, so the server's owner gate decides who may; a refusal prints as error: …. The test covers the list, Done, record again, refusals and bad usage. Door takes the new reader as a ninth, optional constructor argument, and tty.ts passes it in.
  • One rule: alignment() in src/joint-reference.ts now decides Done for both doors. The terminal calls it through verdictLine(). The page script injects alignment() through Function.toString, along with the tolerance constant, in place of its own copy of the maths. A new test runs the page script and checks Done at 0.3° and record again at 2°.
  • README: the Align joints bullet now names /align and /align <joint>.
  • Table-touch test: in the merge with main, I changed that test only to stub querySelectorAll in its fake document, because the page script now calls it.
  • Pose wording: I wrote the six pose descriptions and none has been checked against the real arm. The owner should confirm them before merge. All six references are 0°.
Changes requested — before the latest push

The design is sound: one shared alignment() rule for both doors, the owner gate stays server-side on /settings/joint-zero, and the README covers both doors. Two things block it.

  1. Fix first: alignReader in src/terminal.ts has no test. The Door tests stub it, so nothing checks the real code that signs the GET /settings and GET /status requests, merges the two answers, drops non-numeric values, or turns a failing status into an error line. Add a test beside the poster/versionsReader tests, using a fake fetcher, that covers: a good answer, a 404 or 403 on either route, and a thrown fetch.
  1. The preview does not show it working. The GET /status I fetched from https://arm--492--forge-trevato-apps.open-platform.sh/status has no modelDeg on any joint, although server.ts adds it as null or a number. Check that the preview is running this head. Also say in the pull how the Record check behaves when there is no model (the page prints "the arm gave no model angle to check"), since the preview arm may have none.

Smaller points: the pose wording was not checked against the real arm, so the owner must confirm it before merge. A Record button with an aria-label in a table cell should meet the 44px touch target on a phone; check that against the design CSS.

commented

I added the missing alignReader test. The preview's /status has no modelDeg on any joint, and I could not fix that from here. terminal.test.ts passes; I didn't run the rest of the suite or the type check.

  • alignReader test: src/terminal.test.ts now covers the real reader with a fake fetcher.

- A good answer: both GETs are signed, the two answers are merged, and non-numeric offsets and angles are dropped (a bad angle becomes null). - A 404 or 403 on /settings or on /status each come back as the server's error text. A 404 with no body gives "status 404". - A thrown fetch comes back as its message.

  • Preview has no modelDeg: I fetched /status from the #492 preview myself and got no modelDeg key on any joint. The server always emits the field, as null when there is no model, so that preview is running code from before this feature. It is not this head; the preview most likely hasn't been redeployed since an earlier push. I can't check which commit it runs from this sandbox.
  • No model angle: if the arm reports no model angle, Record still saves the offset. The page then says "Recorded; the arm gave no model angle to check." and the terminal says "<joint> recorded; the arm gave no model angle to check". Neither says Done. A preview arm with no model would show that.
  • Record button size: it needs no change. The page's base button style already sets min-height: 44px, and the Record button uses it. I did not check it on a phone.
  • Pose wording: I wrote the six pose descriptions and none has been checked against the real arm. The owner should confirm them before merge.
Approved

Approved. The page and the terminal share one alignment() rule. Both doors are covered by tests, and the README says how to use them. Every write goes through the server-side joint-zero gate, and the page only shows the section to the owner. The Record button is a native button with an aria-label, a status note and a 44px minimum height. The table is in a scroll wrapper, so it does not break a 360px phone.

I could not see it working in the preview. The preview /status has no modelDeg on any joint, although this head always emits the field (null without a model), so the preview looks like it is running older code. /admin answers 404 to a guest, as it should. I could not look at the Align section itself.

Two things to do next:

  1. Before the owner relies on it, have them confirm the six pose descriptions against the real arm. They are unverified. The elbow_flex line ("forearm at a right angle ... 0°") is the likeliest to be wrong. Also confirm modelDeg shows up once the preview redeploys.
  2. Add a no-JavaScript fallback: without JS the offset column stays at "…" and Record does nothing. Render the offsets server-side, and use a small form post for Record.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs