Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
POST /settings/joint-zero sets one joint's offset so the model reads a known mechanical reference #463
Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.
I added POST /settings/joint-zero and pushed it. The server tests pass except one, and I did not run the whole suite here. The one failure is the /vendor/three/… route test in server.test.ts.
shipped merged
2 earlier comments · 1 event
I added POST /settings/joint-zero and pushed it. The server tests pass except one, and I did not run the whole suite here.
The one failure is the /vendor/three/… route test in server.test.ts. It fails the same way on the unmodified tree, and I did not look into why. I didn't run bun test end to end. bun x tsc --noEmit reports errors elsewhere in the repo, but none in the files I changed.
What it does: the body is {"joint", "referenceDeg"}. It reads that joint's Present_Position and sets jointOffsetsDeg[joint] so the model angle equals referenceDeg. The offset ignores any existing offset, so zeroing twice gives the same result. It saves the settings the way table-here does. It returns the settings plus offsetDeg, the offset it applied, rounded to 0.01°.
Refusals:
- An unknown joint, a non-finite
referenceDeg, or one outside the model's limits for that joint is a 400. - An offset past ±15° is a 409 saying the arm is not at the reference.
- A joint whose servo doesn't answer, or a server with no model loaded, is also a 409.
Relay: the route is in ADMIN_ONLY in src/relay.ts, and lobby.test.ts checks that a non-owner gets 403.
Tests in server.test.ts:
- Bad input: a bad joint, a non-numeric
referenceDegand an out-of-range one are each a 400, and a 20° offset is a 409. - Agreement: after zeroing,
/statusticks plus the offset read the reference within 0.5°, and/settingsshows the saved offset. - Zone risk: in enforce mode, a move to
shoulder_lift80° is blocked. The same physical pose gives the same block before and after zeroing. Link and kind match, and depth matches within 1 mm because of the offset rounding.
I placed the joint-zero test after the "move into the table" test, because that one counts total blocks and the new test adds some.
The route is sound: the relay gates it to admins, input is validated, the offset is idempotent, and the server test is good. But the list is strict and two items are missed.
- Both doors (fix first). The change adds only the HTTP route.
table-hereis reachable from the admin page (admin-page.ts) and from the terminal (terminal.ts, with a poster test interminal.test.ts).joint-zerohas neither, so a person at the terminal cannot zero a joint. Add the terminal command, reusing the signed poster thattable-hereuses, with a test that fails without it. The admin page needs a control only if the issue asks for it. - README.
Software/README.mddocumentstable-here(around lines 543 and 759) and says nothing aboutjoint-zero. Add a short usage: the body, the admin-only rule, the ±15° refusal, and 'put the arm at the reference first'. - Tests. The PR says
bun testwas not run end to end and that the/vendor/three/route test fails on the unmodified tree. Run the full suite and say what you found. Do not leave a red test unexplained.
On the code, server.ts has a long inline case. Move the compute-the-offset logic into a small named function, as other modules do. I did not try the preview as a person would, since without the terminal or page door there is nothing there to use.
POST /settings/joint-zero now has a terminal door, a README entry and a pure offset function. The full bun test run showed 703 pass and 2 fail, and I fixed both failures. I then re-ran only the terminal, joint-zero and server test files, which pass (89), and did not re-run the full suite after that fix. bun x tsc --noEmit reports nothing in the files I touched.
- Terminal:
/zero <joint> [degrees](default 0) posts through the same signedposterthattable-hereuses. It prints<joint> offset is X°or the server's refusal, and the usage line covers bad input. The help line and header comment list it. Tests cover the parser, the door printing both the offset and a 409, and the poster returningoffsetDeg. I did not add an admin-page control, since the issue doesn't ask for one. - README:
Software/README.mdhas a/zerobullet and a short paragraph after the table section. It gives the body, admin-only, the 400s, the ±15° 409, and "put the arm at the reference first". - Refactor:
src/joint-zero.tsholdszeroOffsetDeg(modelRad, referenceDeg), which returns null past ±15°, plus its unit test. The server case now calls it. - Tests: the first full run had two red tests, both in my new
/zerotests. The parser rejected multi-word arguments before reaching the new verb; I fixed it and they pass. - Vendor-route failure: the
/vendor/three/…failure I reported earlier was only a missingbun install. It passes after installing.
I didn't try the preview as a person would.
I merged main into the branch, resolved the conflicts, and pushed. The full bun test run passes (742 pass, 0 fail), and the type check shows nothing in the files I touched.
Both conflicts were places where each side edited the same line:
relay.ts: I keptmain's lists, which addPUT /servo-paramsandPOST /servo-params/factory, and addedPOST /settings/joint-zerotoADMIN_ONLY. The owner-only list stays asmainhas it.terminal.ts: I keptmain's/precisionand its{ precision: true }command. I added/zeroto the help text and{ zero: … }to theTypedunion. The/zeroparsing and dispatch merged without a conflict.
Approved. Unauthenticated POST on the preview answers 401 with the security headers. The route is admin-only in the relay, validated at the boundary (name, finite number, model limits, ±15° guard), saved atomically, and has a terminal door (/zero) plus README. Tests cover server, parser, door, poster and the 403. Two things next: (1) server.ts header comment says "owner only" but the relay gates it to admins; make the wording match the README. (2) In terminal.ts the line const [deg = "0", ...extra] = rest.length ? [rest[0]!, ...rest.slice(1)] : []; just rebuilds rest; use const [deg = "0", ...extra] = rest;. Also add an admin-200 assertion for joint-zero in lobby.test.ts beside the 403.
I added
POST /settings/joint-zeroand pushed it. The server tests pass except one, and I did not run the whole suite here.The one failure is the
/vendor/three/…route test inserver.test.ts. It fails the same way on the unmodified tree, and I did not look into why. I didn't runbun testend to end.bun x tsc --noEmitreports errors elsewhere in the repo, but none in the files I changed.What it does: the body is
{"joint", "referenceDeg"}. It reads that joint's Present_Position and setsjointOffsetsDeg[joint]so the model angle equalsreferenceDeg. The offset ignores any existing offset, so zeroing twice gives the same result. It saves the settings the way table-here does. It returns the settings plusoffsetDeg, the offset it applied, rounded to 0.01°.Refusals:
referenceDeg, or one outside the model's limits for that joint is a 400.Relay: the route is in
ADMIN_ONLYinsrc/relay.ts, andlobby.test.tschecks that a non-owner gets 403.Tests in
server.test.ts:referenceDegand an out-of-range one are each a 400, and a 20° offset is a 409./statusticks plus the offset read the reference within 0.5°, and/settingsshows the saved offset.shoulder_lift80° is blocked. The same physical pose gives the same block before and after zeroing. Link and kind match, and depth matches within 1 mm because of the offset rounding.I placed the joint-zero test after the "move into the table" test, because that one counts total blocks and the new test adds some.
Closes #445