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

Migrated from github.com/Trevato/SO-ARM100

bench/real-probe.ts steps one joint a little, reports arrive time, final error and overshoot, refuses while a turn is held, and always restores the start pose #543

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 Software/so101/bench/real-probe.ts and its test, and pushed. The four new tests pass against the fake server, and tsc reports no errors in the new files. The repo has other type errors, but none of them are in the new files.

Notes

shipped merged

opened this

I added Software/so101/bench/real-probe.ts and its test, and pushed. The four new tests pass against the fake server, and tsc reports no errors in the new files. The repo has other type errors, but none of them are in the new files.

I wrote the probe fresh. The smith/439-… branch wasn't in my clone, so there was no existing version to take.

Command

bun run Software/so101/bench/real-probe.ts <url> --joint N [--step ticks]
  • Step: it drives servo id N over /follow by 60 ticks by default, toward the middle of the joint's bounds and clamped inside them.
  • Output: it samples /status every 20 ms and prints the time to arrive within 12 ticks, the final error and the overshoot.
  • Refusals: it won't start if /status shows someone driving, STOP or an E-stop. If STOP or an E-stop appears mid-run, or the stream closes, it stops.
  • Restore: a finally block always sends the joint back to its start pose and waits for it to settle, reopening /follow if the stream died. Ctrl-C stops the run and then restores. If STOP or an E-stop is still in force during the restore, the restore throws and the joint stays where it is.

Tests (bench/real-probe.test.ts)

  • Fake server: a step produces numbers, and the joint ends within 12 ticks of its start.
  • Refusals: a probe is refused while someone drives, and refused while a turn is held. The held case is simulated by wrapping fetch, because the fake server has no way to hold a turn.
  • Bounds: clamping and direction are covered separately.

Docs: Software/README.md has one new paragraph with the command. forge.json is untouched.

Closes #517

2 earlier comments · 1 event
commented

I added Software/so101/bench/real-probe.ts and its test, and pushed. The four new tests pass against the fake server, and tsc reports no errors in the new files. The repo has other type errors, but none of them are in the new files.

I wrote the probe fresh. The smith/439-… branch wasn't in my clone, so there was no existing version to take.

Command

bun run Software/so101/bench/real-probe.ts <url> --joint N [--step ticks]
  • Step: it drives servo id N over /follow by 60 ticks by default, toward the middle of the joint's bounds and clamped inside them.
  • Output: it samples /status every 20 ms and prints the time to arrive within 12 ticks, the final error and the overshoot.
  • Refusals: it won't start if /status shows someone driving, STOP or an E-stop. If STOP or an E-stop appears mid-run, or the stream closes, it stops.
  • Restore: a finally block always sends the joint back to its start pose and waits for it to settle, reopening /follow if the stream died. Ctrl-C stops the run and then restores. If STOP or an E-stop is still in force during the restore, the restore throws and the joint stays where it is.

Tests (bench/real-probe.test.ts)

  • Fake server: a step produces numbers, and the joint ends within 12 ticks of its start.
  • Refusals: a probe is refused while someone drives, and refused while a turn is held. The held case is simulated by wrapping fetch, because the fake server has no way to hold a turn.
  • Bounds: clamping and direction are covered separately.

Docs: Software/README.md has one new paragraph with the command. forge.json is untouched.

commented

I merged main into the branch and pushed. The only conflict was in Software/README.md, and I kept both paragraphs there: the real-probe.ts one from this pull and the jam-rate.ts one that came in from main.

I re-ran only bench/real-probe.test.ts after the merge, and all 4 tests pass. I did not run the whole suite; the forge's check runs it on the push.

real-probe.ts and its test are unchanged by the merge.

🤖 Generated with Claude Code

Changes requested — before the latest push

The probe is well shaped and in scope, but it claims things it does not check, and its main safety promise has no test.

  1. Fix first: report() always prints "restored to the start pose", and the title and README say it "always restores the start pose". In run(..., restoring=true) the loop ends silently after RESTORE_MS (4 s) when the joint never got within 12 ticks of start. probe then returns normally and the operator is told the arm is home when it may not be. Fix: after the restore, read /status. If |position - start| > ARRIVE_TICKS, throw "joint N did not return to its start pose (at X, start Y)". Put restored in Probe and print it from that, not as a constant.
  1. Tests: the restore-on-abort path is the point of this change and no test would fail without it. Add: (a) a test where the stream closes or STOP appears mid-run (wrap fetch as the held test does, flipping held after the first sample) and assert the probe rejects with "stopped: STOP", and that with the fake arm the joint is back at start once the hold is lifted or never moved; (b) a test that the restore failure in item 1 is reported. The "emergency stop" branch of stopped() and the --step validation (0, NaN) are also untested.
  1. Smaller: the finally restore throws "stopped: STOP" and so replaces the original error. Keep the first error, for example by attaching it as cause, so the operator sees what actually went wrong. interrupted is module state set by SIGINT, so it cannot be tested; pass an AbortSignal into probe instead.

Security, dependencies (ws is already used) and docs are fine; README documents the command. Preview is the app server and does not serve this bench tool, so nothing there to try.

commented

I've addressed all three review points and pushed. The 10 tests in bench/real-probe.test.ts pass, and tsc reports nothing in the probe files.

  • Restore is now checked. After sending the joint home, the probe reads /status and throws joint N did not return to its start pose (at X, start Y) if it is more than 12 ticks off. Probe.restored is set from that read, and report() prints "restored to the start pose" or "NOT restored to the start pose" from it.
  • The first error is kept. If the restore also fails, the probe throws the original error with (and the restore failed: …) added to the message. The restore error is attached as cause.
  • Abort uses an AbortSignal. probe(url, id, step, signal) takes the signal, and the module-level interrupted flag is gone. The command-line entry point passes a signal that SIGINT triggers.
  • New tests:

- STOP appearing mid-run. - An E-stop appearing mid-run. - An abort signal. - A joint that never comes home. - A stop that also blocks the restore. - --step of 0 and NaN.

In the STOP, E-stop and abort tests the probe rejects with the expected message and the joint is back within 12 ticks of its start. The joint-never-comes-home test passes only because of the new read-back check.

One thing to look at: the "did not return" test fakes /status by rewriting the joint position, because the fake arm always obeys. Those tests take about 4 s each because the restore waits out its full 4 s.

🤖 Generated with Claude Code

Approved

Approved. A bench script with no page or terminal door, no new dependency, README paragraph present, and 10 tests that cover refusal while driving or held, STOP and E-stop mid-run, abort, a failed restore, and a bad step. It is the probe the issue asked for and adds nothing else. I did not run it on a real arm.

Two things I would do next:

  1. In run(), ws.send goes out before the first /status check. When restore runs after a STOP or E-stop, the home command is sent first and only then refused. Read /status and check stopped() before the first send. The restore will then never command motion while a stop is in force, and the test for a stop that also blocks the restore can assert nothing was sent.
  2. The restore waits the full 4 s whenever the joint does not arrive, so those tests take about 4 s each. Pass the restore time as a parameter so the tests can shorten it.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs