Zenoh Installation - norlab-ulaval/Norlab_wiki GitHub Wiki

1. Install RMW_Zenoh

sudo apt install ros-$ROS_DISTRO-rmw-zenoh-cpp

2. Create a Zenoh folder on your computer

mkdir ~/zenoh

3. Add the router, session Zenoh configuration files and launch file :

cd ~/zenoh
wget https://raw.githubusercontent.com/norlab-ulaval/Norlab_wiki/refs/heads/main/Tutorials/zenoh/launch-zenoh.sh
wget https://raw.githubusercontent.com/norlab-ulaval/Norlab_wiki/refs/heads/main/Tutorials/zenoh/zenoh_router.json5
wget https://raw.githubusercontent.com/norlab-ulaval/Norlab_wiki/refs/heads/main/Tutorials/zenoh/zenoh_session.json5

4. Add the sourcing for the configuration files in your .bashrc

Add those lines your .bashrc or .zshrc:

export RMW_IMPLEMENTATION=rmw_zenoh_cpp
export ZENOH_ROUTER_CONFIG_URI=~/zenoh/zenoh_router.json5
export ZENOH_SESSION_CONFIG_URI=~/zenoh/zenoh_session.json5

5. Set up the environnment

pkill -9 -f ros && ros2 daemon stop
source ~/.bashrc  # or ~/.zshrc

6. Launch zenoh script

chmod +x ~/zenoh/launch-zenoh.sh
~/zenoh/launch-zenoh.sh

7. Finally test that everything is working

Open one terminal and paste

ros2 run demo_nodes_cpp talker

Open a second terminal and paste

ros2 run demo_nodes_cpp listener

You should see Hello World in both terminals. :tada:


Connection example: connect to Castor

Make sure the robot is set up using Zenoh Robot Setup.

Change the IP in your zenoh_router.json5 config file for Castor IP.

  connect: {
    timeout_ms: { router: -1, peer: -1, client: 0 },
    endpoints: 
      {
        /// connect to castor_norlab WiFi Network and put here Castor IP (192.168.4.2)
        router: ["tcp/192.168.4.2:7447"], 
        peer: [],
        client: [],
    },

    exit_on_failure: { router: false, peer: false, client: true },
    retry: {
      period_init_ms: 1000,
      period_max_ms: 4000,
      period_increase_factor: 2,
    },
  },

Set the $ROS_DOMAIN_ID to Castor and launch Zenoh.

export ROS_DOMAIN_ID=4
bash ~/zenoh/launch-zenoh.sh