a2a-robots-lerobot 0.1.1__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.
@@ -0,0 +1,8 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ build/
5
+ dist/
6
+ *.egg-info/
7
+ .pytest_cache/
8
+ .ruff_cache/
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ ## [0.1.1](https://github.com/hybroai/a2a-robots/compare/a2a-robots-lerobot-v0.1.0...a2a-robots-lerobot-v0.1.1) (2026-11-18)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **lerobot:** bootstrap first PyPI release ([ed37a21](https://github.com/hybroai/a2a-robots/commit/ed37a210aa2d7d9b82aec1f67ca18026aa642d17))
9
+
10
+ ## Changelog
11
+
12
+ All notable changes to this project will be documented in this file.
13
+
14
+ Entries are generated by
15
+ [release-please](https://github.com/googleapis/release-please) from
16
+ Conventional Commits. This project adheres to
17
+ [Semantic Versioning](https://semver.org/).
@@ -0,0 +1,85 @@
1
+ Metadata-Version: 2.5
2
+ Name: a2a-robots-lerobot
3
+ Version: 0.1.1
4
+ Summary: Hugging Face LeRobot backend for a2a-robots
5
+ Project-URL: Repository, https://github.com/hybroai/a2a-robots
6
+ Author-email: HYBRO AI <info@hybro.ai>
7
+ License-Expression: Apache-2.0
8
+ Classifier: Development Status :: 2 - Pre-Alpha
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
14
+ Requires-Python: >=3.11
15
+ Requires-Dist: a2a-robots
16
+ Requires-Dist: numpy>=1.26
17
+ Provides-Extra: dev
18
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
19
+ Requires-Dist: pytest>=8; extra == 'dev'
20
+ Provides-Extra: kinematics
21
+ Requires-Dist: lerobot[kinematics]>=0.7; (python_version >= '3.12') and extra == 'kinematics'
22
+ Provides-Extra: serial
23
+ Requires-Dist: lerobot[kinematics,serial-motors]>=0.7; (python_version >= '3.12') and extra == 'serial'
24
+ Description-Content-Type: text/markdown
25
+
26
+ # a2a-robots-lerobot
27
+
28
+ [Hugging Face LeRobot](https://github.com/huggingface/lerobot) backend for [a2a-robots](../../README.md).
29
+
30
+ Install from PyPI: `pip install a2a-robots-lerobot`.
31
+
32
+ ## LeRobot backend
33
+
34
+ `LeRobotArmBackend` adapts single-arm and bimanual manipulators managed by `lerobot.robots.Robot` (for example `SO100Follower`, `SO101Follower`, `BiSOFollower`, and `KochFollower`) to `a2a_robots.RobotBackend` and `a2a_robots.RobotAdapter`.
35
+
36
+ - **URDF kinematics in radians:** `LeRobotKinematicsPlanner` wraps `lerobot.model.kinematics.RobotKinematics` (Placo/Pinocchio) via `PlacoKinematics`, converting between LeRobot's degree-based joint space and `a2a_robots`'s metre/radian pose contract. Pass `base_transform` in `ArmSpec` (or use `bi_so_arms`) to position bimanual arms in a shared `"world"` frame.
37
+ - **5-DoF arms vs. 6-DoF poses:** 5-DoF arms such as SO-100, SO-101, and Koch cannot independently match arbitrary 6-DoF end-effector orientations at every position. The `so101_arms`, `bi_so_arms`, and `koch_arms` presets set `orientation_weight=0.01` and `check_orientation=False` so `move_to` reaches position accurately while aligning orientation best-effort; set `check_orientation=True` for 6-DoF/7-DoF arms.
38
+ - **Safety guards:**
39
+ - `connect=True` always connects with `calibrate=False` so missing calibration never blocks a headless server on interactive terminal prompts; uncalibrated robots fail fast at startup.
40
+ - Robots with `use_degrees=False` (normalized `[-100, 100]` joint space) are rejected by default (`require_use_degrees=True`) unless explicitly configured with `joint_unit="rad"`.
41
+ - Every `send_action()` sends the complete `robot.action_features` dictionary so non-target arms, grippers, and extra actuators stay held.
42
+ - Set `disable_torque_on_disconnect=False` on your LeRobot config if disconnecting on shutdown should not drop a raised arm under gravity.
43
+
44
+ ## Usage
45
+
46
+ `a2a-robots-lerobot` is an independent `uv` project with its own `uv.lock` and optional extras for `lerobot` (`kinematics`, `serial`). Offline tests and `FakeLeRobot` work out of the box without installing `lerobot` or PyTorch.
47
+
48
+ Live hardware and `PlacoKinematics` require Python `>=3.12`:
49
+
50
+ ```bash
51
+ # Offline with FakeLeRobot (no lerobot install needed):
52
+ LEROBOT_FAKE=1 uv run --directory packages/a2a-robots-lerobot python examples/serve_so101.py
53
+
54
+ # Live SO-101 hardware (installs the `serial` extra: lerobot[kinematics,serial-motors]):
55
+ uv run --directory packages/a2a-robots-lerobot --python 3.12 --extra serial \
56
+ python examples/serve_so101.py --serial-port /dev/ttyACM0 --urdf /path/to/so101_new_calib.urdf
57
+ ```
58
+
59
+ Or in Python:
60
+
61
+ ```python
62
+ from a2a_robots import RobotAdapter, SafetyLimits, Workspace, serve_robot
63
+ from a2a_robots_lerobot import LeRobotArmBackend, so101_arms
64
+ from lerobot.robots.so_follower import SO101Follower, SO101FollowerConfig
65
+
66
+ robot = SO101Follower(
67
+ SO101FollowerConfig(
68
+ port="/dev/ttyACM0", id="my_arm", use_degrees=True, disable_torque_on_disconnect=False
69
+ )
70
+ )
71
+ backend = LeRobotArmBackend(robot, so101_arms("/path/to/so101_new_calib.urdf"), connect=True)
72
+ limits = SafetyLimits(workspace=Workspace("world", (-0.5, -0.5, -0.1), (0.6, 0.5, 0.6)))
73
+ serve_robot(RobotAdapter(backend, limits, name="LeRobot SO-101"), port=9100)
74
+ ```
75
+
76
+ ## Tests
77
+
78
+ ```bash
79
+ # Offline unit, contract, and adapter tests against FakeLeRobot
80
+ uv run --directory packages/a2a-robots-lerobot --extra dev pytest
81
+
82
+ # Integration tests against real lerobot and PlacoKinematics (Python >=3.12)
83
+ A2A_ROBOTS_REQUIRE_LEROBOT=1 uv run --directory packages/a2a-robots-lerobot --python 3.12 \
84
+ --extra serial --extra dev pytest tests/test_lerobot_integration.py
85
+ ```
@@ -0,0 +1,60 @@
1
+ # a2a-robots-lerobot
2
+
3
+ [Hugging Face LeRobot](https://github.com/huggingface/lerobot) backend for [a2a-robots](../../README.md).
4
+
5
+ Install from PyPI: `pip install a2a-robots-lerobot`.
6
+
7
+ ## LeRobot backend
8
+
9
+ `LeRobotArmBackend` adapts single-arm and bimanual manipulators managed by `lerobot.robots.Robot` (for example `SO100Follower`, `SO101Follower`, `BiSOFollower`, and `KochFollower`) to `a2a_robots.RobotBackend` and `a2a_robots.RobotAdapter`.
10
+
11
+ - **URDF kinematics in radians:** `LeRobotKinematicsPlanner` wraps `lerobot.model.kinematics.RobotKinematics` (Placo/Pinocchio) via `PlacoKinematics`, converting between LeRobot's degree-based joint space and `a2a_robots`'s metre/radian pose contract. Pass `base_transform` in `ArmSpec` (or use `bi_so_arms`) to position bimanual arms in a shared `"world"` frame.
12
+ - **5-DoF arms vs. 6-DoF poses:** 5-DoF arms such as SO-100, SO-101, and Koch cannot independently match arbitrary 6-DoF end-effector orientations at every position. The `so101_arms`, `bi_so_arms`, and `koch_arms` presets set `orientation_weight=0.01` and `check_orientation=False` so `move_to` reaches position accurately while aligning orientation best-effort; set `check_orientation=True` for 6-DoF/7-DoF arms.
13
+ - **Safety guards:**
14
+ - `connect=True` always connects with `calibrate=False` so missing calibration never blocks a headless server on interactive terminal prompts; uncalibrated robots fail fast at startup.
15
+ - Robots with `use_degrees=False` (normalized `[-100, 100]` joint space) are rejected by default (`require_use_degrees=True`) unless explicitly configured with `joint_unit="rad"`.
16
+ - Every `send_action()` sends the complete `robot.action_features` dictionary so non-target arms, grippers, and extra actuators stay held.
17
+ - Set `disable_torque_on_disconnect=False` on your LeRobot config if disconnecting on shutdown should not drop a raised arm under gravity.
18
+
19
+ ## Usage
20
+
21
+ `a2a-robots-lerobot` is an independent `uv` project with its own `uv.lock` and optional extras for `lerobot` (`kinematics`, `serial`). Offline tests and `FakeLeRobot` work out of the box without installing `lerobot` or PyTorch.
22
+
23
+ Live hardware and `PlacoKinematics` require Python `>=3.12`:
24
+
25
+ ```bash
26
+ # Offline with FakeLeRobot (no lerobot install needed):
27
+ LEROBOT_FAKE=1 uv run --directory packages/a2a-robots-lerobot python examples/serve_so101.py
28
+
29
+ # Live SO-101 hardware (installs the `serial` extra: lerobot[kinematics,serial-motors]):
30
+ uv run --directory packages/a2a-robots-lerobot --python 3.12 --extra serial \
31
+ python examples/serve_so101.py --serial-port /dev/ttyACM0 --urdf /path/to/so101_new_calib.urdf
32
+ ```
33
+
34
+ Or in Python:
35
+
36
+ ```python
37
+ from a2a_robots import RobotAdapter, SafetyLimits, Workspace, serve_robot
38
+ from a2a_robots_lerobot import LeRobotArmBackend, so101_arms
39
+ from lerobot.robots.so_follower import SO101Follower, SO101FollowerConfig
40
+
41
+ robot = SO101Follower(
42
+ SO101FollowerConfig(
43
+ port="/dev/ttyACM0", id="my_arm", use_degrees=True, disable_torque_on_disconnect=False
44
+ )
45
+ )
46
+ backend = LeRobotArmBackend(robot, so101_arms("/path/to/so101_new_calib.urdf"), connect=True)
47
+ limits = SafetyLimits(workspace=Workspace("world", (-0.5, -0.5, -0.1), (0.6, 0.5, 0.6)))
48
+ serve_robot(RobotAdapter(backend, limits, name="LeRobot SO-101"), port=9100)
49
+ ```
50
+
51
+ ## Tests
52
+
53
+ ```bash
54
+ # Offline unit, contract, and adapter tests against FakeLeRobot
55
+ uv run --directory packages/a2a-robots-lerobot --extra dev pytest
56
+
57
+ # Integration tests against real lerobot and PlacoKinematics (Python >=3.12)
58
+ A2A_ROBOTS_REQUIRE_LEROBOT=1 uv run --directory packages/a2a-robots-lerobot --python 3.12 \
59
+ --extra serial --extra dev pytest tests/test_lerobot_integration.py
60
+ ```
@@ -0,0 +1,85 @@
1
+ """Serve an SO-101 / LeRobot arm on http://127.0.0.1:9100/.
2
+
3
+ Uses ``FakeLeRobot`` when ``--fake`` is passed or ``LEROBOT_FAKE=1`` is set,
4
+ and connects to an ``SO101Follower`` arm on ``LEROBOT_PORT`` (with a URDF path
5
+ via ``LEROBOT_URDF``) otherwise.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import argparse
11
+ import os
12
+ from pathlib import Path
13
+
14
+ from a2a_robots import RobotAdapter, SafetyLimits, Workspace, serve_robot
15
+ from a2a_robots_lerobot import FakeLeRobot, LeRobotArmBackend, so101_arms
16
+
17
+
18
+ def build_adapter(
19
+ *,
20
+ fake: bool = False,
21
+ port: str = "/dev/ttyACM0",
22
+ urdf: str | Path | None = None,
23
+ robot_id: str = "so101_follower",
24
+ ) -> RobotAdapter:
25
+ if fake:
26
+ robot = FakeLeRobot(bimanual=False, dof=5)
27
+ backend = LeRobotArmBackend(robot, robot.arms, solvers=robot.kinematics)
28
+ ee_pos = backend.observe()["right"].pose.position
29
+ robot.place_object("cube", ee_pos)
30
+ else:
31
+ if urdf is None:
32
+ raise ValueError("--urdf (or LEROBOT_URDF) is required for live hardware")
33
+ from lerobot.robots.so_follower import SO101Follower, SO101FollowerConfig
34
+
35
+ cfg = SO101FollowerConfig(
36
+ port=port,
37
+ id=robot_id,
38
+ use_degrees=True,
39
+ disable_torque_on_disconnect=False,
40
+ )
41
+ robot = SO101Follower(cfg)
42
+ backend = LeRobotArmBackend(
43
+ robot,
44
+ so101_arms(urdf),
45
+ connect=True,
46
+ )
47
+
48
+ limits = SafetyLimits(
49
+ workspace=Workspace("world", (-0.5, -0.5, -0.1), (0.6, 0.5, 0.6)),
50
+ max_step_m=0.05,
51
+ max_step_rad=0.25,
52
+ )
53
+ return RobotAdapter(
54
+ backend,
55
+ limits,
56
+ name="LeRobot SO-101",
57
+ description="SO-101 follower arm controlled via Hugging Face LeRobot.",
58
+ )
59
+
60
+
61
+ if __name__ == "__main__":
62
+ parser = argparse.ArgumentParser(description=__doc__)
63
+ parser.add_argument(
64
+ "--fake",
65
+ action="store_true",
66
+ default=os.environ.get("LEROBOT_FAKE") == "1",
67
+ help="Use offline FakeLeRobot instead of connecting to serial hardware.",
68
+ )
69
+ parser.add_argument(
70
+ "--serial-port",
71
+ default=os.environ.get("LEROBOT_PORT", "/dev/ttyACM0"),
72
+ help="Serial port for SO101Follower.",
73
+ )
74
+ parser.add_argument(
75
+ "--urdf",
76
+ default=os.environ.get("LEROBOT_URDF"),
77
+ help="Path to SO-101 URDF file (e.g. from huggingface.co/datasets/lerobot/robot-urdfs).",
78
+ )
79
+ parser.add_argument("--id", default=os.environ.get("LEROBOT_ID", "so101_follower"))
80
+ parser.add_argument("--port", type=int, default=9100)
81
+ args = parser.parse_args()
82
+ serve_robot(
83
+ build_adapter(fake=args.fake, port=args.serial_port, urdf=args.urdf, robot_id=args.id),
84
+ port=args.port,
85
+ )
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.24"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "a2a-robots-lerobot"
7
+ version = "0.1.1"
8
+ description = "Hugging Face LeRobot backend for a2a-robots"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "Apache-2.0"
12
+ authors = [{ name = "HYBRO AI", email = "info@hybro.ai" }]
13
+ classifiers = [
14
+ "Development Status :: 2 - Pre-Alpha",
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ "Programming Language :: Python :: 3.13",
19
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
20
+ ]
21
+ dependencies = ["a2a-robots", "numpy>=1.26"]
22
+
23
+ [project.optional-dependencies]
24
+ kinematics = ["lerobot[kinematics]>=0.7; python_version >= '3.12'"]
25
+ serial = ["lerobot[kinematics,serial-motors]>=0.7; python_version >= '3.12'"]
26
+ dev = ["pytest>=8", "pytest-asyncio>=0.23"]
27
+
28
+ [project.urls]
29
+ Repository = "https://github.com/hybroai/a2a-robots"
30
+
31
+ [tool.uv.sources]
32
+ a2a-robots = { path = "../..", editable = true }
33
+
34
+ [tool.hatch.build.targets.wheel]
35
+ packages = ["src/a2a_robots_lerobot"]
36
+
37
+ [tool.pytest.ini_options]
38
+ asyncio_mode = "auto"
39
+ asyncio_default_fixture_loop_scope = "function"
40
+ testpaths = ["tests"]
@@ -0,0 +1,43 @@
1
+ """Hugging Face LeRobot backend for a2a-robots."""
2
+
3
+ __version__ = "0.1.1"
4
+
5
+ from a2a_robots_lerobot.backend import LeRobotArmBackend
6
+ from a2a_robots_lerobot.config import (
7
+ KOCH_ARM_JOINTS,
8
+ SO_ARM_JOINTS,
9
+ ArmSpec,
10
+ bi_so_arms,
11
+ koch_arms,
12
+ so101_arms,
13
+ so101_hand_spec,
14
+ )
15
+ from a2a_robots_lerobot.fake import AnalyticArmKinematics, FakeLeRobot
16
+ from a2a_robots_lerobot.planner import (
17
+ KinematicsSolver,
18
+ LeRobotKinematicsPlanner,
19
+ PlacoKinematics,
20
+ matrix_to_pose,
21
+ pose_error,
22
+ pose_to_matrix,
23
+ )
24
+
25
+ __all__ = [
26
+ "AnalyticArmKinematics",
27
+ "ArmSpec",
28
+ "FakeLeRobot",
29
+ "KOCH_ARM_JOINTS",
30
+ "KinematicsSolver",
31
+ "LeRobotArmBackend",
32
+ "LeRobotKinematicsPlanner",
33
+ "PlacoKinematics",
34
+ "SO_ARM_JOINTS",
35
+ "__version__",
36
+ "bi_so_arms",
37
+ "koch_arms",
38
+ "matrix_to_pose",
39
+ "pose_error",
40
+ "pose_to_matrix",
41
+ "so101_arms",
42
+ "so101_hand_spec",
43
+ ]