Using ZED and ROS/2 from Docker Container

In this tutorial, you will learn how to use the ROS framework in a Docker Container. Similar to the tutorial that demonstrated the use of OpenCV in a Docker container, this tutorial also gives an overview of using ROS and ROS 2 nodes and packages.

In the next section, you will learn how to create docker containers with ZED SDK and ROS / ROS 2.

Download and run the Docker image #

Pull and run a Docker image with ZED SDK and ROS or ROS 2 based on the application you want to build. You will find examples about how to build such a container on our github.

Similar to the OpenCV containers ROS also requires display support for RVIZ hence making sure that the container includes OpenGL support.

$ docker pull <container_tag> #pull a docker container with ZED SDK , ROS or ROS 2 and OpenGL support  
$ xhost +si:localuser:root  # allows container to communicate with X server
$ docker run  --gpus all --runtime nvidia --privileged -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /dev:/dev -e NVIDIA_DRIVER_CAPABILITIES=all <container_tag> # run the docker container

#Remember: Replace <container tag> with the tag of your container image

The docker run commands used are detailed in an earlier tutorial. You can find the detailed explanation in Docker documentation

Run a ROS sample example #

Assuming that the container you are running has ROS installed and a catkin workspace has been set up, we further go ahead and run a sample example. In the next section, you will learn how to create ROS Docker images along with setting up the workspace.

Install zed-ros-wrapper package that lets you use the ZED cameras with ROS right away.

$ cd ~/catkin_ws/src
$ git clone --recursive https://github.com/stereolabs/zed-ros-wrapper.git
$ cd ../
$ rosdep install --from-paths src --ignore-src -r -y
$ catkin_make -DCMAKE_BUILD_TYPE=Release
$ source ./devel/setup.bash

Now, you can simply launch the ZED node using the below commands to run an example, further details can be found in this documentation.

$ roslaunch zed_wrapper zed.launch
$ roslaunch zed_wrapper zedm.launch
$ roslaunch zed_wrapper zed2.launch
$ roslaunch zed_wrapper zed2i.launch

Further, you can explore zed-ros-examples which contain various examples and tutorials including the display of ZED data and images, depth display, disparity display and more.

Please refer to the appropriate sections in the ROS documentation for a detailed explanation.

Run a ROS 2 sample example #

For ROS 2 users, we can run a ROS 2 example supposing that the Docker image supports ROS 2 and has a colcon workspace. Install zed-ros2-wrapper which lets you use ZED cameras with ROS 2.

$ 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
$ echo source $(pwd)/install/local_setup.bash >> ~/.bashrc
$ source ~/.bashrc

Now, you can launch the ZED node using the below `ros2 launch commands to run an example, further details about the wrapper can be found in this documentation.

Similar to zed-ros-examples, zed-ros2-examples package contains ROS 2 tutorials and example packages for further exploration. Detailed documentation can be found here

Next steps #

Now that you are comfortable with using OpenCV and ROS in a Docker container along with the ZED SDK, you can learn to Create Docker images with ROS and ROS 2.