watson-health--stacked-scrolling--1


Zenoh Installation and Introduction

About Zenoh

Zenoh is a lightweight protocol that integrates pub/sub (data in motion) and distributed query (data at rest) features into a single place. Its elegance lies in the amount of flexibility and efficiency it provides in return for its minimal overhead.

Zenoh can be deployed in a wide range of scenarios. However, my goal is to use it for robotics. It will allow different components within a robotic system to communicate with each other. For example, a sensor and a controller.

This post will cover the installation of the zenoh-cpp library, which is a header-only binding around the zenoh-c API (or zenoh-pico, but that has a more niche use-case). Since most code samples out there are written in Rust, the language zenoh was originally built in, I thought it'd be nice to write a more complete introduction to zenoh-cpp, and shine a light on it. With that said, this will be a more beginner-friendly tutorial. Seasoned veterans may want to skip ahead to some code samples.

Installation

Windows

Prerequisites

Besides installing it on Windows itself, you have the option of using WSL for development and installation instead. You run into a lot less errors there because there's often less uncertainty with development on Linux.

Building from Source and Installation

In order to install zenoh-cpp, we first need to build and install zenoh-c (since zenoh-cpp is a binding around zenoh-c as mentioned above). So crack open a terminal, and run these commands!

  1. Run rustup-update
  2. Clone the zenoh-c repo into a new workspace folder of your choice
    • git clone https://github.com/eclipse-zenoh/zenoh-c.git
  3. We will build zenoh-c in a dedicated build directory, which will be kept separate from the source directory.
    • mkdir -p build && cd build
    • cmake ../zenoh-c
    • cmake --build . --config Release
  4. Install the library into our system
    • cmake --build . --target install
    • On Windows, our default installation path is C:/Program Files/${INSTALLATION}, so you will find it there. If you want to install it into a dedicated local directory, run:
      • cmake ../zenoh-c -DCMAKE_INSTALL_PREFIX="path/to/installation"
      • Do note that you will then have to point your CMake to the library accordingly

Now that we've built zenoh-c, we can begin building zenoh-cpp.

  1. Create a fresh new folder for zenoh-cpp, just to keep things organised.
  2. Clone the zenoh-cpp repository directly into that folder.
    • git clone https://github.com/eclipse-zenoh/zenoh-cpp.git
  3. Install zenoh-cpp with a very similar procedure
    • mkdir -p build && cd build
    • cmake ../zenoh-cpp
    • cmake .. -DCMAKE_PREFIX_PATH="C:/Program Files/${INSTALLATION}"
      • CMAKE_PREFIX_PATH should be where your zenoh-c installation is. By default, C:/Program Files/zenohc
    • cmake --install . --config Release

To get a deeper breakdown of the build process here, you may refer to this optional article.

Next Step: Project Setup

Now that we've installed zenoh-cpp into our system, we can start to dive into setting up a project and writing our first few lines of code. You will find this in the next article.





Glossary

Pub/Sub (publication and subscription)

Distributed Query

Binding