Using ZED with ROS 2 from a Docker Container

Open in ClaudeOpen in ChatGPT

This tutorial shows how to run the ZED SDK with ROS 2 inside a Docker container: pulling and running a ready-made image, then launching the ZED node.

Download and Run the Docker Image

Pull and run a Docker image that includes the ZED SDK and ROS 2. To build your own, see Create and use Docker images for ZED and ROS 2.

If you want to use RViz2 in Docker, make sure the image includes OpenGL support (a gl-devel image).

$docker pull <container_tag> # a container with ZED SDK, ROS 2, and (optionally) OpenGL support
$xhost +si:localuser:root # allow the container to communicate with the X server
$# On a desktop host:
$docker run --gpus all --privileged -e NVIDIA_DRIVER_CAPABILITIES=all -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /dev:/dev <container_tag>
$# On NVIDIA® Jetson™, replace "--gpus all" with "--runtime nvidia"
$# Remember: replace <container_tag> with the tag of your image

For a breakdown of these docker run flags, see the Run the Docker image section of the ROS 2 Docker image guide.

Launch the ZED Node

If your image was built with the ZED ROS 2 Wrapper Docker files, the zed-ros2-wrapper is already installed and compiled, and its environment is sourced automatically by the container entry point. You can launch the ZED node right away, setting camera_model to your camera (for example zed2i, zed2, zedm, zedx, or zedxm):

$ros2 launch zed_wrapper zed_camera.launch.py camera_model:=<camera_model>

If you are using a plain ROS 2 image that does not already include the wrapper, install it in a colcon workspace first:

$cd ~/ros2_ws/src/ # use your current ROS 2 workspace folder
$git clone --recursive 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
$source ./install/local_setup.bash

To go further, explore the zed-ros2-examples package — it provides tutorials and sample packages to display ZED images, depth, point clouds, and more. Full documentation is available in the ROS 2 section.