Stereolabs ZED Camera - ROS2 Foxy Fitzroy (Ubuntu 20.04)
Note: if you are searching for a version of the ROS2 wrapper running on an Nvidia Jetson based on Ubuntu 18.04 that does not require recompiling ROS2 from source, please check out the
eloquent branch, the official ROS2 version running on Ubuntu 18.04.
This package lets you use the ZED stereo cameras with ROS2. It provides access to the following data:
- Left and right rectified/unrectified images
- Depth data
- Colored 3D point cloud
- Position and Mapping
- Sensors data (not available with ZED)
- Detected objects (not available with ZED and ZED Mini)
- Persons skeleton (not available with ZED and ZED Mini)
Image Transport and topic subscriptions
There is an issue with the function
CameraPublisher::getNumSubscribers preventing the correct counting of the number of nodes subscribing one of the topics published by an
We suggest to install the the version v3.0.0, published on 2021-05-26, that contains the fix for this issue.
To install the latest version from sources:
$ cd <colcon_workspace>/src # Access the source folder of your colcon workspace $ git clone https://github.com/ros-perception/image_common.git -b ros2 # clone the "ros" branch of the "image_common" repository $ cd <colcon_workspace> # Go back to the root of your colcon workspace $ colcon build --symlink-install # Compile everything and install
Close the console and re-open it to apply the modifications.
Image Transport Plugins and compressed topics
image_transport_plugins package is not correctly working with ROS2 Foxy (see here, here, here, and here). We suggest you remove it to avoid many annoying warning messages until the ROS2 developers do not fix it or we find a workaround:
$ sudo apt remove ros-foxy-image-transport-plugins ros-foxy-compressed-depth-image-transport ros-foxy-compressed-image-transport
Build the package
The zed_ros2_wrapper is a colcon package.
Note: If you haven’t set up your colcon workspace yet, please follow this short tutorial.
To install the zed_ros2_wrapper, open a bash terminal, clone the package from Github, and build it:
$ cd ~/ros2_ws/src/ #use your current ros2 workspace folder $ git clone https://github.com/stereolabs/zed-ros2-wrapper.git $ cd .. $ rosdep install --from-paths src --ignore-src -r -y $ colcon build --symlink-install --cmake-args=-DCMAKE_BUILD_TYPE=Release $ echo source $(pwd)/install/local_setup.bash >> ~/.bashrc $ source ~/.bashrc
rosdep is missing you can install it with:
$ sudo apt-get install python-rosdep python-rosinstall-generator python-vcstool python-rosinstall build-essential
Note: The option
--symlink-install is very important, it allows to use symlinks instead of copying files to the ROS2 folders during the installation, where possible. Each package in ROS2 must be installed and all the files used by the nodes must be copied into the installation folders. Using symlinks allows you to modify them in your workspace, reflecting the modification during the next executions without the needing to issue a new
colcon build command. This is true only for all the files that don't need to be compiled (Python scripts, configurations, etc.).
Note: If you are using a different console interface like zsh, you have to change the
source command as follows:
echo source $(pwd)/install/local_setup.zsh >> ~/.zshrc and
Starting the ZED node
To start the ZED node, open a terminal and use the CLI command
$ ros2 launch zed_wrapper zed.launch.py
$ ros2 launch zed_wrapper zedm.launch.py
$ ros2 launch zed_wrapper zed2.launch.py
$ ros2 launch zed_wrapper zed2i.launch.py
zed2i.launch.py are three Python scripts that automatically start the ZED node using "manual composition", loading the parameters from the correct "YAML files" and creating the camera model from the correct "URDF file".
Note: You can set your own configurations modifying the parameters in the files common.yaml, zed.yaml zedm.yaml, zed2.yaml and zed2i.yaml available in the folder
For full descriptions of each parameter, follow the complete guide here.
Example launch files to start a pre-configured Rviz environment to visualize the data of ZED, ZED Mini, ZED2, and ZED2i cameras are provided in the
The SDK v3.0 introduces the Object Detection and Tracking module. The Object Detection module is available only with a ZED 2 or ZED 2i camera.
The Object Detection can be enabled automatically when the node start setting the parameter
true in the file
The Object Detection can be enabled/disabled manually calling the services
The Spatial Mapping can be enabled automatically when the node start setting the parameter
true in the file
The Spatial Mapping can be enabled/disabled manually calling the services
For robots moving on a planar surface it is possible to activate the "2D mode" (parameter
The value of the coordinate Z for odometry and pose will have a fixed value (parameter
Roll and pitch and relative velocities will be fixed to zero.
Examples and Tutorials
Examples and tutorials are provided to better understand how to use the ZED wrapper and how to integrate it in the ROS2 framework.
Rviz2 visualization examples
- Example launch files to start a preconfigured instance of Rviz displaying all the ZED Wrapper node information: zed_display_rviz2
- ROS2 plugin for ZED2 to visualize the results of the Object Detection module (bounding boxes and skeletons): rviz-plugin-zed-od