Skip to content

Commit edff06c

Browse files
committed
Split four examples into separate page, upload gif files.
1 parent 21b7eb7 commit edff06c

12 files changed

Lines changed: 212 additions & 182 deletions

File tree

content/learning-paths/cross-platform/zenoh-multinode-ros2/3_zenoh-multinode.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,15 @@ If you have [Corellium](https://www.corellium.com/) account, you can
100100
2. Use the [Clone](https://support.corellium.com/features/snapshots) function to duplicate the environment.
101101
3. Optionally, you may optionally rename the device to avh* for easy device recognition by changing the setting in the `/etc/hostname` file.
102102

103+
## Run Zenoh in Multi-Node Environment
103104

104-
With your multi-node environment in place, you’re now ready to run and test Zenoh communication flows across distributed edge devices.
105+
You’re now ready to run and test Zenoh communication flows across distributed edge devices.
106+
107+
The source of the examples written in Rust will be provided, and both are interoperable. The
108+
Rust binaries are already available under: `$ZENOH_LOC/target/release/examples/` directory.
109+
110+
The following sections illustrate the procedures to run the Zenoh examples so as to demonstrate the primary capabilities of Zenoh
111+
1. Basic Pub/Sub – for real-time message distribution
112+
2. Query and Storage – to persist and retrieving historical data
113+
3. Queryable – to enable on-demand remote computation
114+
4. Dynamic Queryable with Computation
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: Zenoh Example-1 Simple Pub/Sub
3+
weight: 5
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
## Example 1: Simple Pub/Sub
10+
11+
This first test demonstrates Zenoh’s real-time publish/subscribe model using two Raspberry Pi devices.
12+
13+
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`.
14+
15+
### Step 1: Run Subscriber
16+
17+
Log in to Pi using any of the methods:
18+
19+
```bash
20+
cd ~/zenoh/target/release/examples
21+
./z_sub
22+
```
23+
24+
### Step 2: Run Publisher
25+
26+
Then, log in to another machine Pi.
27+
28+
```bash
29+
cd ~/zenoh/target/release/examples
30+
./z_pub
31+
```
32+
33+
The result will look like:
34+
![img1 alt-text#center](zenoh_ex1.gif "Figure 1: Simple Pub/Sub")
35+
36+
In the left-side window, I have logged into the device Pi4 and run the z_sub program.
37+
It receives values with the key `demo/example/zenoh-rs-pub` continuously published by z_pub running on Pi in the right-side window.
38+
39+
This basic example shows Zenoh’s zero-config discovery and low-latency pub/sub across physical nodes.

content/learning-paths/cross-platform/zenoh-multinode-ros2/4_zenoh-examples.md

Lines changed: 0 additions & 176 deletions
This file was deleted.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: Zenoh Example-2 Storage and Query
3+
weight: 6
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
## Example 2: Storage and Query
10+
11+
The second example adds Zenoh’s data storage and querying capabilities—enabling nodes to retrieve historical values on demand.
12+
13+
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.
14+
15+
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.
16+
17+
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.
18+
19+
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.
20+
21+
This is especially useful for distributed systems where nodes may intermittently connect or request snapshots of state from peers.
22+
23+
24+
### Step 1: Start the Zenoh Daemon with In-Memory Storage
25+
26+
On one Raspberry Pi, launch the Zenoh daemon with a configuration that enables in-memory storage for keys under demo/example/**:
27+
28+
```bash
29+
cd ~/zenoh/target/release/
30+
./zenohd --cfg='plugins/storage_manager/storages/demo:{key_expr:"demo/example/**",volume:"memory"}' &
31+
```
32+
33+
This starts the Zenoh daemon with in-memory storage support.
34+
35+
You should see log messages indicating that the storage_manager plugin is loaded.
36+
If port 7447 is already in use, either stop any previous Zenoh processes or configure a custom port using the listen.endpoints.router setting.
37+
38+
### Step 2: Publish Data
39+
40+
On 2nd device, use z_put to send a key-value pair that will be handled by the zenohd storage:
41+
42+
```bash
43+
cd ~/zenoh/target/release/examples
44+
./z_put -k demo/example/test1 -p "Hello from storage!"
45+
```
46+
47+
This command stores the string `Hello from storage!` under the key demo/example/test1.
48+
49+
50+
### Step 3: Query the Data
51+
52+
Back on first Raspberry Pi, you can now query the stored data from any Zenoh-connected node:
53+
54+
```bash
55+
cd ~/zenoh/target/release/examples
56+
./z_get -s demo/example/test1
57+
```
58+
59+
You should see an output similar to:
60+
61+
```bash
62+
Sending Query 'demo/example/test1'...
63+
>> Received ('demo/example/test1': 'Hello from storage!')
64+
```
65+
66+
The result will look like:
67+
![img2 alt-text#center](zenoh_ex2.gif "Figure 2: Storage and Query")
68+
69+
{{% notice tip %}}
70+
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.
71+
{{% /notice %}}
72+
73+
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.
74+
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
title: Zenoh Example-3 Computation on Query using Queryable
3+
weight: 7
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
## Example 3: Computation on Query using Queryable
10+
11+
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.
12+
13+
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).
14+
15+
### Use Case: On-Demand Battery Health Estimation
16+
17+
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.
18+
19+
This saves bandwidth and enables edge compute optimization using Zenoh’s Queryable.
20+
21+
### Step 1: Launch a Queryable Node
22+
23+
On one Raspberry Pi device, run the built-in Zenoh example to register a queryable handler.
24+
25+
```bash
26+
cd ~/zenoh/target/release/examples
27+
./z_queryable
28+
```
29+
30+
You'll see the output like:
31+
32+
```
33+
pi@raspberrypi:~/zenoh/target/release/examples$ ./z_queryable
34+
Opening session...
35+
Declaring Queryable on 'demo/example/zenoh-rs-queryable'...
36+
Press CTRL-C to quit...
37+
```
38+
39+
The node is now ready to accept queries on the key demo/example/zenoh-rs-queryable and respond with a predefined message.
40+
41+
### Step 2: Trigger a Query from Another Node
42+
43+
On another Raspberry Pi device, run:
44+
45+
```bash
46+
cd ~/zenoh/target/release/examples
47+
./z_get -s demo/example/zenoh-rs-queryable
48+
```
49+
50+
You should see:
51+
52+
```
53+
./z_get -s demo/example/zenoh-rs-queryable
54+
Opening session...
55+
Sending Query 'demo/example/zenoh-rs-queryable'...
56+
>> Received ('demo/example/zenoh-rs-queryable': 'Queryable from Rust!')
57+
```
58+
59+
The result will look like:
60+
![img3 alt-text#center](zenoh_ex3.gif "Figure 3: Computation on Query using Queryable")
61+
62+
The value you receive comes not from storage, but from the computation inside the queryable handler.
63+
64+
### Real-World Application: Distributed Inference & Computation
65+
66+
This model enables edge-based intelligence, such as:
67+
- Executing custom logic in response to a query (e.g., “calculate load average”)
68+
- Triggering ML inference (e.g., “classify image X on demand”)
69+
- Decentralized diagnostics (e.g., “report actuator status”)
70+
71+
Queryable is a key feature for data-in-use scenarios, allowing fine-grained, on-demand compute inside your Zenoh-powered architecture.
72+
73+
Next, you’ll extend this Queryable pattern to perform parameterized computation — simulating edge diagnostics and adaptive inference.

0 commit comments

Comments
 (0)