a2a-robots-ros2 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.
- a2a_robots_ros2-0.1.1/.gitignore +8 -0
- a2a_robots_ros2-0.1.1/CHANGELOG.md +17 -0
- a2a_robots_ros2-0.1.1/PKG-INFO +154 -0
- a2a_robots_ros2-0.1.1/README.md +134 -0
- a2a_robots_ros2-0.1.1/examples/turtlesim_bridge.py +56 -0
- a2a_robots_ros2-0.1.1/pyproject.toml +35 -0
- a2a_robots_ros2-0.1.1/src/a2a_robots_ros2/__init__.py +22 -0
- a2a_robots_ros2-0.1.1/src/a2a_robots_ros2/adapter.py +332 -0
- a2a_robots_ros2-0.1.1/src/a2a_robots_ros2/config.py +107 -0
- a2a_robots_ros2-0.1.1/src/a2a_robots_ros2/gateway.py +97 -0
- a2a_robots_ros2-0.1.1/src/a2a_robots_ros2/rclpy_gateway.py +217 -0
- a2a_robots_ros2-0.1.1/tests/test_bridge.py +562 -0
- a2a_robots_ros2-0.1.1/tests/test_rclpy_gateway.py +217 -0
- a2a_robots_ros2-0.1.1/tests/test_skill_config.py +75 -0
- a2a_robots_ros2-0.1.1/tests/test_turtlesim_example.py +94 -0
- a2a_robots_ros2-0.1.1/uv.lock +1083 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.1.1](https://github.com/hybroai/a2a-robots/compare/a2a-robots-ros2-v0.1.0...a2a-robots-ros2-v0.1.1) (2026-11-18)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Miscellaneous Chores
|
|
7
|
+
|
|
8
|
+
* **ros2:** bootstrap first PyPI release ([bbaac1a](https://github.com/hybroai/a2a-robots/commit/bbaac1a702729c7f444042f51b1242da7966c6fc))
|
|
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,154 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: a2a-robots-ros2
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: An allowlisted ROS 2 bridge over A2A, for robot bring-up and debugging
|
|
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-adapter<0.5,>=0.4.1
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
18
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# a2a-robots-ros2
|
|
22
|
+
|
|
23
|
+
An allowlisted ROS 2 bridge for [a2a-robots](../../README.md): it exposes the ROS 2 actions, services and topics you list as A2A skills, for robot bring-up and debugging.
|
|
24
|
+
|
|
25
|
+
Install from PyPI: `pip install a2a-robots-ros2`.
|
|
26
|
+
|
|
27
|
+
This is not the typed robot skill agent. `a2a_robots.RobotAdapter` gives planners one contract (`move_to`, `stop`, the busy rule, safety limits, one result shape) on any robot; this bridge passes configured ROS calls through and adds no safety limits of its own. Anything physical, such as joint limits or an emergency stop, stays in the robot's ROS stack.
|
|
28
|
+
|
|
29
|
+
The bridge talks to ROS only through the `RosGateway` interface. `RclpyGateway` implements it for a live ROS 2 graph.
|
|
30
|
+
|
|
31
|
+
## Allowlist
|
|
32
|
+
|
|
33
|
+
Each entry maps one skill to one ROS interface. Nothing else can be reached through the bridge.
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from a2a_robots_ros2 import Ros2BridgeAdapter, serve_bridge
|
|
37
|
+
from a2a_robots_ros2.rclpy_gateway import RclpyGateway
|
|
38
|
+
|
|
39
|
+
skills = [
|
|
40
|
+
{
|
|
41
|
+
"id": "rotate",
|
|
42
|
+
"kind": "action",
|
|
43
|
+
"ros_name": "/turtle1/rotate_absolute",
|
|
44
|
+
"type": "turtlesim/action/RotateAbsolute",
|
|
45
|
+
"description": "Turn the turtle to an absolute heading in radians.",
|
|
46
|
+
},
|
|
47
|
+
{"id": "spawn", "kind": "service", "ros_name": "/spawn", "type": "turtlesim/srv/Spawn"},
|
|
48
|
+
{"id": "pose", "kind": "topic", "ros_name": "/turtle1/pose", "type": "turtlesim/msg/Pose"},
|
|
49
|
+
]
|
|
50
|
+
serve_bridge(Ros2BridgeAdapter(skills, RclpyGateway())) # http://127.0.0.1:9200/
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
| Field | Meaning |
|
|
54
|
+
| --- | --- |
|
|
55
|
+
| `id` | Skill name callers use. |
|
|
56
|
+
| `kind` | `action`, `service`, or `topic` (returns the latest message). |
|
|
57
|
+
| `ros_name` | Absolute ROS name. |
|
|
58
|
+
| `type` | Interface type, such as `turtlesim/action/RotateAbsolute`. |
|
|
59
|
+
| `description` | Optional. Shown in the Agent Card. |
|
|
60
|
+
| `timeout_s` | Optional. Bounds the whole call, including waiting for the server. Defaults: 60 s for actions, 10 s otherwise. |
|
|
61
|
+
| `exclusive` | Optional. Refuse a new call to this skill while one is still running. |
|
|
62
|
+
|
|
63
|
+
The allowlist is checked when the adapter is built, and the gateway loads every interface type then, so a typo or a missing message package fails at startup.
|
|
64
|
+
|
|
65
|
+
## Requests and results
|
|
66
|
+
|
|
67
|
+
Requests are JSON, sent as a text part or a data part. `args` holds the goal or request fields, with nested messages as nested objects; a topic skill takes none.
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{"skill": "rotate", "args": {"theta": 1.57}}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
| Kind | Result |
|
|
74
|
+
| --- | --- |
|
|
75
|
+
| action | `{"skill": "rotate", "status": "succeeded", "result": {...}}`, where `status` is `succeeded`, `aborted` or `canceled` |
|
|
76
|
+
| service | `{"skill": "spawn", "response": {...}}` |
|
|
77
|
+
| topic | `{"skill": "pose", "message": {...}, "age_s": 0.04}`, where `age_s` is the time since the message arrived |
|
|
78
|
+
|
|
79
|
+
A goal that ran but did not succeed is a completed A2A task with its status, like a skill result with `success: false`. A malformed request, a rejected goal, a missing server or a timeout fails the task with the reason.
|
|
80
|
+
|
|
81
|
+
Feedback is streamed by default. The reply is then newline-delimited JSON in the response artifact: for an action an `accepted` line, then feedback lines (at most 2 per second; set `max_feedback_hz`; feedback that arrives before acceptance is held until the `accepted` line), then the result as the last line. Feedback appears in the response artifact, not as task status messages. With `stream_feedback=False` the reply is just the result, as JSON text and as an `application/json` data part.
|
|
82
|
+
|
|
83
|
+
## Cancel and timeouts
|
|
84
|
+
|
|
85
|
+
- `tasks/cancel` cancels the goal and waits for the action server's answer before the task is reported cancelled. A cancel that arrives while the goal is still being sent cancels it as soon as it is accepted. A timeout or shutdown cancels the goal too.
|
|
86
|
+
- If the server does not confirm the cancel within `cancel_timeout_s` (5 s by default), or the cancel fails, the bridge logs that the goal may still be running and tries again when the call stops and on shutdown. The call then waits for the goal to end, even past the skill's `timeout_s` and when the stream is closed. If the goal has not ended within a2a-adapter's cancel wait (10 s), `tasks/cancel` returns the task failed with that message instead of cancelled.
|
|
87
|
+
- ROS 2 services cannot be cancelled. Cancelling a service task, or its timeout, stops the wait, but the call may still complete on the robot.
|
|
88
|
+
- `serve_bridge()` binds `127.0.0.1` by default, because anyone who can reach the server can move the robot.
|
|
89
|
+
|
|
90
|
+
## ROS 2
|
|
91
|
+
|
|
92
|
+
rclpy is not on PyPI. It comes with a ROS 2 install and is built for that distribution's Python, so it is not a dependency of this package. ROS 2 Jazzy (Python 3.12) and newer are supported; Humble (Python 3.10) is below the Python 3.11 minimum.
|
|
93
|
+
|
|
94
|
+
To use `RclpyGateway`, source ROS 2 and use a virtual environment on the ROS Python that can see its packages:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
source /opt/ros/jazzy/setup.bash
|
|
98
|
+
uv venv --system-site-packages --python /usr/bin/python3
|
|
99
|
+
uv pip install ./packages/a2a-robots-ros2 # from a checkout of this repository
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
`RclpyGateway(node_name="a2a_ros2_bridge")` creates one node in its own rclpy context and spins it on a background thread, so ROS callbacks never block the A2A server. The interface packages named in the allowlist (for example `turtlesim`) must be installed and sourced.
|
|
103
|
+
|
|
104
|
+
- Topics are read with the sensor-data QoS (best effort, keep last 5), which matches both reliable and best-effort publishers. A read returns the latest message, or waits for the first one.
|
|
105
|
+
- Args are set with `rosidl_runtime_py.set_message_fields`; a field that does not fit the message fails the task without calling ROS.
|
|
106
|
+
- The bridge waits for an action or service server within the skill's `timeout_s`.
|
|
107
|
+
|
|
108
|
+
## Try it with turtlesim
|
|
109
|
+
|
|
110
|
+
[`examples/turtlesim_bridge.py`](examples/turtlesim_bridge.py) allowlists turtlesim's `rotate_absolute` action, the `teleport_absolute` and `spawn` services and the pose topic. With ROS 2 Jazzy, `ros-jazzy-turtlesim` installed and the virtual environment from [ROS 2](#ros-2), run each in its own shell with ROS 2 sourced:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
ros2 run turtlesim turtlesim_node
|
|
114
|
+
python packages/a2a-robots-ros2/examples/turtlesim_bridge.py # http://127.0.0.1:9200/
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The Agent Card at `http://127.0.0.1:9200/.well-known/agent-card.json` lists the four skills. Turn the turtle:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
curl -s http://127.0.0.1:9200/ -H 'Content-Type: application/json' -d '{
|
|
121
|
+
"jsonrpc": "2.0", "id": 1, "method": "message/send",
|
|
122
|
+
"params": {"message": {"role": "user", "messageId": "m1", "parts": [
|
|
123
|
+
{"kind": "text", "text": "{\"skill\": \"rotate\", \"args\": {\"theta\": 1.57}}"}]}}}' \
|
|
124
|
+
| jq -j '.result.artifacts[0].parts[].text'
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
```text
|
|
128
|
+
{"skill": "rotate", "status": "accepted"}
|
|
129
|
+
{"skill": "rotate", "feedback": {"remaining": 1.5700000524520874}}
|
|
130
|
+
{"skill": "rotate", "feedback": {"remaining": 1.058000087738037}}
|
|
131
|
+
{"skill": "rotate", "feedback": {"remaining": 0.5460000038146973}}
|
|
132
|
+
{"skill": "rotate", "feedback": {"remaining": 0.03400003910064697}}
|
|
133
|
+
{"skill": "rotate", "status": "succeeded", "result": {"delta": -1.5520000457763672}}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Use a new `messageId` for each request. Other requests: `{"skill": "pose"}`, `{"skill": "teleport", "args": {"x": 2.0, "y": 3.0, "theta": 0.0}}` and `{"skill": "spawn", "args": {"x": 8.0, "y": 8.0, "theta": 0.0}}`. Stopping the server shuts the ROS node down.
|
|
137
|
+
|
|
138
|
+
## Tests
|
|
139
|
+
|
|
140
|
+
The bridge tests use a fake `RosGateway`, so they need no ROS install:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
uv run --directory packages/a2a-robots-ros2 --extra dev pytest
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
The `RclpyGateway` tests run against a live graph and are skipped without rclpy. The turtlesim example test starts a headless `turtlesim_node` (`QT_QPA_PLATFORM=offscreen`) and drives it over JSON-RPC. CI runs both in the `ros:jazzy-ros-base` image with `ros-jazzy-example-interfaces` and `ros-jazzy-turtlesim` installed:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
source /opt/ros/jazzy/setup.bash
|
|
150
|
+
export UV_PROJECT_ENVIRONMENT=/opt/a2a-venv
|
|
151
|
+
uv venv --system-site-packages --python /usr/bin/python3 "$UV_PROJECT_ENVIRONMENT"
|
|
152
|
+
uv sync --locked --project packages/a2a-robots-ros2 --extra dev
|
|
153
|
+
A2A_ROBOTS_REQUIRE_ROS=1 uv run --no-sync --project packages/a2a-robots-ros2 pytest packages/a2a-robots-ros2
|
|
154
|
+
```
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# a2a-robots-ros2
|
|
2
|
+
|
|
3
|
+
An allowlisted ROS 2 bridge for [a2a-robots](../../README.md): it exposes the ROS 2 actions, services and topics you list as A2A skills, for robot bring-up and debugging.
|
|
4
|
+
|
|
5
|
+
Install from PyPI: `pip install a2a-robots-ros2`.
|
|
6
|
+
|
|
7
|
+
This is not the typed robot skill agent. `a2a_robots.RobotAdapter` gives planners one contract (`move_to`, `stop`, the busy rule, safety limits, one result shape) on any robot; this bridge passes configured ROS calls through and adds no safety limits of its own. Anything physical, such as joint limits or an emergency stop, stays in the robot's ROS stack.
|
|
8
|
+
|
|
9
|
+
The bridge talks to ROS only through the `RosGateway` interface. `RclpyGateway` implements it for a live ROS 2 graph.
|
|
10
|
+
|
|
11
|
+
## Allowlist
|
|
12
|
+
|
|
13
|
+
Each entry maps one skill to one ROS interface. Nothing else can be reached through the bridge.
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from a2a_robots_ros2 import Ros2BridgeAdapter, serve_bridge
|
|
17
|
+
from a2a_robots_ros2.rclpy_gateway import RclpyGateway
|
|
18
|
+
|
|
19
|
+
skills = [
|
|
20
|
+
{
|
|
21
|
+
"id": "rotate",
|
|
22
|
+
"kind": "action",
|
|
23
|
+
"ros_name": "/turtle1/rotate_absolute",
|
|
24
|
+
"type": "turtlesim/action/RotateAbsolute",
|
|
25
|
+
"description": "Turn the turtle to an absolute heading in radians.",
|
|
26
|
+
},
|
|
27
|
+
{"id": "spawn", "kind": "service", "ros_name": "/spawn", "type": "turtlesim/srv/Spawn"},
|
|
28
|
+
{"id": "pose", "kind": "topic", "ros_name": "/turtle1/pose", "type": "turtlesim/msg/Pose"},
|
|
29
|
+
]
|
|
30
|
+
serve_bridge(Ros2BridgeAdapter(skills, RclpyGateway())) # http://127.0.0.1:9200/
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
| Field | Meaning |
|
|
34
|
+
| --- | --- |
|
|
35
|
+
| `id` | Skill name callers use. |
|
|
36
|
+
| `kind` | `action`, `service`, or `topic` (returns the latest message). |
|
|
37
|
+
| `ros_name` | Absolute ROS name. |
|
|
38
|
+
| `type` | Interface type, such as `turtlesim/action/RotateAbsolute`. |
|
|
39
|
+
| `description` | Optional. Shown in the Agent Card. |
|
|
40
|
+
| `timeout_s` | Optional. Bounds the whole call, including waiting for the server. Defaults: 60 s for actions, 10 s otherwise. |
|
|
41
|
+
| `exclusive` | Optional. Refuse a new call to this skill while one is still running. |
|
|
42
|
+
|
|
43
|
+
The allowlist is checked when the adapter is built, and the gateway loads every interface type then, so a typo or a missing message package fails at startup.
|
|
44
|
+
|
|
45
|
+
## Requests and results
|
|
46
|
+
|
|
47
|
+
Requests are JSON, sent as a text part or a data part. `args` holds the goal or request fields, with nested messages as nested objects; a topic skill takes none.
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{"skill": "rotate", "args": {"theta": 1.57}}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
| Kind | Result |
|
|
54
|
+
| --- | --- |
|
|
55
|
+
| action | `{"skill": "rotate", "status": "succeeded", "result": {...}}`, where `status` is `succeeded`, `aborted` or `canceled` |
|
|
56
|
+
| service | `{"skill": "spawn", "response": {...}}` |
|
|
57
|
+
| topic | `{"skill": "pose", "message": {...}, "age_s": 0.04}`, where `age_s` is the time since the message arrived |
|
|
58
|
+
|
|
59
|
+
A goal that ran but did not succeed is a completed A2A task with its status, like a skill result with `success: false`. A malformed request, a rejected goal, a missing server or a timeout fails the task with the reason.
|
|
60
|
+
|
|
61
|
+
Feedback is streamed by default. The reply is then newline-delimited JSON in the response artifact: for an action an `accepted` line, then feedback lines (at most 2 per second; set `max_feedback_hz`; feedback that arrives before acceptance is held until the `accepted` line), then the result as the last line. Feedback appears in the response artifact, not as task status messages. With `stream_feedback=False` the reply is just the result, as JSON text and as an `application/json` data part.
|
|
62
|
+
|
|
63
|
+
## Cancel and timeouts
|
|
64
|
+
|
|
65
|
+
- `tasks/cancel` cancels the goal and waits for the action server's answer before the task is reported cancelled. A cancel that arrives while the goal is still being sent cancels it as soon as it is accepted. A timeout or shutdown cancels the goal too.
|
|
66
|
+
- If the server does not confirm the cancel within `cancel_timeout_s` (5 s by default), or the cancel fails, the bridge logs that the goal may still be running and tries again when the call stops and on shutdown. The call then waits for the goal to end, even past the skill's `timeout_s` and when the stream is closed. If the goal has not ended within a2a-adapter's cancel wait (10 s), `tasks/cancel` returns the task failed with that message instead of cancelled.
|
|
67
|
+
- ROS 2 services cannot be cancelled. Cancelling a service task, or its timeout, stops the wait, but the call may still complete on the robot.
|
|
68
|
+
- `serve_bridge()` binds `127.0.0.1` by default, because anyone who can reach the server can move the robot.
|
|
69
|
+
|
|
70
|
+
## ROS 2
|
|
71
|
+
|
|
72
|
+
rclpy is not on PyPI. It comes with a ROS 2 install and is built for that distribution's Python, so it is not a dependency of this package. ROS 2 Jazzy (Python 3.12) and newer are supported; Humble (Python 3.10) is below the Python 3.11 minimum.
|
|
73
|
+
|
|
74
|
+
To use `RclpyGateway`, source ROS 2 and use a virtual environment on the ROS Python that can see its packages:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
source /opt/ros/jazzy/setup.bash
|
|
78
|
+
uv venv --system-site-packages --python /usr/bin/python3
|
|
79
|
+
uv pip install ./packages/a2a-robots-ros2 # from a checkout of this repository
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`RclpyGateway(node_name="a2a_ros2_bridge")` creates one node in its own rclpy context and spins it on a background thread, so ROS callbacks never block the A2A server. The interface packages named in the allowlist (for example `turtlesim`) must be installed and sourced.
|
|
83
|
+
|
|
84
|
+
- Topics are read with the sensor-data QoS (best effort, keep last 5), which matches both reliable and best-effort publishers. A read returns the latest message, or waits for the first one.
|
|
85
|
+
- Args are set with `rosidl_runtime_py.set_message_fields`; a field that does not fit the message fails the task without calling ROS.
|
|
86
|
+
- The bridge waits for an action or service server within the skill's `timeout_s`.
|
|
87
|
+
|
|
88
|
+
## Try it with turtlesim
|
|
89
|
+
|
|
90
|
+
[`examples/turtlesim_bridge.py`](examples/turtlesim_bridge.py) allowlists turtlesim's `rotate_absolute` action, the `teleport_absolute` and `spawn` services and the pose topic. With ROS 2 Jazzy, `ros-jazzy-turtlesim` installed and the virtual environment from [ROS 2](#ros-2), run each in its own shell with ROS 2 sourced:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
ros2 run turtlesim turtlesim_node
|
|
94
|
+
python packages/a2a-robots-ros2/examples/turtlesim_bridge.py # http://127.0.0.1:9200/
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The Agent Card at `http://127.0.0.1:9200/.well-known/agent-card.json` lists the four skills. Turn the turtle:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
curl -s http://127.0.0.1:9200/ -H 'Content-Type: application/json' -d '{
|
|
101
|
+
"jsonrpc": "2.0", "id": 1, "method": "message/send",
|
|
102
|
+
"params": {"message": {"role": "user", "messageId": "m1", "parts": [
|
|
103
|
+
{"kind": "text", "text": "{\"skill\": \"rotate\", \"args\": {\"theta\": 1.57}}"}]}}}' \
|
|
104
|
+
| jq -j '.result.artifacts[0].parts[].text'
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
```text
|
|
108
|
+
{"skill": "rotate", "status": "accepted"}
|
|
109
|
+
{"skill": "rotate", "feedback": {"remaining": 1.5700000524520874}}
|
|
110
|
+
{"skill": "rotate", "feedback": {"remaining": 1.058000087738037}}
|
|
111
|
+
{"skill": "rotate", "feedback": {"remaining": 0.5460000038146973}}
|
|
112
|
+
{"skill": "rotate", "feedback": {"remaining": 0.03400003910064697}}
|
|
113
|
+
{"skill": "rotate", "status": "succeeded", "result": {"delta": -1.5520000457763672}}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Use a new `messageId` for each request. Other requests: `{"skill": "pose"}`, `{"skill": "teleport", "args": {"x": 2.0, "y": 3.0, "theta": 0.0}}` and `{"skill": "spawn", "args": {"x": 8.0, "y": 8.0, "theta": 0.0}}`. Stopping the server shuts the ROS node down.
|
|
117
|
+
|
|
118
|
+
## Tests
|
|
119
|
+
|
|
120
|
+
The bridge tests use a fake `RosGateway`, so they need no ROS install:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
uv run --directory packages/a2a-robots-ros2 --extra dev pytest
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
The `RclpyGateway` tests run against a live graph and are skipped without rclpy. The turtlesim example test starts a headless `turtlesim_node` (`QT_QPA_PLATFORM=offscreen`) and drives it over JSON-RPC. CI runs both in the `ros:jazzy-ros-base` image with `ros-jazzy-example-interfaces` and `ros-jazzy-turtlesim` installed:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
source /opt/ros/jazzy/setup.bash
|
|
130
|
+
export UV_PROJECT_ENVIRONMENT=/opt/a2a-venv
|
|
131
|
+
uv venv --system-site-packages --python /usr/bin/python3 "$UV_PROJECT_ENVIRONMENT"
|
|
132
|
+
uv sync --locked --project packages/a2a-robots-ros2 --extra dev
|
|
133
|
+
A2A_ROBOTS_REQUIRE_ROS=1 uv run --no-sync --project packages/a2a-robots-ros2 pytest packages/a2a-robots-ros2
|
|
134
|
+
```
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""Serve turtlesim through the ROS 2 bridge on http://127.0.0.1:9200/.
|
|
2
|
+
|
|
3
|
+
Start turtlesim first, in a shell with ROS 2 sourced:
|
|
4
|
+
|
|
5
|
+
ros2 run turtlesim turtlesim_node
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from a2a_robots_ros2 import Ros2BridgeAdapter, serve_bridge
|
|
9
|
+
|
|
10
|
+
SKILLS = [
|
|
11
|
+
{
|
|
12
|
+
"id": "rotate",
|
|
13
|
+
"kind": "action",
|
|
14
|
+
"ros_name": "/turtle1/rotate_absolute",
|
|
15
|
+
"type": "turtlesim/action/RotateAbsolute",
|
|
16
|
+
"description": "Turn the turtle to an absolute heading, theta in radians.",
|
|
17
|
+
"timeout_s": 30,
|
|
18
|
+
"exclusive": True,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"id": "teleport",
|
|
22
|
+
"kind": "service",
|
|
23
|
+
"ros_name": "/turtle1/teleport_absolute",
|
|
24
|
+
"type": "turtlesim/srv/TeleportAbsolute",
|
|
25
|
+
"description": "Move the turtle to x, y (0 to 11) and heading theta.",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"id": "spawn",
|
|
29
|
+
"kind": "service",
|
|
30
|
+
"ros_name": "/spawn",
|
|
31
|
+
"type": "turtlesim/srv/Spawn",
|
|
32
|
+
"description": "Add a turtle at x, y, theta; returns its name.",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"id": "pose",
|
|
36
|
+
"kind": "topic",
|
|
37
|
+
"ros_name": "/turtle1/pose",
|
|
38
|
+
"type": "turtlesim/msg/Pose",
|
|
39
|
+
"description": "Where turtle1 is now.",
|
|
40
|
+
},
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def make_adapter() -> Ros2BridgeAdapter:
|
|
45
|
+
from a2a_robots_ros2.rclpy_gateway import RclpyGateway
|
|
46
|
+
|
|
47
|
+
return Ros2BridgeAdapter(
|
|
48
|
+
SKILLS,
|
|
49
|
+
RclpyGateway("turtlesim_bridge"),
|
|
50
|
+
name="Turtlesim",
|
|
51
|
+
description="turtle1 in turtlesim, through the allowlisted ROS 2 bridge.",
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
if __name__ == "__main__":
|
|
56
|
+
serve_bridge(make_adapter())
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.24"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "a2a-robots-ros2"
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "An allowlisted ROS 2 bridge over A2A, for robot bring-up and debugging"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
authors = [{ name = "HYBRO AI", email = "info@hybro.ai" }]
|
|
12
|
+
requires-python = ">=3.11"
|
|
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
|
+
# rclpy comes from the ROS 2 install, not PyPI, so it is not listed here.
|
|
22
|
+
dependencies = ["a2a-adapter>=0.4.1,<0.5"]
|
|
23
|
+
|
|
24
|
+
[project.optional-dependencies]
|
|
25
|
+
dev = ["pytest>=8", "pytest-asyncio>=0.23"]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Repository = "https://github.com/hybroai/a2a-robots"
|
|
29
|
+
|
|
30
|
+
[tool.hatch.build.targets.wheel]
|
|
31
|
+
packages = ["src/a2a_robots_ros2"]
|
|
32
|
+
|
|
33
|
+
[tool.pytest.ini_options]
|
|
34
|
+
asyncio_mode = "auto"
|
|
35
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""An allowlisted ROS 2 bridge for a2a-robots: bring-up and debugging over A2A."""
|
|
2
|
+
|
|
3
|
+
__version__ = "0.1.1"
|
|
4
|
+
|
|
5
|
+
from .adapter import Ros2BridgeAdapter, serve_bridge
|
|
6
|
+
from .config import Kind, SkillSpec, parse_skills
|
|
7
|
+
from .gateway import GoalHandle, GoalResult, RequestError, RosError, RosGateway, TopicSample
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"GoalHandle",
|
|
11
|
+
"GoalResult",
|
|
12
|
+
"Kind",
|
|
13
|
+
"RequestError",
|
|
14
|
+
"Ros2BridgeAdapter",
|
|
15
|
+
"RosError",
|
|
16
|
+
"RosGateway",
|
|
17
|
+
"SkillSpec",
|
|
18
|
+
"TopicSample",
|
|
19
|
+
"__version__",
|
|
20
|
+
"parse_skills",
|
|
21
|
+
"serve_bridge",
|
|
22
|
+
]
|