Metadata-Version: 2.5
Name: lerobot_teleoperator_rfabricd
Version: 0.1.0
Summary: LeRobot plugin: the rFabric remote operator drives a LeRobot robot over the rFabric realtime control UDS (rfabricd teleoperator and its follower robot types).
Project-URL: Homepage, https://rfabric.io
Project-URL: Repository, https://github.com/rfabric/lerobot-teleoperator-rfabricd
Author-email: rFabric <engineering@rfabric.io>
License: Apache-2.0
Keywords: lerobot,rfabric,robotics,teleoperation
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Typing :: Typed
Requires-Python: >=3.12
Requires-Dist: lerobot<0.8,>=0.6.1
Requires-Dist: rfabric-control-wire>=0.1.0
Provides-Extra: dev
Requires-Dist: lerobot[dataset]<0.8,>=0.6.1; extra == 'dev'
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.5; extra == 'dev'
Provides-Extra: feetech
Requires-Dist: lerobot[feetech]<0.8,>=0.6.1; extra == 'feetech'
Description-Content-Type: text/markdown

# lerobot_teleoperator_rfabricd

LeRobot plugin that lets an rFabric remote operator drive a LeRobot robot, with
stock `lerobot-teleoperate` and `lerobot-record`. It is the follower end of the
rFabric realtime control UDS: `rfabricd` connects to the socket
the teleoperator binds and relays the operator console's control frames
(`rfabric-control-wire`).

Works with stock LeRobot 0.6 and 0.7. LeRobot discovers the plugin by its
distribution name (`lerobot_teleoperator_*`); installing it in the LeRobot
environment adds:

| Flag | What it is |
|---|---|
| `--teleop.type=rfabricd` | The remote operator |
| `--robot.type=rfabric_bi_so_follower` | `bi_so_follower` that shares its joint readings with the teleoperator |
| `--robot.type=rfabric_so101_follower` | `so101_follower` that shares its joint readings with the teleoperator |

The operator sends one velocity (`-1..1`) per joint; turning it into a joint
position needs the arm's present position, which LeRobot gives a teleoperator
only through the robot. The follower robot types are the stock robots - same
flags, calibration files, features and `robot_type` in datasets - that also
publish every observation and completed write to the teleoperator in the same
process.

## Install

Into the Python environment LeRobot runs from:

```bash
uv pip install lerobot_teleoperator_rfabricd
```

## Run

Teleoperate a bimanual SO-101 (what `rfabric-arms.service` runs):

```bash
lerobot-teleoperate \
  --robot.type=rfabric_bi_so_follower --robot.id=bimanual_follower \
  --robot.left_arm_config.port=/dev/ttyACM0 --robot.right_arm_config.port=/dev/ttyACM1 \
  --robot.left_arm_config.max_relative_target=24 --robot.right_arm_config.max_relative_target=24 \
  --teleop.type=rfabricd --teleop.socket_path=/run/rfabric/control.sock \
  --teleop.arms='[left,right]' --fps=60
```

Record while the remote operator drives (the dataset action is the joint
position target):

```bash
lerobot-record <the same --robot.* and --teleop.* flags> \
  --dataset.repo_id=local/remote_demo --dataset.single_task="Pick the cube"
```

A single-arm robot uses `--robot.type=rfabric_so101_follower` and leaves
`--teleop.arms` empty.

## What the operator gets

- **Capabilities**: on each rfabricd connection, a `mode` frame declaring
  `accepts: [joint_velocity, stop]`, the arm tags and each arm's joints. The joint
  layout comes from the follower's first observation (`<arm>_<joint>.pos` keys).
- **State**: one `snapshot` per arm at `state_publish_hz`, `values` keyed
  `<joint>.pos`, tagged with `arm`.
- **Safety**: an arm holds its present position when it receives `stop`, when its
  last command is older than `watchdog_ms`, and when rfabricd disconnects; a
  `stop` without an arm tag stops every arm.
- **Stop ack**: once the follower's write that carries a `stop`'s hold returned,
  the teleoperator answers with `ack{kind:"stop"}` - the preflight stop check of
  rfabricd, which the operator console requires before motion by default.
- **Episodes**: operator `terminate` / `success` / `rerecord` mode frames are
  reported by `get_teleop_events()`.

## Servo settings (`--teleop.*`)

| Flag | Default | Meaning |
|---|---|---|
| `joint_speed` | `60.0` | Joint speed at full velocity, per second (degrees for SO-101) |
| `gripper_speed` | `180.0` | Gripper speed at full velocity, per second (`0..100`) |
| `lead_cap` | `12.0` | How far a target may run ahead of the present position |
| `velocity_tau_s` | `0.10` | Low-pass time constant on operator velocities; `0` disables |
| `velocity_idle_epsilon` | `0.04` | Smoothed velocity below which a released joint holds |
| `joint_signs` | `{}` | `-1` reverses a joint, e.g. `'{right_shoulder_pan: -1}'` |
| `watchdog_ms` | `200` | Command age after which an arm holds |

Keep `--robot.*.max_relative_target` at about twice `lead_cap`: the robot then
caps any single command as a second line of defence.

## Development

```bash
uv sync --extra dev --extra feetech
.venv/bin/ruff check src tests && .venv/bin/ruff format --check src tests
.venv/bin/mypy src
.venv/bin/pytest
```

`rfabric-control-wire` resolves from the sibling checkout
(`[tool.uv.sources]`).
