diff --git a/content/learning-paths/cross-platform/zenoh-multinode-ros2/1_intro-zenoh.md b/content/learning-paths/cross-platform/zenoh-multinode-ros2/1_intro-zenoh.md index 65d30cc1ea..5e1595325a 100644 --- a/content/learning-paths/cross-platform/zenoh-multinode-ros2/1_intro-zenoh.md +++ b/content/learning-paths/cross-platform/zenoh-multinode-ros2/1_intro-zenoh.md @@ -8,55 +8,43 @@ layout: learningpathall ## The Need for Scalable Communication in Robotics and Edge Computing -Modern robotics and industrial IoT (IIoT) systems are evolving rapidly—from indoor collaborative arms on assembly lines to fleets of outdoor autonomous delivery robots. +Modern robotics and industrial IoT systems are evolving rapidly, from indoor collaborative arms on assembly lines to fleets of outdoor autonomous delivery robots. These applications must operate in real-time, often across multiple compute nodes, over networks that may span factory LANs, 5G cellular links, or even cloud data centers. Such systems require fast, reliable, and scalable data communication between nodes. -This includes not just broadcasting sensor updates or actuator commands (i.e., pub/sub), but also performing state queries, storing values for later use, and even distributed computation across nodes. A modern protocol must be: +This includes not just broadcasting sensor updates or actuator commands (pub/sub), but also performing state queries, storing values for later use, and even distributed computation across nodes. + +A modern protocol must be: * Low-latency: Immediate delivery of time-critical messages. * High-throughput: Efficient data flow across many devices. * Decentralized: No reliance on central brokers or fixed infrastructure. * Flexible: Able to run on lightweight edge devices, across WANs, or inside cloud-native environments. -Traditional communication stacks such as DDS ([Data Distribution Service](https://en.wikipedia.org/wiki/Data_Distribution_Service)) serve as the backbone for middleware like ROS 2. However, DDS struggles in multi-network or wireless environments where multicast is unavailable, or NAT traversal is needed. +Traditional communication stacks such as Data Distribution Service (DDS) serve as the backbone for middleware like ROS 2. However, DDS struggles in multi-network or wireless environments where multicast is unavailable, or NAT traversal is needed. These constraints can severely impact deployment and performance at the edge. -## Zenoh: An Open-Source Pub/Sub Protocol for the Industrial Edge +## Zenoh: an open-source pub/sub protocol for the Industrial Edge -[Eclipse Zenoh](https://zenoh.io/) is a modern, [open-source](https://github.com/eclipse-zenoh/zenoh) data-centric communication protocol that goes beyond traditional pub/sub. Designed specifically for edge computing, IIoT, robotics, and autonomous systems, Zenoh unifies: +[Eclipse Zenoh](https://zenoh.io/) is a modern, open-source, data-centric communication protocol that goes beyond traditional pub/sub. Designed specifically for edge computing, industrial IoT, robotics, and autonomous systems, Zenoh unifies: -* Data in motion through a powerful and efficient pub/sub model. -* Data at rest via geo-distributed storage plugins. -* Data in use with direct query support. -* On-demand computation via queryable nodes that can generate data dynamically. +- Data in motion through a powerful and efficient pub/sub model. +- Data at rest via geo-distributed storage plugins. +- Data in use with direct query support. +- On-demand computation via queryable nodes that can generate data dynamically. Unlike most traditional stacks, Zenoh is fully decentralized and designed to operate across cloud-to-edge-to-thing topologies, making it ideal for industrial robotics, autonomous systems, and smart environments. + It supports heterogeneous platforms, is implemented in Rust for performance and safety, and also offers bindings for Python, enabling rapid prototyping. Zenoh is particularly effective in wireless, 5G, or cross-network deployments where multicast and DDS fall short. -Its routing engine avoids excessive discovery traffic, conserves bandwidth, and supports seamless bridging between legacy ROS 2/DDS apps and modern, optimized Zenoh networks using zenoh-bridge-dds. - -In this learning path, you’ll use Zenoh to build and validate a multi-node distributed communication system across multiple Arm-based platforms, gaining hands-on experience with data exchange and coordination between edge devices. - -To make the upcoming demo more intuitive and easy to follow, we’ll demonstrate the setup using two physical Cortex-A Linux devices. - -I’ll be using Raspberry Pi boards in this learning path, but you’re free to substitute them with any Cortex-A devices that support network connectivity with Linux-based OS installed, depending on your development setup. - -In real-world ROS 2 deployment scenarios, developers typically conduct validation and performance testing across systems with more than two nodes. -To simulate such environments, using [Arm virtual hardware](https://www.arm.com/products/development-tools/simulation/virtual-hardware) is also a common and efficient approach. - -This will help you quickly validate your architecture choices and communication patterns when designing distributed applications. - -* Raspberry Pi, -* Linux-based Cortex-A, or -* Arm Virtual Hardware (AVH). +Its routing engine avoids excessive discovery traffic, conserves bandwidth, and supports seamless bridging between legacy ROS 2/DDS apps and modern, optimized Zenoh networks using Zenoh-Bridge-DDS, a bridge between DDS systems and Zenoh networks. -After this learning path, you will: -* Understand the core architecture and data flow principles behind Eclipse Zenoh, including its support for pub/sub, querying, and queryable edge functions. -* Build and run distributed Zenoh examples across multiple Arm-based nodes—using Raspberry Pi or AVH to simulate scalable deployment environments. -* Rebuild and extend the Zenoh queryable example to simulate edge-side logic. +In this Learning Path, you’ll use Zenoh to build and validate a multi-node distributed communication system across multiple Arm-based platforms, gaining hands-on experience with data exchange and coordination between edge devices. -By the end of this learning path, you’ll have deployed a fully functional, scalable, and latency-aware Zenoh system. +The examples use Raspberry Pi boards, but you’re free to substitute any Cortex-A or Neoverse devices that support network connectivity running Linux. -You can also check [here](https://zenoh.io/docs/getting-started/first-app) to find some simple examples. +Upon completion, you will be able to: +- Understand the core architecture and data flow principles behind Eclipse Zenoh, including its support for pub/sub, querying, and queryable edge functions. +- Build and run distributed Zenoh examples across multiple Arm-based nodes using Raspberry Pi or other Arm Linux devices. +- Rebuild and extend the Zenoh queryable example to simulate edge-side logic. diff --git a/content/learning-paths/cross-platform/zenoh-multinode-ros2/2_zenoh-install.md b/content/learning-paths/cross-platform/zenoh-multinode-ros2/2_zenoh-install.md index 5a750202ec..da1a28cbe4 100644 --- a/content/learning-paths/cross-platform/zenoh-multinode-ros2/2_zenoh-install.md +++ b/content/learning-paths/cross-platform/zenoh-multinode-ros2/2_zenoh-install.md @@ -8,56 +8,59 @@ layout: learningpathall ## Setting Up Zenoh on Arm Devices -The following instructions are verified on both Raspberry Pi 4/5 and Arm Virtual Hardware, but you can implement them on any Cortex-A Linux device. +The following instructions have been verified on both Raspberry Pi 4 and 5 devices, but you can implement them on any Arm Linux device. Before building Zenoh, make sure your system has the necessary development tools and runtime libraries. -### Install the Rust build environment +### Install the Rust development environment -First, we need to install the [Rust](https://www.rust-lang.org/) build environment, since the core of Zenoh is totally developed using Rust to keep it safe and efficient. - -Follow this [installation guide](https://learn.arm.com/install-guides/rust/) to install Rust and Cargo on Arm Linux, a build system for Rust. Or, simply use the following commands. +First, install the [Rust](https://www.rust-lang.org/) environment, since the core of Zenoh is developed using Rust to keep it safe and efficient. ```bash -curl https://sh.rustup.rs -sSf | sh +sudo apt update +sudo apt install -y curl gcc +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y ``` -Follow the prompts to complete the installation. If successful, you’ll see: +Near the end of the installation you will see the success message: ```output Rust is installed now. Great! ``` -For more details, refer to [Rust’s official install guide.](https://doc.rust-lang.org/cargo/getting-started/installation.html#install-rust-and-cargo) +Make sure to source the environment to add Rust to your shell environment: -### Install ROS 2 +```bash +source "$HOME/.cargo/env" +``` -[Robot Operating System](https://www.ros.org/) is a set of software libraries and tools that help you build robot applications. From drivers to state-of-the-art algorithms, and with powerful developer tools, ROS has what you need for your next robotics project. And it's all open source. +You can learn more using the [Rust install guide](/install-guides/rust/) for Arm Linux. -Since ROS was started in 2007, a lot has changed in the robotics and ROS community. The goal of the [ROS 2](https://docs.ros.org/en/rolling/index.html) project is to adapt to these changes, leveraging what is great about ROS 1 and improving what isn’t. +### Install ROS 2 -Here is the quick [installation guide](https://learn.arm.com/install-guides/ros2/) about how to install ROS 2 in Arm platform. +[Robot Operating System](https://www.ros.org/) is a set of software libraries and tools that help you build robot applications. ROS provides everything from drivers to state-of-the-art algorithms, as well as developer tools. It is completely open-source. + +Follow the [ROS2 installation guide](/install-guides/ros2/) to install ROS 2 on your Arm platforms. ### Download and build the Zenoh source -Now, we can clone the Zenoh. +Clone the Zenoh repository: ```bash -cd ~ +cd $HOME git clone https://github.com/eclipse-zenoh/zenoh.git ``` -After that, simply use cargo to build the source. +After cloning, use cargo to build the source: ```bash cd zenoh cargo build --release --all-targets -j $(nproc) ``` -This will take several minutes depending on your device. Once the installation is complete, you should see: +This process will take several minutes depending on your device. Once the installation is complete, you should see: ```output -cargo build --release --all-targets -j $(nproc) Updating crates.io index Downloaded humantime v2.2.0 Downloaded spin v0.10.0 @@ -101,7 +104,26 @@ This may become a hard error in the future; see plugins/zenoh-plugin-storage-manager/tests/operations.rs:91:55 +``` + +Edit the file `./plugins/zenoh-plugin-storage-manager/tests/operations.rs` and comment the line shown below and add the second line to the file: + +```rust +//use zenoh_plugin_trait::Plugin; +use crate::path::to::Plugin; +``` + +Run the build again: + +```bash +cargo clean && cargo build +``` + With Zenoh successfully compiled, you’re ready to explore how nodes communicate using the Zenoh runtime. diff --git a/content/learning-paths/cross-platform/zenoh-multinode-ros2/3_zenoh-multinode.md b/content/learning-paths/cross-platform/zenoh-multinode-ros2/3_zenoh-multinode.md index 8d21f0bfc0..3a75f81e64 100644 --- a/content/learning-paths/cross-platform/zenoh-multinode-ros2/3_zenoh-multinode.md +++ b/content/learning-paths/cross-platform/zenoh-multinode-ros2/3_zenoh-multinode.md @@ -10,28 +10,26 @@ layout: learningpathall After building Zenoh and its core examples, your next step is to deploy them across multiple Arm-based devices. -In this session, you’ll use Raspberry Pi boards to simulate a scalable, distributed environment—but the same workflow applies to any Arm Linux system, including Arm cloud instances and Arm Virtual Hardware. +In this section, you’ll use Raspberry Pi boards to simulate a scalable, distributed environment, but the same workflow applies to any Arm Linux system, including Arm cloud instances. -You’ll learn how to use Docker to deploy the environment on physical devices, and how to duplicate virtual instances using snapshot cloning on Arm Virtual Hardware. +You’ll learn how to use Docker to deploy the environment on physical devices. -This setup lets you simulate `real-world`, `cross-node communication`, making it ideal for validating Zenoh's performance in robotics and industrial IoT use cases. +This setup lets you simulate real-world, cross-node communication, making it ideal for validating Zenoh's performance in robotics and industrial IoT use cases. -### Install Docker on Raspberry Pi +### Install Docker -To simplify this process and ensure consistency, you’ll use Docker to containerize your Zenoh and ROS 2 environment. +To simplify this process and ensure consistency, you can use Docker to containerize your Zenoh and ROS 2 environment. This lets you quickly replicate the same runtime on any device without needing to rebuild from source. This enables multi-node testing and real-world distributed communication scenarios. -First, install the docker environment on each of Raspberry Pi if you don't have that. +First, install Docker on each of Raspberry Pi. ```bash -curl -sSL https://get.docker.com | sh -sudo usermod -aG docker pi +curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh +sudo usermod -aG docker $USER ; newgrp docker ``` -Log out and back in, or run newgrp docker to activate Docker group permissions. - ### Create a ROS 2 + DDS Docker Image In a working directory, create a `Dockerfile` with the following content to create the ROS 2 / DDS docker image. @@ -47,24 +45,22 @@ CMD bash Under the directory where the above Dockerfile exists, run the following command to generate the docker image. ```bash -$ docker build -t zenoh-node . +docker build -t zenoh-node . ``` -After this has been done, the created ROS 2 docker image can be seen by the following command. +After this has been done, the created ROS 2 Docker image can be seen by the following command. ```bash -$ docker images | grep zenoh-node +docker images | grep zenoh-node ``` ```output zenoh-node latest b7a9c27cf8a8 About a minute ago 962MB ``` -### Transfer the Docker Image on Another RPi - -You now need to transfer the Docker image to your second device. Choose one of the following methods: +### Transfer the Docker image to the other Raspberry Pi -You have two options: +There are two options to transfer the Docker image to your second device. Choose one of the following methods. Option 1: Save and copy via file @@ -74,31 +70,24 @@ scp zenoh-node.tar pi@:/home/pi/ ``` On the target device: + ```bash docker load < zenoh-node.tar ``` -Option 2: Push to a container registry (e.g., DockerHub or GHCR). +Option 2: Push the image to a container registry such as Docker Hub You can also push the image to Docker Hub or GitHub Container Registry and pull it on the second device. ### Run the Docker Image -Once the image is successfully loaded into second device, you can run the container by +Once the image is successfully loaded on second device, you can run the container. ```bash docker run -it --network=host zenoh-node ``` -Now, all the Zenoh example binaries are now available within this container, allowing you to test pub/sub and query flows across devices. - -### Another Duplicate Setting Option on Arm Virtual Hardware - -If you have [Corellium](https://www.corellium.com/) account, you can - -1. Set up and install Zenoh on a single AVH instance. -2. Use the [Clone](https://support.corellium.com/features/snapshots) function to duplicate the environment. -3. Optionally, you may optionally rename the device to avh* for easy device recognition by changing the setting in the `/etc/hostname` file. +The Zenoh example binaries are now available within this container, allowing you to test pub/sub and query flows across devices. ## Run Zenoh in Multi-Node Environment diff --git a/content/learning-paths/cross-platform/zenoh-multinode-ros2/4_zenoh-ex1-pubsub.md b/content/learning-paths/cross-platform/zenoh-multinode-ros2/4_zenoh-ex1-pubsub.md index fc0115618a..6075c7cf3e 100644 --- a/content/learning-paths/cross-platform/zenoh-multinode-ros2/4_zenoh-ex1-pubsub.md +++ b/content/learning-paths/cross-platform/zenoh-multinode-ros2/4_zenoh-ex1-pubsub.md @@ -6,34 +6,36 @@ weight: 5 layout: learningpathall --- -## Example 1: Simple Pub/Sub +## Example 1: Simple pub/sub -This first test demonstrates real-time publish/subscribe model using two Raspberry Pi devices. +This first test demonstrates the real-time publish/subscribe model using two Raspberry Pi devices. -The following command is to initiate a subscriber for a key expression `demo/example/**`, i.e. a set of topics starting with the path `demo/example`. +The following command is to initiate a subscriber for a key expression `demo/example/**`, a set of topics starting with the path `demo/example`. -### Step 1: Run Subscriber +### Step 1: Run subscriber -Log in to Pi using any of the methods: +Run the subscriber example on one of the Raspberry Pi systems. ```bash cd ~/zenoh/target/release/examples ./z_sub ``` -### Step 2: Run Publisher +### Step 2: Run publisher -Then, log in to another machine Pi. +Then, log in to the other Raspberry Pi and run the publisher. ```bash cd ~/zenoh/target/release/examples ./z_pub ``` -The result will look like: +The result is shown below: + ![img1 alt-text#center](zenoh_ex1.gif "Figure 1: Simple Pub/Sub") -In the left-side window, I have logged into the device Pi4 and run the z_sub program. -It receives values with the key `demo/example/zenoh-rs-pub` continuously published by z_pub running on Pi in the right-side window. +The left-side window shows the `z_sub` program. + +It receives values with the key `demo/example/zenoh-rs-pub` continuously published by `z_pub` running in the right-side window. This basic example shows Zenoh's zero-config discovery and low-latency pub/sub across physical nodes. diff --git a/content/learning-paths/cross-platform/zenoh-multinode-ros2/5_zenoh-ex2-storagequery.md b/content/learning-paths/cross-platform/zenoh-multinode-ros2/5_zenoh-ex2-storagequery.md index a0cdea6cef..4de6612a67 100644 --- a/content/learning-paths/cross-platform/zenoh-multinode-ros2/5_zenoh-ex2-storagequery.md +++ b/content/learning-paths/cross-platform/zenoh-multinode-ros2/5_zenoh-ex2-storagequery.md @@ -6,24 +6,23 @@ weight: 6 layout: learningpathall --- -## Example 2: Storage and Query +## Example 2: Storage and query -The second example adds Zenoh's data storage and querying capabilities—enabling nodes to retrieve historical values on demand. +The second example adds Zenoh's data storage and querying capabilities by enabling nodes to retrieve historical values on demand. -Building on the previous Pub/Sub example, you’ll now explore how Zenoh supports `persistent data storage` and `on-demand querying` -- a powerful feature for robotics and IIoT applications. +Building on the previous pub/sub example, you’ll now explore how Zenoh supports persistent data storage and on-demand querying, a powerful feature for robotics and IIoT applications. -In a typical warehouse or factory scenario, autonomous robots may periodically publish sensor data (e.g., position, temperature, battery level), and a central system—or another robot—may later need to query the latest state of each unit. +In a typical warehouse or factory scenario, autonomous robots may periodically publish sensor data such as position, temperature, battery level, and a central system or another robot—may later need to query the latest state of each unit. Unlike Pub/Sub, which requires live, real-time message exchange, Zenoh's storage and query model enables asynchronous access to data that was published earlier, even if the original publisher is no longer online. -In this example, you’ll run the zenohd daemon with in-memory storage and use z_put to publish data and z_get to retrieve it. +In this example, you’ll run the `zenohd` daemon with in-memory storage and use `z_put` to publish data and `z_get` to retrieve it. This is especially useful for distributed systems where nodes may intermittently connect or request snapshots of state from peers. +### Step 1: Start the Zenoh daemon with in-memory storage -### Step 1: Start the Zenoh Daemon with In-Memory Storage - -On one Raspberry Pi, launch the Zenoh daemon with a configuration that enables in-memory storage for keys under demo/example/**: +On one Raspberry Pi, launch the Zenoh daemon with a configuration that enables in-memory storage for keys in the `demo/example/**` directory. ```bash cd ~/zenoh/target/release/ @@ -33,11 +32,12 @@ cd ~/zenoh/target/release/ This starts the Zenoh daemon with in-memory storage support. You should see log messages indicating that the storage_manager plugin is loaded. -If port 7447 is already in use, either stop any previous Zenoh processes or configure a custom port using the listen.endpoints.router setting. -### Step 2: Publish Data +If port 7447 is already in use, either stop any previous Zenoh processes or configure a custom port using the `listen.endpoints.router` setting. + +### Step 2: Publish data -On 2nd device, use z_put to send a key-value pair that will be handled by the zenohd storage: +On 2nd Raspberry Pi device, use `z_put` to send a key-value pair that will be handled by the `zenohd` storage. ```bash cd ~/zenoh/target/release/examples @@ -46,10 +46,9 @@ cd ~/zenoh/target/release/examples This command stores the string `Hello from storage!` under the key demo/example/test1. +### Step 3: Query the data -### Step 3: Query the Data - -Back on first Raspberry Pi, you can now query the stored data from any Zenoh-connected node: +Back on first Raspberry Pi, you can now query the stored data from any Zenoh connected node. ```bash cd ~/zenoh/target/release/examples @@ -63,12 +62,13 @@ Sending Query 'demo/example/test1'... >> Received ('demo/example/test1': 'Hello from storage!') ``` -The result will look like: +The result is shown below: + ![img2 alt-text#center](zenoh_ex2.gif "Figure 2: Storage and Query") {{% notice tip %}} -If you have more than two Raspberry Pi devices, you can run the z_get command on a third RPi to validate that storage queries work seamlessly across a multi-node setup. +If you have more than two Raspberry Pi devices, you can run the `z_get` command on a third device to validate that storage queries work seamlessly across a multi-node setup. {{% /notice %}} -This example shows how Zenoh's Storage + Query model supports asynchronous data access and resilient state-sharing—critical capabilities in robotics and industrial IoT systems where network connectivity may be intermittent or system components loosely coupled. +This example shows how Zenoh's storage with query model supports asynchronous data access and resilient state-sharing—critical capabilities in robotics and industrial IoT systems where network connectivity may be intermittent or system components loosely coupled. diff --git a/content/learning-paths/cross-platform/zenoh-multinode-ros2/6_zenoh-ex3-queryable.md b/content/learning-paths/cross-platform/zenoh-multinode-ros2/6_zenoh-ex3-queryable.md index 13f15e0020..ed9d07ea5e 100644 --- a/content/learning-paths/cross-platform/zenoh-multinode-ros2/6_zenoh-ex3-queryable.md +++ b/content/learning-paths/cross-platform/zenoh-multinode-ros2/6_zenoh-ex3-queryable.md @@ -6,41 +6,40 @@ weight: 7 layout: learningpathall --- -## Example 3: Computation on Query using Queryable +## Example 3: Computation on query -Next, you’ll explore Zenoh's queryable capability, which lets a node dynamically respond to data queries by executing a custom computation or data generation function in this example. +Next, you’ll explore Zenoh's queryable capability, which lets a node dynamically respond to data queries by executing a custom computation or data generation function. -Unlike zenohd which simply returns stored data, a queryable node can register to handle a specific key expression and generate responses at runtime. This is ideal for distributed computing at the edge, where lightweight devices—such as Raspberry Pi nodes—can respond to requests with calculated values (e.g., sensor fusion, AI inference results, or diagnostics). +Unlike `zenohd` which simply returns stored data, a queryable node can register to handle a specific key expression and generate responses at runtime. This is ideal for distributed computing at the edge, where lightweight devices, such as Raspberry Pi nodes, can respond to requests with calculated values. This enables sensor fusion, AI inference results, and diagnostics. -### Use Case: On-Demand Battery Health Estimation +### Use Case: On-Demand battery health estimation Imagine a robot fleet management system where the central planner queries each robot for its latest battery health score, which is not published continuously but calculated only when queried. This saves bandwidth and enables edge compute optimization using Zenoh's Queryable. -### Step 1: Launch a Queryable Node +### Step 1: Launch a queryable node -On one Raspberry Pi device, run the built-in Zenoh example to register a queryable handler. +On one Raspberry Pi device, run the `z_queryable` Zenoh example to register a queryable handler. ```bash cd ~/zenoh/target/release/examples ./z_queryable ``` -You'll see the output like: +You'll see the output: -``` -pi@raspberrypi:~/zenoh/target/release/examples$ ./z_queryable +```output Opening session... Declaring Queryable on 'demo/example/zenoh-rs-queryable'... Press CTRL-C to quit... ``` -The node is now ready to accept queries on the key demo/example/zenoh-rs-queryable and respond with a predefined message. +The node is now ready to accept queries on the key `demo/example/zenoh-rs-queryable` and respond with a predefined message. -### Step 2: Trigger a Query from Another Node +### Step 2: Trigger a query from another node -On another Raspberry Pi device, run: +On the other Raspberry Pi device, run the `z_get` example. ```bash cd ~/zenoh/target/release/examples @@ -49,25 +48,25 @@ cd ~/zenoh/target/release/examples You should see: -``` -./z_get -s demo/example/zenoh-rs-queryable +```output Opening session... Sending Query 'demo/example/zenoh-rs-queryable'... >> Received ('demo/example/zenoh-rs-queryable': 'Queryable from Rust!') ``` -The result will look like: +The result is shown below: + ![img3 alt-text#center](zenoh_ex3.gif "Figure 3: Computation on Query using Queryable") The value you receive comes not from storage, but from the computation inside the queryable handler. -### Real-World Application: Distributed Inference & Computation +### Real-world application: distributed inference and computation This model enables edge-based intelligence, such as: -- Executing custom logic in response to a query (e.g., “calculate load average”) -- Triggering ML inference (e.g., “classify image X on demand”) -- Decentralized diagnostics (e.g., “report actuator status”) +- Executing custom logic in response to a query such as “calculate load average” +- Triggering ML inference such as “classify image X on demand” +- Decentralized diagnostics such as “report actuator status” Queryable is a key feature for data-in-use scenarios, allowing fine-grained, on-demand compute inside your Zenoh-powered architecture. -Next, you’ll extend this Queryable pattern to perform parameterized computation — simulating edge diagnostics and adaptive inference. \ No newline at end of file +Next, you’ll extend this Queryable pattern to perform parameterized computation, simulating edge diagnostics and adaptive inference. \ No newline at end of file diff --git a/content/learning-paths/cross-platform/zenoh-multinode-ros2/7_zenoh-querycomp.md b/content/learning-paths/cross-platform/zenoh-multinode-ros2/7_zenoh-querycomp.md index a870fe5b54..1afd3c1103 100644 --- a/content/learning-paths/cross-platform/zenoh-multinode-ros2/7_zenoh-querycomp.md +++ b/content/learning-paths/cross-platform/zenoh-multinode-ros2/7_zenoh-querycomp.md @@ -6,7 +6,7 @@ weight: 8 layout: learningpathall --- -## Parameterized Battery Health Estimation with Zenoh Queryable +## Parameterized battery health estimation with Zenoh queryable Finally, you’ll combine pub/sub, storage, and queryable components to simulate a distributed computation flow—demonstrating how Zenoh enables intelligent, coordinated edge systems. @@ -14,15 +14,15 @@ You’ll learn how to use Zenoh's Queryable API in Rust to build a parameterized This extends a previous example by supporting runtime query parameters like battery level and temperature. -## Use Case: Real-time Battery Health via Computation +## Use Case: Real-time battery health via computation In robotic fleet management, a central controller may need to assess each robot’s battery health on demand. Instead of streaming data continuously, robots expose a queryable endpoint that returns a real-time health score based on current battery level and temperature. -This saves bandwidth and enables lightweight edge-side decision-making.” +This saves bandwidth and enables lightweight edge-side decision-making. -### Step 1: Create a New Zenoh Rust Project +### Step 1: Create a new Zenoh rust project On any Raspberry Pi: @@ -31,20 +31,20 @@ cd ~/zenoh cargo new zenoh_battery_estimator ``` -Update following `dependencies` setting at ~/zenoh/zenoh_battery_estimator/Cargo.toml. +Update following dependencies setting by editing the file `$HOME/zenoh/zenoh_battery_estimator/Cargo.toml` -``` +```toml [dependencies] zenoh = { path = "../zenoh" } tokio = { version = "1", features = ["full"] } url = "2" ``` -### Step 2: Implement the Queryable Node +### Step 2: Implement the queryable node -Then, log in to another machine Pi. +Next, log in to the other Raspberry Pi. -Replace the contents of ~/zenoh/zenoh_battery_estimator/src/main.rs with: +Replace the contents of `$HOME/zenoh/zenoh_battery_estimator/src/main.rs` with the code below. ```rust use zenoh::{open, Config}; @@ -103,64 +103,69 @@ Inside the callback: - A health score is computed from these inputs. - The result is sent back to the querying client using query.reply(). -This design pattern enables efficient, on-demand data exchange with minimal bandwidth usage—ideal for edge computing scenarios where resources and connectivity are constrained. +This design pattern enables efficient, on-demand data exchange with minimal bandwidth usage. This is ideal for edge computing scenarios where resources and connectivity are constrained. The health score is calculated using the following logic: ```rust let health_score = 100 - (100 - battery) - ((temp.saturating_sub(25)) / 2); ``` + This formula estimates battery health as a percentage, considering both battery level and temperature: - battery: Current battery level (default 50%) - temp: Current temperature (default 25°C) The health estimation logic begins with the battery level as the baseline score. If the temperature rises above 25°C, the score is adjusted downward—specifically, for every 2°C above this threshold, the health is reduced by 1%. + To ensure the calculation remains safe even when the temperature is below 25°C, the code uses saturating_sub(25), which prevents the result from becoming negative and avoids potential underflow errors. For example, if battery = 88 and temp = 32, then: - Temperature offset = (32 - 25) / 2 = 3 - Health = 88 - 3 = 85% -### Step 3: Build and Run +### Step 3: Build and run ```bash -cd ~/zenoh/zenoh_battery_estimator +cd $HOME/zenoh/zenoh_battery_estimator cargo build --release ``` After the build process, you will see: -``` -cargo build --release +```output Compiling zenoh_battery_estimator v1.4.0 (/home/ubuntu/zenoh_v1.4/zenoh_battery_estimator) Finished `release` profile [optimized] target(s) in 1m 22s ``` -### Step 4: Query It with Parameters +### Step 4: Query it with parameters + +Run it on the Raspberry Pi you used for the build run: -Run it on the Raspberry Pi you just built. ```bash -cd ~/zenoh/target/release/ +cd $HOME/zenoh/target/release/ ./zenoh_battery_estimator ``` -You can reuse the built-in Zenoh z_get CLI in another Raspberry Pi. +You can reuse the built-in Zenoh `z_get` CLI from the other Raspberry Pi. ```bash cd ~/zenoh/target/release/examples ./z_get -s "robot/battery/estimate?level=88&temp=32" ``` -The result will look like: +The result is shown below: + ![img4 alt-text#center](zenoh_ex4.gif "Figure 4: Dynamic Queryable with Computation") -The excepted output will be -``` +The excepted output is: + +```output >> Received ('robot/battery/estimate': 'Estimated battery health: 85%') ``` -You’ve just built a responsive, parameterized edge compute service using Zenoh's Queryable API in Rust — a lightweight but powerful pattern for real-time intelligence at the edge. +You’ve just built a responsive, parameterized edge compute service using Zenoh's Queryable API in Rust. It's lightweight but a powerful pattern for real-time intelligence at the edge. This approach not only minimizes network overhead but also enables each device to process and respond to context-aware queries on demand. + It’s a strong foundation for building scalable, event-driven IoT systems that can adapt dynamically to operational needs. diff --git a/content/learning-paths/cross-platform/zenoh-multinode-ros2/_index.md b/content/learning-paths/cross-platform/zenoh-multinode-ros2/_index.md index 48fa9c5db9..833978a14d 100644 --- a/content/learning-paths/cross-platform/zenoh-multinode-ros2/_index.md +++ b/content/learning-paths/cross-platform/zenoh-multinode-ros2/_index.md @@ -7,18 +7,16 @@ cascade: minutes_to_complete: 45 -who_is_this_for: This learning path is designed for robotics developers, industrial automation engineers, and IoT system architects building distributed, scalable, and low-latency applications. Whether you are using Robot Operating System (ROS), developing autonomous systems, or designing multi-node communication frameworks, this guide will show you how to leverage the Eclipse Zenoh protocol on Arm-based platforms — both in the cloud (AVH or EC2) and on physical devices like Raspberry Pi. +who_is_this_for: This Learning Path is for robotics developers, industrial automation engineers, and IoT system architects building distributed, scalable, and low-latency applications. Whether you are using Robot Operating System (ROS), developing autonomous systems, or designing multi-node communication frameworks, you can use Eclipse Zenoh on Arm-based platforms, both in the cloud and on local devices like Raspberry Pi. learning_objectives: - Understand Zenoh's architecture and its integration of pub/sub, storage, querying, and computation models. - Build and run Zenoh examples on both Arm servers and Raspberry Pi. - - Set up and deploy a multi-node Zenoh system using Arm-based hardware or virtual environments. + - Set up and deploy a multi-node Zenoh system. prerequisites: - - At least two [Raspberry Pi5 or Pi4](https://www.raspberrypi.com/products/raspberry-pi-5/) or other Cortex-A instances with a Linux-based OS installed. - - Basic understanding with the Linux command line. + - At least two local Cortex-A devices running Linux, such as Raspberry Pi 4 or Pi 5. You can also use Arm servers or cloud instances. - Experience with ROS 2 applications. - - Corellium account for virtual hardware testing. (Option) author: - Odin Shen