Understand the shared-memory experiment

After observing simulation resource usage, enable shared memory in both Zenoh configuration files. Then, restart the relevant processes and repeat the measurement.

By default, processes on the same machine exchange data over TCP loopback. Zenoh shared-memory transport places large messages in /dev/shm and avoids the network stack. Applications don’t need code changes or loaned buffers, and Zenoh falls back to TCP if shared memory is unavailable.

Measure the TCP-loopback baseline

Before enabling shared memory, measure the default TCP-loopback baseline.

Stop Navigation2 in the third bash shell in the robot container. The latency measurement needs wall-clock timestamps, and Navigation2 doesn’t operate in this mode.

Stop the current simulation. Restart it in second bash shell with wall-clock time and without the Gazebo viewer:

    

        
        
just rox_simu use_wall_time:=True no_gui

    

Open a new bash shell in the robot container and measure the point-cloud latency:

    

        
        
just cam_latency

    

On the supplied reference system, the point-cloud latency is around 9–10 ms:

    

        
        Mean : 9.40 ms | Std : 0.82 ms | Min : 7.91 ms | Max : 12.15 ms

        
    

Record the mean for comparison.

Enable shared memory in both configurations

Open the following working files using your choice of editor in one of the robot bash shells:

  • ~/container_data/ROUTER_CONFIG.json5
  • ~/container_data/SESSION_CONFIG.json5

In each file, find the transport/shared_memory block and change its enabled value to true.

Important

Both files contain multiple enabled fields. In both ROUTER_CONFIG.json5 and SESSION_CONFIG.json5, change only the enabled value inside the shared_memory block.

The router and ROS 2 sessions read these files when their processes start.

Stop the router and simulation processes with Ctrl+C, then restart them so they load the updated setting.

Restart the router in the first bash shell:

    

        
        
# Router bash shell
just router

    

Restart the simulation in the second bash shell:

    

        
        
# Simulation bash shell
just rox_simu use_wall_time:=True no_gui

    

Run the latency measurement again from another bash shell in the robot container:

    

        
        
just cam_latency

    

The supplied reference system produced these results:

MeasurementTCP loopback (default)Shared memory
Mean latency9.3–10.2 ms6.3–7.4 ms
Standard deviationApproximately 1.0 msApproximately 0.65 ms
/dev/shm usage8 KB247 MB

The reference mean latency improves by approximately 30%, with lower jitter. Your result depends on the server, workload, and run conditions. Compare the two measurements from your own system.

Verify the transport change

Check the shared-memory directory and loopback traffic:

    

        
        
ls /dev/shm
just iftop_lo

    

.zenoh files appear under /dev/shm for Zenoh processes using shared memory. The large loopback flows should also disappear because the data now moves through memory.

Restore the environment for the next Learning Path

Keep the shared-memory configuration enabled. In the second bash shell, press Ctrl+C to stop the temporary wall-time simulation if it’s still running.

Keep the Zenoh router running in the first bash shell. If it has stopped, restart it after re-sourcing the environment:

    

        
        
source ~/workshop_env.bash
just router

    

In the second bash shell, source the environment if needed and start the normal headless simulation:

    

        
        
source ~/workshop_env.bash
just rox_simu no_gui

    

In the third bash shell, source the environment if needed and restart Navigation2:

    

        
        
source ~/workshop_env.bash
just rox_nav2

    

Confirm that the router is running, the simulation starts without errors, and Navigation2 reports Managed nodes are active. Leave these three processes running for the next Learning Path.

What you’ve accomplished

You’ve built a ROS 2 and Zenoh simulation environment and compared TCP-loopback communication with shared-memory transport.

Next, complete the Distribute a ROS 2 robotic system across Arm devices with Zenoh Learning Path.

Back
Next