macbot 0.1.0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. {macbot-0.1.0 → macbot-0.2.0}/PKG-INFO +18 -32
  2. {macbot-0.1.0 → macbot-0.2.0}/README.md +11 -31
  3. {macbot-0.1.0 → macbot-0.2.0}/macbot/__init__.py +1 -1
  4. {macbot-0.1.0 → macbot-0.2.0}/macbot/cameras/__init__.py +49 -5
  5. {macbot-0.1.0 → macbot-0.2.0}/macbot/cli.py +64 -29
  6. {macbot-0.1.0 → macbot-0.2.0}/macbot/collect/checks.py +8 -6
  7. {macbot-0.1.0 → macbot-0.2.0}/macbot/collect/server.py +78 -57
  8. {macbot-0.1.0 → macbot-0.2.0}/macbot/config.py +6 -4
  9. {macbot-0.1.0 → macbot-0.2.0}/macbot/data/export.py +43 -15
  10. {macbot-0.1.0 → macbot-0.2.0}/macbot/data/health.py +18 -12
  11. {macbot-0.1.0 → macbot-0.2.0}/macbot/default.yaml +7 -1
  12. macbot-0.2.0/macbot/doctor.py +191 -0
  13. {macbot-0.1.0 → macbot-0.2.0}/macbot/policy/bench.py +8 -3
  14. {macbot-0.1.0 → macbot-0.2.0}/macbot/policy/executors.py +5 -3
  15. {macbot-0.1.0 → macbot-0.2.0}/macbot/policy/models.py +12 -1
  16. {macbot-0.1.0 → macbot-0.2.0}/macbot/policy/runner.py +108 -67
  17. macbot-0.2.0/macbot/robot/__init__.py +33 -0
  18. macbot-0.2.0/macbot/robot/base.py +97 -0
  19. macbot-0.2.0/macbot/robot/fake.py +112 -0
  20. {macbot-0.1.0 → macbot-0.2.0}/macbot/robot/gravity.py +4 -4
  21. macbot-0.2.0/macbot/robot/lerobot_generic.py +154 -0
  22. {macbot-0.1.0 → macbot-0.2.0}/macbot/robot/rebot.py +42 -1
  23. macbot-0.2.0/macbot/robot/sim.py +110 -0
  24. {macbot-0.1.0 → macbot-0.2.0}/macbot/viz/video.py +2 -2
  25. {macbot-0.1.0 → macbot-0.2.0}/macbot/web/static/common.js +15 -7
  26. {macbot-0.1.0 → macbot-0.2.0}/macbot/web/templates/collect.html +5 -2
  27. {macbot-0.1.0 → macbot-0.2.0}/macbot/web/templates/run.html +11 -8
  28. {macbot-0.1.0 → macbot-0.2.0}/macbot.egg-info/PKG-INFO +18 -32
  29. {macbot-0.1.0 → macbot-0.2.0}/macbot.egg-info/SOURCES.txt +6 -1
  30. {macbot-0.1.0 → macbot-0.2.0}/macbot.egg-info/requires.txt +7 -0
  31. {macbot-0.1.0 → macbot-0.2.0}/pyproject.toml +17 -2
  32. {macbot-0.1.0 → macbot-0.2.0}/tests/test_core.py +21 -1
  33. macbot-0.2.0/tests/test_doctor.py +134 -0
  34. macbot-0.2.0/tests/test_generic_robots.py +152 -0
  35. macbot-0.1.0/macbot/doctor.py +0 -86
  36. macbot-0.1.0/macbot/robot/__init__.py +0 -3
  37. macbot-0.1.0/macbot/robot/fake.py +0 -63
  38. {macbot-0.1.0 → macbot-0.2.0}/LICENSE +0 -0
  39. {macbot-0.1.0 → macbot-0.2.0}/macbot/cameras/swift/uvc_stream.swift +0 -0
  40. {macbot-0.1.0 → macbot-0.2.0}/macbot/collect/__init__.py +0 -0
  41. {macbot-0.1.0 → macbot-0.2.0}/macbot/data/__init__.py +0 -0
  42. {macbot-0.1.0 → macbot-0.2.0}/macbot/i18n.py +0 -0
  43. {macbot-0.1.0 → macbot-0.2.0}/macbot/policy/__init__.py +0 -0
  44. {macbot-0.1.0 → macbot-0.2.0}/macbot/policy/gripper.py +0 -0
  45. {macbot-0.1.0 → macbot-0.2.0}/macbot/system.py +0 -0
  46. {macbot-0.1.0 → macbot-0.2.0}/macbot/viz/__init__.py +0 -0
  47. {macbot-0.1.0 → macbot-0.2.0}/macbot/viz/replay.py +0 -0
  48. {macbot-0.1.0 → macbot-0.2.0}/macbot/web/__init__.py +0 -0
  49. {macbot-0.1.0 → macbot-0.2.0}/macbot/web/static/fonts/JetBrainsMono.ttf +0 -0
  50. {macbot-0.1.0 → macbot-0.2.0}/macbot/web/static/fonts/OFL-JetBrainsMono.txt +0 -0
  51. {macbot-0.1.0 → macbot-0.2.0}/macbot/web/static/logo-dark.svg +0 -0
  52. {macbot-0.1.0 → macbot-0.2.0}/macbot/web/static/logo-mark.svg +0 -0
  53. {macbot-0.1.0 → macbot-0.2.0}/macbot/web/static/logo.svg +0 -0
  54. {macbot-0.1.0 → macbot-0.2.0}/macbot/web/static/theme.css +0 -0
  55. {macbot-0.1.0 → macbot-0.2.0}/macbot/web/templates/_head.html +0 -0
  56. {macbot-0.1.0 → macbot-0.2.0}/macbot/web/templates/replay.html +0 -0
  57. {macbot-0.1.0 → macbot-0.2.0}/macbot.egg-info/dependency_links.txt +0 -0
  58. {macbot-0.1.0 → macbot-0.2.0}/macbot.egg-info/entry_points.txt +0 -0
  59. {macbot-0.1.0 → macbot-0.2.0}/macbot.egg-info/top_level.txt +0 -0
  60. {macbot-0.1.0 → macbot-0.2.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: macbot
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Real-robot learning on a MacBook: teleoperate, record, export to LeRobot and run ACT / pi0.5 on Apple silicon.
5
5
  Author: MuQY1818
6
6
  License-Expression: Apache-2.0
@@ -28,8 +28,14 @@ Provides-Extra: orbbec
28
28
  Requires-Dist: pyorbbecsdk2; extra == "orbbec"
29
29
  Provides-Extra: pi
30
30
  Requires-Dist: lerobot[pi]==0.7.0; extra == "pi"
31
+ Provides-Extra: sim
32
+ Requires-Dist: mujoco==3.3.7; extra == "sim"
31
33
  Provides-Extra: dev
32
34
  Requires-Dist: pytest; extra == "dev"
35
+ Requires-Dist: pyflakes; extra == "dev"
36
+ Requires-Dist: ruff==0.14.14; extra == "dev"
37
+ Requires-Dist: build; extra == "dev"
38
+ Requires-Dist: pre-commit; extra == "dev"
33
39
  Dynamic: license-file
34
40
 
35
41
  <p align="center">
@@ -82,8 +88,8 @@ Measured on a MacBook Pro (M5 Pro, 48 GB), PyTorch MPS:
82
88
  slow two-stage return to zero, and every trial saved with video and timing.
83
89
  - **Replay** of saved trials (all cameras in sync, command vs. measured traces, chunk boundaries) and
84
90
  side-by-side **MP4** export.
85
- - **`macbot doctor`** checks packages, MPS, the CAN driver, cameras and calibration before you start.
86
- - **`--fake`** on every robot command: simulated arm and cameras, so the whole pipeline runs on any Mac.
91
+ - **`macbot doctor`** checks packages, MPS and the configured robot and cameras before you start.
92
+ - **`--fake`** on `collect` and `run` substitutes a fake arm and cameras; `run` still runs the policy.
87
93
  - English and Chinese in every web page (toggle in the top bar), light and dark mode.
88
94
 
89
95
  | Run a policy | Replay a trial |
@@ -92,17 +98,10 @@ Measured on a MacBook Pro (M5 Pro, 48 GB), PyTorch MPS:
92
98
 
93
99
  ## Hardware
94
100
 
95
- | | Used here | Notes |
96
- |---|---|---|
97
- | Follower arm | Seeed reBot B601-RS | driven through LeRobot's `rebot_b601_follower` |
98
- | Leader arm | Seeed reBot Arm 102 | USB serial |
99
- | CAN adapter | PEAK PCAN-USB | macOS driver: PCBUSB |
100
- | Scene camera | any UVC webcam (1080p) | opened by AVFoundation uniqueID |
101
- | Wrist camera | Orbbec Gemini 2 | color stream through `pyorbbecsdk2` |
102
- | Computer | MacBook Pro, Apple silicon | 32 GB+ memory recommended for π0.5 |
103
-
104
- Other arms that LeRobot supports can be added in `macbot/robot/`; the consoles only need `connect`,
105
- `get_observation`, `send_action` and `disconnect`.
101
+ The reBot B601-RS is the reference arm tested on hardware. See [robot support](docs/robots.md)
102
+ for the SO-100/101 and other compatible LeRobot arms, the local simulator, and what has been
103
+ verified. The [setup guide](docs/setup.md) covers drivers and cameras. For π0.5, we recommend
104
+ an Apple silicon Mac with at least 32 GB of memory.
106
105
 
107
106
  ## Quick start
108
107
 
@@ -116,7 +115,8 @@ macbot collect --fake # the collection console with a simulated
116
115
  ```
117
116
 
118
117
  Open <http://127.0.0.1:8766>. Press **S** to record, **Enter** to save, **←** to discard.
119
- For the real robot, install the PCAN driver and set your camera IDs first: see [docs/setup.md](https://github.com/MuQY1818/macbot/blob/main/docs/setup.md).
118
+ For MuJoCo, use `pip install -e '.[sim]'` in the source checkout, then
119
+ `macbot --config configs/so101_sim.yaml collect`. For hardware, follow [setup](docs/setup.md).
120
120
 
121
121
  ## Workflow
122
122
 
@@ -146,24 +146,10 @@ back to [macbot/default.yaml](https://github.com/MuQY1818/macbot/blob/main/macbo
146
146
  skipped, which saves about 80 s per load.
147
147
  - **Files written as root** are handed back to the user who ran `sudo`.
148
148
 
149
- ## Repository layout
149
+ ## Contributing
150
150
 
151
- ```
152
- macbot/
153
- cli.py entry point: macbot <command>
154
- default.yaml every setting, with comments
155
- robot/ reBot follower with feedforward, leader, safe shutdown, simulated arm
156
- cameras/ UVC (Swift helper), Orbbec, simulated cameras
157
- collect/ collection server and episode checks
158
- data/ export to LeRobot, data health report
159
- policy/ ACT / π0.5 wrappers, execution schemes, binary gripper, runner, benchmark
160
- viz/ trial replay server, MP4 export
161
- web/ pages, theme, shared scripts (en / zh)
162
- train/ lerobot-train with openpi-style augmentation, example launch scripts
163
- scripts/ double-click launchers for Finder
164
- tools/ logo generator, screenshot renderer
165
- tests/ fast tests without hardware
166
- ```
151
+ See [CONTRIBUTING](CONTRIBUTING.md) for development and hardware reports,
152
+ [architecture](docs/architecture.md) for the code layout, and the [roadmap](ROADMAP.md) for planned work.
167
153
 
168
154
  ## Safety
169
155
 
@@ -48,8 +48,8 @@ Measured on a MacBook Pro (M5 Pro, 48 GB), PyTorch MPS:
48
48
  slow two-stage return to zero, and every trial saved with video and timing.
49
49
  - **Replay** of saved trials (all cameras in sync, command vs. measured traces, chunk boundaries) and
50
50
  side-by-side **MP4** export.
51
- - **`macbot doctor`** checks packages, MPS, the CAN driver, cameras and calibration before you start.
52
- - **`--fake`** on every robot command: simulated arm and cameras, so the whole pipeline runs on any Mac.
51
+ - **`macbot doctor`** checks packages, MPS and the configured robot and cameras before you start.
52
+ - **`--fake`** on `collect` and `run` substitutes a fake arm and cameras; `run` still runs the policy.
53
53
  - English and Chinese in every web page (toggle in the top bar), light and dark mode.
54
54
 
55
55
  | Run a policy | Replay a trial |
@@ -58,17 +58,10 @@ Measured on a MacBook Pro (M5 Pro, 48 GB), PyTorch MPS:
58
58
 
59
59
  ## Hardware
60
60
 
61
- | | Used here | Notes |
62
- |---|---|---|
63
- | Follower arm | Seeed reBot B601-RS | driven through LeRobot's `rebot_b601_follower` |
64
- | Leader arm | Seeed reBot Arm 102 | USB serial |
65
- | CAN adapter | PEAK PCAN-USB | macOS driver: PCBUSB |
66
- | Scene camera | any UVC webcam (1080p) | opened by AVFoundation uniqueID |
67
- | Wrist camera | Orbbec Gemini 2 | color stream through `pyorbbecsdk2` |
68
- | Computer | MacBook Pro, Apple silicon | 32 GB+ memory recommended for π0.5 |
69
-
70
- Other arms that LeRobot supports can be added in `macbot/robot/`; the consoles only need `connect`,
71
- `get_observation`, `send_action` and `disconnect`.
61
+ The reBot B601-RS is the reference arm tested on hardware. See [robot support](docs/robots.md)
62
+ for the SO-100/101 and other compatible LeRobot arms, the local simulator, and what has been
63
+ verified. The [setup guide](docs/setup.md) covers drivers and cameras. For π0.5, we recommend
64
+ an Apple silicon Mac with at least 32 GB of memory.
72
65
 
73
66
  ## Quick start
74
67
 
@@ -82,7 +75,8 @@ macbot collect --fake # the collection console with a simulated
82
75
  ```
83
76
 
84
77
  Open <http://127.0.0.1:8766>. Press **S** to record, **Enter** to save, **←** to discard.
85
- For the real robot, install the PCAN driver and set your camera IDs first: see [docs/setup.md](https://github.com/MuQY1818/macbot/blob/main/docs/setup.md).
78
+ For MuJoCo, use `pip install -e '.[sim]'` in the source checkout, then
79
+ `macbot --config configs/so101_sim.yaml collect`. For hardware, follow [setup](docs/setup.md).
86
80
 
87
81
  ## Workflow
88
82
 
@@ -112,24 +106,10 @@ back to [macbot/default.yaml](https://github.com/MuQY1818/macbot/blob/main/macbo
112
106
  skipped, which saves about 80 s per load.
113
107
  - **Files written as root** are handed back to the user who ran `sudo`.
114
108
 
115
- ## Repository layout
109
+ ## Contributing
116
110
 
117
- ```
118
- macbot/
119
- cli.py entry point: macbot <command>
120
- default.yaml every setting, with comments
121
- robot/ reBot follower with feedforward, leader, safe shutdown, simulated arm
122
- cameras/ UVC (Swift helper), Orbbec, simulated cameras
123
- collect/ collection server and episode checks
124
- data/ export to LeRobot, data health report
125
- policy/ ACT / π0.5 wrappers, execution schemes, binary gripper, runner, benchmark
126
- viz/ trial replay server, MP4 export
127
- web/ pages, theme, shared scripts (en / zh)
128
- train/ lerobot-train with openpi-style augmentation, example launch scripts
129
- scripts/ double-click launchers for Finder
130
- tools/ logo generator, screenshot renderer
131
- tests/ fast tests without hardware
132
- ```
111
+ See [CONTRIBUTING](CONTRIBUTING.md) for development and hardware reports,
112
+ [architecture](docs/architecture.md) for the code layout, and the [roadmap](ROADMAP.md) for planned work.
133
113
 
134
114
  ## Safety
135
115
 
@@ -1,3 +1,3 @@
1
1
  """macbot: real-robot learning on a MacBook. Teleoperate, record, export to LeRobot and run policies on Apple silicon."""
2
2
 
3
- __version__ = "0.1.0"
3
+ __version__ = "0.2.0"
@@ -5,6 +5,7 @@
5
5
  The helper crops, encodes JPEG and stamps the capture time.
6
6
  * ``OrbbecColor``: color stream of an Orbbec Gemini 2 through ``pyorbbecsdk`` (needs sudo on macOS).
7
7
  * ``FakeCamera``: moving test pattern for ``--fake`` runs.
8
+ * ``RobotCamera``: a rendered frame published by the simulation control loop.
8
9
 
9
10
  All share one interface: ``latest() -> (BGR image, capture time)`` and ``close()``.
10
11
  """
@@ -208,15 +209,55 @@ class FakeCamera(_Latest):
208
209
 
209
210
 
210
211
  def _source_size(c: dict) -> tuple[int, int]:
211
- if c.get("crop"):
212
- x0, y0, x1, y1 = c["crop"]
212
+ """Size of the frames a camera delivers: the crop box, or the full frame ([0, 0, 0, 0] = no crop)."""
213
+ if crop := _crop_box(c):
214
+ x0, y0, x1, y1 = crop
213
215
  return x1 - x0, y1 - y0
214
- return tuple(c.get("expect_size") or (1280, 720))
216
+ if c["type"] == "robot":
217
+ return tuple(c["save_size"])
218
+ return tuple(c.get("expect_size") or ((1920, 1080) if c.get("type") == "uvc" else (1280, 720)))
219
+
220
+
221
+ def _crop_box(c):
222
+ x0, y0, x1, y1 = c.get("crop") or [0, 0, 0, 0]
223
+ return [x0, y0, x1, y1] if x1 > x0 and y1 > y0 else None
224
+
225
+
226
+ class RobotCamera:
227
+ def __init__(self, robot, name, cfg):
228
+ self.robot, self.key, self.crop = robot, cfg.get("key", name), _crop_box(cfg)
229
+ shapes = getattr(robot, "camera_shapes", {})
230
+ if self.key not in shapes:
231
+ raise ValueError(f"camera {name}: robot observation lacks {self.key!r}; available: {', '.join(shapes)}")
232
+ h, w, channels = shapes[self.key]
233
+ if channels != 3:
234
+ raise ValueError(f"camera {name}: expected an HWC RGB observation")
235
+ if self.crop:
236
+ x0, y0, x1, y1 = self.crop
237
+ if not (0 <= x0 < x1 <= w and 0 <= y0 < y1 <= h):
238
+ raise ValueError(f"camera {name}: crop {self.crop} lies outside {w}x{h}")
239
+
240
+ def latest(self):
241
+ img, stamp = self.robot.camera_frame(self.key)
242
+ if img is not None and self.crop:
243
+ x0, y0, x1, y1 = self.crop
244
+ img = img[y0:y1, x0:x1]
245
+ return img, stamp
246
+
247
+ def age(self):
248
+ img, stamp = self.latest()
249
+ return None if img is None else time.time() - stamp
250
+
251
+ def close(self):
252
+ pass
215
253
 
216
254
 
217
- def open_cameras(cams_cfg: dict, fps: int, fake: bool) -> dict:
255
+ def open_cameras(cams_cfg: dict, fps: int, fake: bool, robot=None) -> dict:
218
256
  """Open every camera in the ``cameras`` config section. Closes what was opened if one fails."""
219
257
  out = {}
258
+ if getattr(robot, "kind", None) == "sim" and (
259
+ not cams_cfg or any(c["type"] != "robot" for c in cams_cfg.values())):
260
+ raise ValueError("simulation requires cameras with type: robot")
220
261
  try:
221
262
  for name, c in cams_cfg.items():
222
263
  if fake:
@@ -225,6 +266,8 @@ def open_cameras(cams_cfg: dict, fps: int, fake: bool) -> dict:
225
266
  out[name] = UVCCamera(c["unique_id"], c.get("crop"), fps, name)
226
267
  elif c["type"] == "orbbec":
227
268
  out[name] = OrbbecColor(tuple(c.get("expect_size", (1280, 720))), name)
269
+ elif c["type"] == "robot":
270
+ out[name] = RobotCamera(robot, name, c)
228
271
  else:
229
272
  raise ValueError(f"camera {name}: unknown type {c['type']}")
230
273
  except Exception:
@@ -235,5 +278,6 @@ def open_cameras(cams_cfg: dict, fps: int, fake: bool) -> dict:
235
278
 
236
279
 
237
280
  def camera_info(cams_cfg: dict) -> dict:
238
- return {k: {"type": c["type"], "unique_id": c.get("unique_id"), "crop": c.get("crop"), "size": c["save_size"]}
281
+ return {k: {"type": c["type"], "unique_id": c.get("unique_id"), "crop": _crop_box(c), "size": c["save_size"],
282
+ **({"key": c.get("key", k)} if c["type"] == "robot" else {})}
239
283
  for k, c in cams_cfg.items()}
@@ -1,8 +1,9 @@
1
1
  """Command line entry point: ``macbot <command>``.
2
2
 
3
- macbot doctor check the Mac: Python packages, MPS, PCAN driver, cameras, sudo
3
+ macbot doctor check dependencies, the configured robot and cameras
4
4
  macbot cameras list video devices with their uniqueIDs
5
5
  macbot joints read leader and follower joint angles without powering anything
6
+ macbot robots list the LeRobot arm types macbot can drive (robot.type: lerobot)
6
7
  macbot collect [--fake] teleoperate and record episodes (web page)
7
8
  macbot export convert recorded episodes to a LeRobot dataset
8
9
  macbot health per-episode tracking and timing report of recorded data
@@ -11,8 +12,8 @@
11
12
  macbot video ROLLOUT export a rollout as a side-by-side MP4
12
13
  macbot bench --policy DIR time policy inference on this Mac
13
14
 
14
- Robot commands need ``sudo -E`` on macOS (the Orbbec SDK requires root). Everything that does not
15
- touch the hardware runs as a normal user, and ``--fake`` simulates robot and cameras.
15
+ On macOS the Orbbec SDK requires ``sudo -E``. Simulation, fake mode and UVC-only setups run
16
+ without sudo when the robot driver permits it.
16
17
  """
17
18
  from __future__ import annotations
18
19
 
@@ -20,7 +21,6 @@ import argparse
20
21
  import sys
21
22
 
22
23
 
23
-
24
24
  def _cfg(args):
25
25
  from .config import load
26
26
  return load(args.config)
@@ -42,28 +42,62 @@ def cmd_cameras(args):
42
42
 
43
43
 
44
44
  def cmd_joints(args):
45
- from .system import preload_pcan
46
- preload_pcan()
47
- from .config import JOINTS
48
- from .robot.rebot import make_leader, read_joints_passive
49
45
  cfg = _cfg(args)
50
- leader = make_leader(leader_id=cfg["robot"].get("leader_id", "rebot_arm_102_leader"))
51
- leader.connect(calibrate=False) # leader: unlock (torque off) and reset turn counters; it does not move
52
- act = leader.get_action()
53
- leader.disconnect()
54
- fol = read_joints_passive(cfg["robot"])
55
- print(f"{'joint':14s} {'leader':>8s} {'follower':>9s} {'diff':>8s}")
56
- for n in JOINTS:
57
- a, f = act[f"{n}.pos"], fol[n]
58
- print(f"{n:14s} {a:8.1f} {f:9.1f} {a - f:+8.1f}")
46
+ rcfg = cfg["robot"]
47
+ if rcfg.get("type") == "sim":
48
+ raise SystemExit("use collect or run to see simulated joints")
49
+ if rcfg.get("type", "rebot_b601") == "rebot_b601":
50
+ _preload(cfg)
51
+ from .robot.rebot import JOINTS, make_leader, read_joints_passive
52
+ leader = make_leader(leader_id=rcfg.get("leader_id", "rebot_arm_102_leader"))
53
+ leader.connect(calibrate=False) # leader: unlock (torque off) and reset turn counters; it does not move
54
+ act = leader.get_action()
55
+ leader.disconnect()
56
+ fol = read_joints_passive(rcfg)
57
+ print(f"{'joint':14s} {'leader':>8s} {'follower':>9s} {'diff':>8s}")
58
+ for n in JOINTS:
59
+ a, f = act[f"{n}.pos"], fol[n]
60
+ print(f"{n:14s} {a:8.1f} {f:9.1f} {a - f:+8.1f}")
61
+ return
62
+ # Generic LeRobot arms: only the leader is read. Connecting a follower enables its torque, and
63
+ # disconnecting it again would let the arm drop, so it is not touched here.
64
+ from .robot.lerobot_generic import joint_names, make_leader, require_calibration
65
+ if not rcfg.get("leader"):
66
+ raise SystemExit("robot.leader is not set")
67
+ leader = make_leader(rcfg["leader"])
68
+ require_calibration(leader)
69
+ try:
70
+ leader.connect(calibrate=False)
71
+ act = leader.get_action()
72
+ finally:
73
+ if leader.is_connected:
74
+ leader.disconnect()
75
+ for n in joint_names(leader):
76
+ print(f"{n:16s} {act[f'{n}.pos']:8.1f}")
77
+
78
+
79
+ def cmd_robots(args):
80
+ from .robot.lerobot_generic import known_types
81
+ robots, teleops = known_types()
82
+ print("robot.type: rebot_b601 (reference profile), sim (local simulation), or lerobot:\n")
83
+ print("registered follower types:", ", ".join(r for r in robots if r != "sim"))
84
+ print("leaders: ", ", ".join(teleops))
85
+ print("\nInstall the driver extra for your robot; e.g. pip install 'lerobot[feetech]==0.7.0' for SO-100/101.")
86
+
87
+
88
+ def _preload(cfg):
89
+ """reBot talks CAN through PCBUSB, which must be preloaded before anything else (may re-exec)."""
90
+ if cfg["robot"].get("type", "rebot_b601") == "rebot_b601":
91
+ from .system import preload_pcan
92
+ preload_pcan()
59
93
 
60
94
 
61
95
  def cmd_collect(args):
96
+ cfg = _cfg(args)
62
97
  if not args.fake:
63
- from .system import preload_pcan
64
- preload_pcan()
98
+ _preload(cfg)
65
99
  from .collect.server import run
66
- run(_cfg(args), fake=args.fake, port=args.port, out=args.out)
100
+ run(cfg, fake=args.fake, port=args.port, out=args.out)
67
101
 
68
102
 
69
103
  def cmd_export(args):
@@ -77,11 +111,11 @@ def cmd_health(args):
77
111
 
78
112
 
79
113
  def cmd_run(args):
114
+ cfg = _cfg(args)
80
115
  if not args.fake:
81
- from .system import preload_pcan
82
- preload_pcan()
116
+ _preload(cfg)
83
117
  from .policy.runner import run
84
- run(_cfg(args), args)
118
+ run(cfg, args)
85
119
 
86
120
 
87
121
  def cmd_replay(args):
@@ -104,9 +138,10 @@ def main(argv=None):
104
138
  ap.add_argument("--config", help="YAML file overriding the built-in defaults")
105
139
  sub = ap.add_subparsers(dest="cmd", required=True, metavar="command")
106
140
 
107
- sub.add_parser("doctor", help="check this Mac").set_defaults(fn=cmd_doctor)
141
+ sub.add_parser("doctor", help="check the configured robot and cameras without connecting").set_defaults(fn=cmd_doctor)
108
142
  sub.add_parser("cameras", help="list video devices and uniqueIDs").set_defaults(fn=cmd_cameras)
109
143
  sub.add_parser("joints", help="read joint angles without powering motors").set_defaults(fn=cmd_joints)
144
+ sub.add_parser("robots", help="list the LeRobot robot and leader types available here").set_defaults(fn=cmd_robots)
110
145
 
111
146
  p = sub.add_parser("collect", help="teleoperate and record (web page)")
112
147
  p.add_argument("--fake", action="store_true", help="simulate robot, leader and cameras")
@@ -119,10 +154,10 @@ def main(argv=None):
119
154
  p.add_argument("--out", help="dataset folder (default <data_root>/datasets/<task>[_bin])")
120
155
  p.add_argument("--repo-id")
121
156
  p.add_argument("--gripper", choices=["raw", "binary"], default="raw", help="gripper action: leader angle, or 0/1")
122
- p.add_argument("--close-above", type=float, default=-40.0, help="binary: leader angle above this = closed")
123
- p.add_argument("--open-below", type=float, default=-80.0, help="binary: once closed, below this = open")
124
- p.add_argument("--open-deg", type=float, default=-150.0, help="binary: gripper angle commanded for 'open'")
125
- p.add_argument("--close-deg", type=float, default=0.0, help="binary: gripper angle commanded for 'closed'")
157
+ p.add_argument("--close-above", type=float, help="binary: leader value above this = closed (default: export.gripper_close_above)")
158
+ p.add_argument("--open-below", type=float, help="binary: once closed, below this = open (default: export.gripper_open_below)")
159
+ p.add_argument("--open-deg", type=float, help="binary: gripper value commanded for 'open' (default: export.gripper_open_deg)")
160
+ p.add_argument("--close-deg", type=float, help="binary: gripper value commanded for 'closed' (default: export.gripper_close_deg)")
126
161
  p.add_argument("--skip-warnings", action="store_true", help="also skip episodes with warnings")
127
162
  p.add_argument("--images", action="store_true", help="store PNG frames instead of video (debugging)")
128
163
  p.add_argument("--overwrite", action="store_true")
@@ -150,7 +185,7 @@ def main(argv=None):
150
185
  p.add_argument("--device", default="mps")
151
186
  p.add_argument("--port", type=int)
152
187
  p.add_argument("--fake", action="store_true", help="simulate robot and cameras (policy runs for real)")
153
- p.add_argument("--autostart", type=float, default=0, help="with --fake: run this many seconds, save, quit")
188
+ p.add_argument("--autostart", type=float, default=0, help="in fake or sim mode: run this many seconds, save, quit")
154
189
  p.set_defaults(fn=cmd_run)
155
190
 
156
191
  p = sub.add_parser("replay", help="browse recorded rollouts")
@@ -3,11 +3,10 @@ from __future__ import annotations
3
3
 
4
4
  import numpy as np
5
5
 
6
- from ..config import ARM
7
6
  from ..i18n import tr
8
7
 
9
8
 
10
- def check_episode(d: dict, cams, fps: int, checks: dict, min_s: float) -> dict:
9
+ def check_episode(d: dict, cams, fps: int, checks: dict, min_s: float, joints=None, gripper=None) -> dict:
11
10
  """``d`` holds arrays ``qpos``, ``late`` and ``<cam>_age`` / ``<cam>_repeat`` per camera.
12
11
  Returns ``{ok, errors, warnings, stats}``; errors block export, warnings are shown."""
13
12
  n = len(d["qpos"])
@@ -24,11 +23,14 @@ def check_episode(d: dict, cams, fps: int, checks: dict, min_s: float) -> dict:
24
23
  if rep > checks["max_repeat_ratio"]:
25
24
  warnings.append(tr(f"{k} repeated frames {rep:.0%}", f"{k} 画面重复 {rep:.0%}"))
26
25
  if n > 1:
27
- step = np.abs(np.diff(np.asarray(d["qpos"])[:, :6], axis=0)).max(axis=0)
28
- stats["max_joint_step_deg"] = round(float(step.max()), 1)
26
+ q = np.asarray(d["qpos"])
27
+ names = list(joints) if joints else [f"joint_{i}" for i in range(q.shape[1])]
28
+ arm = [i for i, j in enumerate(names) if j != gripper]
29
+ step = np.abs(np.diff(q[:, arm], axis=0)).max(axis=0)
30
+ worst = names[arm[int(step.argmax())]]
31
+ stats["max_joint_step"] = round(float(step.max()), 1)
29
32
  if step.max() > checks["max_joint_step_deg"]:
30
- warnings.append(tr(f"{ARM[int(step.argmax())]} jumped {step.max():.0f} deg in one frame",
31
- f"{ARM[int(step.argmax())]} 一帧跳 {step.max():.0f}°"))
33
+ warnings.append(tr(f"{worst} jumped {step.max():.0f} in one frame", f"{worst} 一帧跳 {step.max():.0f}"))
32
34
  late = float(np.mean(d["late"])) if n else 0.0
33
35
  stats["late_ratio"] = round(late, 3)
34
36
  if late > checks["max_late_ratio"]: