Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
05241c15dThis file is pinned to the selected release. Download the original to open it in your design tool.
# armcade — agent guide
Monorepo for the ARMCADE robot-teleop system.
- **`client/`** — the Next.js web app: the operator UI (watch the arm, queue up, take control). Its conventions live in `client/AGENTS.md` (loaded automatically when you work under `client/`).
- **`robot/`** — the robot-side teleop stack (Python): the `tomctl` package (control core + sim, real-arm teleop, the LiveKit camera publisher + control bridge, calibration) plus a vendored `lerobot` hardware subset. Run components as `python -m tomctl.<x>` **from `robot/`**. See `robot/README.md`, `robot/OPERATIONS.md`, `robot/REMOTE_CONTROL.md`.
- **`edge/`** — an early robot-side stub (test-pattern camera + teleop logger), superseded by `robot/`.
- **`tools/`** — standalone, no-build debug utilities (`tools/livekit_viewer.html`, `tools/latency_probe.py`).
## Working in `robot/`
- Run from the `robot/` dir so `tomctl` and the vendored `lerobot` both resolve: `python -m tomctl.control --web`, `python -m tomctl.livekit.bridge`, etc.
- **Torch-free rule:** nothing on the teleop path imports `torch`. When editing `robot/lerobot/`, never add a module-level `import torch` — guard it lazily. Verify: `python -c "from lerobot.robots.tom.tom import Tom; import lerobot.utils"`.
- Calibration is **strictly per-arm** (`assets/ik_calibration_<id>.json`); no shared/legacy default.
- On the Pi a live rig may be running (`livekit-server`, camera publisher, bridge on room `tom-cams`). When testing, use an **isolated room/UDP port** (e.g. `tom-sim`) so you don't disturb it.
- Fast no-hardware checks: `python -m tomctl.tests.test_remote` and `python -m tomctl.livekit.bridge --selftest`.
## Operational shorthand — what the user means
Map spoken requests to commands. Everything runs **from `robot/`** as `python -m tomctl.<x>`.
| The user says… | Do this (from `robot/`) |
|---|---|
| **"start the bridge"** (dev) | `python -m tomctl.livekit.bridge` — dev defaults matching `livekit-server --dev` (`ws://localhost:7880`, `devkey`/`secret`), room `tom-cams`, both arms, 2-min turns. |
| **"start the bridge in prod"** | Source real creds from env, then `--prod`:<br>`LIVEKIT_URL=wss://<project>.livekit.cloud LIVEKIT_API_KEY=… LIVEKIT_API_SECRET=… LIVEKIT_ROOM=armcade-prod python -m tomctl.livekit.bridge --prod`<br>`--prod` reads LiveKit url/key/secret/room from the `LIVEKIT_*` env vars (same names the web app uses) and **refuses the dev-mode defaults**. |
| **"restart the bridge"** | `git pull`; stop the running `pi-control` process; relaunch it the way it was started — a systemd unit (`sudo systemctl restart armcade-bridge`) if present, else the same `python -m tomctl.livekit.bridge …` command with its flags. |
| **"run the remote stack"** (real arm) | `python -m tomctl.remote_real --port <serial> --id <id> --room tom-cams` — bundles teleop + bridge + cameras. Sim: `python -m tomctl.remote_sim --arms arm1 arm2 --room tom-sim`. |
| **"selftest the bridge / queue"** | `python -m tomctl.livekit.bridge --selftest` (offline logic, no server/hardware). |
## Control-bridge behavior & defaults (`tomctl.livekit.bridge`)
- **Strictly one driver at a time**; with two arms it cycles arm1 → arm2 → arm1 across turns. `--operator <id>` restricts joining (repeatable allow-list); omit for **open access**.
- **Turn bounds:** `--max-session-s` **120s** (`0` = unlimited) + `--idle-timeout-s` **30s** (no active driving).
- **Refresh/reconnect:** an operator's slot + queue spot is held `--disconnect-grace-s` **15s** so a reconnect with the **same LiveKit identity** (the browser persists it in localStorage) resumes it in place — no re-home.
- **Restart survival:** the queue + active session persist to `--state-file` (`assets/queue_state.json`, gitignored) and restore on startup, holding restored operators `--restore-grace-s` **45s** to reconnect.
- **`--prod` is bridge-only today.** The camera publisher (`tomctl.livekit.cameras`) and the orchestrator (`tomctl.remote_real`) still take dev-default creds via `--url/--api-key/--api-secret` — for a full prod deploy point them at the same Cloud server/room too (or extend `--prod` there).
- Full flag list + wire protocol: **`robot/OPERATIONS.md`** and **`robot/REMOTE_CONTROL.md`**.
## Client (`client/`)
The Next.js web app carries its own **`client/AGENTS.md`** (auto-loaded when working under `client/`) — heed it: this is a non-standard Next.js build, so read the relevant bundled docs before writing code there.