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

Migrated from github.com/Trevato/SO-ARM100

setup: find LeRobot calibration in its nested folders (calibration/robots/so_follower/*.json) #577

Merged opened this in answer to

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

Merged

`so101 setup` now finds LeRobot's calibration files in their nested folders, such as `calibration/robots/so_follower/so101_follower.json`. It shows which file it found and reuses it. I didn't run it against the owner's real Mac layout. The new tests and the existing `setup` tests pass. `tsc --noEmit` reports errors in other files that I left alone, none in the files I touched.

shipped merged

opened this

so101 setup now finds LeRobot's calibration files in their nested folders, such as calibration/robots/so_follower/so101_follower.json. It shows which file it found and reuses it. I didn't run it against the owner's real Mac layout. The new tests and the existing setup tests pass. tsc --noEmit reports errors in other files that I left alone, none in the files I touched.

  • Search: newestLerobotFile in arm-calibration.ts looks under calibration/{robots,teleoperators} to a depth of four folders and picks the newest .json. newestLerobot parses whichever file it picks.
  • HF_LEROBOT_CALIBRATION: when it is set, lerobotDirs reads $HF_LEROBOT_CALIBRATION/{robots,teleoperators} and ignores the other cache locations. I read the variable as the calibration folder itself, not the LeRobot cache root. Say if you meant the other.
  • Visibility: the dry run now prints N joints found in <path>. The calibration step on a real run prints Reference: <path> after its summary.
  • Tests: in arm-calibration.test.ts, one covers the nested layout (finds the file, parses the joints, and gives no result when teleoperators is empty), and one covers the HF_LEROBOT_CALIBRATION path.

Closes #576

2 earlier comments · 1 event
commented

so101 setup now finds LeRobot's calibration files in their nested folders, such as calibration/robots/so_follower/so101_follower.json. It shows which file it found and reuses it. I didn't run it against the owner's real Mac layout. The new tests and the existing setup tests pass. tsc --noEmit reports errors in other files that I left alone, none in the files I touched.

  • Search: newestLerobotFile in arm-calibration.ts looks under calibration/{robots,teleoperators} to a depth of four folders and picks the newest .json. newestLerobot parses whichever file it picks.
  • HF_LEROBOT_CALIBRATION: when it is set, lerobotDirs reads $HF_LEROBOT_CALIBRATION/{robots,teleoperators} and ignores the other cache locations. I read the variable as the calibration folder itself, not the LeRobot cache root. Say if you meant the other.
  • Visibility: the dry run now prints N joints found in <path>. The calibration step on a real run prints Reference: <path> after its summary.
  • Tests: in arm-calibration.test.ts, one covers the nested layout (finds the file, parses the joints, and gives no result when teleoperators is empty), and one covers the HF_LEROBOT_CALIBRATION path.
commented

so101 setup now finds LeRobot's calibration in its nested folders, such as calibration/robots/so_follower/*.json. It shows which file it found and reuses it to map the leader onto the follower.

  • Search: it looks under calibration/{robots,teleoperators}, up to four folders deep, and takes the newest .json. When HF_LEROBOT_CALIBRATION is set, it treats that as the calibration folder (so $HF_LEROBOT_CALIBRATION/robots, /teleoperators) and ignores the other cache locations. Say if you meant a different root.
  • Display: the dry run prints N joints found in <path>. A real run prints Reference: <path> after the calibration summary. The code is in arm-calibration.ts and setup.ts.
  • Tests: arm-calibration.test.ts covers the nested layout and the HF_LEROBOT_CALIBRATION path. I haven't run setup against a real Mac layout.
  • Failed preview deploy: the failure was in data-view.test.ts (the Pi under-voltage chart), not in anything I changed. The test waited a fixed 120 ms for the chart to draw, which is too short on a loaded machine. It passed three times in a row when run alone here. I changed the test to wait until the chart is drawn, so the test was wrong, not the code. I did not re-run the full suite, so the forge's check on this push is the confirmation.
Changes requested — before the latest push

The nested search is the right fix and the two new tests cover it. Two things fail the bar.

  1. Fix first: the new behaviour is undocumented and partly untested. Software/so101/README.md:15 still says calibration lives in ~/.cache/huggingface/lerobot/calibration/. It says nothing about nested folders, the depth limit, or the new HF_LEROBOT_CALIBRATION variable, which changes where setup reads from. Add both to the README. No test covers the new dryRun line (N joints found in <path>) or the Reference: <path> line in ensureCalibrated. Both are behaviour the issue asked for, and they would not fail if removed. Test dryRun through its write callback, which takes a fake writer.
  1. The file is walked twice, once for the path and once inside newestLerobot. Another run can change the directory between the two walks, so the displayed Reference: file may not be the one parsed. Make one function return {file, calibration} and use it in both setup.ts call sites.

Smaller: the (best as { file: string } | null)?.file cast only works around closure narrowing. Have walk return the best file instead. One unreadable subfolder currently aborts the whole search, because the try/catch wraps the entire walk. Catch per directory so a sibling's file is still found.

The data-view.test.ts change is outside this issue. It is a reasonable fix for a flaky test, but it belongs in its own small pull. Keep it here only if you leave the explanation in the pull.

This is a CLI change, so the preview has nothing to show and the web and tty doors do not apply.

commented

All of juniper's points are addressed except the data-view.test.ts change, which stays in this pull with its explanation. The arm-calibration and setup tests pass, and tsc reports nothing in the files I touched. I didn't run the full suite, so the forge's check on this push is the confirmation.

  • One walk: findLerobot(dir) in arm-calibration.ts returns {file, calibration}. Both call sites in setup.ts use it, so the Reference: file is the one that was parsed.
  • Walk cleanup: the walk returns the best file directly, so the cast is gone. An unreadable folder is skipped on its own and its siblings are still searched.
  • README: Software/so101/README.md now describes the nested search, the four-folder depth limit, that setup prints the file it uses, and HF_LEROBOT_CALIBRATION. That variable replaces the default location when set.
  • Tests:

- A dryRun test uses a fake writer and checks the N joints found in <path> line and the "none found" line. - An ensureCalibrated test checks the Reference: <path> line. - A search test checks that the newest file wins across folders and that anything past the depth limit is ignored.

  • Left in on purpose: the data-view.test.ts change. The Pi under-voltage chart test waited a fixed 120 ms for the chart to draw, which is too short on a loaded machine and failed the preview deploy once. It now waits until the chart is drawn. I left it here instead of splitting it out so this pull's deploy goes green; I can move it to its own pull if you'd rather.
Approved

Approved. The change does what #576 asks. setup searches calibration/{robots,teleoperators} up to four folders deep, respects HF_LEROBOT_CALIBRATION, names the file it uses in both the dry run and the real run, and reuses that same file because there is now only one walk.

I applied the head diff to a copy of Software/so101. bun test on arm-calibration, setup and data-view gives 19 passed and 0 failed, and tsc reports nothing in the touched files. Each new test would fail without the change: the nested layout, the env override, newest-wins with the depth cut-off, the dryRun line, and the Reference: line.

Security: this is a local CLI that reads only the user's own cache. Nothing is shelled out or written. Symlinked directories are not followed (isDirectory() on a Dirent is false for symlinks), so a loop cannot hang the walk. The depth cap bounds the search, and an unreadable folder is skipped on its own. The preview at this head answers / with 200 and keeps CSP, nosniff and Referrer-Policy. This pull changes nothing on the web or in the tty, so those doors are untouched.

The data-view.test.ts wait is out of scope, but it is explained in the pull and is a test-only fix. That is acceptable.

One low-severity point is inline: "newest anywhere" can pick another device's calibration. It is not blocking.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs