stereolabs / zed-ros2-wrapper

ROS 2 wrapper for the ZED SDK
https://www.stereolabs.com/docs/ros2/
Apache License 2.0
158 stars 161 forks source link

Jetson Orin Nano Dockerfile Fails Build -- Missing point_cloud_transport #252

Closed javieryu closed 2 weeks ago

javieryu commented 1 month ago

Preliminary Checks

Description

When running the docker build process on my Jetson Orin Nano the docker build fails to complete the colcon build step in the docker file because zed _components is missing the point_cloud_transport package.

Steps to Reproduce

  1. git clone --recursive https://github.com/stereolabs/zed-ros2-wrapper.git
  2. cd zed-ros2-wrapper/docker
  3. ./jetson_build_dockerfile_from_sdk_and_l4T_version.sh l4t-r35.4.1 zedsdk4.1.2

...

Expected Result

Docker image finishes building.

Actual Result

Error snippet:

...
373.9 CMake Error at CMakeLists.txt:142 (find_package):
373.9   By not providing "Findpoint_cloud_transport.cmake" in CMAKE_MODULE_PATH
373.9   this project has asked CMake to find a package configuration file provided
373.9   by "point_cloud_transport", but CMake did not find one.
373.9
373.9   Could not find a package configuration file provided by
373.9   "point_cloud_transport" with any of the following names:
373.9
373.9     point_cloud_transportConfig.cmake
373.9     point_cloud_transport-config.cmake
373.9
373.9   Add the installation prefix of "point_cloud_transport" to CMAKE_PREFIX_PATH
373.9   or set "point_cloud_transport_DIR" to a directory containing one of the
373.9   above files.  If "point_cloud_transport" provides a separate development
373.9   package or SDK, be sure it has been installed.
373.9
373.9
373.9 -- Configuring incomplete, errors occurred!
374.1 --- stderr: zed_components
374.1 CMake Warning (dev) at /usr/local/zed/zed-config.cmake:72 (find_package):
374.1   Policy CMP0146 is not set: The FindCUDA module is removed.  Run "cmake
374.1   --help-policy CMP0146" for policy details.  Use the cmake_policy command to
374.1   set the policy and suppress this warning.
374.1
374.1 Call Stack (most recent call first):
374.1   CMakeLists.txt:81 (find_package)
374.1 This warning is for project developers.  Use -Wno-dev to suppress it.
374.1
374.1 CMake Warning (dev) at CMakeLists.txt:88 (find_package):
374.1   Policy CMP0146 is not set: The FindCUDA module is removed.  Run "cmake
374.1   --help-policy CMP0146" for policy details.  Use the cmake_policy command to
374.1   set the policy and suppress this warning.
374.1
374.1 This warning is for project developers.  Use -Wno-dev to suppress it.
374.1
374.1 CMake Error at CMakeLists.txt:142 (find_package):
374.1   By not providing "Findpoint_cloud_transport.cmake" in CMAKE_MODULE_PATH
374.1   this project has asked CMake to find a package configuration file provided
374.1   by "point_cloud_transport", but CMake did not find one.
374.1
374.1   Could not find a package configuration file provided by
374.1   "point_cloud_transport" with any of the following names:
374.1
374.1     point_cloud_transportConfig.cmake
374.1     point_cloud_transport-config.cmake
374.1
374.1   Add the installation prefix of "point_cloud_transport" to CMAKE_PREFIX_PATH
374.1   or set "point_cloud_transport_DIR" to a directory containing one of the
374.1   above files.  If "point_cloud_transport" provides a separate development
374.1   package or SDK, be sure it has been installed.
374.1
374.1
374.1 ---
374.1 Failed   <<< zed_components [8.40s, exited with code 1]
374.1
374.1 Summary: 40 packages finished [6min 13s]
374.1   1 package failed: zed_components
374.1   22 packages had stderr output: ament_clang_format ament_clang_tidy ament_copyright ament_cppcheck ament_cpplint ament_flake8 ament_lint ament_lint_cmake ament_mypy ament_pclint ament_pep257 ament_pycodestyle ament_pyflakes ament_uncrustify ament_xmllint diagnostic_aggregator geographic_msgs nmea_msgs robot_localization xacro zed_components zed_interfaces
374.1   2 packages not processed
------
Dockerfile.l4t-humble:89
--------------------
  88 |     # Build the dependencies and the ZED ROS2 Wrapper
  89 | >>> RUN /bin/bash -c "source /opt/ros/$ROS_DISTRO/install/setup.bash && \
  90 | >>>   colcon build --parallel-workers $(nproc) --symlink-install \
  91 | >>>   --event-handlers console_direct+ --base-paths src \
  92 | >>>   --cmake-args ' -DCMAKE_BUILD_TYPE=Release' \
  93 | >>>   ' -DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs' \
  94 | >>>   ' -DCMAKE_CXX_FLAGS="-Wl,--allow-shlib-undefined"' \
  95 | >>>   ' --no-warn-unused-cli' "
  96 |
--------------------
ERROR: failed to solve: process "/bin/bash -c /bin/bash -c \"source /opt/ros/$ROS_DISTRO/install/setup.bash &&   colcon build --parallel-workers $(nproc) --symlink-install   --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

Here's a log file of the full output from the docker build: build.log

ZED Camera model

ZED Mini

Environment

Jetson Orin Nano DevKit
OS: L4T 35.4.1 (JP 5.1.2)

Anything else?

The rosdep install step that I would have expected to install the point_cloud_transport package seems to have run without throwing errors since the docker build proceeds past this step in the Dockerfile. When I inspect the logs for the rosdep install (see below for a snippet) I don't see any of the packages from the zed_components/package.xml which suggests to me that there might be some other issue.

...
#15 [11/16] RUN apt-get update -y || true && rosdep update &&   rosdep install --from-paths src --ignore-src -r -y &&   rm -rf /var/lib/apt/lists/*
#15 0.473 Get:1 http://packages.ros.org/ros2/ubuntu focal InRelease [4,685 B]
#15 0.519 Get:2 https://repo.download.nvidia.com/jetson/common r35.4 InRelease [2,555 B]
#15 0.598 Get:3 http://packages.ros.org/ros2/ubuntu focal/main arm64 Packages [1,173 kB]
#15 0.734 Get:4 https://repo.download.nvidia.com/jetson/common r35.4/main arm64 Packages [19.6 kB]
#15 0.780 Get:5 http://ports.ubuntu.com/ubuntu-ports focal InRelease [265 kB]
#15 1.621 Get:6 http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease [128 kB]
#15 1.905 Get:7 http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease [128 kB]
#15 2.244 Get:8 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease [128 kB]
#15 2.548 Get:9 http://ports.ubuntu.com/ubuntu-ports focal/universe arm64 Packages [11.1 MB]
#15 14.74 Get:10 http://ports.ubuntu.com/ubuntu-ports focal/main arm64 Packages [1,234 kB]
#15 15.30 Get:11 http://ports.ubuntu.com/ubuntu-ports focal/restricted arm64 Packages [1,317 B]
#15 15.30 Get:12 http://ports.ubuntu.com/ubuntu-ports focal/multiverse arm64 Packages [139 kB]
#15 15.37 Get:13 http://ports.ubuntu.com/ubuntu-ports focal-updates/restricted arm64 Packages [59.4 kB]
#15 15.40 Get:14 http://ports.ubuntu.com/ubuntu-ports focal-updates/multiverse arm64 Packages [12.0 kB]
#15 15.40 Get:15 http://ports.ubuntu.com/ubuntu-ports focal-updates/main arm64 Packages [3,370 kB]
#15 17.43 Get:16 http://ports.ubuntu.com/ubuntu-ports focal-updates/universe arm64 Packages [1,457 kB]
#15 19.09 Get:17 http://ports.ubuntu.com/ubuntu-ports focal-backports/universe arm64 Packages [27.8 kB]
#15 19.11 Get:18 http://ports.ubuntu.com/ubuntu-ports focal-backports/main arm64 Packages [54.8 kB]
#15 19.19 Get:19 http://ports.ubuntu.com/ubuntu-ports focal-security/restricted arm64 Packages [59.1 kB]
#15 19.24 Get:20 http://ports.ubuntu.com/ubuntu-ports focal-security/multiverse arm64 Packages [5,924 B]
#15 19.24 Get:21 http://ports.ubuntu.com/ubuntu-ports focal-security/main arm64 Packages [3,000 kB]
#15 21.50 Get:22 http://ports.ubuntu.com/ubuntu-ports focal-security/universe arm64 Packages [1,170 kB]
#15 22.68 Fetched 23.6 MB in 22s (1,060 kB/s)
#15 22.68 Reading package lists...
#15 37.50 reading in sources list data from /etc/ros/rosdep/sources.list.d
#15 37.50 Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
#15 37.50 Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
#15 37.50 Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
#15 37.50 Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
#15 37.50 Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
#15 37.50 Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
#15 37.50 Skip end-of-life distro "ardent"
#15 37.50 Skip end-of-life distro "bouncy"
#15 37.50 Skip end-of-life distro "crystal"
#15 37.50 Skip end-of-life distro "dashing"
#15 37.50 Skip end-of-life distro "eloquent"
#15 37.50 Skip end-of-life distro "foxy"
#15 37.50 Skip end-of-life distro "galactic"
#15 37.50 Skip end-of-life distro "groovy"
#15 37.50 Add distro "humble"
#15 37.50 Skip end-of-life distro "hydro"
#15 37.50 Skip end-of-life distro "indigo"
#15 37.50 Add distro "iron"
#15 37.50 Skip end-of-life distro "jade"
#15 37.50 Add distro "jazzy"
#15 37.50 Skip end-of-life distro "kinetic"
#15 37.50 Skip end-of-life distro "lunar"
#15 37.50 Skip end-of-life distro "melodic"
#15 37.50 Add distro "noetic"
#15 37.50 Add distro "rolling"
#15 37.50 updated cache in /root/.ros/rosdep/sources.cache
#15 37.50 Warning: running 'rosdep update' as root is not recommended.
#15 37.50   You should run 'sudo rosdep fix-permissions' and invoke 'rosdep update' again without sudo.
#15 43.91 Reading package lists...
#15 45.36 Building dependency tree...
#15 45.78 Reading state information...
#15 46.43 The following packages were automatically installed and are no longer required:
#15 46.43   libgtk2.0-0 libgtk2.0-common
#15 46.43 Use 'apt autoremove' to remove them.
#15 46.43 The following additional packages will be installed:
#15 46.44   clang-format-10 libclang-cpp10 libllvm10
#15 46.50 The following NEW packages will be installed:
#15 46.50   clang-format clang-format-10 libclang-cpp10 libllvm10
#15 46.81 0 upgraded, 4 newly installed, 0 to remove and 174 not upgraded.
...
javieryu commented 1 month ago

Partial solution found on the ZED Community Forums!

https://community.stereolabs.com/t/zed-ros-2-wrapper-docker-build-fails/6756/5

This fix also worked for me and I can confirm that everything seems to work properly with my ZEDM afterwards. I'm not experiencing the topic issues that the OP for the forum post had, and that seems to be a separate issue.

I'll leave this open for now because it would seem that this indicates the current master branch is broken for the docker install.

Copy of my working Dockerfile.l4t-humble for posterity:

ARG L4T_VERSION=l4t-r35.4.1
ARG IMAGE_NAME=dustynv/ros:humble-ros-base-${L4T_VERSION}

FROM ${IMAGE_NAME}

ARG ZED_SDK_MAJOR=4
ARG ZED_SDK_MINOR=1
ARG ZED_SDK_PATCH=0
ARG JETPACK_MAJOR=5
ARG JETPACK_MINOR=0
ARG L4T_MAJOR=35
ARG L4T_MINOR=1

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

# ZED SDK link
ENV ZED_SDK_URL="https://stereolabs.sfo2.cdn.digitaloceanspaces.com/zedsdk/${ZED_SDK_MAJOR}.${ZED_SDK_MINOR}/ZED_SDK_Tegra_L4T${L4T_MAJOR}.${L4T_MINOR}_v${ZED_SDK_MAJOR}.${ZED_SDK_MINOR}.${ZED_SDK_PATCH}.zstd.run"

# Check that this SDK exists
RUN if [ "$(curl -I "${ZED_SDK_URL}" -o /dev/null -s -w '%{http_code}\n' | head -n 1)" = "200" ]; then \
        echo "The URL points to something."; \
    else \
        echo "The URL does not point to a .run file or the file does not exist."; \
        exit 1; \
    fi

# 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/Paris

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 && \    
  rm -rf /var/lib/apt/lists/*

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 \
  ${ZED_SDK_URL} && \
  chmod +x ZED_SDK_Linux_JP.run ; ./ZED_SDK_Linux_JP.run silent skip_tools && \
  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}

# Copy the sources in the Docker image
WORKDIR /root/ros2_ws/src
COPY tmp_sources/ ./

# 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 && \
  git clone https://github.com/ros2/rcpputils.git --branch humble && \
  git clone https://github.com/ros-perception/point_cloud_transport.git --branch humble

# 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/install/setup.bash && \
  colcon build --parallel-workers $(nproc) --symlink-install --packages-select rcpputils point_cloud_transport \
  --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' "

RUN /bin/bash -c "source /opt/ros/$ROS_DISTRO/install/setup.bash && source install/local_setup.bash && \
  colcon build --parallel-workers $(nproc) --symlink-install \
  --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

# Set the default DDS middleware to FastRTPS for improved big data transmission
ENV RMW_IMPLEMENTATION=rmw_fastrtps_cpp

# 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"]
juliangaal commented 1 month ago

Any idea why this multi-step build is necessary, even though the dependencies are stated correctly?

https://github.com/stereolabs/zed-ros2-wrapper/blob/baad42b042370732f5e8d3639753c561db7c1e30/zed_components/package.xml#L30

and

https://github.com/stereolabs/zed-ros2-wrapper/blob/baad42b042370732f5e8d3639753c561db7c1e30/zed_ros2/package.xml#L15

Myzhar commented 1 month ago

I'm sorry, I cannot understand your question.

juliangaal commented 1 month ago

In the patch that @javieryu posted, the build is separated into two steps.

First, rcpputils and point_cloud_transport are built separately

# Build the dependencies and the ZED ROS2 Wrapper
RUN /bin/bash -c "source /opt/ros/$ROS_DISTRO/install/setup.bash && \
  colcon build --parallel-workers $(nproc) --symlink-install --packages-select rcpputils point_cloud_transport \
  --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' "

Then, the rest is built

RUN /bin/bash -c "source /opt/ros/$ROS_DISTRO/install/setup.bash && source install/local_setup.bash && \
  colcon build --parallel-workers $(nproc) --symlink-install \
  --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' "

To my knowledge, this two-step process shoudn't be needed, because the dependencies are correctly stated, as alluded to in

Any idea why this multi-step build is necessary, even though the dependencies are stated correctly?

https://github.com/stereolabs/zed-ros2-wrapper/blob/baad42b042370732f5e8d3639753c561db7c1e30/zed_components/package.xml#L30

and

https://github.com/stereolabs/zed-ros2-wrapper/blob/baad42b042370732f5e8d3639753c561db7c1e30/zed_ros2/package.xml#L15

Do you understand my confusion?

Myzhar commented 1 month ago

@javieryu can you justify your choice?

javieryu commented 1 month ago

Any idea why this multi-step build is necessary, even though the dependencies are stated correctly?

https://github.com/stereolabs/zed-ros2-wrapper/blob/baad42b042370732f5e8d3639753c561db7c1e30/zed_components/package.xml#L30

and

https://github.com/stereolabs/zed-ros2-wrapper/blob/baad42b042370732f5e8d3639753c561db7c1e30/zed_ros2/package.xml#L15

@javieryu can you justify your choice?

Per the post on the ZED community forums "I then also had to first build rcpputils and point_cloud_transport, source the local workspace and then build the rest of the packages. Otherwise it wouldn’t find the point_cloud_transport package". I also was not sure why the original solution used separate colcon builds, but I assume that the original author of the patch tested with the single call to colcon build first. It seems like for whatever reason the zed_components package.xml is not being correctly parsed by colcon/rosdep.

The truth is that I have ICRA deadlines this week, and didn't have time to investigate a more elegant patch. Hence no PR etc.

github-actions[bot] commented 3 weeks ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment otherwise it will be automatically closed in 5 days