ROS 2 Interoperability
ros-z nodes — whether written in Rust, Python, or Go — speak the same Zenoh wire protocol as rmw_zenoh_cpp, the official ROS 2 middleware plugin for Zenoh. This means they interoperate transparently: a Go subscriber can receive messages from a ROS 2 C++ talker, a Python publisher can send to a Rust listener, and so on.
Prerequisites
- A ROS 2 installation with
rmw_zenoh_cppanddemo_nodes_cpp - A Zenoh router running on
localhost:7447(see Networking)
How It Works
All participants connect to the same Zenoh router on the local machine.
graph LR
talker["demo_nodes_cpp<br>talker"] --> rmw["rmw_zenoh_cpp"] --> router(["Zenoh router<br>localhost:7447"])
router <-->|Zenoh| rust["Rust<br>(ros-z)"]
router <-->|Zenoh| python["Python<br>(ros-z-py)"]
router <-->|Zenoh| go["Go<br>(ros-z-go)"]
The Zenoh router can be rmw_zenohd, zenohd, cargo run --example zenoh_router, or Docker.
See Networking for all options.
Requirements for successful message exchange:
- Both sides must use the same message type with matching RIHS01 type hashes
- ROS 2 nodes must use
rmw_zenoh_cpp(export RMW_IMPLEMENTATION=rmw_zenoh_cpp)
If type hashes differ (e.g. mismatched message definitions), nodes silently drop messages.
Enable RUST_LOG=ros_z=debug to inspect the hash in the key expression and compare with the ROS 2 side.
See Troubleshooting for diagnosis steps.
Setup
# Terminal 1 — router
ros2 run rmw_zenoh_cpp rmw_zenohd
# Terminal 2 — ROS 2 talker
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 run demo_nodes_cpp talker
# Terminal 3 — ros-z listener (see Rust / Python / Go below)
Rust
cargo run --example demo_nodes_listener
For more detail on publisher/subscriber patterns see Pub/Sub.
Python
cd crates/ros-z-py
source .venv/bin/activate
python examples/topic_demo.py -r listener
Or go the other way — Python publishes, ROS 2 listens:
python examples/topic_demo.py -r talker
# On ROS 2 side:
ros2 topic echo /chatter std_msgs/msg/String
For more detail see Python Bindings.
Go
just -f crates/ros-z-go/justfile run-example subscriber
For more detail see Go Quick Start.