Problem with adding zed-ros2-examples to Dockerfile

Hello
When I try to add to my Dockerfile this line:
RUN git clone --recursive GitHub - stereolabs/zed-ros2-examples: A collection of examples and tutorials to illustrate how to better use the ZED cameras in the ROS2 framework

during build i see error:

181.2 Finished <<< zed_depth_to_laserscan [5.87s]
183.7 [100%] Linking CXX shared library libzed_aruco_localization_component.so
184.1 [100%] Built target zed_aruco_localization_component
184.2 -- Install configuration: "Release"
184.2 -- Installing: /root/ros2_ws/install/zed_aruco_localization/lib/libzed_aruco_localization_component.so
184.2 -- Set runtime path of "/root/ros2_ws/install/zed_aruco_localization/lib/libzed_aruco_localization_component.so" to ""
184.2 -- Installing: /root/ros2_ws/install/zed_aruco_localization/include/zed_aruco_localization/
184.2 -- Installing: /root/ros2_ws/install/zed_aruco_localization/include/zed_aruco_localization//aruco_loc_visibility_control.hpp
184.2 CMake Error at cmake_install.cmake:69 (file):
184.2   file INSTALL cannot find
184.2   "/root/ros2_ws/src/zed-ros2-examples/examples/zed_aruco_localization/DIRECTORY":
184.2   No such file or directory.
184.2 
184.2 
184.2 [100%] Linking CXX executable zed_rgb_convert
184.3 --- stderr: zed_aruco_localization
184.3 CMake Error at cmake_install.cmake:69 (file):
184.3   file INSTALL cannot find
184.3   "/root/ros2_ws/src/zed-ros2-examples/examples/zed_aruco_localization/DIRECTORY":
184.3   No such file or directory.
184.3 
184.3 
184.3 ---
184.3 Failed   <<< zed_aruco_localization [27.6s, exited with code 1]
184.8 [100%] Built target zed_rgb_convert
184.8 Aborted  <<< zed_rgb_convert [28.1s]
184.9 
184.9 Summary: 15 packages finished [3min 4s]
184.9   1 package failed: zed_aruco_localization
184.9   1 package aborted: zed_rgb_convert
184.9   3 packages had stderr output: zed_aruco_localization zed_interfaces zed_topic_benchmark_interfaces
------

 2 warnings found (use --debug to expand):
 - LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 20)
 - LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 54)
Dockerfile.zed_sdk:114
--------------------
 113 |     # Build the dependencies and the ZED ROS2 Wrapper
 114 | >>> RUN /bin/bash -c "source /opt/ros/$ROS_DISTRO/setup.bash && \
 115 | >>>   colcon build --parallel-workers $(nproc) \
 116 | >>>   --event-handlers console_direct+ --base-paths src \
 117 | >>>   --cmake-args ' -DCMAKE_BUILD_TYPE=Release' \
 118 | >>>   ' -DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs' \
 119 | >>>   ' -DCMAKE_CXX_FLAGS="-Wl,--allow-shlib-undefined"' \
 120 | >>>   ' --no-warn-unused-cli' "
 121 |     
--------------------
ERROR: failed to solve: process "/bin/bash -c /bin/bash -c \"source /opt/ros/$ROS_DISTRO/setup.bash &&   colcon build --parallel-workers $(nproc)   --event-handlers console_direct+ --base-paths src   --cmake-args ' -DCMAKE_BUILD_TYPE=Release'   ' -DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs'   ' -DCMAKE_CXX_FLAGS=\"-Wl,--allow-shlib-undefined\"'   ' --no-warn-unused-cli' \"" did not complete successfully: exit code: 1

This is my Dockerfile:

ARG BASE_IMAGE
FROM ${BASE_IMAGE}

ARG ZED_SDK_MAJOR=4
ARG ZED_SDK_MINOR=1
ARG ZED_SDK_PATCH=0
ARG JETPACK_MAJOR=6
ARG JETPACK_MINOR=0
ARG L4T_MAJOR=36
ARG L4T_MINOR=3

ARG ROS2_DIST=humble       # ROS2 distribution

# ZED ROS2 Wrapper dependencies version
ARG XACRO_VERSION=2.0.8
ARG DIAGNOSTICS_VERSION=3.0.0
ARG AMENT_LINT_VERSION=0.12.4
ARG GEOGRAPHIC_INFO_VERSION=1.0.4
ARG ROBOT_LOCALIZATION_VERSION=3.4.2
ENV DEBIAN_FRONTEND noninteractive

# Disable apt-get warnings
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 42D5A192B819C5DA || true && \
  apt-get update || true && apt-get install -y --no-install-recommends apt-utils dialog && \
  rm -rf /var/lib/apt/lists/*

ENV TZ=Europe/Poland

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \ 
  apt-get update && \
  apt-get install --yes lsb-release wget less udev sudo build-essential cmake python3 python3-dev python3-pip python3-wheel git jq libpq-dev zstd usbutils \
  libgstreamer1.0-0 gstreamer1.0-libav libgstrtspserver-1.0-0 gstreamer1.0-tools  \
  gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio  \
  libgstreamer1.0-dev libgstrtspserver-1.0-dev libgstreamer-plugins-base1.0-0 libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-0 \
  libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-0 libgstreamer-plugins-bad1.0-dev gstreamer1.0-rtsp gstreamer1.0-plugins-ugly && \ 
  rm -rf /var/lib/apt/lists/*



# Install the ZED SDK, skip_tools; skip_drivers
RUN echo "# R${L4T_MAJOR} (release), REVISION: ${L4T_MINOR}" > /etc/nv_tegra_release && \
  apt-get update -y || true && \
  apt-get install -y --no-install-recommends zstd wget less cmake curl gnupg2 \
  build-essential python3 python3-pip python3-dev python3-setuptools libusb-1.0-0-dev -y && \
  pip install protobuf && \
  wget -q --no-check-certificate -O ZED_SDK_Linux_JP.run \
  https://download.stereolabs.com/zedsdk/${ZED_SDK_MAJOR}.${ZED_SDK_MINOR}/l4t${L4T_MAJOR}.${L4T_MINOR}/jetsons && \
  chmod +x ZED_SDK_Linux_JP.run ; ./ZED_SDK_Linux_JP.run silent skip_drivers && \ 
  rm -rf /usr/local/zed/resources/* && \
  rm -rf ZED_SDK_Linux_JP.run && \
  rm -rf /var/lib/apt/lists/*

# Install the ZED ROS2 Wrapper
ENV ROS_DISTRO ${ROS2_DIST}

# Install the ZED ROS2 Wrapper
WORKDIR /root/ros2_ws/src
RUN git clone --recursive https://github.com/stereolabs/zed-ros2-wrapper.git
RUN git clone --recursive https://github.com/stereolabs/zed-ros2-examples.git

# Install missing dependencies
#WORKDIR /root/ros2_ws/src
#RUN wget https://github.com/ros/xacro/archive/refs/tags/${XACRO_VERSION}.tar.gz -O - | tar -xvz && mv xacro-${XACRO_VERSION} xacro && \
#  wget https://github.com/ros/diagnostics/archive/refs/tags/${DIAGNOSTICS_VERSION}.tar.gz -O - | tar -xvz && mv diagnostics-${DIAGNOSTICS_VERSION} diagnostics && \
#  wget https://github.com/ament/ament_lint/archive/refs/tags/${AMENT_LINT_VERSION}.tar.gz -O - | tar -xvz && mv ament_lint-${AMENT_LINT_VERSION} ament-lint && \
#  wget https://github.com/cra-ros-pkg/robot_localization/archive/refs/tags/${ROBOT_LOCALIZATION_VERSION}.tar.gz -O - | tar -xvz && mv robot_localization-${ROBOT_LOCALIZATION_VERSION} robot-localization && \
#  wget https://github.com/ros-geographic-info/geographic_info/archive/refs/tags/${GEOGRAPHIC_INFO_VERSION}.tar.gz -O - | tar -xvz && mv geographic_info-${GEOGRAPHIC_INFO_VERSION} geographic-info && \
#  cp -r geographic-info/geographic_msgs/ . && \
#  rm -rf geographic-info && \
#  git clone https://github.com/ros-drivers/nmea_msgs.git --branch ros2 && \  
#  git clone https://github.com/ros/angles.git --branch humble-devel

RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -y \
  ros-humble-depthimage-to-laserscan \
  ros-humble-ament-package \
  ros-humble-ament-cmake-core \
  ros-humble-ament-lint \
  ros-humble-depthimage-to-laserscan \
  ros-humble-angles \
  ros-humble-ament-cmake-clang-format \
  ros-humble-nmea-msgs \
  ros-humble-geographic-msgs \
  ros-humble-robot-localization \
  ros-humble-grid-map   

  # ROS Python fundamentals
RUN python3 -m pip install -U \
  pyads

# Install zed-gstreamer
WORKDIR /code
RUN git clone https://github.com/stereolabs/zed-gstreamer.git \
    && cd zed-gstreamer \
    && mkdir build \
    && cd build \
    && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs -DCMAKE_CXX_FLAGS="-Wl,--allow-shlib-undefined" -DCUDA_CUDART_LIBRARY="/usr/local/cuda/lib64/libcudart.so" .. \
    && make \
    && sudo make install

# Check that all the dependencies are satisfied
WORKDIR /root/ros2_ws
RUN apt-get update -y || true && rosdep update && \
  rosdep install --from-paths src --ignore-src -r -y && \
  rm -rf /var/lib/apt/lists/*

# Install cython
RUN python3 -m pip install --upgrade cython




# Build the dependencies and the ZED ROS2 Wrapper
RUN /bin/bash -c "source /opt/ros/$ROS_DISTRO/setup.bash && \
  colcon build --parallel-workers $(nproc) \
  --event-handlers console_direct+ --base-paths src \
  --cmake-args ' -DCMAKE_BUILD_TYPE=Release' \
  ' -DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs' \
  ' -DCMAKE_CXX_FLAGS="-Wl,--allow-shlib-undefined"' \
  ' --no-warn-unused-cli' "

#WORKDIR /root/ros2_ws

# Setup environment variables
#COPY ros_entrypoint_jetson.sh /sbin/ros_entrypoint.sh
#RUN sudo chmod 755 /sbin/ros_entrypoint.sh

#ENTRYPOINT ["/sbin/ros_entrypoint.sh"]
#CMD ["bash"]

#This symbolic link is needed to use the streaming features on Jetson inside a container
RUN ln -sf /usr/lib/aarch64-linux-gnu/tegra/libv4l2.so.0 /usr/lib/aarch64-linux-gnu/libv4l2.so

RUN chmod -R 777 /usr/local/zed/
RUN chmod -R 777 /usr/local/lib/
RUN chmod -R 777 /root/
RUN chmod -R 777 /opt/ros/humble/

Hi @Piotr
Welcome to the Stereolabs community.

zed-ros2-examples is not a repository that should be added to a docker image.
It provides examples and tutorial, you can run it externally.

Thank you for answer. Unfortunately i don’t know how to do it properly.

agv@AGV:~/workspaces/isaac_ros-dev/src/isaac_ros_common$ docker exec -it --user root isaac_ros_dev-aarch64-container bash
root@AGV:/workspaces/isaac_ros-dev# cd /root/ros2_ws/src
root@AGV:~/ros2_ws/src# git clone GitHub - stereolabs/zed-ros2-examples: A collection of examples and tutorials to illustrate how to better use the ZED cameras in the ROS2 framework
Cloning into ‘zed-ros2-examples’…
remote: Enumerating objects: 2334, done.
remote: Counting objects: 100% (67/67), done.
remote: Compressing objects: 100% (41/41), done.
remote: Total 2334 (delta 34), reused 29 (delta 24), pack-reused 2267
Receiving objects: 100% (2334/2334), 5.64 MiB | 3.02 MiB/s, done.
Resolving deltas: 100% (1324/1324), done.
root@AGV:~/ros2_ws/src# cd …
root@AGV:~/ros2_ws# rosdep install --from-paths src --ignore-src -r -y
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
zed_robot_integration: Cannot locate rosdep definition for [scout_description]
Continuing to install resolvable dependencies…
#All required rosdeps installed successfully
root@AGV:~/ros2_ws# colcon build --symlink-install --cmake-args=-DCMAKE_BUILD_TYPE=Release
Starting >>> zed_interfaces
Starting >>> zed_topic_benchmark_interfaces
Starting >>> zed_tutorial_depth
Starting >>> zed_tutorial_pos_tracking
Starting >>> zed_tutorial_video
— stderr: zed_interfaces
Traceback (most recent call last):
File “/opt/ros/humble/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py”, line 21, in
from ament_package.templates import get_environment_hook_template_path
ModuleNotFoundError: No module named ‘ament_package’
CMake Error at /opt/ros/humble/share/ament_cmake_core/cmake/ament_cmake_package_templates-extras.cmake:41 (message):
execute_process(/usr/bin/python3
/opt/ros/humble/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py
/root/ros2_ws/build/zed_interfaces/ament_cmake_package_templates/templates.cmake)
returned error code 1
Call Stack (most recent call first):
/opt/ros/humble/share/ament_cmake_core/cmake/ament_cmake_coreConfig.cmake:41 (include)
/opt/ros/humble/share/ament_cmake/cmake/ament_cmake_export_dependencies-extras.cmake:15 (find_package)
/opt/ros/humble/share/ament_cmake/cmake/ament_cmakeConfig.cmake:41 (include)
/opt/ros/humble/share/ament_cmake_auto/cmake/ament_cmake_auto-extras.cmake:17 (find_package)
/opt/ros/humble/share/ament_cmake_auto/cmake/ament_cmake_autoConfig.cmake:41 (include)
CMakeLists.txt:54 (find_package)


Failed <<< zed_interfaces [0.29s, exited with code 1]
Aborted <<< zed_topic_benchmark_interfaces [0.59s]
Aborted <<< zed_tutorial_depth [0.59s]
Aborted <<< zed_tutorial_pos_tracking [0.63s]
Aborted <<< zed_tutorial_video [0.65s]

Summary: 0 packages finished [1.12s]
1 package failed: zed_interfaces
4 packages aborted: zed_topic_benchmark_interfaces zed_tutorial_depth zed_tutorial_pos_tracking zed_tutorial_video
5 packages had stderr output: zed_interfaces zed_topic_benchmark_interfaces zed_tutorial_depth zed_tutorial_pos_tracking zed_tutorial_video
12 packages not processed
root@AGV:~/ros2_ws#

root@AGV:/# source /opt/ros/humble/setup.bash
root@AGV:/# ros2 pkg list
action_msgs
actionlib_msgs
ament_clang_format
ament_cmake
ament_cmake_auto
ament_cmake_clang_format
ament_cmake_copyright
ament_cmake_core
ament_cmake_cppcheck
ament_cmake_cpplint
ament_cmake_export_definitions
ament_cmake_export_dependencies
ament_cmake_export_include_directories
ament_cmake_export_interfaces
ament_cmake_export_libraries
ament_cmake_export_link_flags
ament_cmake_export_targets
ament_cmake_flake8
ament_cmake_gen_version_h
ament_cmake_gmock
ament_cmake_google_benchmark
ament_cmake_gtest
ament_cmake_include_directories
ament_cmake_libraries
ament_cmake_lint_cmake
ament_cmake_pep257
ament_cmake_pytest
ament_cmake_python
ament_cmake_ros
ament_cmake_target_dependencies
ament_cmake_test
ament_cmake_uncrustify
ament_cmake_version
ament_cmake_xmllint
ament_copyright
ament_cppcheck
ament_cpplint
ament_flake8
ament_index_cpp
ament_index_python
ament_lint
ament_lint_auto
ament_lint_cmake
ament_lint_common
ament_package

Could you help me, please?

It seems that you are using the zed-ros2-examples packages without installing the main zed-ros2-wrapper packages.

Can you explain what’s your goal?

Well… probably I should use source /opt/ros/humble/setup.bash before colcon build.
I want to run zed-ros2-examples packages on isaac-ros-common container. Unfortunately I don’t have enough experience with ROS and Docker.

After source /opt/ros/humble/setup.bash:
docker exec -it --user root isaac_ros_dev-aarch64-container bash
root@AGV:/workspaces/isaac_ros-dev# cd /root/ros2_ws/
root@AGV:~/ros2_ws# ls
build install log src
root@AGV:~/ros2_ws# cd src
root@AGV:~/ros2_ws/src# ls
zed-ros2-wrapper
root@AGV:~/ros2_ws/src# git clone GitHub - stereolabs/zed-ros2-examples: A collection of examples and tutorials to illustrate how to better use the ZED cameras in the ROS2 framework
Cloning into ‘zed-ros2-examples’…
remote: Enumerating objects: 2334, done.
remote: Counting objects: 100% (59/59), done.
remote: Compressing objects: 100% (40/40), done.
remote: Total 2334 (delta 27), reused 22 (delta 17), pack-reused 2275
Receiving objects: 100% (2334/2334), 5.63 MiB | 4.48 MiB/s, done.
Resolving deltas: 100% (1326/1326), done.
root@AGV:/# source /opt/ros/humble/setup.bash
root@AGV:/# cd /root/ros2_ws/
root@AGV:~/ros2_ws# rosdep install --from-paths src --ignore-src -r -y
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
zed_robot_integration: Cannot locate rosdep definition for [scout_description]
Continuing to install resolvable dependencies…
#All required rosdeps installed successfully
root@AGV:~/ros2_ws# colcon build --symlink-install --cmake-args=-DCMAKE_BUILD_TYPE=Releas
Starting >>> zed_interfaces
Starting >>> zed_topic_benchmark_interfaces
Starting >>> zed_tutorial_depth
Starting >>> zed_tutorial_pos_tracking
Starting >>> zed_tutorial_video
— stderr: zed_interfaces
failed to create symbolic link ‘/root/ros2_ws/build/zed_interfaces/ament_cmake_python/zed_interfaces/zed_interfaces’ because existing path cannot be removed: Is a directory
gmake[2]: *** [CMakeFiles/ament_cmake_python_symlink_zed_interfaces.dir/build.make:70: CMakeFiles/ament_cmake_python_symlink_zed_interfaces] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:448: CMakeFiles/ament_cmake_python_symlink_zed_interfaces.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs…
gmake: *** [Makefile:146: all] Error 2

Failed <<< zed_interfaces [4.24s, exited with code 2]
Aborted <<< zed_topic_benchmark_interfaces [4.46s]
Aborted <<< zed_tutorial_pos_tracking [4.59s]
Aborted <<< zed_tutorial_video [18.4s]
Aborted <<< zed_tutorial_depth [18.5s]

Summary: 0 packages finished [19.1s]
1 package failed: zed_interfaces
4 packages aborted: zed_topic_benchmark_interfaces zed_tutorial_depth zed_tutorial_pos_tracking zed_tutorial_video
1 package had stderr output: zed_interfaces
12 packages not processed

You cannot use the zed-ros2-examples packages without installing the main zed-ros2-wrapper packages.

ISAAC ROS is something that is not related to the zed-ros2-examples packages.

You are mixing packages that cannot work together.