Skip to content

Commit f99697f

Browse files
docs: add Python interface section to main README
Summarizes xbot_service_interface_py (schema modes, RPC, transactions, xbot-shell, xbot-logs) and links to its full README for details.
1 parent e537e36 commit f99697f

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

Readme.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ code necessary for service discovery and configuration.
5959

6060
All dependencies are included here as submodules. Not every dependency is needed by every part of the software.
6161

62+
### /xbot_service_interface_py
63+
64+
Python service interface — connect to xBot services from Python without any code generation. See
65+
[Python Interface](#python-interface) below for a summary, or the
66+
[package README](xbot_service_interface_py/README.md) for full details.
67+
6268
---
6369

6470
## Wire Protocol
@@ -255,6 +261,58 @@ Then inherit from the generated `MyServiceNameBase` or `MyInterfaceNameBase` cla
255261

256262
---
257263

264+
## Python Interface
265+
266+
`xbot_service_interface_py` is a pure-Python client for xBot services — no codegen step required. It talks directly
267+
to the wire protocol described above, so it's a good fit for scripting, quick prototyping, ROS bridges, or driving
268+
services from Jupyter/IPython.
269+
270+
Two ways to use a service:
271+
272+
- **Schema provided:** pass a `service.json` file (or dict) to `ServiceInterface`. The schema is validated against
273+
the service's advertisement on connect, and an `IncompatibleServiceError` aborts the connection on a mismatch.
274+
- **Schema-free:** omit the schema entirely. The full service description is embedded in the advertisement itself, so
275+
inputs, outputs, registers, and RPC functions are all available immediately after discovery.
276+
277+
```python
278+
from xbot_service_interface import XbotServiceIo, ServiceInterface
279+
280+
xbot = XbotServiceIo(bind_ip='0.0.0.0')
281+
echo = ServiceInterface(service_id=1, schema='echo_service.json')
282+
xbot.register(echo)
283+
284+
@echo.on_connected
285+
def connected():
286+
echo.registers['Prefix'] = "py: "
287+
288+
@echo.on_echo_changed
289+
def got_echo(value: str, timestamp: int):
290+
print(f"echo: {value!r}")
291+
292+
xbot.start()
293+
```
294+
295+
Beyond the core send/receive/register API, the package includes:
296+
297+
- **RPC calls** — synchronous `call_{name}(*args, timeout_ms=...)` with typed exceptions (`RpcTimeoutError`,
298+
`RpcBusyError`, `RpcError`).
299+
- **Atomic transactions** — bundle multiple sends into one UDP packet via `with iface.transaction(): ...`.
300+
- **`xbot-shell`** — an IPython-based interactive shell (`pip install "xbot-service-interface-py[shell]"`) with
301+
tab-completable service proxies, a `services()` discovery table, live output streaming (`svc.watch_all()`), and an
302+
interactive register configuration wizard.
303+
- **`xbot-logs`** — a CLI remote log viewer for the `LOG` multicast stream, filterable by level.
304+
305+
Install from a tagged release:
306+
307+
```bash
308+
pip install "xbot-service-interface-py @ git+https://github.com/xtech/xbot_framework.git@v1.0.0#subdirectory=xbot_service_interface_py"
309+
```
310+
311+
Requires Python 3.10+. Full API reference, type mapping table, and shell walkthrough in the
312+
[package README](xbot_service_interface_py/README.md).
313+
314+
---
315+
258316
## Status and Contributions
259317

260318
xBot Framework is stable and running in production as the hardware layer for **[OpenMower](https://github.com/ClemensElflein/OpenMower)**.

0 commit comments

Comments
 (0)