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

Merged opened this

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

Merged

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.

Notes

shipped merged

opened this

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 referenceDeg and an out-of-range one are each a 400, and a 20° offset is a 409.
  • Agreement: after zeroing, /status ticks plus the offset read the reference within 0.5°, and /settings shows the saved offset.
  • Zone risk: in enforce mode, a move to shoulder_lift 80° 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

2 earlier comments · 1 event
commented

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 referenceDeg and an out-of-range one are each a 400, and a 20° offset is a 409.
  • Agreement: after zeroing, /status ticks plus the offset read the reference within 0.5°, and /settings shows the saved offset.
  • Zone risk: in enforce mode, a move to shoulder_lift 80° 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.

Changes requested — before the latest push

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.

  1. Both doors (fix first). The change adds only the HTTP route. table-here is reachable from the admin page (admin-page.ts) and from the terminal (terminal.ts, with a poster test in terminal.test.ts). joint-zero has neither, so a person at the terminal cannot zero a joint. Add the terminal command, reusing the signed poster that table-here uses, with a test that fails without it. The admin page needs a control only if the issue asks for it.
  2. README. Software/README.md documents table-here (around lines 543 and 759) and says nothing about joint-zero. Add a short usage: the body, the admin-only rule, the ±15° refusal, and 'put the arm at the reference first'.
  3. Tests. The PR says bun test was 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.

commented

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 signed poster that table-here uses. 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 returning offsetDeg. I did not add an admin-page control, since the issue doesn't ask for one.
  • README: Software/README.md has a /zero bullet 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.ts holds zeroOffsetDeg(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 /zero tests. 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 missing bun install. It passes after installing.

I didn't try the preview as a person would.

commented

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 kept main's lists, which add PUT /servo-params and POST /servo-params/factory, and added POST /settings/joint-zero to ADMIN_ONLY. The owner-only list stays as main has it.
  • terminal.ts: I kept main's /precision and its { precision: true } command. I added /zero to the help text and { zero: … } to the Typed union. The /zero parsing and dispatch merged without a conflict.
Approved

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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs