Metadata-Version: 2.4
Name: macbot
Version: 0.3.2
Summary: LeRobot on a MacBook: one standard workflow to teleoperate, record, export and run LeRobot policies such as ACT, pi0.5 and SmolVLA, with fast inference on Apple silicon.
Author: MuQY1818
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/MuQY1818/macbot
Project-URL: Documentation, https://github.com/MuQY1818/macbot/blob/main/docs/guide.md
Project-URL: Issues, https://github.com/MuQY1818/macbot/issues
Project-URL: Changelog, https://github.com/MuQY1818/macbot/releases
Keywords: robotics,lerobot,teleoperation,imitation-learning,vla,pi0,act,apple-silicon,mps,macos
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: Operating System :: MacOS
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Human Machine Interfaces
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: lerobot[dataset,dynamixel,feetech,rebot]==0.7.0
Requires-Dist: numpy
Requires-Dist: opencv-python
Requires-Dist: pyyaml
Requires-Dist: pyserial<4,>=3.5
Provides-Extra: orbbec
Requires-Dist: pyorbbecsdk2; extra == "orbbec"
Provides-Extra: pi
Requires-Dist: lerobot[pi]==0.7.0; extra == "pi"
Provides-Extra: mlx
Requires-Dist: lerobot[pi]==0.7.0; extra == "mlx"
Requires-Dist: mlx>=0.32.4; (sys_platform == "darwin" and platform_machine == "arm64") and extra == "mlx"
Provides-Extra: sim
Requires-Dist: mujoco==3.3.7; extra == "sim"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pyflakes; extra == "dev"
Requires-Dist: ruff==0.14.14; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Dynamic: license-file

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/MuQY1818/macbot/main/assets/logo-dark.svg">
    <img src="https://raw.githubusercontent.com/MuQY1818/macbot/main/assets/logo.svg" alt="macbot" height="72">
  </picture>
</p>

<p align="center"><b>LeRobot on a MacBook.</b><br>
One standard workflow to teleoperate, record, export and run LeRobot policies such as ACT, π0.5, SmolVLA and X-VLA
on the robot, with fast inference on Apple silicon.</p>

<p align="center">
  <img alt="macOS" src="https://img.shields.io/badge/macOS-Apple%20silicon-18171F">
  <img alt="Python" src="https://img.shields.io/badge/python-3.12%2B-F2701A">
  <img alt="LeRobot" src="https://img.shields.io/badge/LeRobot-0.7.0-1F9D63">
  <img alt="License" src="https://img.shields.io/badge/license-Apache--2.0-6B6A75">
  <a href="https://github.com/MuQY1818/macbot/actions/workflows/test.yml"><img alt="tests" src="https://github.com/MuQY1818/macbot/actions/workflows/test.yml/badge.svg"></a>
</p>

<p align="center"><b>English</b> · <a href="https://github.com/MuQY1818/macbot/blob/main/README_zh.md">中文</a></p>

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/MuQY1818/macbot/main/assets/scene-dark.svg">
    <img src="https://raw.githubusercontent.com/MuQY1818/macbot/main/assets/scene.svg" alt="Collect on the robot, export a LeRobot dataset, train on a GPU, bring the checkpoint back and run it on the MacBook" width="100%">
  </picture>
</p>

## Why

Real-robot setups usually assume an Ubuntu workstation with an NVIDIA GPU next to the arm. We found a
MacBook is enough for everything that happens at the robot: teleoperated data collection, data checks,
export to LeRobot, and closed-loop policy inference, π0.5 included. Training still goes to a GPU machine.
macbot is the toolkit we use for that, cleaned up so others can reuse it.

Measured on a MacBook Pro (M5 Pro, 48 GB). Approximate time per action chunk:

| Policy | Chunk | PyTorch MPS | MLX |
|---|---:|---:|---:|
| π0.5 | 50 | 270 ms | **165 ms** |
| π0.5 with RTC | 50 | 350 ms | **170 ms** |
| SmolVLA | 50 | 300 ms | — |
| X-VLA | 30 | 235 ms | — |
| ACT | 100 | 25 ms | — |

π0.5 runs 10 denoising steps, in bf16 with `torch.compile` on PyTorch and in fp16 with `--backend mlx`. The
MLX actions match PyTorch within 0.1° on average. RTC is Real-Time Chunking guidance. SmolVLA is the official
base checkpoint and X-VLA the SO-101 fine-tune. Method and full results are in
[docs/acceleration.md](https://github.com/MuQY1818/macbot/blob/main/docs/acceleration.md), other policies in
[docs/policies.md](https://github.com/MuQY1818/macbot/blob/main/docs/policies.md).

| Data collection | Measured |
|---|---:|
| Teleoperation loop | 60 Hz |
| Recording | 30 fps |
| Camera frame age at sampling, p95 | ≤ 40 ms |

## What is inside

- **Collection console** in the browser: live cameras, one-key record / save / discard, per-episode language
  instruction, automatic quality checks (frame age, repeated frames, joint jumps, timing), instant replay of
  any episode with joint traces.
- **Export** to a LeRobot v3 dataset, optionally with a binary (open / closed) gripper action.
- **Policy runner** console for LeRobot checkpoints. ACT and π0.5 have four execution schemes (synchronous chunks, temporal
  ensembling, asynchronous chunks, Real-Time Chunking), velocity and joint limits, pause / home / quit with a
  slow two-stage return to zero, and every trial saved with video and timing.
- **Replay** of saved trials (all cameras in sync, command vs. measured traces, chunk boundaries) and
  side-by-side **MP4** export.
- **`macbot doctor`** checks packages, MPS and the configured robot and cameras before you start.
- **`--fake`** on `collect` and `run` substitutes a fake arm and cameras; `run` still runs the policy.
- English and Chinese in every web page (toggle in the top bar), light and dark mode.

<p align="center"><img src="https://raw.githubusercontent.com/MuQY1818/macbot/main/docs/img/collect_en.jpg" alt="The macbot collection console" width="100%"></p>

| Run a policy | Replay a trial |
|---|---|
| <img src="https://raw.githubusercontent.com/MuQY1818/macbot/main/docs/img/run_en.jpg" alt="Policy runner"> | <img src="https://raw.githubusercontent.com/MuQY1818/macbot/main/docs/img/replay_en.jpg" alt="Trial replay"> |

## Hardware

The reBot B601-RS is the reference arm tested on hardware. See [robot support](docs/robots.md)
for the SO-100/101 and other compatible LeRobot arms, the local simulator, and what has been
verified. See [policy support](docs/policies.md) for tested checkpoints and Apple GPU compatibility.
The [setup guide](docs/setup.md) covers drivers and cameras. For π0.5, we recommend
an Apple silicon Mac with at least 32 GB of memory.

## Quick start

```bash
pip install macbot
macbot init
macbot collect
```

Use Python 3.12+ on Apple silicon and install the Xcode Command Line Tools for UVC cameras.
Confirm the arms and camera roles in the setup page, then follow its calibration prompts.
Open the collection URL printed in Terminal. Press **S** to record, **Enter** to save, **←** to discard.
See the [quickstart](docs/quickstart.md) for a fresh Mac, a hardware-free trial, and reBot and Orbbec setup.

## Workflow

```bash
sudo -E $(which python) -m macbot.cli collect          # 1. teleoperate and record (sudo: Orbbec SDK)
macbot health                                          # 2. per-episode tracking and timing report
macbot export --gripper binary                         # 3. LeRobot dataset in ~/macbot-data/datasets/
DATASET=... ./train/train_pi05.sh my_run               # 4. train on a GPU machine (train_act.sh for ACT)
sudo -E $(which python) -m macbot.cli run --policy runs/my_run/checkpoints/last/pretrained_model
macbot replay                                          # 5. browse trials;  macbot video <rollout.npz> for an MP4
```

The full walkthrough, including the data format and the execution schemes, is in [docs/guide.md](https://github.com/MuQY1818/macbot/blob/main/docs/guide.md).
Put your settings in a YAML file and pass `macbot --config my.yaml <command>`; anything you leave out falls
back to [macbot/default.yaml](https://github.com/MuQY1818/macbot/blob/main/macbot/default.yaml). [configs/example.yaml](https://github.com/MuQY1818/macbot/blob/main/configs/example.yaml) is a starting point.

## What it took to run this on macOS

- **CAN under sudo.** The Orbbec SDK needs root, and dyld ignores `/usr/local/lib` for root processes, so
  `libPCBUSB.dylib` is preloaded explicitly before the CAN backend looks for it.
- **The right camera.** Opening a UVC camera by name or index can grab an iPhone through Continuity
  Camera. macbot opens cameras by AVFoundation uniqueID through a small Swift helper, and still finds the
  camera when it moves to another USB port.
- **π0.5 on MPS.** bf16 weights under autocast; the masked third camera slot is skipped (identical output,
  ~70 ms saved); `torch.compile` on the denoising step and the language model cuts per-kernel dispatch
  overhead (~410 → ~280 ms); the random weight initialization that the checkpoint overwrites anyway is
  skipped, which saves about 80 s per load.
- **Optional π0.5 on MLX.** See the [inference benchmarks](https://github.com/MuQY1818/macbot/blob/main/docs/acceleration.md) for recorded-observation
  latency, action fidelity, and the checkpoint requirements.
- **Files written as root** are handed back to the user who ran `sudo`.

## Contributing

See [CONTRIBUTING](CONTRIBUTING.md) for development and hardware reports,
[architecture](docs/architecture.md) for the code layout, and the [roadmap](ROADMAP.md) for planned work.

## Safety

macbot moves a real arm. Every console starts paused or idle, limits joint speed and range, clamps the
gripper force, pauses when a camera stalls, and returns to zero slowly before disabling the motors. Keep the
workspace clear and a hand near the power switch, and start new policies at `--speed 0.3`.

## Acknowledgements

Built on [LeRobot](https://github.com/huggingface/lerobot). π0.5 and the augmentation recipe come from
[openpi](https://github.com/Physical-Intelligence/openpi); Real-Time Chunking from Black et al., 2025.
The reBot arms are by [Seeed Studio](https://github.com/Seeed-Projects). JetBrains Mono is under the SIL
Open Font License.

## License

Apache-2.0. See [LICENSE](https://github.com/MuQY1818/macbot/blob/main/LICENSE).
