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

Migrated from github.com/Trevato/SO-ARM100

`so101 teleop` drives the follower from the leader in one process at 60 Hz, with a joint table, lag and space to STOP #574

Merged opened this

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

Merged

`so101 teleop [--leader P --follower P] [--hz 60]` now drives the follower from the leader in one process. The tests I ran pass: the new ones plus the existing teleop and readme tests (21 in all). The `tsc` run printed type errors in other files (`src/ui/zone-notes.js`, `src/visitor-counts.ts` and others); I only filtered its output for the files I touched, which showed none. I never ran it agains…

shipped merged

opened this

so101 teleop [--leader P --follower P] [--hz 60] now drives the follower from the leader in one process. The tests I ran pass: the new ones plus the existing teleop and readme tests (21 in all). The tsc run printed type errors in other files (src/ui/zone-notes.js, src/visitor-counts.ts and others); I only filtered its output for the files I touched, which showed none. I never ran it against a real arm, only the fake buses.

  • Ports:

- Both ports open before the terminal goes raw, and one finally closes both ports and the terminal. - A wrong or busy port is a plain error. - Command-line ports win. Otherwise the remembered roles are found by USB serial number, and if they aren't known the error says to run so101 setup. - Setup itself isn't part of this pull.

  • Space and q:

- Space stops the follower, which holds with torque on. - Resuming re-reads where the follower really is and ramps toward the leader by at most RAMP_STEP ticks per frame. - q quits, and the screen says the follower stays holding with torque on.

  • Keys: src/keys.ts keeps a key pressed while nobody waits for the next waiter, and a waiter ends with its signal.
  • Where it lives: the run loop is in src/local-teleop.ts, resolveRoles is in src/arms.ts, and the command and screen are in src/local-teleop-run.ts. I didn't use teleop.ts because it already exists on main for something else.
  • Tests: they use fake buses and cover following, STOP holding, the bounded first step after resume, the key queue, and resolveRoles.
  • Other changes:

- cli.ts now loads server.ts only when serve runs, so the CLI doesn't pull in bun:sqlite at startup. - The new flags are named --leader and --follower, as the issue says. Closed pull #566 used --leader-port and --follower-port. - The README has a "Plug in and play" section with the command and a link to https://huggingface.co/docs/lerobot/so101.

Closes #571

3 earlier comments · 2 events
commented

so101 teleop [--leader P --follower P] [--hz 60] now drives the follower from the leader in one process. The tests I ran pass: the new ones plus the existing teleop and readme tests (21 in all). The tsc run printed type errors in other files (src/ui/zone-notes.js, src/visitor-counts.ts and others); I only filtered its output for the files I touched, which showed none. I never ran it against a real arm, only the fake buses.

  • Ports:

- Both ports open before the terminal goes raw, and one finally closes both ports and the terminal. - A wrong or busy port is a plain error. - Command-line ports win. Otherwise the remembered roles are found by USB serial number, and if they aren't known the error says to run so101 setup. - Setup itself isn't part of this pull.

  • Space and q:

- Space stops the follower, which holds with torque on. - Resuming re-reads where the follower really is and ramps toward the leader by at most RAMP_STEP ticks per frame. - q quits, and the screen says the follower stays holding with torque on.

  • Keys: src/keys.ts keeps a key pressed while nobody waits for the next waiter, and a waiter ends with its signal.
  • Where it lives: the run loop is in src/local-teleop.ts, resolveRoles is in src/arms.ts, and the command and screen are in src/local-teleop-run.ts. I didn't use teleop.ts because it already exists on main for something else.
  • Tests: they use fake buses and cover following, STOP holding, the bounded first step after resume, the key queue, and resolveRoles.
  • Other changes:

- cli.ts now loads server.ts only when serve runs, so the CLI doesn't pull in bun:sqlite at startup. - The new flags are named --leader and --follower, as the issue says. Closed pull #566 used --leader-port and --follower-port. - The README has a "Plug in and play" section with the command and a link to https://huggingface.co/docs/lerobot/so101.

commented

I changed the one test that failed on the preview deploy, the Pi chart draws under-voltage minutes… in src/data-view.test.ts, and pushed. It passed when I ran it locally, so I haven't seen it fail here, and I haven't confirmed the cause. The only difference I found was timing. The test waited a fixed 120 ms for the Pi chart to render, and the failure took 132 ms on a busy deploy machine.

piChart now waits, up to about 5 seconds, until the chart shows a mark or the "none" note, instead of sleeping a fixed time. This is a test fix only. The teleop code is untouched, and nothing in it is near that test.

After the change, src/data-view.test.ts passes in about 0.9 s. I did not rerun the whole suite here; the preview deploy will do that on this push.

Changes requested — before the latest push

Reviewed from the diff; the preview serves the hosted app only, and so101 teleop is a terminal command, so there is nothing in it to try. The loop, the key queue and STOP/resume are well built and tested. Two things block it.

  1. The default path cannot work (fix first). teleop with no ports needs ~/.config/so101/arms.json, but nothing outside the tests writes it. saveRoles has no production caller, and the error and README send people to so101 setup, which does not exist in this pull. So "plug in and play" fails every time unless --leader and --follower are given, and saveRoles is dead code. Pick one: (a) drop saveRoles, configFile and the saved-roles path, and say in the README that the ports are required until setup (#564) lands; or (b) add a small way to write the roles, such as so101 teleop --save after a successful start, with a test. Whichever you pick, the error text and README must not name a command that is missing.
  1. The ramp limits following all the time, not only after a resume. goal is rate-limited to RAMP_STEP (50 ticks) per frame on every frame. At 60 Hz that is about 3000 ticks/s (roughly 260°/s), so a quick leader move is followed late. Neither the lag figure (which times only the read and write) nor the screen shows this. Apply the clamp only for the frames after a resume, until the goal reaches the leader, and then pass the leader reading straight through. Add a test that a fast leader jump during normal running arrives within one frame. Also label the screen column "target", because it shows the written goal and not the follower position.

Smaller: the data-view.test.ts flake fix is unrelated to this issue. It is fine to keep, but it belongs in its own pull next time.

commented

I've pushed changes for both blockers. The tests that cover these changes pass (12 across arms, keys, local-teleop-run and readme); I did not run the full suite or a real arm.

1. The default path now works (option b).

  • so101 teleop --leader P --follower P --save writes both arms' USB serial numbers to arms.json. After that, plain so101 teleop finds them on whichever ports they are plugged into.
  • --save fails with a plain error if either adapter has no serial number, or if both ports are the same adapter. A new helper, rolesOf in src/arms.ts, has its own test.
  • The error and the README now say "pass --leader and --follower (add --save to remember them)". Neither names so101 setup.
  • This departs from the issue's wording, which asked for the 'run: so101 setup' error. I followed your rule that the text must not name a missing command. When setup lands, that string can go back in one line.
  • One line in the README's story paragraph (line 31, already on main) still says bun so101 setup. I left it alone because it isn't part of this pull.

2. The ramp is now only for a start or resume.

  • The goal is clamped to RAMP_STEP per frame only after the start or a resume. Once the goal equals the leader reading, the reading goes straight through.
  • A new test makes a 900-tick leader jump during normal running and checks that the follower arrives within a few frames. The ramped path would have taken about 18.
  • The screen column is now labelled "target".

Flake fix. Agreed that the data-view.test.ts fix belongs in its own pull. I'll keep it separate next time.

Changes requested — before the latest push

The teleop itself is sound. The run loop is small, the ramp applies only to a start or a resume, STOP holds with torque on, and the key queue and role resolution are tested. This is a CLI feature with no page or terminal door, so the preview has nothing to exercise and I judged the diff only. One thing to fix first: the pull carries a change that is not the issue. src/data-view.test.ts rewrites the piChart wait to fix a flaky Pi chart test, which has nothing to do with teleop. The author said in the thread that it belongs in its own pull, but it is still here. Revert that hunk and open a separate small pull for the flake. Two smaller points, which can be fixed in this pull or opened as issues: (1) teleop() and terminalKeys() have no test, and teleopScreen is only checked through one substring, so a screen regression would pass. Add a test that the STOPPED line and the joint rows render. (2) configFile falls back to FORGE_APP_DATA, which the issue did not ask for and which does not belong in a Pi-side CLI. Drop it, or say why it is there. Also, --save compares the typed path against the adapter list, so /dev/tty.usbmodem* on macOS never matches the cu.* path. Run it through calloutDevice first.

commented

I've pushed the fixes. The tests for what I changed pass (src/arms.test.ts and src/local-teleop.test.ts, 8 tests), and tsc shows no errors in arms or local-teleop. I didn't run the whole suite or try it on a real arm.

  • Unrelated change: I reverted src/data-view.test.ts to main, so the flake fix is out of this pull. I can't open a pull from here, so the flake still needs its own small pull. The Pi chart test waits a fixed 120 ms for the chart to render and can fail on a busy machine.
  • FORGE_APP_DATA: I removed it from configFile in src/arms.ts. The saved arms now live in $SO101_HOME or ~/.config/so101/arms.json.
  • --save on macOS: rolesOf now runs both typed paths through calloutDevice before comparing, so /dev/tty.usbmodemX matches /dev/cu.usbmodemX. A new test covers this.
  • Screen test: The new tests in src/local-teleop.test.ts check that the screen shows six joint rows with the leader reading and the target. A joint with no target shows -. They also check the lag line, the live "press SPACE to STOP" line, and the full STOPPED line.
  • Still untested: teleop() and terminalKeys() have no tests, since both open real ports and a raw terminal. driveScreen and the key queue are tested.
Approved

Approved. The preview answers 200 on /. This is a CLI-only change in Software/so101, so there is no new page or terminal door to check, and no web, auth or request-body surface changed. I did not run tests or a real arm. The tests cover following, STOP holding, the bounded resume ramp, the key queue, role resolution and the screen. The README documents the command, and the CLI now loads server.ts lazily so Node does not hit bun:sqlite.

Two things to do next:

  1. Add a test for the target column while stopped. onTick still reports the mapped leader target even though nothing is sent, so the screen shows a target the follower is not chasing. Show - while stopped, or label it.
  2. The follow tests use real timers at 200 Hz with 40-60 ms settles, and the pull already hit one timing flake on a busy deploy machine. Poll for the condition instead of sleeping a fixed time. Also open the separate small pull for the data-view.test.ts flake, and restore the setup-pointing error wording when #564 lands.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs