ROS 2 Composition and ZED ROS 2 Wrapper
ROS 2 expanded the concept of nodelet from ROS 1 replacing nodelets with components and introducing the new concept of “Composition”.
Each node can be written as a “Component” which is a shared library loaded at runtime.
This tutorial explains how to:
- run multiple nodes in separate processes with the benefits of process/fault isolation as well as easier debugging of individual nodes
- run multiple nodes in a single process with lower overhead and optionally more efficient communication (see Intra Process Communication).
The launch file of the zed_wrapper package is designed to take advantage of both.
Run one ZED camera component in a single process
You can run a ZED Node in a single process by using the default launch command zed_camera.launch.py as it is:
the launch file creates a ROS 2 Container process called zed_container:
then it loads a stereolabs::ZedCamera or stereolabs::ZedCameraOne into it:
Compose multiple node components in a single process to leverage IPC
Intra Process Communication (IPC) is an advanced concept of ROS 2 that allows to optimize the performance of nodes running on the same machine.
The ZED IPC tutorial
The ZED IPC tutorial demonstrates how to leverage ROS 2 Composition and Intra-Process Communication to create a new node component that subscribes to point cloud topics published by all ZED Camera node components running within the same process.
The tutorial guides you through the creation of a new launch file. This launch file utilizes the launch file of the ZED Multi-Camera tutorial to:
- Start multiple ZED nodes within a single process.
- Load a new node component that subscribes to the point cloud topics.
- Achieve zero-copy data transfer for efficient data exchange.
This approach enhances performance and reduces resource consumption by minimizing data copying between nodes within the same process.
The zed_ipc.launch.py launch File
The zed_ipc.launch.py launch file is designed to facilitate the setup of multiple ZED Camera nodes within a single process, along with a custom node component that subscribes to their point cloud topics. This launch file ensures efficient intra-process communication by leveraging zero-copy data transfer.
Key Features
- Multiple ZED Nodes: Initializes and manages multiple ZED Camera nodes within the same process to capture point cloud data.
- Custom Subscriber Node: Loads a custom node component that subscribes to the point cloud topics published by the ZED Camera nodes.
- Zero-Copy Data Transfer: Utilizes ROS 2’s intra-process communication capabilities to achieve zero-copy data transfer, enhancing performance and reducing resource usage.
Usage
To use the zed_ipc.launch.py launch file, execute the following command:
This command will start the launch file, initializing the ZED Camera nodes and the custom subscriber node within the same process.
The code explained
First step: create a ROS 2 Container and load the two ZED camera components nodes inside it. Here we use the multi-camera launch file described in the multi-camera tutorial.
Second step: remap the topic names. The demo node that receives the Point Cloud messages subscribes to generic pointcloud_X topic names.
The launch file must create a correct remapping between pointcloud_X and each ZED node Point Cloud topic name /zed_multi/<camera_name/point_cloud/cloud_registered.
Third step: create the demo component node that subscribes to the Point Cloud topics and processes the relative messages.
Final step: load the Point Cloud component node in the existing ZED Container process to leverage Intra Process Communication.
You can verify that all the nodes are now running into the same container process by using the command ros2 component list.
Example
Here’s an example for two ZED X cameras named zedx_front and zedx_rear:
- Launch command:
- Running check:

