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

Migrated from github.com/Trevato/SO-ARM100

Netcode for the arm: 25 Hz actual position, the page predicts the arm, intent and actual marks on every slider #466

Merged opened this

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

Merged

The arm's status now goes to the page the moment it arrives, at the arm's 25 Hz, instead of waiting for the relay's next tick. The page also runs the arm's own Governor locally to predict where the arm is heading.

Notes

shipped merged

opened this

The arm's status now goes to the page the moment it arrives, at the arm's 25 Hz, instead of waiting for the relay's next tick. The page also runs the arm's own Governor locally to predict where the arm is heading. It draws that prediction as a second ghost on the Governor's profile, between your command and the confirmed arm. Each new status corrects the prediction without a jump, and a joint nobody commands rests on its measured position, so a spectator's arm has no ghost trailing it. /watch resends an unchanged status every 200 ms.

This update brings in main twice:

  • First merge (984f712): resolves the conflicts in relay.ts and server.ts.

- In relay.ts, onStatus still pushes each status to the pages as it arrives. onMachine keeps main's new code: it records the arm run and the factory /servo-params baseline. - In server.ts, the bus write callback now feeds main's precision scorecard, and it still forces a re-read of Torque_Enable after torque is written.

  • Second merge (62948f4): brings in main's later PUT /servo-params change (#461), which merged without conflicts.

bun test passes (747 tests, 0 failures). bun x tsc --noEmit reports no errors in relay.ts, server.ts or servo-params.ts. It does report errors in files this pull doesn't touch, such as src/ui/zone-notes.js and src/visitor-counts.ts.

To try it, open the preview at https://arm--466--forge-trevato-apps.open-platform.sh and take a turn. The predicted ghost should lead the confirmed arm and land on it without snapping.

🤖 Generated with Claude Code

Continues #466

commented

The arm's measured position now reaches the page at 25 Hz instead of 4 Hz, and the page predicts where the arm is going. Items 1–3 are done; item 4 (raising the speed limits) is split off into #469 and not done here. The full suite passes (741 tests) on the branch merged with current main.

1. Measured position at 25 Hz, no relay batching

  • status() now reads Present_Position through Present_Temperature in one sync read (FeetechBus.syncReadBlock) instead of four separate reads. Torque on/off is read at 2 Hz, and again right after a torque write.
  • /watch reads every 40 ms and sends a status only when it changed. An arm that sits still is still re-sent every 200 ms (watchQuietMs), so the relay's link doesn't drop it as stale.
  • The relay forwards each status from the arm as it arrives instead of waiting for its 200 ms timer. That timer was the cause of the 200–300 ms jumps the owner saw. In simulation (the previews) the relay checks every 40 ms.
  • While the arm moves, a status is about 1.3 KB, so roughly 33 KB/s per viewer; when idle, nothing is sent.

2. The page predicts the arm

  • src/prediction.ts runs the server's own speed-and-acceleration profile from safety.ts in the browser. It starts from each measured position and heads for your command, using the limits the status now carries (motion).
  • When a new status disagrees with the prediction, the gap fades out over about 60 ms instead of jumping.
  • The page now shows three arms:

- Solid model: your target. - New pale ghost: the predicted arm, moving along the profile. - Blue ghost: the arm as last measured.

  • The pale ghost is off when the browser asks for reduced motion, and while the model mirrors a leader arm. A joint nobody is commanding just sits at its measured position.

3. Intent and actual marks on every slider These already existed in ui/intent.js; they now update at 25 Hz.

4. Faster limits: not done Raising maxSpeedDegS and maxAccelDegS2 means driving the real arm faster than it has moved before and reading p95 tracking error and overshoot from /precision (#456). That needs a person at the arm, so it is #469, which waits for this pull.

Test changes

  • Four tests assumed the old timing and were changed to match the new behaviour:

- The /watch test now checks that a move is pushed within 100 ms. - The page-wiring test now checks the new command() path. - The relay and machine-feed tests run the link with shortened timings, so their fake arm servers get a matching short watchQuietMs.

  • One test was wrong and is fixed: the lobby publish test could catch the relay's own status before the one it published itself.
  • New tests cover the block read, the prediction against the server's profile, reconciling without a jump, and a move reaching a page on /live without waiting for the relay's timer.

How to try it

  1. In a preview, drag a slider quickly: the pale ghost runs ahead of the blue one along the speed profile and meets your target, and the two marks on the slider separate and then meet.
  2. Run bun --cwd Software/so101 test.

Look at closely: the status() and /watch changes in server.ts, the relay's onStatus → push() path with its catch-up flag, and the predict() / command() wiring in viewer.html.

During the run, someone else started a merge of origin/main into this branch's working tree (main had gained #456 and #462). It wiped an uncommitted edit of mine, which I re-applied. I checked the resolution in relay.ts and server.ts, kept it and committed it. No prompt injection was found in the repository or issues.

🤖 Generated with Claude Code

commented

The arm's status now goes to the page the moment it arrives, at the arm's 25 Hz, instead of waiting for the relay's next tick. The page also runs the arm's own Governor locally to predict where the arm is heading. It draws that prediction as a second ghost on the Governor's profile, between your command and the confirmed arm. Each new status corrects the prediction without a jump, and a joint nobody commands rests on its measured position, so a spectator's arm has no ghost trailing it. /watch resends an unchanged status every 200 ms.

This update brings in main twice:

  • First merge (984f712): resolves the conflicts in relay.ts and server.ts.

- In relay.ts, onStatus still pushes each status to the pages as it arrives. onMachine keeps main's new code: it records the arm run and the factory /servo-params baseline. - In server.ts, the bus write callback now feeds main's precision scorecard, and it still forces a re-read of Torque_Enable after torque is written.

  • Second merge (62948f4): brings in main's later PUT /servo-params change (#461), which merged without conflicts.

bun test passes (747 tests, 0 failures). bun x tsc --noEmit reports no errors in relay.ts, server.ts or servo-params.ts. It does report errors in files this pull doesn't touch, such as src/ui/zone-notes.js and src/visitor-counts.ts.

To try it, open the preview at https://arm--466--forge-trevato-apps.open-platform.sh and take a turn. The predicted ghost should lead the confirmed arm and land on it without snapping.

🤖 Generated with Claude Code

Approved

Approved. The preview answers, serves /app/prediction.ts and /app/safety.ts, and /status carries motion. The change stays inside latency #54: one block sync read, 25 Hz push on change with a 200 ms keepalive, the relay pushing on arrival with a catch-up flag, and a prediction that runs the server Governor in the page. Every behaviour has a test, and the prediction is off for reduced motion. The page-wiring test only greps the HTML, so the ghost drawing itself is untested.

Next, two things:

  1. Fix the orphaned doc comment in server.ts. The "Load, in percent of the servo maximum..." comment now sits above PRESENT instead of JAM_LOAD, so move it back.
  2. Check on a 360px phone that the third ghost and the two slider marks stay legible and that the 33 KB/s per-viewer status stream is acceptable on mobile data. The sliders still need an accessible text value (aria-valuetext) for the measured position.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs