-
Notifications
You must be signed in to change notification settings - Fork 2
Zenoh rmw
This guide explains how to use Zenoh as an alternative middleware to DDS for ROS 2 communication on norlab robots.
At the moment of writing this guide ros2-humble-rmw-zenoh-cpp
is not yet officially released. Therefore, you will need to enable deb testing repos by following this guide. Then install zenoh rmw
with
sudo apt install ros-$ROS_DISTRO-rmw-zenoh-cpp
ℹ️ It might be a good idea to change ros2 debian repository back to stable from testing at this point.
If an old rmw was already running (you didn't start the robot with all zenoh enabled), kill it with
pkill -9 -f ros && ros2 daemon stop
Open three terminal panes. In one, run the zenoh router. This we will eventually move to systemctl service:
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 run rmw_zenoh_cpp rmw_zenohd
In the remaining two panes, execute:
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 run demo_nodes_cpp talker
and
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 run demo_nodes_cpp listener
You should see now messages going through the network from one node to another.
We will now create a systemctl
service that starts rmw_zenohd
automatically on startup. Create a file /etc/systemctl/systemd/launch-zenoh.service
with the following content:
[Unit]
Description=Eclipse Zenoh RMW Router
Documentation=https://github.com/ros2/rmw_zenoh
After=network-online.target
Wants=network-online.target
[Service]
Type=forking
WorkingDirectory=/home/robot/
ExecStart=/home/robot/ros2_ws/src/norlab_robot/scripts/startup/launch-zenoh.sh
KillMode=mixed
KillSignal=SIGINT
RestartKillSignal=SIGINT
Restart=on-failure
RestartSec=2
User=robot
StandardOutput=journal
StandardError=journal
SyslogIdentifier=rmw_zenohd
[Install]
WantedBy=default.target
This service launches a file in norlab_robot
, which in turns starts rmw_zenohd
in screen named zenoh_router
:
#! /bin/bash
# service file: /etc/systemd/system/launch-zenoh.service
screen_name="zenoh_router"
screen -S $screen_name -X stuff $'\003'
source /home/robot/ros2_ws/src/norlab_robot/scripts/bash/env.sh
source /opt/ros/humble/setup.bash
source /home/robot/ros2_ws/install/local_setup.bash
sleep 2
echo "Starting Zenoh router.."
export RUST_LOG=zenoh=info
screen -dmS $screen_name ros2 run rmw_zenoh_cpp rmw_zenohd
sleep 2
if screen -list | grep -q $screen_name; then
echo "Zenoh router started successfully in screen '$screen_name.'"
else
echo "ERROR! Failed to start Zenoh router."
fi
If you have any other ROS services running at startup, make sure to add the following lines to their respective service files, in order to only start them after zenoh
is running:
[Unit]
...
After=launch_zenoh
Wants=launch_zenoh
Finally, we will need to specify that we want to use zenoh_rmw
for all our nodes. This can be done by placing
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
in norlab_robot/scripts/bash/env.sh
.
Once this is done, sudo reboot
and now your computer executes all ROS communication over the Zenoh network!
With zenoh_rmw
, there are two configuration files we need to consider:
- Router config - started with
ros2 run rmw_zenoh_cpp rmw_zenohd
- Session config - any other ROS 2 node
For more info on
zenoh_rmw
design, check this git page. In our case, the configuration files are located innorlab_robot/scripts/config/zenoh_router.json5
andnorlab_robot/scripts/config/zenoh_session.json5
. For now on Castor, these look exactly the same as the default files here (router) and here (session). To letzenoh
know that we want to use our configuration files, we need to add
export ZENOH_ROUTER_CONFIG_URI=$NORLAB_ROBOT_PATH/config/zenoh_router.json5
export ZENOH_SESSION_CONFIG_URI=$NORLAB_ROBOT_PATH/config/zenoh_session.json5
in norlab_robot/scripts/bash/env.sh
.
If you wanna be able to access the topics and nodes published on Castor's computer, you can again sudo apt install ros-$ROS_DISTRO-rmw-zenoh-cpp
. In your zenoh_router.json5
, specify Castor computer's IP address:
{
connect: {
/// assuming you are connected to the wifi network castor_norlab
endpoints: ["tcp/192.168.4.2:7447"],
},
}
and run zenoh-router with
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
export ZENOH_ROUTER_CONFIG_URI=$HOME/config/zenoh_router.json5
export ROS_DOMAIN_ID=4 # 4 is Castor's domain id
ros2 run rmw_zenoh_cpp rmw_zenohd
in a second terminal window, list all available topics on Castor with
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
export ROS_DOMAIN_ID=4 # 4 is Castor's domain id
ros2 topic list
While the above was working on both Ubuntu 22 and 24, we didn't get any messages through with ros2 topic echo
on Ubuntu 24.
Even though a small message, such as /joy
or /chatter
, passed on Ubuntu 22, we still weren't able to receive larger ROS messages, such as point clouds. The router config probably needs more tweaking to achieve the desired performance.
- Warthog Teach and Repeat (ROS1)
- Warthog Teach and Repeat (ROS2)
- Time Synchronization (NTP)
- Time Synchronization (PTP)
- Deployment of Robotic Total Stations (RTS)
- Deployment of the backpack GPS
- Warthog Emlid GPS
- Atlans-C INS
- How to use a CB Radio when going in the forest
- IP forwarding
- Emlid Data Postprocessing (PPK)
- Setting up a reliable robot communication with Zenoh
- Zenoh rmw
- Lessons Learned
- Robots' 3D Models
- Order Management
- Fast track Master → PhD
- Intellectual Property
- Repository Guidelines
- TF Cheatsheet
- Montmorency Forest Wintertime Dataset
- RTS-GT Dataset 2023
- Deschenes2021 Dataset
- TIGS Dataset
- DRIVE Datasets
- BorealHDR
- TimberSeg 1.0
- DARPA Subterranean Challenge - Urban Dataset
- How to upload a dataset to VALERIA
- ROS1 Bridge
- Migrating a repository to ROS2 (Humble)
- ROS2 and rosbags
- MCAP rosbags
- DDS Configuration (work in progress)
- Using a USB Microphone with ROS2
- ROS2 in VSCode
- ROS2 Troubleshooting