Metadata-Version: 2.5
Name: rfabric-yam-bridge
Version: 0.1.5
Summary: Standalone bridge that exposes i2rt YAM arms over the rFabric realtime control UDS, with no lerobot dependency.
Project-URL: Homepage, https://rfabric.io
Project-URL: Repository, https://github.com/rfabric/rfabric
Author-email: rFabric <engineering@rfabric.io>
License: Apache-2.0
Keywords: i2rt,rfabric,robotics,teleoperation,yam
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.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: numpy>=1.24
Requires-Dist: rfabric-control-wire>=0.1.1
Provides-Extra: dev
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.5; extra == 'dev'
Description-Content-Type: text/markdown

# rfabric-yam-bridge

Standalone bridge between the rFabric realtime control UDS and an i2rt YAM
arm (single or bimanual). Pip-install this package on the robot host, run
the `rfabric-yam-bridge` CLI as a systemd unit, and `rfabricd` will drive
your YAM the moment an operator session opens.

## Install

`i2rt` is not on PyPI. Install both in one step:

```bash
uv tool install rfabric-yam-bridge \
  --with "i2rt @ git+https://github.com/i2rt-robotics/i2rt.git"
```

## Run

Single arm:

```bash
rfabric-yam-bridge --can-channel can0 --gripper linear_4310
```

Bimanual:

```bash
rfabric-yam-bridge \
    --left-channel can0  --left-gripper linear_4310 \
    --right-channel can1 --right-gripper linear_4310
```

The socket defaults to `$XDG_RUNTIME_DIR/rfabric/control.sock` (typically
`/run/user/<uid>/rfabric/control.sock`). Override with `--socket-path` when
running under a systemd unit that pre-creates `/run/rfabric/`.

The bridge:

- Binds the UDS, accepts a single client (`rfabricd`), and
  decodes inbound length-prefixed CBOR `Frame`s (control wire version 2; a
  frame of another version is dropped and the arms hold).
- Declares the arms in a `capabilities` frame on connect: the fingerprint,
  `stateNames`, `actionNames`, the action groups, `accepts`,
  `positionHold: true`, each group's `home` row (`--home`, `--left-home`,
  `--right-home`) and its `velocityScale`: per joint the `joint_velocity`
  gain (`--velocity-gain`; rad/s, the gripper's normalised stroke per second,
  at normalised velocity 1), which rfabricd uses to bound operator velocities
  by the group's `maxRate`. See [Embodiment](#embodiment).
- Maps every operator payload kind (`joint_targets`, `joint_deltas`,
  `joint_velocity`, `end_effector_velocity`, `stop`, `home`) into the same
  per-arm latest target / latest velocity, integrated by a single
  fixed-rate tick (default 100 Hz) into `MotorChainRobot.command_joint_pos`.
  A `joint_targets` frame (`arm` names the group) is commanded as given,
  clipped to the joint range: rfabricd limits how fast consecutive targets
  move (the group's `maxRate`) and turns an operator `home` into targets
  toward the home row; a `home` that reaches the bridge is the home row as
  one target.
- Follows `end_effector_velocity` (gamepad) commands like `joint_velocity`:
  each frame is the arm's latest command, and every tick low-pass smooths it
  and integrates it over the real tick time, then solves the commanded tool
  pose with i2rt's IK against the arm's MJCF. See
  [End-effector velocity](#end-effector-velocity).
- Sends one `snapshot` at `--state-publish-hz` (default 30 Hz): the
  fingerprint and every arm's joint positions and velocities, packed as
  float32 in `stateNames` order.
- Drops any per-arm command stream older than `--watchdog-ms` so the arm
  freezes when the operator UI stutters, and holds on a malformed payload;
  the i2rt motor 400 ms safety timeout is the second line of defence. The
  gripper keeps its commanded target through the watchdog, a `stop` and
  idle, so a grip never loosens.

The wire format is the same one consumed by the LeRobot teleoperator plugin
`lerobot_teleoperator_rfabricd`: both surfaces share the `rfabric-control-wire` package.

## Embodiment

The robot's `Embodiment` on the platform must declare the state components
and action groups below, with the same names, joints and order: rfabricd
compares its fingerprint with the bridge's (`embodiment`) and refuses the
session when they differ.

| Part | Name | Declared as | Elements |
|---|---|---|---|
| Action group, one per arm | `arm` for a single arm; `left`, `right` for a bimanual YAM | `target: joints`, `mode: position` | `joint1` to `joint6`, then `gripper` when fitted |
| State component, per arm | `<group>_position` | `quantity: joint_position` | the same joints |
| State component, per arm, after its position | `<group>_velocity` | `quantity: joint_velocity` | the joints whose velocities i2rt reports (the same joints) |

Arms come in `left`, `right` order. Values are i2rt's: radians and rad/s,
the gripper normalised `0..1`. With a gripper, a single YAM's fingerprint is
`2947396534` and a bimanual YAM's `622219696`.

The matching `Embodiment` of a single YAM with a gripper (add `low`, `high`
and `maxRate` to the group; a remote inference session needs `maxRate`):

```json
{
  "state": {"components": [
    {"name": "arm_position", "quantity": "joint_position", "joints": ["joint1", "joint2", "joint3", "joint4", "joint5", "joint6", "gripper"]},
    {"name": "arm_velocity", "quantity": "joint_velocity", "joints": ["joint1", "joint2", "joint3", "joint4", "joint5", "joint6", "gripper"]}
  ]},
  "actions": {"groups": [
    {"name": "arm", "target": "joints", "mode": "position", "joints": ["joint1", "joint2", "joint3", "joint4", "joint5", "joint6", "gripper"]}
  ]}
}
```

## End-effector velocity

Every value of an `end_effector_velocity` command is a fraction (`-1..1`) of
a top speed:

| Input | Moves | Top speed (default) |
| --- | --- | --- |
| `linear.x/y/z` | the wrist point, in the arm's base frame (`+x` forward, `+y` left, `+z` up) | `--tip-speed` (0.1 m/s) |
| `pitch` | tilts the gripper about its wrist; positive raises the fingertips | `--pitch-speed` (1.0 rad/s) |
| `roll` | turns the gripper about its approach axis; positive is clockwise seen from behind the gripper | `--roll-speed` (1.5 rad/s) |
| `gripper` | opens (`+`) or closes (`-`) the jaws | the gripper's `--velocity-gain` (1.0 stroke/s) |

- **Frames** (from the YAM MJCF): the tool frame is `grasp_site`; the wrist
  point is the origin of body `link4`, the anchor of the wrist pitch joint
  `joint4`; the pitch axis is the tool's +X (the jaw-stroke axis, parallel to
  `joint4` at the zero pose), positive being the right-hand turn. At the zero
  pose a pure tilt moves `joint4` alone, like `wrist_flex` on an SO-101. The
  roll axis is the tool's +Z (the approach axis out of the jaws), the axis of
  the last joint `joint6`, positive being the right-hand turn: a pure roll
  moves `joint6` alone.
- **Smoothing**: the command is low-passed with `--velocity-tau-s` (0.1 s);
  a released input eases to rest, then stops.
- **No wind-up**: after each solve the commanded pose is the forward
  kinematics of the solved joints, clipped to their limits; an unreachable
  target or a solve that would flip a joint holds the arm joints. Pushing on
  at a limit winds nothing up, and the reverse moves at once.
- **Gripper**: its target moves only on a non-zero `gripper` input, leading
  the measured jaws by at most `--gripper-lead-cap` (0.1 of the stroke), so a
  grip squeezes with a bounded force. At zero it keeps its target.
- **Stops**: a stale command or `stop` holds the arm at once; `joint_targets`,
  `joint_deltas`, `joint_velocity` and `home` leave Cartesian control. Coming
  back seeds the pose and the gripper from the commanded joints.

The speed, lead and smoothing settings apply to every arm.
