iassc ros container updated to jetpack 6

This commit is contained in:
Rooholla-KhorramBakht 2024-06-04 22:11:19 -05:00
parent 2590b1c914
commit 7b43efd27c
26 changed files with 10432 additions and 1035 deletions

View File

@ -1,4 +1,4 @@
# Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved. # Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.
# #
# NVIDIA CORPORATION and its licensors retain all intellectual property # NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation # and proprietary rights in and to this software, related documentation
@ -7,224 +7,240 @@
# license agreement from NVIDIA CORPORATION is strictly prohibited. # license agreement from NVIDIA CORPORATION is strictly prohibited.
# Docker file for aarch64 based Jetson device # Docker file for aarch64 based Jetson device
ARG BASE_IMAGE="nvcr.io/nvidia/l4t-base:35.4.1" ARG BASE_IMAGE="nvcr.io/nvidia/l4t-cuda:12.2.12-devel"
FROM ${BASE_IMAGE} FROM ${BASE_IMAGE}
# Store list of packages (must be first)
RUN mkdir -p /opt/nvidia/isaac_ros_dev_base && dpkg-query -W | sort > /opt/nvidia/isaac_ros_dev_base/aarch64-start-packages.csv
# Disable terminal interaction for apt # Disable terminal interaction for apt
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
ENV SHELL /bin/bash ENV SHELL /bin/bash
SHELL ["/bin/bash", "-c"] SHELL ["/bin/bash", "-c"]
# Ensure we have universe # Ensure we have universe
RUN apt-get update \ RUN --mount=type=cache,target=/var/cache/apt \
&& apt-get install -y software-properties-common \ apt-get update && apt-get install -y \
&& add-apt-repository universe software-properties-common \
&& add-apt-repository universe \
&& apt-get update
# Fundamentals # Fundamentals
RUN apt-get update && apt-get install -y \ RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -y \
apt-utils \
bash-completion \
build-essential \ build-essential \
ca-certificates \ ca-certificates \
curl \ curl \
git \ git \
git-lfs \
gnupg2 \ gnupg2 \
iputils-ping \ iputils-ping \
libgoogle-glog-dev \
locales \
lsb-release \ lsb-release \
software-properties-common \
sudo \ sudo \
tar \ tar \
unzip \ unzip \
vim \ vim \
wget \ wget \
libgoogle-glog-dev \ zlib1g-dev
software-properties-common \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Upgrade cmake to 3.22.1 to match Ubuntu 22.04 # Add Isaac apt repository
# Key rotation 2024-01-10 RUN --mount=type=cache,target=/var/cache/apt \
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null \ wget -qO - https://isaac.download.nvidia.com/isaac-ros/repos.key | apt-key add - && \
&& echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ focal main' | tee /etc/apt/sources.list.d/kitware.list >/dev/null \ grep -qxF "deb https://isaac.download.nvidia.com/isaac-ros/release-3 $(lsb_release -cs) release-3.0" /etc/apt/sources.list || \
&& apt-get update \ echo "deb https://isaac.download.nvidia.com/isaac-ros/release-3 $(lsb_release -cs) release-3.0" | tee -a /etc/apt/sources.list \
&& apt-get remove -y cmake && apt-get purge -y cmake && apt-get remove -y cmake-data && apt-get purge -y cmake-data \ && apt-get update
&& apt-get install -y cmake=3.22.1-0kitware1ubuntu20.04.1 cmake-data=3.22.1-0kitware1ubuntu20.04.1 \
&& cmake --version \ # Setup Jetson debian repositories
&& rm -rf /var/lib/apt/lists/* \ RUN --mount=type=cache,target=/var/cache/apt \
&& apt-get clean apt-key adv --fetch-keys https://repo.download.nvidia.com/jetson/jetson-ota-public.asc \
&& apt-key adv --fetch-keys http://l4t-repo.nvidia.com/jetson-ota-internal.key \
&& echo 'deb https://repo.download.nvidia.com/jetson/common r36.3 main' > /etc/apt/sources.list.d/nvidia-l4t-apt-source.list \
&& echo 'deb https://repo.download.nvidia.com/jetson/t234 r36.3 main' >> /etc/apt/sources.list.d/nvidia-l4t-apt-source.list \
&& apt-get update
# Python basics
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -y \
python3-dev \
python3-distutils \
python3-flake8 \
python3-pip \
python3-pytest-cov \
python3-venv \
python3-zmq \
python3.10 \
python3.10-venv
# Set Python3 as default # Set Python3 as default
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1 RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
# Python basics # Core dev libraries
RUN apt-get update && apt-get install -y \ RUN --mount=type=cache,target=/var/cache/apt \
python3-dev \ apt-get update && apt-get install -y \
python3-flake8 \ ffmpeg \
python3-pip \ gfortran \
python3-pytest-cov \ graphicsmagick-libmagick-dev-compat \
&& rm -rf /var/lib/apt/lists/* \ jq \
&& apt-get clean kmod \
lcov \
# Install OpenCV dependencies libasio-dev \
RUN apt-get update && apt-get install -y \ libassimp-dev \
libavformat-dev \ libatlas-base-dev \
libjpeg-dev \ libblas3 \
libopenjp2-7-dev \ libatlas3-base \
libpng-dev \
libpq-dev \
libswscale-dev \
libtbb2 \
libtbb-dev \
libtiff-dev \
pkg-config \
yasm \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Install additional packages needed for ROS 2 dependencies
RUN apt-get update && apt-get install -y \
python3-distutils \
libboost-all-dev \ libboost-all-dev \
libboost-dev \ libboost-dev \
libpcl-dev \
libode-dev \
lcov \
python3-zmq \
libxaw7-dev \
libgraphicsmagick++1-dev \
graphicsmagick-libmagick-dev-compat \
libceres-dev \ libceres-dev \
libsuitesparse-dev \ libbullet-dev \
libcunit1-dev \
libffi7 \
libfreetype6 \
libgraphicsmagick++1-dev \
libhidapi-libusb0 \
libinput10 \
libjpeg8 \
liblapack3 \
libmnl0 \
libmnl-dev \
libncurses5-dev \ libncurses5-dev \
libassimp-dev \ libode-dev \
libyaml-cpp-dev \ libopenblas0 \
libopencv-dev=4.5.4+dfsg-9ubuntu4 \
libopenmpi3 \
libpcap-dev \ libpcap-dev \
&& rm -rf /var/lib/apt/lists/* \ libpcl-dev \
&& apt-get clean libsuitesparse-dev \
libtinyxml2-dev \
libturbojpeg \
linuxptp \
libunwind8 \
libv4l-0 \
libx264-dev \
libxaw7-dev \
libyaml-cpp-dev \
llvm-14 \
nlohmann-json3-dev \
python3-opencv=4.5.4+dfsg-9ubuntu4 \
python3-scipy
# sklearn dependencies # Additional Python dependencies
RUN apt-get update && apt-get install -y \
gfortran \
libatlas-base-dev \
python3-scipy \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# sklearn Python dependencies
RUN python3 -m pip install -U \ RUN python3 -m pip install -U \
Cython \ Cython \
wheel pymongo \
wheel \
scikit-learn \
ninja \
networkx \
numpy \
numpy-quaternion \
pyyaml \
setuptools_scm>=6.2 \
trimesh \
yourdfpy>=0.0.53 \
warp-lang>=0.9.0 \
scipy>=1.7.0 \
tqdm \
importlib_resources
# Install sklearn
RUN python3 -m pip install -U \
scikit-learn
# Install Git-LFS
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash && \
apt-get update && apt-get install -y \
git-lfs \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Install TensorRT and VPI
RUN apt-get update && apt-get install -y \
tensorrt \
vpi2-dev \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Install tao-converter
COPY tao/tao-converter-aarch64-tensorrt8.4.zip /opt/nvidia/tao/tao-converter-aarch64-tensorrt8.4.zip
RUN mkdir -p /opt/nvidia/tao && \
cd /opt/nvidia/tao && \
unzip -j tao-converter-aarch64-tensorrt8.4.zip -d /opt/nvidia/tao/jp5 && \
chmod 755 $(find /opt/nvidia/tao -name "tao-converter") && \
ln -sf $(find /opt/nvidia/tao -name "tao-converter") /opt/nvidia/tao/tao-converter && \
rm tao-converter-aarch64-tensorrt8.4.zip
ENV PATH="${PATH}:/opt/nvidia/tao"
# Update environment # Update environment
ENV LD_LIBRARY_PATH="/opt/nvidia/vpi2/lib64:${LD_LIBRARY_PATH}" RUN update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-14 14
ENV LD_LIBRARY_PATH="/opt/nvidia/vpi3/lib64:${LD_LIBRARY_PATH}"
ENV LD_LIBRARY_PATH="/usr/lib/aarch64-linux-gnu/tegra:${LD_LIBRARY_PATH}" ENV LD_LIBRARY_PATH="/usr/lib/aarch64-linux-gnu/tegra:${LD_LIBRARY_PATH}"
ENV LD_LIBRARY_PATH="/usr/local/cuda-11.4/targets/aarch64-linux/lib:${LD_LIBRARY_PATH}" ENV LD_LIBRARY_PATH="/usr/local/cuda-12.2/targets/aarch64-linux/lib:${LD_LIBRARY_PATH}"
ENV LD_LIBRARY_PATH="/usr/lib/aarch64-linux-gnu/tegra-egl:${LD_LIBRARY_PATH}" ENV LD_LIBRARY_PATH="/usr/lib/aarch64-linux-gnu/tegra-egl:${LD_LIBRARY_PATH}"
ENV LD_LIBRARY_PATH="/usr/lib/aarch64-linux-gnu/tegra/weston:${LD_LIBRARY_PATH}" ENV LD_LIBRARY_PATH="/usr/lib/aarch64-linux-gnu/tegra/weston:${LD_LIBRARY_PATH}"
ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/lib/aarch64-linux-gnu-host" ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/lib/aarch64-linux-gnu-host"
ENV PATH="${PATH}:/usr/local/cuda/bin" ENV PATH="/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/src/tensorrt/bin:${PATH}"
# https://forums.developer.nvidia.com/t/error-importerror-usr-lib-aarch64-linux-gnu-libgomp-so-1-cannot-allocate-memory-in-static-tls-block-i-looked-through-available-threads-already/166494/3 # Install CUDA packages
ENV LD_PRELOAD="/usr/lib/aarch64-linux-gnu/libgomp.so.1" RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -y --no-install-recommends \
cuda-cudart-12-2 \
cuda-libraries-12-2 \
cuda-nvml-dev-12-2 \
cuda-sanitizer-12-2 \
cuda-toolkit-12-2 \
libcublas-12-2 \
libcudnn8 \
libcusparse-12-2 \
libnpp-12-2
# Install TensorRT and VPI
RUN --mount=type=cache,target=/var/cache/apt \
mkdir -p /lib/firmware && \
apt-get update && apt-get install -y \
libnvvpi3 \
tensorrt \
vpi3-dev
# Install Tao converter
RUN mkdir -p /opt/nvidia/tao && cd /opt/nvidia/tao && \
wget --content-disposition 'https://api.ngc.nvidia.com/v2/resources/org/nvidia/team/tao/tao-converter/v5.1.0_jp6.0_aarch64/files?redirect=true&path=tao-converter' -O tao-converter && \
chmod 755 tao-converter
ENV PATH="${PATH}:/opt/nvidia/tao"
ENV TRT_LIB_PATH="/usr/lib/aarch64-linux-gnu"
ENV TRT_INCLUDE_PATH="/usr/include/aarch64-linux-gnu"
# PyTorch (NV CUDA edition) # PyTorch (NV CUDA edition)
# https://docs.nvidia.com/deeplearning/frameworks/install-pytorch-jetson-platform/index.html # https://docs.nvidia.com/deeplearning/frameworks/install-pytorch-jetson-platform/index.html
RUN python3 -m pip install --no-cache \ RUN python3 -m pip install --no-cache \
https://developer.download.nvidia.cn/compute/redist/jp/v50/pytorch/torch-1.13.0a0+340c4120.nv22.06-cp38-cp38-linux_aarch64.whl https://developer.download.nvidia.com/compute/redist/jp/v60dp/pytorch/torch-2.2.0a0+6a974be.nv23.11-cp310-cp310-linux_aarch64.whl
# Install Triton server 2.24 from https://github.com/triton-inference-server/server/releases/tag/v2.24.0 # Install Triton server from https://github.com/triton-inference-server/server/releases/tag/v2.40.0
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN --mount=type=cache,target=/var/cache/apt \
autoconf \ apt-get update && apt-get install -y --no-install-recommends \
automake \ libb64-0d \
libb64-dev \ libre2-9 \
libcurl4-openssl-dev \
libopenblas-dev \
libre2-dev \
libssl-dev \
libtool \
patchelf \
rapidjson-dev \ rapidjson-dev \
zlib1g-dev \ libopenblas-dev \
&& rm -rf /var/lib/apt/lists/* \ libarchive-dev
&& apt-get clean
RUN mkdir -p /opt/tritonserver && cd /opt/tritonserver \ RUN --mount=type=cache,target=/var/cache/apt \
&& wget https://github.com/triton-inference-server/server/releases/download/v2.24.0/tritonserver2.24.0-jetpack5.0.2.tgz \ cd /opt \
&& tar -xzvf tritonserver2.24.0-jetpack5.0.2.tgz \ && wget https://github.com/triton-inference-server/server/releases/download/v2.40.0/tritonserver2.40.0-igpu.tar.gz \
&& rm tritonserver2.24.0-jetpack5.0.2.tgz && tar -xzvf tritonserver2.40.0-igpu.tar.gz \
&& chmod 644 /opt/tritonserver/backends/tensorflow/libtensorflow_cc.so.2 \
&& chmod 644 /opt/tritonserver/backends/tensorflow/libtensorflow_framework.so.2 \
&& rm tritonserver2.40.0-igpu.tar.gz
ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/opt/tritonserver/lib" ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/opt/tritonserver/lib"
# Install boost version >= 1.78 for boost::span
# Current libboost-dev apt packages are < 1.78, so install from tar.gz
RUN --mount=type=cache,target=/var/cache/apt \
wget -O /tmp/boost.tar.gz \
https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.gz \
&& (cd /tmp && tar xzf boost.tar.gz) \
&& cd /tmp/boost_1_80_0 \
&& ./bootstrap.sh --prefix=/usr \
&& ./b2 install \
&& rm -rf /tmp/boost*
# Install CV-CUDA
RUN --mount=type=cache,target=/var/cache/apt \
cd /tmp && \
wget https://github.com/CVCUDA/CV-CUDA/releases/download/v0.5.0-beta/nvcv-lib-0.5.0_beta_DP-cuda12-aarch64-linux.deb && \
dpkg -i nvcv-lib-0.5.0_beta_DP-cuda12-aarch64-linux.deb && \
wget https://github.com/CVCUDA/CV-CUDA/releases/download/v0.5.0-beta/nvcv-dev-0.5.0_beta_DP-cuda12-aarch64-linux.deb && \
dpkg -i nvcv-dev-0.5.0_beta_DP-cuda12-aarch64-linux.deb
# Add MQTT binaries and libraries # Add MQTT binaries and libraries
RUN apt-add-repository ppa:mosquitto-dev/mosquitto-ppa \ RUN --mount=type=cache,target=/var/cache/apt \
&& apt-get update && apt-get install -y \ apt-add-repository ppa:mosquitto-dev/mosquitto-ppa \
&& apt-get update && apt-get install -y \
mosquitto \ mosquitto \
mosquitto-clients \ mosquitto-clients
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Note: VPN cannot be on for pymongo download # Install jtop
RUN python3 -m pip install -U \ RUN python3 -m pip install -U \
pymongo \ jetson-stats
paho-mqtt
# Core dev libraries # Store list of packages (must be last)
RUN apt-get update && apt-get install -y \ RUN mkdir -p /opt/nvidia/isaac_ros_dev_base && dpkg-query -W | sort > /opt/nvidia/isaac_ros_dev_base/aarch64-end-packages.csv
libasio-dev \
libbullet-dev \
libtinyxml2-dev \
libcunit1-dev \
libopencv-dev=4.2.0+dfsg-5 \
python3-opencv=4.2.0+dfsg-5 \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# NPP library
RUN apt-get update && apt-get install -y --no-install-recommends \
libnpp-dev-11-4 \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Upgrade libc to resolve vulnerabilities including CVE-2019-11477
RUN apt-get update && apt-get install -y --only-upgrade \
linux-libc-dev \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Downgrade protobuf
RUN python3 -m pip install \
protobuf==3.20.1
# # GPU usage monitoring on Jetson
# RUN python3 -m pip install -U \
# jetson-stats
# Apply libcudacxx patch for fixing C++17 compilation errors in GXF
COPY patches/libcudacxx_aarch64_cuda_11_4.diff /tmp/
RUN patch -i /tmp/libcudacxx_aarch64_cuda_11_4.diff /usr/local/cuda-11.4/targets/aarch64-linux/include/cuda/std/detail/libcxx/include/cmath

View File

@ -1,9 +0,0 @@
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
FROM nvcr.io/nvidia/isaac/ros:aarch64-ros2_humble_b7e1ed6c02a6fa3c1c7392479291c035

View File

@ -1,30 +0,0 @@
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
# Install cvCUDA into the dev image
ARG BASE_IMAGE
FROM ${BASE_IMAGE}
RUN if [ "$(uname -m)" = "x86_64" ]; then \
cd /tmp; \
wget https://github.com/CVCUDA/CV-CUDA/releases/download/v0.4.0-beta/nvcv-lib-0.4.0_beta-cuda11-x86_64-linux.deb; \
dpkg -i nvcv-lib-0.4.0_beta-cuda11-x86_64-linux.deb; \
wget https://github.com/CVCUDA/CV-CUDA/releases/download/v0.4.0-beta/nvcv-dev-0.4.0_beta-cuda11-x86_64-linux.deb; \
dpkg -i nvcv-dev-0.4.0_beta-cuda11-x86_64-linux.deb; \
wget https://github.com/CVCUDA/CV-CUDA/releases/download/v0.4.0-beta/nvcv-lib-0.4.0_beta-cuda11-x86_64-linux.deb; \
dpkg -i nvcv-lib-0.4.0_beta-cuda11-x86_64-linux.deb; \
else \
echo "Not available on aarch64 pending availability of https://github.com/CVCUDA/CV-CUDA/releases/download/v0.4.0-beta/nvcv-lib-0.4.0_beta-cuda11-aarch64-linux.deb" ; \
# cd /tmp; \
# wget https://github.com/CVCUDA/CV-CUDA/releases/download/v0.4.0-beta/nvcv-lib-0.4.0_beta-cuda11-aarch64-linux.deb; \
# dpkg -i nvcv-lib-0.4.0_beta-cuda11-aarch64-linux.deb; \
# wget https://github.com/CVCUDA/CV-CUDA/releases/download/v0.4.0-beta/nvcv-dev-0.4.0_beta-cuda11-aarch64-linux.deb; \
# dpkg -i nvcv-dev-0.4.0_beta-cuda11-aarch64-linux.deb; \
fi

View File

@ -1,23 +1,11 @@
ARG BASE_IMAGE ARG BASE_IMAGE
FROM ${BASE_IMAGE} FROM ${BASE_IMAGE}
# Install dependencies
RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=bind,source=scripts/install-tools.sh,target=/tmp/install-tools.sh \
bash /tmp/install-tools.sh
RUN --mount=type=cache,target=/root/.cache/pip \
--mount=type=bind,source=scripts/install-python-requirements.sh,target=/tmp/install-python-requirements.sh \
bash /tmp/install-python-requirements.sh
RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=bind,source=scripts/install-3rdparty.sh,target=/tmp/install-3rdparty.sh \
bash /tmp/install-3rdparty.sh
# Install unitree_ros2
RUN --mount=type=cache,target=/var/cache/apt \ RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=bind,source=scripts/install-unitree-ros2.sh,target=/tmp/install-unitree-ros2.sh \ --mount=type=bind,source=scripts/install-unitree-ros2.sh,target=/tmp/install-unitree-ros2.sh \
bash /tmp/install-unitree-ros2.sh bash /tmp/install-unitree-ros2.sh
RUN apt install -y ros-humble-isaac-ros-h264-decoder ros-humble-isaac-ros-h264-encoder RUN apt install -y ros-humble-isaac-ros-h264-decoder ros-humble-isaac-ros-h264-encoder
USER $USERNAME RUN mkdir -p /realsense-ws/src && cd /realsense-ws/src && git clone https://github.com/IntelRealSense/realsense-ros.git && cd .. && source /opt/ros/humble/setup.bash && colcon build
USER $USERNAME

View File

@ -11,25 +11,39 @@
ARG BASE_IMAGE ARG BASE_IMAGE
FROM ${BASE_IMAGE} FROM ${BASE_IMAGE}
ARG LIBREALSENSE_SOURCE_VERSION=v2.55.1
ARG LIBREALSENSE_DEB_VERSION=2.55.1-0~realsense.12474
ARG LIBREALSENSE_DKMS_DEB_VERSION=1.3.26-0ubuntu1
ARG REALSENSE2_CAMERA_ROS_DEB_VERSION=4.54.1-1jammy.20240517.191635
# Install realsense2-camera ROS package and librealsense from binaries for x86_64 only
RUN --mount=type=cache,target=/var/cache/apt \
if [[ "$(uname -m)" == "x86_64" ]]; then \
mkdir -p /etc/apt/keyrings && \
curl -sSf https://librealsense.intel.com/Debian/librealsense.pgp | \
tee /etc/apt/keyrings/librealsense.pgp > /dev/null && \
echo "deb [signed-by=/etc/apt/keyrings/librealsense.pgp] \
https://librealsense.intel.com/Debian/apt-repo `lsb_release -cs` main" | \
tee /etc/apt/sources.list.d/librealsense.list && apt-get update && \
apt-get install -y \
librealsense2-dkms=${LIBREALSENSE_DKMS_DEB_VERSION} \
librealsense2-utils=${LIBREALSENSE_DEB_VERSION} \
librealsense2-dev=${LIBREALSENSE_DEB_VERSION} \
ros-humble-realsense2-camera=${REALSENSE2_CAMERA_ROS_DEB_VERSION}; \
fi
COPY scripts/build-librealsense.sh /opt/realsense/build-librealsense.sh COPY scripts/build-librealsense.sh /opt/realsense/build-librealsense.sh
COPY scripts/install-realsense-dependencies.sh /opt/realsense/install-realsense-dependencies.sh COPY scripts/install-realsense-dependencies.sh /opt/realsense/install-realsense-dependencies.sh
RUN chmod +x /opt/realsense/install-realsense-dependencies.sh && /opt/realsense/install-realsense-dependencies.sh # Build librealsense from source for aarch64 only
RUN chmod +x /opt/realsense/build-librealsense.sh && /opt/realsense/build-librealsense.sh # The realsense2-camera ROS package will be built from source as part of the "RealSense Setup docs" for aarch64 only
RUN if [[ $(uname -m) == "aarch64" ]]; then \
chmod +x /opt/realsense/install-realsense-dependencies.sh && \
/opt/realsense/install-realsense-dependencies.sh; \
chmod +x /opt/realsense/build-librealsense.sh && /opt/realsense/build-librealsense.sh -v ${LIBREALSENSE_SOURCE_VERSION}; \
fi
# Copy hotplug script which will get invoked whenever a devices plugged or un-plugged # Copy hotplug script for udev rules/hotplug for RealSense
RUN mkdir -p /opt/realsense/ RUN mkdir -p /opt/realsense/
COPY scripts/hotplug-realsense.sh /opt/realsense/hotplug-realsense.sh COPY scripts/hotplug-realsense.sh /opt/realsense/hotplug-realsense.sh
# Copy custom udev rules file
COPY udev_rules/99-realsense-libusb-custom.rules /etc/udev/rules.d/99-realsense-libusb-custom.rules COPY udev_rules/99-realsense-libusb-custom.rules /etc/udev/rules.d/99-realsense-libusb-custom.rules
# Clone and compile the realsense ros
RUN mkdir -p /home/realsenes-ws/src && cd /home/realsenes-ws/src && \
git clone https://github.com/IntelRealSense/realsense-ros.git && \
cd .. && \
source /opt/ros/humble/setup.bash && \
colcon build --symlink-install
# add the source to the bashrc
RUN echo "source /home/realsenes-ws/install/setup.bash" >> /root/.bashrc

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. # Copyright (c) 2023-2024, NVIDIA CORPORATION. All rights reserved.
# #
# NVIDIA CORPORATION and its licensors retain all intellectual property # NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation # and proprietary rights in and to this software, related documentation
@ -9,14 +9,16 @@
ARG BASE_IMAGE ARG BASE_IMAGE
FROM $BASE_IMAGE FROM $BASE_IMAGE
# Store list of packages (must be first)
RUN mkdir -p /opt/nvidia/isaac_ros_dev_base && dpkg-query -W | sort > /opt/nvidia/isaac_ros_dev_base/ros2_humble-start-packages.csv
# disable terminal interaction for apt # disable terminal interaction for apt
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
ENV SHELL /bin/bash ENV SHELL /bin/bash
SHELL ["/bin/bash", "-c"] SHELL ["/bin/bash", "-c"]
# Env setup # Env setup
RUN locale-gen en_US en_US.UTF-8 RUN locale-gen en_US en_US.UTF-8 && update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
RUN update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
ENV LANG=en_US.UTF-8 ENV LANG=en_US.UTF-8
ENV ROS_PYTHON_VERSION=3 ENV ROS_PYTHON_VERSION=3
ENV ROS_DISTRO=humble ENV ROS_DISTRO=humble
@ -25,31 +27,23 @@ ENV RMW_IMPLEMENTATION=rmw_fastrtps_cpp
# Avoid setup.py and easy_install deprecation warnings caused by colcon and setuptools # Avoid setup.py and easy_install deprecation warnings caused by colcon and setuptools
# https://github.com/colcon/colcon-core/issues/454 # https://github.com/colcon/colcon-core/issues/454
ENV PYTHONWARNINGS=ignore:::setuptools.command.install,ignore:::setuptools.command.easy_install,ignore:::pkg_resources ENV PYTHONWARNINGS=ignore:::setuptools.command.install,ignore:::setuptools.command.easy_install,ignore:::pkg_resources,ignore:::setuptools.command.develop
RUN echo "Warning: Using the PYTHONWARNINGS environment variable to silence setup.py and easy_install deprecation warnings caused by colcon" RUN echo "Warning: Using the PYTHONWARNINGS environment variable to silence setup.py and easy_install deprecation warnings caused by colcon"
# Add ROS 2 apt repository # Add ROS 2 apt repository
RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg RUN --mount=type=cache,target=/var/cache/apt \
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2-testing/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null \
# Add Isaac apt repository && apt-get update
RUN wget -qO - https://isaac.download.nvidia.com/isaac-ros/repos.key | apt-key add - && \
grep -qxF 'deb https://isaac.download.nvidia.com/isaac-ros/ubuntu/main focal main' /etc/apt/sources.list || \
echo 'deb https://isaac.download.nvidia.com/isaac-ros/ubuntu/main focal main' | tee -a /etc/apt/sources.list
# Basics
RUN apt-get update && apt-get install -y \
curl \
gnupg \
lsb-release \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# ROS fundamentals # ROS fundamentals
RUN apt-get update && apt-get install -y \ RUN --mount=type=cache,target=/var/cache/apt \
build-essential \ apt-get update && apt-get install -y \
git \ devscripts \
libyaml-cpp-dev=0.7.0+dfsg-8backport \ dh-make \
fakeroot \
libxtensor-dev \
python3-bloom \
python3-colcon-common-extensions \ python3-colcon-common-extensions \
python3-pip \ python3-pip \
python3-pybind11 \ python3-pybind11 \
@ -57,9 +51,7 @@ RUN apt-get update && apt-get install -y \
python3-rosdep \ python3-rosdep \
python3-rosinstall-generator \ python3-rosinstall-generator \
python3-vcstool \ python3-vcstool \
wget \ quilt
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# ROS Python fundamentals # ROS Python fundamentals
RUN python3 -m pip install -U \ RUN python3 -m pip install -U \
@ -71,24 +63,16 @@ RUN python3 -m pip install -U \
flake8-docstrings \ flake8-docstrings \
flake8-import-order \ flake8-import-order \
flake8-quotes \ flake8-quotes \
pytest-repeat \ numpy>=1.24.4 \
pytest-rerunfailures \ matplotlib \
pytest \ pandas \
rosbags \
setuptools==65.7.0 setuptools==65.7.0
# Basics
RUN apt-get update && apt-get install -y \
curl \
gnupg \
locales \
lsb-release \
python3-bloom \
libxtensor-dev \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Install ROS 2 Humble # Install ROS 2 Humble
RUN apt-get update && apt-get install -y ros-humble-ros-base \ RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -y \
ros-humble-ros-base \
ros-humble-angles \ ros-humble-angles \
ros-humble-apriltag \ ros-humble-apriltag \
ros-humble-behaviortree-cpp-v3 \ ros-humble-behaviortree-cpp-v3 \
@ -100,6 +84,7 @@ RUN apt-get update && apt-get install -y ros-humble-ros-base \
ros-humble-cv-bridge \ ros-humble-cv-bridge \
ros-humble-demo-nodes-cpp \ ros-humble-demo-nodes-cpp \
ros-humble-demo-nodes-py \ ros-humble-demo-nodes-py \
ros-humble-diagnostic-aggregator \
ros-humble-diagnostic-updater \ ros-humble-diagnostic-updater \
ros-humble-example-interfaces \ ros-humble-example-interfaces \
ros-humble-foxglove-bridge \ ros-humble-foxglove-bridge \
@ -114,12 +99,22 @@ RUN apt-get update && apt-get install -y ros-humble-ros-base \
ros-humble-nav2-bringup \ ros-humble-nav2-bringup \
ros-humble-nav2-msgs \ ros-humble-nav2-msgs \
ros-humble-nav2-mppi-controller \ ros-humble-nav2-mppi-controller \
ros-humble-nav2-graceful-controller \
ros-humble-navigation2 \ ros-humble-navigation2 \
ros-humble-ompl \ ros-humble-ompl \
ros-humble-resource-retriever \ ros-humble-resource-retriever \
ros-humble-rmw-cyclonedds-cpp \
ros-humble-rmw-fastrtps-cpp \
ros-humble-rosbag2 \
ros-humble-rosbag2-compression-zstd \
ros-humble-rosbag2-cpp \
ros-humble-rosbag2-py \
ros-humble-rosbag2-storage-mcap \
ros-humble-rosbridge-suite \
ros-humble-rqt-graph \ ros-humble-rqt-graph \
ros-humble-rqt-reconfigure \
ros-humble-rqt-image-view \ ros-humble-rqt-image-view \
ros-humble-rqt-reconfigure \
ros-humble-rqt-robot-monitor \
ros-humble-rviz2 \ ros-humble-rviz2 \
ros-humble-rviz-common \ ros-humble-rviz-common \
ros-humble-rviz-default-plugins \ ros-humble-rviz-default-plugins \
@ -128,56 +123,32 @@ RUN apt-get update && apt-get install -y ros-humble-ros-base \
ros-humble-v4l2-camera \ ros-humble-v4l2-camera \
ros-humble-vision-opencv \ ros-humble-vision-opencv \
ros-humble-vision-msgs \ ros-humble-vision-msgs \
&& rm -rf /var/lib/apt/lists/* \ ros-humble-vision-msgs-rviz-plugins
&& apt-get clean
# Build Essentials
RUN apt-get update && apt-get install -y \
build-essential \
devscripts \
dh-make \
quilt \
fakeroot \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Setup rosdep # Setup rosdep
RUN rosdep init \ COPY rosdep/extra_rosdeps.yaml /etc/ros/rosdep/sources.list.d/nvidia-isaac.yaml
&& mkdir -p /etc/ros/rosdep/sources.list.d/ \ RUN --mount=type=cache,target=/var/cache/apt \
&& curl -o /etc/ros/rosdep/sources.list.d/nvidia-isaac.yaml https://isaac.download.nvidia.com/isaac-ros/extra_rosdeps.yaml \ rosdep init \
&& echo "yaml file:///etc/ros/rosdep/sources.list.d/nvidia-isaac.yaml" | tee /etc/ros/rosdep/sources.list.d/00-nvidia-isaac.list \ && echo "yaml file:///etc/ros/rosdep/sources.list.d/nvidia-isaac.yaml" | tee /etc/ros/rosdep/sources.list.d/00-nvidia-isaac.list \
&& rosdep update && rosdep update
####### -- Install updated packages over installed debians ####### -- Install updated packages over installed debians
# Install negotiated from source # Install negotiated from source
RUN apt-get update && mkdir -p ${ROS_ROOT}/src && cd ${ROS_ROOT}/src \ RUN --mount=type=cache,target=/var/cache/apt \
mkdir -p ${ROS_ROOT}/src && cd ${ROS_ROOT}/src \
&& git clone https://github.com/osrf/negotiated && cd negotiated && git checkout master \ && git clone https://github.com/osrf/negotiated && cd negotiated && git checkout master \
&& source ${ROS_ROOT}/setup.bash \ && source ${ROS_ROOT}/setup.bash \
&& cd negotiated_interfaces && bloom-generate rosdebian && fakeroot debian/rules binary \ && cd negotiated_interfaces && bloom-generate rosdebian && fakeroot debian/rules binary \
&& cd ../ && apt-get install -y ./*.deb && rm ./*.deb \ && cd ../ && apt-get install -y ./*.deb && rm ./*.deb \
&& cd negotiated && bloom-generate rosdebian && fakeroot debian/rules binary \ && cd negotiated && bloom-generate rosdebian && fakeroot debian/rules binary \
&& cd ../ && apt-get install -y ./*.deb && rm ./*.deb \ && cd ../ && apt-get install -y ./*.deb && rm ./*.deb
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Install vda5050_msgs from source
RUN apt-get update && mkdir -p ${ROS_ROOT}/src && cd ${ROS_ROOT}/src \
&& git clone https://github.com/ipa320/vda5050_msgs.git vda5050_root \
&& cd vda5050_root && git checkout ros2 && cd .. \
&& mv vda5050_root/vda5050_msgs/ vda5050_msgs \
&& rm -rf vda5050_root \
&& source ${ROS_ROOT}/setup.bash \
&& cd vda5050_msgs && bloom-generate rosdebian && fakeroot debian/rules binary \
&& cd ../ && apt-get install -y ./*.deb \
&& cd ../ && rm -Rf src build log \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Install image_proc from 55bf2a38 with backported resize node fix # Install image_proc from 55bf2a38 with backported resize node fix
# https://github.com/ros-perception/image_pipeline/pull/786/commits/969d6c763df99b42844742946f7a70c605a72a15 # https://github.com/ros-perception/image_pipeline/pull/786/commits/969d6c763df99b42844742946f7a70c605a72a15
# Revert breaking QoS changes in https://github.com/ros-perception/image_pipeline/pull/814 # Revert breaking QoS changes in https://github.com/ros-perception/image_pipeline/pull/814
RUN apt-get update && mkdir -p ${ROS_ROOT}/src && cd ${ROS_ROOT}/src \ RUN --mount=type=cache,target=/var/cache/apt \
mkdir -p ${ROS_ROOT}/src && cd ${ROS_ROOT}/src \
&& git clone https://github.com/ros-perception/image_pipeline.git && cd image_pipeline && git checkout 55bf2a38c327b829c3da444f963a6c66bfe0598f \ && git clone https://github.com/ros-perception/image_pipeline.git && cd image_pipeline && git checkout 55bf2a38c327b829c3da444f963a6c66bfe0598f \
&& git config user.email "builder@nvidia.com" && git config user.name "NVIDIA Builder" \ && git config user.email "builder@nvidia.com" && git config user.name "NVIDIA Builder" \
&& git remote add fork https://github.com/schornakj/image_pipeline.git && git fetch fork && git cherry-pick 969d6c763df99b42844742946f7a70c605a72a15 \ && git remote add fork https://github.com/schornakj/image_pipeline.git && git fetch fork && git cherry-pick 969d6c763df99b42844742946f7a70c605a72a15 \
@ -185,15 +156,14 @@ RUN apt-get update && mkdir -p ${ROS_ROOT}/src && cd ${ROS_ROOT}/src \
&& cd image_proc && bloom-generate rosdebian && fakeroot debian/rules binary \ && cd image_proc && bloom-generate rosdebian && fakeroot debian/rules binary \
&& cd ../ && apt-get install -y --allow-downgrades ./*.deb \ && cd ../ && apt-get install -y --allow-downgrades ./*.deb \
&& echo "image_pipeline (image_proc) https://github.com/ros-perception/image_pipeline/pull/786/commits/969d6c763df99b42844742946f7a70c605a72a15 on 55bf2a38" >> ${ROS_ROOT}/VERSION \ && echo "image_pipeline (image_proc) https://github.com/ros-perception/image_pipeline/pull/786/commits/969d6c763df99b42844742946f7a70c605a72a15 on 55bf2a38" >> ${ROS_ROOT}/VERSION \
&& cd ../ && rm -Rf src build log \ && cd ../ && rm -Rf src build log
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Install patched rclcpp package with backported multithreadedexecutor fix # Install patched rclcpp package with backported multithreadedexecutor fix
# https://github.com/ros2/rclcpp/commit/232262c02a1265830c7785b7547bd51e1124fcd8 # https://github.com/ros2/rclcpp/commit/232262c02a1265830c7785b7547bd51e1124fcd8
COPY patches/rclcpp-disable-tests.patch /tmp/ COPY patches/rclcpp-disable-tests.patch /tmp/
RUN apt-get update && mkdir -p ${ROS_ROOT}/src && cd ${ROS_ROOT}/src \ RUN --mount=type=cache,target=/var/cache/apt \
&& export RCLCPP_VERSION="release/humble/rclcpp/$(apt-cache madison ros-humble-rclcpp | grep -m1 -oP 'ros-humble-rclcpp \| \K[^f]+(?=focal)')" \ mkdir -p ${ROS_ROOT}/src && cd ${ROS_ROOT}/src \
&& export RCLCPP_VERSION="release/humble/rclcpp/$(apt-cache madison ros-humble-rclcpp | grep -m1 -oP 'ros-humble-rclcpp \| \K[^j]+(?=jammy)')" \
&& echo ${RCLCPP_VERSION} \ && echo ${RCLCPP_VERSION} \
&& git clone https://github.com/ros2-gbp/rclcpp-release.git && cd rclcpp-release && git checkout ${RCLCPP_VERSION} \ && git clone https://github.com/ros2-gbp/rclcpp-release.git && cd rclcpp-release && git checkout ${RCLCPP_VERSION} \
&& patch -i /tmp/rclcpp-disable-tests.patch \ && patch -i /tmp/rclcpp-disable-tests.patch \
@ -206,21 +176,107 @@ RUN apt-get update && mkdir -p ${ROS_ROOT}/src && cd ${ROS_ROOT}/src \
&& cd rclcpp-release && bloom-generate rosdebian && fakeroot debian/rules binary \ && cd rclcpp-release && bloom-generate rosdebian && fakeroot debian/rules binary \
&& cd ../ && apt-get install -y --allow-downgrades ./*.deb \ && cd ../ && apt-get install -y --allow-downgrades ./*.deb \
&& echo "rclcpp https://github.com/ros2/rclcpp/commit/232262c02a1265830c7785b7547bd51e1124fcd8" >> ${ROS_ROOT}/VERSION \ && echo "rclcpp https://github.com/ros2/rclcpp/commit/232262c02a1265830c7785b7547bd51e1124fcd8" >> ${ROS_ROOT}/VERSION \
&& cd ../ && rm -Rf src build log \ && cd ../ && rm -Rf src build log
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Install additional ROS packages # Install Moveit 2 ROS packages
RUN apt-get update && apt-get install -y \ RUN --mount=type=cache,target=/var/cache/apt \
ros-humble-camera-info-manager \ apt-get update && apt-get install -y \
ros-humble-rosbag2 \ ros-humble-ament-cmake \
ros-humble-rosbag2-compression-zstd \ ros-humble-ament-cmake-gtest \
ros-humble-rosbag2-cpp \ ros-humble-control-msgs \
ros-humble-rosbag2-py \ ros-humble-controller-manager \
ros-humble-rosbridge-suite \ ros-humble-geometric-shapes \
ros-humble-rqt-graph \ ros-humble-gripper-controllers \
ros-humble-rqt-reconfigure \ ros-humble-interactive-markers \
ros-humble-rviz-common \ ros-humble-joint-state-broadcaster \
ros-humble-rviz-default-plugins \ ros-humble-joint-state-publisher \
&& rm -rf /var/lib/apt/lists/* \ ros-humble-joint-trajectory-controller \
&& apt-get clean ros-humble-joy \
ros-humble-launch-param-builder \
ros-humble-moveit \
ros-humble-moveit-common \
ros-humble-moveit-configs-utils \
ros-humble-moveit-core \
ros-humble-moveit-msgs \
ros-humble-moveit-ros-perception \
ros-humble-moveit-ros-planning \
ros-humble-moveit-ros-planning-interface \
ros-humble-moveit-servo \
ros-humble-moveit-visual-tools \
ros-humble-pluginlib \
ros-humble-robot-state-publisher \
ros-humble-ros2-control \
ros-humble-rviz-visual-tools \
ros-humble-rviz2 \
ros-humble-srdfdom \
ros-humble-tf2-eigen \
ros-humble-tf2-geometry-msgs \
ros-humble-tf2-ros \
ros-humble-topic-based-ros2-control \
ros-humble-ur-description \
ros-humble-ur-moveit-config \
ros-humble-ur-msgs \
ros-humble-xacro
# Install various moveit_resources packages from source.
RUN --mount=type=cache,target=/var/cache/apt \
mkdir -p ${ROS_ROOT}/src && cd ${ROS_ROOT}/src \
&& git clone https://github.com/ros-planning/moveit_resources.git -b humble \
&& cd moveit_resources && source ${ROS_ROOT}/setup.bash \
&& cd fanuc_description && bloom-generate rosdebian && fakeroot debian/rules binary \
&& cd .. && apt-get install -y ./*.deb && rm *.deb \
&& cd fanuc_moveit_config && bloom-generate rosdebian && fakeroot debian/rules binary \
&& cd .. && apt-get install -y ./*.deb && rm *.deb \
&& cd panda_description && bloom-generate rosdebian && fakeroot debian/rules binary \
&& cd .. && apt-get install -y ./*.deb && rm *.deb \
&& cd panda_moveit_config && bloom-generate rosdebian && fakeroot debian/rules binary \
&& cd .. && apt-get install -y ./*.deb && rm *.deb \
&& cd pr2_description && bloom-generate rosdebian && fakeroot debian/rules binary \
&& cd .. && apt-get install -y ./*.deb && rm *.deb \
&& cd moveit_resources && bloom-generate rosdebian && fakeroot debian/rules binary \
&& cd .. && apt-get install -y ./*.deb && rm *.deb
# Install MoveIt task constructor from source. The "demo" package depends on moveit_resources_panda_moveit_config,
# installed from source above.
RUN --mount=type=cache,target=/var/cache/apt \
mkdir -p ${ROS_ROOT}/src && cd ${ROS_ROOT}/src \
&& git clone https://github.com/ros-planning/moveit_task_constructor.git -b humble \
&& cd moveit_task_constructor && source ${ROS_ROOT}/setup.bash \
&& cd msgs && bloom-generate rosdebian && fakeroot debian/rules binary \
&& cd ../ && apt-get install -y ./*.deb && rm ./*.deb \
&& cd rviz_marker_tools && bloom-generate rosdebian && fakeroot debian/rules binary \
&& cd ../ && apt-get install -y ./*.deb && rm ./*.deb \
&& cd core && bloom-generate rosdebian && fakeroot debian/rules binary DEB_BUILD_OPTIONS=nocheck \
&& cd ../ && apt-get install -y ./*.deb && rm ./*.deb \
&& cd capabilities && bloom-generate rosdebian && fakeroot debian/rules binary DEB_BUILD_OPTIONS=nocheck \
&& cd ../ && apt-get install -y ./*.deb && rm ./*.deb \
&& cd visualization && bloom-generate rosdebian && fakeroot debian/rules binary DEB_BUILD_OPTIONS=nocheck \
&& cd ../ && apt-get install -y ./*.deb && rm ./*.deb \
&& cd demo && bloom-generate rosdebian && fakeroot debian/rules binary DEB_BUILD_OPTIONS=nocheck \
&& cd ../ && apt-get install -y ./*.deb && rm ./*.deb
# MoveIt 2's hybrid planning package depends on moveit_resources_panda_moveit_config, installed from source above.
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -y \
ros-humble-moveit-hybrid-planning
# Install moveit2_tutorials from source (depends on moveit_hybrid_planning).
RUN --mount=type=cache,target=/var/cache/apt \
mkdir -p ${ROS_ROOT}/src && cd ${ROS_ROOT}/src \
&& git clone https://github.com/ros-planning/moveit2_tutorials.git -b humble \
&& cd moveit2_tutorials && source ${ROS_ROOT}/setup.bash \
&& bloom-generate rosdebian && fakeroot debian/rules binary \
&& cd ../ && apt-get install -y ./*.deb && rm ./*.deb
# Install paho-mqtt for isaac_ros_mission_client
RUN python3 -m pip install -U \
paho-mqtt==1.6.1
# Patch gtest to make it work with CXX 17
RUN sudo sed -i '917i #ifdef GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL' /usr/src/googletest/googletest/include/gtest/internal/gtest-internal.h \
&& sudo sed -i '920i #endif' /usr/src/googletest/googletest/include/gtest/internal/gtest-internal.h \
&& sudo sed -i '2392i #if defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \\\n GTEST_INTERNAL_CPLUSPLUS_LANG < 201703L\n#define GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL 1\n#endif' \
/usr/src/googletest/googletest/include/gtest/internal/gtest-port.h
# Store list of packages (must be last)
RUN mkdir -p /opt/nvidia/isaac_ros_dev_base && dpkg-query -W | sort > /opt/nvidia/isaac_ros_dev_base/ros2_humble-end-packages.csv

View File

@ -15,11 +15,10 @@ ARG USER_UID=1000
ARG USER_GID=1000 ARG USER_GID=1000
# Install prerequisites # Install prerequisites
RUN apt-get update && apt-get install -y \ RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -y \
sudo \ sudo \
udev \ udev
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Reuse triton-server user as 'admin' user if exists # Reuse triton-server user as 'admin' user if exists
RUN if [ $(getent group triton-server) ]; then \ RUN if [ $(getent group triton-server) ]; then \
@ -27,12 +26,14 @@ RUN if [ $(getent group triton-server) ]; then \
usermod -l ${USERNAME} -u ${USER_UID} -m -d /home/${USERNAME} triton-server ; \ usermod -l ${USERNAME} -u ${USER_UID} -m -d /home/${USERNAME} triton-server ; \
mkdir -p /home/${USERNAME} ; \ mkdir -p /home/${USERNAME} ; \
sudo chown ${USERNAME}:${USERNAME} /home/${USERNAME} ; \ sudo chown ${USERNAME}:${USERNAME} /home/${USERNAME} ; \
# Wipe files that may create issues for users with large uid numbers.
rm -f /var/log/lastlog /var/log/faillog ; \
fi fi
# Create the 'admin' user if not already exists # Create the 'admin' user if not already exists
RUN if [ ! $(getent passwd ${USERNAME}) ]; then \ RUN if [ ! $(getent passwd ${USERNAME}) ]; then \
groupadd --gid ${USER_GID} ${USERNAME} ; \ groupadd --gid ${USER_GID} ${USERNAME} ; \
useradd --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME} ; \ useradd --no-log-init --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME} ; \
fi fi
# Update 'admin' user # Update 'admin' user
@ -52,3 +53,9 @@ COPY middleware_profiles/*profile.xml /usr/local/share/middleware_profiles/
ENV USERNAME=${USERNAME} ENV USERNAME=${USERNAME}
ENV USER_GID=${USER_GID} ENV USER_GID=${USER_GID}
ENV USER_UID=${USER_UID} ENV USER_UID=${USER_UID}
# Switch to non-root user and return to root
USER ${USERNAME}
RUN --mount=type=cache,target=/var/cache/apt \
rosdep update
USER root

View File

@ -1,65 +0,0 @@
FROM nvidia/cuda:12.1.1-devel-ubuntu22.04
SHELL ["/bin/bash", "-c"]
# Install dependencies
RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=bind,source=docker/scripts/install-tools.sh,target=/tmp/install-tools.sh \
bash /tmp/install-tools.sh
RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=bind,source=docker/scripts/install-ros2.sh,target=/tmp/install-ros2.sh \
bash /tmp/install-ros2.sh
RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=bind,source=docker/scripts/install-clang.sh,target=/tmp/install-clang.sh \
bash /tmp/install-clang.sh
RUN --mount=type=cache,target=/root/.cache/pip \
--mount=type=bind,source=docker/scripts/install-python-requirements.sh,target=/tmp/install-python-requirements.sh \
bash /tmp/install-python-requirements.sh
RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=bind,source=docker/scripts/install-3rdparty.sh,target=/tmp/install-3rdparty.sh \
bash /tmp/install-3rdparty.sh
# Last installation layer as we update ROS dependencies often
RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=bind,source=.,target=/tmp/ros_ws \
/tmp/ros_ws/docker/scripts/install-rosdep.sh
# Clean cache
RUN apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
ARG USERNAME=dev
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Create a workspace directory
RUN mkdir -p /workspace/go2-devcontainer/src/go2-devcontainer \
&& cd /workspace/go2-devcontainer \
&& chown -R $USERNAME:$USERNAME /workspace/go2-devcontainer/
RUN --mount=type=bind,source=docker/config/docker.bashrc,target=/tmp/docker.bashrc \
cat /tmp/docker.bashrc >> /home/$USERNAME/.bashrc
# Clone unitree_ros2
RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=bind,source=docker/scripts/install-unitree-ros2.sh,target=/tmp/install-unitree-ros2.sh \
bash /tmp/install-unitree-ros2.sh
# NVIDIA-related environment variables
ENV NVIDIA_VISIBLE_DEVICES \
${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES \
${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics
USER $USERNAME

View File

@ -1,4 +1,4 @@
# Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved. # Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.
# #
# NVIDIA CORPORATION and its licensors retain all intellectual property # NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation # and proprietary rights in and to this software, related documentation
@ -9,32 +9,34 @@
# Docker file to build on x86_64 # Docker file to build on x86_64
# https://docs.nvidia.com/deeplearning/frameworks/user-guide/index.html # https://docs.nvidia.com/deeplearning/frameworks/user-guide/index.html
# https://docs.nvidia.com/deeplearning/frameworks/support-matrix/index.html # https://docs.nvidia.com/deeplearning/frameworks/support-matrix/index.html
ARG BASE_IMAGE=nvcr.io/nvidia/tritonserver:22.09-py3 ARG BASE_IMAGE=nvcr.io/nvidia/tritonserver:23.10-py3
FROM ${BASE_IMAGE} FROM ${BASE_IMAGE}
# Store list of packages (must be first)
RUN mkdir -p /opt/nvidia/isaac_ros_dev_base && dpkg-query -W | sort > /opt/nvidia/isaac_ros_dev_base/x86_64-start-packages.csv
# disable terminal interaction for apt # disable terminal interaction for apt
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
ENV SHELL /bin/bash ENV SHELL /bin/bash
SHELL ["/bin/bash", "-c"] SHELL ["/bin/bash", "-c"]
# NVIDIA repository keys: https://developer.nvidia.com/blog/updating-the-cuda-linux-gpg-repository-key/ # Ensure we have universe
RUN apt-key del 7fa2af80 && mkdir -p /tmp && cd /tmp \ RUN --mount=type=cache,target=/var/cache/apt \
&& wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb \ apt-get update && apt-get install -y \
&& dpkg -i cuda-keyring_1.0-1_all.deb \ software-properties-common \
&& rm cuda-keyring_1.0-1_all.deb \ && add-apt-repository universe \
&& add-apt-repository --remove 'deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /' && apt-get update
# Add Isaac apt repository # Add Isaac apt repository
RUN wget -qO - https://isaac.download.nvidia.com/isaac-ros/repos.key | apt-key add - RUN --mount=type=cache,target=/var/cache/apt \
RUN echo 'deb https://isaac.download.nvidia.com/isaac-ros/ubuntu/main focal main' | tee -a /etc/apt/sources.list wget -qO - https://isaac.download.nvidia.com/isaac-ros/repos.key | apt-key add - && \
grep -qxF "deb https://isaac.download.nvidia.com/isaac-ros/release-3 $(lsb_release -cs) release-3.0" /etc/apt/sources.list || \
# Ensure we have universe echo "deb https://isaac.download.nvidia.com/isaac-ros/release-3 $(lsb_release -cs) release-3.0" | tee -a /etc/apt/sources.list \
RUN apt-get update \ && apt-get update
&& apt-get install -y software-properties-common \
&& add-apt-repository universe
# Fundamentals # Fundamentals
RUN apt-get update && apt-get install -y \ RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -y \
apt-transport-https \ apt-transport-https \
bash-completion \ bash-completion \
build-essential \ build-essential \
@ -43,6 +45,7 @@ RUN apt-get update && apt-get install -y \
cmake \ cmake \
curl \ curl \
git \ git \
git-lfs \
gnupg2 \ gnupg2 \
iputils-ping \ iputils-ping \
locales \ locales \
@ -53,41 +56,40 @@ RUN apt-get update && apt-get install -y \
vim \ vim \
unzip \ unzip \
mlocate \ mlocate \
libgoogle-glog-dev \ libgoogle-glog-dev
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean # Python basics
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -y \
python3-pip \
python3-pybind11 \
python3-pytest \
python3-pytest-repeat \
python3-pytest-rerunfailures \
python3-pytest-cov
# Set Python3 as default # Set Python3 as default
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1 RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
# Python basics
RUN apt-get update && apt-get install -y \
python3-pip \
python3-pybind11 \
python3-pytest-cov \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Video utilities
RUN apt-get update && apt-get install -y \
v4l-utils \
mesa-utils \
libcanberra-gtk-module \
libcanberra-gtk3-module \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Core dev libraries # Core dev libraries
RUN apt-get update && apt-get install -y \ RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -y \
ffmpeg \
libasio-dev \ libasio-dev \
libbullet-dev \ libbullet-dev \
libtinyxml2-dev \ libtinyxml2-dev \
libcunit1-dev \ libcunit1-dev \
libmnl0 \
libmnl-dev \
libv4l-dev \
libyaml-cpp-dev \ libyaml-cpp-dev \
libopencv-dev \ libopencv-dev \
libpython3.10 \
libx264-dev \
kmod \
patchelf \
python3-opencv \ python3-opencv \
&& rm -rf /var/lib/apt/lists/* \ nlohmann-json3-dev
&& apt-get clean
# Python3 (PIP) # Python3 (PIP)
RUN python3 -m pip install -U \ RUN python3 -m pip install -U \
@ -103,117 +105,71 @@ RUN python3 -m pip install -U \
flake8-import-order \ flake8-import-order \
flake8-quotes \ flake8-quotes \
onnx \ onnx \
pytest-repeat \
pytest-rerunfailures \
pytest \
pydocstyle \ pydocstyle \
scikit-learn scikit-learn \
ninja \
networkx \
numpy \
numpy-quaternion \
pyyaml \
setuptools_scm>=6.2 \
trimesh \
yourdfpy>=0.0.53 \
warp-lang>=0.9.0 \
scipy>=1.7.0 \
tqdm \
importlib_resources
# Install Git-LFS # Install nvv4l2 for GXF Multimedia h264 codec
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash && \ RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -y \ apt-get update && apt-get install -y \
git-lfs \ nvv4l2 \
&& rm -rf /var/lib/apt/lists/* \ && ln -s /usr/lib/x86_64-linux-gnu/libnvcuvid.so.1 /usr/lib/x86_64-linux-gnu/libnvcuvid.so \
&& apt-get clean && ln -s /usr/lib/x86_64-linux-gnu/libnvidia-encode.so.1 /usr/lib/x86_64-linux-gnu/libnvidia-encode.so
# Upgrade cmake to 3.22.1 to match Ubuntu 22.04 # Install VPI packages
# Key rotation 2024-01-10 ARG HAS_GPU="true"
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null \ RUN --mount=type=cache,target=/var/cache/apt \
&& echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ focal main' | tee /etc/apt/sources.list.d/kitware.list >/dev/null \ if [ "$HAS_GPU" = "true" ]; then \
&& apt-get update \ set -e ; \
&& apt-get remove -y cmake && apt-get purge -y cmake && apt-get remove -y cmake-data && apt-get purge -y cmake-data \ apt-key adv --fetch-key https://repo.download.nvidia.com/jetson/jetson-ota-public.asc ; \
&& apt-get install -y cmake=3.22.1-0kitware1ubuntu20.04.1 cmake-data=3.22.1-0kitware1ubuntu20.04.1 \ add-apt-repository "deb http://repo.download.nvidia.com/jetson/x86_64/$(lsb_release -cs) r36.3 main" ; \
&& cmake --version \ apt-get update ; \
&& rm -rf /var/lib/apt/lists/* \ apt-get install libnvvpi3 vpi3-dev ; \
&& apt-get clean fi
# Pytorch # Pytorch
RUN python3 -m pip install -U --extra-index-url https://download.pytorch.org/whl/cu113 \ RUN python3 -m pip install -U --extra-index-url https://download.pytorch.org/whl/cu121 \
torch \ torch \
torchvision \ torchvision \
torchaudio torchaudio
# Install VPI packages
ARG HAS_GPU="true"
RUN if [ "$HAS_GPU" = "true" ]; then \
set -e ; \
apt-key adv --fetch-key https://repo.download.nvidia.com/jetson/jetson-ota-public.asc ; \
add-apt-repository 'deb http://repo.download.nvidia.com/jetson/x86_64/focal r35.4 main' ; \
apt-get update ; \
apt-get install libnvvpi2 vpi2-dev ; \
rm -rf /var/lib/apt/lists/* ; \
apt-get clean ; \
fi
# Install Tao converter # Install Tao converter
RUN mkdir -p /opt/nvidia/tao && \ RUN mkdir -p /opt/nvidia/tao && cd /opt/nvidia/tao && \
cd /opt/nvidia/tao && \ wget --content-disposition 'https://api.ngc.nvidia.com/v2/resources/org/nvidia/team/tao/tao-converter/v5.1.0_8.6.3.1_x86/files?redirect=true&path=tao-converter' -O tao-converter && \
wget https://developer.nvidia.com/tao-converter-80 && \ chmod 755 tao-converter
unzip tao-converter-80 && \
chmod 755 $(find /opt/nvidia/tao -name "tao-converter") && \
ln -sf $(find /opt/nvidia/tao -name "tao-converter") /opt/nvidia/tao/tao-converter && \
rm tao-converter-80
ENV PATH="${PATH}:/opt/nvidia/tao" ENV PATH="${PATH}:/opt/nvidia/tao"
ENV TRT_LIB_PATH="/usr/lib/x86_64-linux-gnu"
ENV TRT_INC_PATH="/usr/include/x86_64-linux-gnu"
# Update environment # Update environment
ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/opt/tritonserver/lib" ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/opt/tritonserver/lib"
# Install CV-CUDA
RUN --mount=type=cache,target=/var/cache/apt \
cd /tmp && \
wget https://github.com/CVCUDA/CV-CUDA/releases/download/v0.5.0-beta/nvcv-lib-0.5.0_beta-cuda12-x86_64-linux.deb && \
dpkg -i nvcv-lib-0.5.0_beta-cuda12-x86_64-linux.deb && \
wget https://github.com/CVCUDA/CV-CUDA/releases/download/v0.5.0-beta/nvcv-dev-0.5.0_beta-cuda12-x86_64-linux.deb && \
dpkg -i nvcv-dev-0.5.0_beta-cuda12-x86_64-linux.deb
# Add MQTT binaries and libraries # Add MQTT binaries and libraries
RUN apt-add-repository ppa:mosquitto-dev/mosquitto-ppa \ RUN --mount=type=cache,target=/var/cache/apt \
&& apt-get update \ apt-add-repository ppa:mosquitto-dev/mosquitto-ppa \
&& apt-get install -y mosquitto mosquitto-clients \ && apt-get update && apt-get install -y \
&& rm -rf /var/lib/apt/lists/* \ mosquitto \
&& apt-get clean mosquitto-clients
RUN python3 -m pip install -U \ # Store list of packages (must be last)
paho-mqtt RUN mkdir -p /opt/nvidia/isaac_ros_dev_base && dpkg-query -W | sort > /opt/nvidia/isaac_ros_dev_base/x86_64-end-packages.csv
# Compression dependencies
RUN apt-get update && apt-get install -y \
libv4l-dev \
kmod \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Install NVIDIA v4l2 extensions for h264 support
RUN apt-get update && apt-get install -y nvv4l2
# Upgrade libc to resolve vulnerabilities including CVE-2019-11477
RUN apt-get update && apt-get install -y --only-upgrade \
linux-libc-dev \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Downgrade protobuf
RUN python3 -m pip install \
protobuf==3.20.1
# GPU usage monitoring on x86
RUN python3 -m pip install \
gpustat==0.6.0
# Python3 (PIP)
RUN python3 -m pip install -U \
mailcap-fix
# Resolve vulnerability in mailcap.py by removing it (CVE-2015-20107)
RUN rm -f /opt/tritonserver/backends/dali/conda/envs/dalienv/lib/python3.8/mailcap.py
# Remove any platform entangling dependencies
RUN touch \
/usr/lib/x86_64-linux-gnu/libcuda.so \
/usr/lib/x86_64-linux-gnu/libnvcuvid.so \
/usr/lib/x86_64-linux-gnu/libnvidia.so \
/usr/lib/firmware \
/usr/local/cuda/compat/lib || true
RUN rm -rf \
/usr/lib/x86_64-linux-gnu/libcuda.so* \
/usr/lib/x86_64-linux-gnu/libnvcuvid.so* \
/usr/lib/x86_64-linux-gnu/libnvidia-*.so* \
/usr/lib/firmware \
/usr/local/cuda/compat/lib || true
# Restore symlink for nvencode
RUN ln -f -s /usr/lib/x86_64-linux-gnu/libnvidia-encode.so.1 /usr/lib/x86_64-linux-gnu/libnvidia-encode.so

View File

@ -1,9 +0,0 @@
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
FROM nvcr.io/nvidia/isaac/ros:x86_64-ros2_humble_bcf535ea3b9d16a854aaeb1701ab5a86

View File

@ -1,44 +0,0 @@
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
ARG BASE_IMAGE
FROM ${BASE_IMAGE}
ARG ZED_SDK_MAJOR=4
ARG ZED_SDK_MINOR=0
# zed-ros2-wrapper dependencies
RUN apt-get update && apt-get install -y \
libgeographic-dev \
ros-humble-geographic-info \
ros-humble-nmea-msgs \
ros-humble-robot-localization \
ros-humble-xacro \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
RUN mkdir -p /opt/zed/
# The zed installation script expects to be run as non-root user and needs the USER ENV variable to be set
ENV USER=${USERNAME}
USER ${USERNAME}
COPY scripts/install-zed-x86_64.sh /opt/zed/install-zed-x86_64.sh
COPY scripts/install-zed-aarch64.sh /opt/zed/install-zed-aarch64.sh
RUN sudo chmod +x /opt/zed/install-zed-x86_64.sh
RUN sudo chmod +x /opt/zed/install-zed-aarch64.sh
RUN if [ "$(uname -m)" = "x86_64" ]; then \
/opt/zed/install-zed-x86_64.sh; \
else \
/opt/zed/install-zed-aarch64.sh; \
fi
# Revert to root user
USER root

View File

@ -1,149 +0,0 @@
##############################################
## Bash Script
##############################################
PROMPT_COMMAND='history -a'
HISTFILE=/home/dev/.bash_history
LOG_WORKSPACE=/workspace/logging
ROS_WORKSPACE=/workspace/go2-devcontainer
export CC=clang
export CXX=clang++
export MAKEFLAGS="-j 8"
export RCUTILS_COLORIZED_OUTPUT=1
export ROS_LOG_DIR=/workspace/logging/logs
export ROS_DATA_DIR=/workspace/logging/data
export ROS_BAG_MAX_SIZE=1073741824
export RCUTILS_CONSOLE_OUTPUT_FORMAT="[{severity}] [{time}] [{name}:{line_number}]: {message}"
# unitree_ros2
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
export CYCLONEDDS_URI='<CycloneDDS><Domain><General><Interfaces>
<NetworkInterface name="enp118s0" priority="default" multicast="default" />
</Interfaces></General></Domain></CycloneDDS>'
# https://github.com/ament/ament_cmake/issues/382
PYTHONWARNINGS="ignore:easy_install command is deprecated,ignore:setup.py install is deprecated"
export PYTHONWARNINGS
echo '/workspace/logging/coredump/core.%e.%p.%h.%t' | sudo tee /proc/sys/kernel/core_pattern >/dev/null
_show_workspace_logging_usage() {
# For each dir under logging workspace, show disk usages.
echo "==================================================="
echo "Disk usage for each directory under $LOG_WORKSPACE:"
for dir in $(find $LOG_WORKSPACE -maxdepth 1 -mindepth 1 -type d); do
du -sh $dir
done
echo "Make sure to clean up old logs to save disk space."
echo "==================================================="
}
_update_dependencies() {
source /opt/ros/humble/setup.bash
sudo apt-get update
cd $ROS_WORKSPACE \
&& rosdep update \
&& rosdep install --from-paths src --ignore-src -y
}
_ensure_not_in_workspace_src() {
# If current dir ends with "src", prompt user to switch to workspace dir.
# colcon build will stupidly build inside src folder.
if [[ "$(basename "$(pwd)")" == "src" ]]; then
echo "It looks like you're in a 'src' directory. Please switch to ${ROS_WORKSPACE}."
return 1
fi
return 0
}
COMMON_CMAKE_ARGS="\
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-GNinja \
-DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld \
-DCMAKE_MODULE_LINKER_FLAGS=-fuse-ld=lld \
-DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld
"
COMMON_COLCON_ARGS="--symlink-install --event-handlers console_cohesion+"
RELEASE_CMAKE_ARGS="$COMMON_CMAKE_ARGS -DCMAKE_BUILD_TYPE=RelWithDebInfo"
DEBUG_CMAKE_ARGS="$COMMON_CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug"
_colcon_release_build() {
_ensure_not_in_workspace_src || return 1
# Run 'colcon build' with passed arguments
colcon build \
${COMMON_COLCON_ARGS} \
--cmake-args $RELEASE_CMAKE_ARGS \
"$@"
}
_colcon_debug_build() {
_ensure_not_in_workspace_src || return 1
# Run 'colcon build' with passed arguments
colcon build \
${COMMON_COLCON_ARGS} \
--cmake-args $DEBUG_CMAKE_ARGS \
"$@"
}
_colcon_test() {
_ensure_not_in_workspace_src || return 1
# Run 'colcon test' with passed arguments
colcon test --event-handlers console_cohesion+ "$@"
}
_remove_directories() {
if [ -d "build" ]; then
rm -r build
fi
if [ -d "install" ]; then
rm -r install
fi
if [ -d "log" ]; then
rm -r log
fi
}
colcon_clean() {
_ensure_not_in_workspace_src || return 1
if [ -d "build" ] || [ -d "install" ] || [ -d "log" ]; then
while true; do
read -p "Do you wish to remove build, install, and log directories? [y/n] " yn
case $yn in
[Yy]* ) _remove_directories; break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
fi
}
# Colcon build aliases
alias update_dep=_update_dependencies
alias source_ws='source install/setup.bash'
alias colcon_build='_colcon_release_build'
alias colcon_debug_build='_colcon_debug_build'
alias colcon_build_package='_colcon_release_build --packages-select'
alias colcon_debug_build_package='_colcon_debug_build --packages-select'
alias colcon_build_up_to='_colcon_release_build --packages-up-to'
alias colcon_debug_build_up_to='_colcon_debug_build --packages-up-to'
alias colcon_test='_colcon_test'
alias colcon_test_package='_colcon_test --packages-select'
alias colcon_test_up_to='_colcon_test --packages-up-to'
source /opt/ros/humble/setup.bash
# Source ROS workspace if it exists
if [ -f "/workspace/go2-devcontainer/install/setup.bash" ]; then
source /workspace/go2-devcontainer/install/setup.bash
fi
# colcon_cd
source /usr/share/colcon_cd/function/colcon_cd.sh
export _colcon_cd_root=/opt/ros/humble/
_show_workspace_logging_usage

View File

@ -1,28 +0,0 @@
"""
SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
--- usr/local/cuda-11.4/targets/aarch64-linux/include/cuda/std/detail/libcxx/include/cmath 2022-11-09 12:28:48.381859565 -0800
+++ usr/local/cuda-11.4/targets/aarch64-linux/include/cuda/std/detail/libcxx/include/cmath 2022-11-09 12:28:58.021653123 -0800
@@ -565,7 +565,7 @@
using ::truncl;
#endif
-#if _LIBCUDACXX_STD_VER > 14 && (defined(_LIBCUDACXX_NO_HOST_CPP17_HYPOT) || !defined(_LIBCUDACXX_COMPILER_NVCC))
+#if _LIBCUDACXX_STD_VER > 14 && !defined(__cuda_std__)
inline _LIBCUDACXX_INLINE_VISIBILITY float hypot( float x, float y, float z ) { return sqrt(x*x + y*y + z*z); }
inline _LIBCUDACXX_INLINE_VISIBILITY double hypot( double x, double y, double z ) { return sqrt(x*x + y*y + z*z); }
#ifdef _LIBCUDACXX_HAS_COMPLEX_LONG_DOUBLE

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
set -e set -e
apt-get install -y ros-humble-rmw-cyclonedds-cpp ros-humble-rosidl-generator-dds-idl apt-get install -y ros-humble-rmw-cyclonedds-cpp ros-humble-rosidl-generator-dds-idl
cd /workspace cd ~
git clone https://github.com/unitreerobotics/unitree_ros2 git clone https://github.com/unitreerobotics/unitree_ros2
cd unitree_ros2/cyclonedds_ws/src cd unitree_ros2/cyclonedds_ws/src
git clone https://github.com/ros2/rmw_cyclonedds -b humble git clone https://github.com/ros2/rmw_cyclonedds -b humble
@ -11,4 +11,4 @@ git clone https://github.com/eclipse-cyclonedds/cyclonedds -b releases/0.10.x
cd .. cd ..
colcon build --packages-select cyclonedds colcon build --packages-select cyclonedds
source /opt/ros/humble/setup.bash source /opt/ros/humble/setup.bash
colcon build colcon build

View File

@ -14,6 +14,10 @@ export CUDA_MINOR="$(nvcc --version | grep -o -P ' release .{0,4}' | cut -d. -f2
sudo apt-get update -y || true sudo apt-get update -y || true
sudo apt-get install --no-install-recommends lsb-release wget less udev sudo zstd build-essential cmake libpng-dev libgomp1 -y sudo apt-get install --no-install-recommends lsb-release wget less udev sudo zstd build-essential cmake libpng-dev libgomp1 -y
# TODO: Remove this when zed-ros2-wrapper has a compatible version with ZED_SDK 4.1 (which supports cuda 12.2).
CUDA_MAJOR=12
CUDA_MINOR=1
# Download zed SDK installation RUN file to /tmp directory # Download zed SDK installation RUN file to /tmp directory
cd /tmp cd /tmp
wget -q -O ZED_SDK_Linux_Ubuntu${UBUNTU_RELEASE_YEAR}.run https://download.stereolabs.com/zedsdk/${ZED_SDK_MAJOR}.${ZED_SDK_MINOR}/cu${CUDA_MAJOR}${CUDA_MINOR%.*}/ubuntu${UBUNTU_RELEASE_YEAR} wget -q -O ZED_SDK_Linux_Ubuntu${UBUNTU_RELEASE_YEAR}.run https://download.stereolabs.com/zedsdk/${ZED_SDK_MAJOR}.${ZED_SDK_MINOR}/cu${CUDA_MAJOR}${CUDA_MINOR%.*}/ubuntu${UBUNTU_RELEASE_YEAR}

View File

@ -12,13 +12,14 @@
echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> ~/.bashrc echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> ~/.bashrc
source /opt/ros/${ROS_DISTRO}/setup.bash source /opt/ros/${ROS_DISTRO}/setup.bash
sudo apt-get update
rosdep update
# Restart udev daemon # Restart udev daemon
sudo service udev restart sudo service udev restart
export CMAKE_PREFIX_PATH=/workspace/unitree_ros2/cyclonedds_ws/install/cyclonedds/
python3 -m pip install --upgrade pip cd ~
cd /workspaces/Go2Py/ && python3 -m pip install -e . source /realsense-ws/install/setup.bash
source /home/realsenes-ws/install/setup.bash #source $HOME/unitree_ros2/cyclonedds_ws/install/setup.bash
#export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
#export CYCLONEDDS_URI='<CycloneDDS><Domain><General><Interfaces>
# <NetworkInterface name="enp3s0" priority="default" multicast="default" />
# </Interfaces></General></Domain></CycloneDDS>'
$@ $@

View File

@ -1,2 +1,2 @@
CONFIG_IMAGE_KEY="ros2_humble.go2py.realsense" CONFIG_IMAGE_KEY="ros2_humble.realsense.go2py"
CONFIG_DOCKER_SEARCH_DIRS=(../docker) CONFIG_DOCKER_SEARCH_DIRS=(../docker)

View File

@ -1,4 +1,4 @@
#!/bin/bash -e #!/bin/bash
# #
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. # Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
# #
@ -7,196 +7,14 @@
# and any modifications thereto. Any use, reproduction, disclosure or # and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express # distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited. # license agreement from NVIDIA CORPORATION is strictly prohibited.
set -e
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $ROOT/utils/print_color.sh source $ROOT/utils/print_color.sh
DOCKER_DIR="${ROOT}/../docker"
function usage() { BUILDKIT_DISABLED_STR=""
print_info "Usage: build_base_image.sh" {target image, period delimited components, required} {target image name, optional} {disable_build boolean, optional} if [[ ! -z "$5" ]]; then
print_info "Copyright (c) 2022, NVIDIA CORPORATION." BUILDKIT_DISABLED_STR="--disable_buildkit"
}
DOCKER_SEARCH_DIRS=(${DOCKER_DIR})
# Read and parse config file if exists
#
# CONFIG_DOCKER_SEARCH_DIRS (array, can be empty)
if [[ -f "${ROOT}/.isaac_ros_common-config" ]]; then
. "${ROOT}/.isaac_ros_common-config"
# Prepend configured docker search dirs
if [ ${#CONFIG_DOCKER_SEARCH_DIRS[@]} -gt 0 ]; then
for (( i=${#CONFIG_DOCKER_SEARCH_DIRS[@]}-1 ; i>=0 ; i-- )); do
# If the path is relative, then prefix ROOT to the path
if [[ "${CONFIG_DOCKER_SEARCH_DIRS[i]}" != /* ]]; then
CONFIG_DOCKER_SEARCH_DIRS[$i]="${ROOT}/${CONFIG_DOCKER_SEARCH_DIRS[i]}"
fi
done
CONFIG_DOCKER_SEARCH_DIRS+=(${DOCKER_SEARCH_DIRS[@]})
DOCKER_SEARCH_DIRS=(${CONFIG_DOCKER_SEARCH_DIRS[@]})
print_info "Using configured docker search paths: ${DOCKER_SEARCH_DIRS[*]}"
fi
fi fi
TARGET_IMAGE_STR="$1" $ROOT/build_image_layers.sh --image_key "$1" --image_name "$2" --base_image "$3" --context_dir "$4" $BUILDKIT_DISABLED_STR
if [[ -z "$TARGET_IMAGE_STR" ]]; then
print_error "target image not specified"
exit 1
fi
shift 1
TARGET_IMAGE_NAME="$1"
if [[ -z "$TARGET_IMAGE_NAME" ]]; then
TARGET_IMAGE_NAME="${TARGET_IMAGE_STR//./-}-image"
print_warning "Target image name not specified, using ${TARGET_IMAGE_NAME}"
fi
shift 1
BASE_IMAGE_NAME="$1"
if [[ -z "$BASE_IMAGE_NAME" ]]; then
print_warning "Using base image name not specified, using '${BASE_IMAGE_NAME}'"
fi
shift 1
DOCKER_CONTEXT_DIR="$1"
if [[ -z "$DOCKER_CONTEXT_DIR" ]]; then
print_warning "Using docker context dir not specified, using Dockerfile directory"
fi
shift 1
DOCKER_BUILDKIT=1
DISABLE_BUILDKIT_STR="$1"
if [[ ! -z "$DISABLE_BUILDKIT_STR" ]]; then
print_warning "WARNING: Explicitly disabling BuildKit"
DOCKER_BUILDKIT=0
fi
shift 1
ON_EXIT=()
function cleanup {
for command in "${ON_EXIT[@]}"
do
$command &>/dev/null
done
}
trap cleanup EXIT
PLATFORM="$(uname -m)"
# Resolve Dockerfiles by matching target image ids to available files
TARGET_IMAGE_IDS=(${TARGET_IMAGE_STR//./ })
IMAGE_IDS=(${TARGET_IMAGE_IDS[@]})
# Loop over components and find largest tail sequences
# For example, a target image id of 'aarch64.jp5.carter.nav' should match
# Dockerfiles with suffixes in the following order:
# ".aarch64.jp5.carter.nav", ".jp5.carter.nav", ".carter.nav", ".nav"
# If the first file found is ".carter.nav", the matching recurses by then
# looking for the preceding components ".aarch64.jp5" in the same manner
DOCKERFILES=()
DOCKERFILE_CONTEXT_DIRS=()
until [ ${#IMAGE_IDS[@]} -le 0 ]; do
UNMATCHED_ID_COUNT=${#IMAGE_IDS[@]}
for (( i=0; i<${#IMAGE_IDS[@]}; i++ )) do
LAYER_IMAGE_IDS=${IMAGE_IDS[@]:i}
LAYER_IMAGE_SUFFIX="${LAYER_IMAGE_IDS[@]// /.}"
for DOCKER_SEARCH_DIR in ${DOCKER_SEARCH_DIRS[@]}; do
DOCKERFILE="${DOCKER_SEARCH_DIR}/Dockerfile.${LAYER_IMAGE_SUFFIX}"
if [[ -f "${DOCKERFILE}" ]]; then
DOCKERFILES+=(${DOCKERFILE})
DOCKERFILE_CONTEXT_DIRS+=(${DOCKER_SEARCH_DIR})
IMAGE_IDS=(${IMAGE_IDS[@]:0:i})
break 2
fi
done
done
if [ ${UNMATCHED_ID_COUNT} -eq ${#IMAGE_IDS[@]} ]; then
UNMATCHED_IDS=${IMAGE_IDS[@]}
MATCHED_DOCKERFILES=${DOCKERFILES[@]}
print_error "Could not resolve Dockerfiles for target image ids: ${UNMATCHED_IDS// /.}"
if [ ${#DOCKERFILES[@]} -gt 0 ]; then
print_warning "Partially resolved the following Dockerfiles for target image: ${TARGET_IMAGE_STR}"
for DOCKERFILE in ${DOCKERFILES[@]}; do
print_warning "${DOCKERFILE}"
done
fi
exit 1
fi
done
# Arguments for docker build
BUILD_ARGS+=("--build-arg" "USERNAME="admin"")
BUILD_ARGS+=("--build-arg" "USER_UID=`id -u`")
BUILD_ARGS+=("--build-arg" "USER_GID=`id -g`")
BUILD_ARGS+=("--build-arg" "PLATFORM=$PLATFORM")
# Check if GPU is installed
if [[ $PLATFORM == "x86_64" ]]; then
if type nvidia-smi &>/dev/null; then
GPU_ATTACHED=(`nvidia-smi -a | grep "Attached GPUs"`)
if [ ! -z $GPU_ATTACHED ]; then
BUILD_ARGS+=("--build-arg" "HAS_GPU="true"")
fi
fi
fi
print_info "Resolved the following Dockerfiles for target image: ${TARGET_IMAGE_STR}"
for DOCKERFILE in ${DOCKERFILES[@]}; do
print_info "${DOCKERFILE}"
done
# Build image layers
for (( i=${#DOCKERFILES[@]}-1 ; i>=0 ; i-- )); do
DOCKERFILE=${DOCKERFILES[i]}
DOCKERFILE_CONTEXT_DIR=${DOCKERFILE_CONTEXT_DIRS[i]}
IMAGE_NAME=${DOCKERFILE#*"/Dockerfile."}
IMAGE_NAME="${IMAGE_NAME//./-}-image"
# Build the base images in layers first
BASE_IMAGE_ARG=
if [ $i -eq $(( ${#DOCKERFILES[@]} - 1 )) ]; then
if [[ ! -z "${BASE_IMAGE_NAME}" ]] ; then
BASE_IMAGE_ARG="--build-arg BASE_IMAGE="${BASE_IMAGE_NAME}""
fi
fi
if [ $i -lt $(( ${#DOCKERFILES[@]} - 1 )) ]; then
BASE_DOCKERFILE=${DOCKERFILES[i+1]}
BASE_IMAGE_NAME=${BASE_DOCKERFILE#*"/Dockerfile."}
BASE_IMAGE_NAME="${BASE_IMAGE_NAME//./-}-image"
BASE_IMAGE_ARG="--build-arg BASE_IMAGE="${BASE_IMAGE_NAME}""
fi
# The last image should be the target image name
# Use docker context dir script arg only for last image
DOCKER_CONTEXT_ARG=${DOCKERFILE_CONTEXT_DIR}
if [ $i -eq 0 ]; then
IMAGE_NAME=${TARGET_IMAGE_NAME}
if [[ ! -z "${DOCKER_CONTEXT_DIR}" ]]; then
DOCKER_CONTEXT_ARG=${DOCKER_CONTEXT_DIR}
fi
fi
print_warning "Building ${DOCKERFILE} as image: ${IMAGE_NAME} with base: ${BASE_IMAGE_NAME}"
DOCKER_BUILDKIT=${DOCKER_BUILDKIT} docker build -f ${DOCKERFILE} \
--network host \
-t ${IMAGE_NAME} \
${BASE_IMAGE_ARG} \
"${BUILD_ARGS[@]}" \
$@ \
${DOCKER_CONTEXT_ARG}
done

342
scripts/build_image_layers.sh Executable file
View File

@ -0,0 +1,342 @@
#!/bin/bash
#
# Copyright (c) 2022-2024, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
set -e
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $ROOT/utils/print_color.sh
DOCKER_DIR="${ROOT}/../docker"
function usage() {
print_info "Usage: ${0##*/}"
print_info "Copyright (c) 2024, NVIDIA CORPORATION."
}
# Initialize arguments
DOCKER_BUILDKIT=1
IGNORE_COMPOSITE_KEYS=0
ADDITIONAL_BUILD_ARGS=()
DOCKER_SEARCH_DIRS=(${DOCKER_DIR})
SKIP_REGISTRY_CHECK=0
BASE_DOCKER_REGISTRY_NAMES=("nvcr.io/isaac/ros")
# Read and parse config file if exists
#
# CONFIG_DOCKER_SEARCH_DIRS (array, can be empty)
if [[ -f "${ROOT}/.isaac_ros_common-config" ]]; then
. "${ROOT}/.isaac_ros_common-config"
fi
# Override with config from user home directory if exists
if [[ -f ~/.isaac_ros_common-config ]]; then
. ~/.isaac_ros_common-config
fi
# Prepend configured docker search dirs
if [ ${#CONFIG_DOCKER_SEARCH_DIRS[@]} -gt 0 ]; then
for (( i=${#CONFIG_DOCKER_SEARCH_DIRS[@]}-1 ; i>=0 ; i-- )); do
# If the path is relative, then prefix ROOT to the path
if [[ "${CONFIG_DOCKER_SEARCH_DIRS[i]}" != /* ]]; then
CONFIG_DOCKER_SEARCH_DIRS[$i]="${ROOT}/${CONFIG_DOCKER_SEARCH_DIRS[i]}"
fi
done
CONFIG_DOCKER_SEARCH_DIRS+=(${DOCKER_SEARCH_DIRS[@]})
DOCKER_SEARCH_DIRS=(${CONFIG_DOCKER_SEARCH_DIRS[@]})
fi
# Parse command-line args
VALID_ARGS=$(getopt -o hra:b:c:ki:n:u --long help,skip_registry_check,build_arg:,base_image:,context_dir:,disable_buildkit,image_key:,image_name:,ignore_composite_keys -- "$@")
eval set -- "$VALID_ARGS"
while [ : ]; do
case "$1" in
-a | --build_arg)
ADDITIONAL_BUILD_ARGS+=("$2")
shift 2
;;
-b | --base_image)
BASE_IMAGE_NAME="$2"
shift 2
;;
-c | --context_dir)
DOCKER_CONTEXT_DIR="$2"
shift 2
;;
-k | --disable_buildkit)
DOCKER_BUILDKIT=0
shift
;;
-i | --image_key)
TARGET_IMAGE_STR="$2"
shift 2
;;
-n | --image_name)
TARGET_IMAGE_NAME="$2"
shift 2
;;
-r | --skip_registry_check)
SKIP_REGISTRY_CHECK=1
shift
;;
-y | --ignore_composite_keys)
IGNORE_COMPOSITE_KEYS=1
shift
;;
-h | --help)
usage
exit 0
;;
--) shift;
break
;;
esac
done
# Check arguments
if [[ -z "$TARGET_IMAGE_STR" ]]; then
print_error "Target image not specified with -i/--image_key"
exit 1
fi
if [[ -z "$TARGET_IMAGE_NAME" ]]; then
TARGET_IMAGE_NAME="${TARGET_IMAGE_STR//./-}-image"
print_warning "Target image name not specified, using ${TARGET_IMAGE_NAME}"
fi
if [[ ! -z "$DOCKER_CONTEXT_DIR" ]]; then
DOCKER_SEARCH_DIRS+=($DOCKER_CONTEXT_DIR)
fi
# Summarize final arguments for script
print_info "Building layered image for key ${TARGET_IMAGE_STR} as ${TARGET_IMAGE_NAME}"
if [[ ! -z "${BASE_IMAGE_NAME}" ]]; then
print_info "Build image on top of base: |${BASE_IMAGE_NAME}|"
fi
print_info "Using configured docker search paths: ${DOCKER_SEARCH_DIRS[*]}"
if [[ ! -z "${DOCKER_CONTEXT_DIR}" ]]; then
print_info "Docker context directory for final layer: ${DOCKER_CONTEXT_DIR}"
fi
for BUILD_ARG in "${ADDITIONAL_BUILD_ARGS[@]}"
do
print_info "Additional build arg: ${BUILD_ARG}"
done
if [[ $DOCKER_BUILDKIT -eq 0 ]]; then
print_warning "WARNING: Explicitly disabling BuildKit"
fi
if [[ $IGNORE_COMPOSITE_KEYS -eq 1 ]]; then
print_warning "WARNING: Explicitly disabling matching composite image keys"
fi
if [[ $SKIP_REGISTRY_CHECK -eq 1 ]]; then
print_warning "WARNING: Skipping remote registry check for prebuilt images"
fi
# Setup on-exit cleanup
ON_EXIT=()
function cleanup {
for command in "${ON_EXIT[@]}"
do
$command &>/dev/null
done
}
trap cleanup EXIT
PLATFORM="$(uname -m)"
# Resolve Dockerfiles by matching target image ids to available files
TARGET_IMAGE_IDS=(${TARGET_IMAGE_STR//./ })
IMAGE_IDS=(${TARGET_IMAGE_IDS[@]})
# Loop over components and find largest tail sequences
# For example, a target image id of 'aarch64.jp5.carter.nav' should match
# Dockerfiles with suffixes in the following order:
# ".aarch64.jp5.carter.nav", ".jp5.carter.nav", ".carter.nav", ".nav"
# If the first file found is ".carter.nav", the matching recurses by then
# looking for the preceding components ".aarch64.jp5" in the same manner
DOCKERFILES=()
DOCKERFILE_CONTEXT_DIRS=()
until [ ${#IMAGE_IDS[@]} -le 0 ]; do
UNMATCHED_ID_COUNT=${#IMAGE_IDS[@]}
for (( i=0; i<${#IMAGE_IDS[@]}; i++ )) do
# Abort matching composite keys if disabled
if [[ $IGNORE_COMPOSITE_KEYS -gt 1 && $i -eq 1 ]]; then
break
fi
LAYER_IMAGE_IDS=${IMAGE_IDS[@]:i}
LAYER_IMAGE_SUFFIX="${LAYER_IMAGE_IDS[@]// /.}"
for DOCKER_SEARCH_DIR in ${DOCKER_SEARCH_DIRS[@]}; do
DOCKERFILE="${DOCKER_SEARCH_DIR}/Dockerfile.${LAYER_IMAGE_SUFFIX}"
if [[ -f "${DOCKERFILE}" ]]; then
DOCKERFILES+=(${DOCKERFILE})
DOCKERFILE_CONTEXT_DIRS+=(${DOCKER_SEARCH_DIR})
IMAGE_IDS=(${IMAGE_IDS[@]:0:i})
break 2
fi
done
done
if [ ${UNMATCHED_ID_COUNT} -eq ${#IMAGE_IDS[@]} ]; then
UNMATCHED_IDS=${IMAGE_IDS[@]}
MATCHED_DOCKERFILES=${DOCKERFILES[@]}
print_error "Could not resolve Dockerfiles for target image ids: ${UNMATCHED_IDS// /.}"
if [ ${#DOCKERFILES[@]} -gt 0 ]; then
print_warning "Partially resolved the following Dockerfiles for target image: ${TARGET_IMAGE_STR}"
for DOCKERFILE in ${DOCKERFILES[@]}; do
print_warning "${DOCKERFILE}"
done
fi
exit 1
fi
done
# Find pre-built image if available
if [[ $SKIP_REGISTRY_CHECK -eq 0 && -z "${BASE_IMAGE_NAME}" ]]; then
# Generate the possible base image names to look for from first image key onward
BASE_IMAGE_FULLNAMES=()
BASE_DOCKERFILES=()
BASE_DOCKERFILE_CONTEXT_DIRS=()
BASE_IMAGE_DOCKERFILES_INDICES=()
for (( i=${#DOCKERFILES[@]}-1 ; i>=0 ; i-- )); do
BASE_DOCKERFILES+=(${DOCKERFILES[i]})
BASE_DOCKERFILE_CONTEXT_DIRS+=(${DOCKERFILE_CONTEXT_DIRS[i]})
BASE_IMAGE_KEYS=()
DOCKER_HASH_FILE=$(mktemp)
ON_EXIT+=("rm -Rf ${DOCKER_HASH_FILE}")
# Determine hash of all Dockerfiles for this base image name
for (( j=0 ; j<${#BASE_DOCKERFILES[@]} ; j++ )); do
BASE_DOCKERFILE=${BASE_DOCKERFILES[j]}
BASE_DOCKERFILE_CONTEXT_DIR=${BASE_DOCKERFILE_CONTEXT_DIRS[j]}
LAYER_IMAGE_SUFFIX=${BASE_DOCKERFILE#*"/Dockerfile."}
BASE_IMAGE_KEYS+=(${LAYER_IMAGE_SUFFIX//./ })
pushd . >/dev/null
cd $BASE_DOCKERFILE_CONTEXT_DIR
BASE_DOCKERFILE="Dockerfile.${LAYER_IMAGE_SUFFIX}"
md5sum ${BASE_DOCKERFILE} >> $DOCKER_HASH_FILE
popd >/dev/null
done
SOURCE_DOCKERFILE_HASH=($(md5sum $DOCKER_HASH_FILE))
# Determine base image name
for (( j=${#BASE_DOCKER_REGISTRY_NAMES[@]}-1 ; j>= 0; j-- )); do
BASE_DOCKER_REGISTRY_NAME=${BASE_DOCKER_REGISTRY_NAMES[j]}
BASE_IMAGE_TAG=${BASE_IMAGE_KEYS[*]}
BASE_IMAGE_TAG=${BASE_IMAGE_TAG// /.}
BASE_IMAGE_FULLNAME="${BASE_DOCKER_REGISTRY_NAME}:${BASE_IMAGE_TAG//./-}_${SOURCE_DOCKERFILE_HASH}"
BASE_IMAGE_FULLNAMES+=(${BASE_IMAGE_FULLNAME})
# Remember which index goes with this base image so we can skip those Dockerfiles
# if this image exists
BASE_IMAGE_DOCKERFILES_INDICES+=($i)
done
done
for (( i=${#BASE_IMAGE_FULLNAMES[@]}-1 ; i>=0 ; i-- )); do
BASE_IMAGE_FULLNAME=${BASE_IMAGE_FULLNAMES[i]}
# Check if image exists on remote server
print_info "Checking if base image ${BASE_IMAGE_FULLNAME} exists on remote registry"
OUTPUT=$(docker manifest inspect ${BASE_IMAGE_FULLNAME} >/dev/null 2>&1 ; echo $?)
if [[ ${OUTPUT} -eq 0 ]]; then
BASE_IMAGE_NAME=${BASE_IMAGE_FULLNAME}
DOCKERFILES=(${DOCKERFILES[@]:0:${BASE_IMAGE_DOCKERFILES_INDICES[i]-1}})
print_info "Found pre-built base image: ${BASE_IMAGE_FULLNAME}"
docker pull ${BASE_IMAGE_FULLNAME}
print_info "Finished pulling pre-built base image: ${BASE_IMAGE_FULLNAME}"
break
fi
done
fi
# Arguments for docker build
BUILD_ARGS+=("--build-arg" "USERNAME="admin"")
BUILD_ARGS+=("--build-arg" "USER_UID=`id -u`")
BUILD_ARGS+=("--build-arg" "USER_GID=`id -g`")
BUILD_ARGS+=("--build-arg" "PLATFORM=$PLATFORM")
for BUILD_ARG in ${ADDITIONAL_BUILD_ARGS[@]}
do
BUILD_ARGS+=("--build-arg" "${BUILD_ARG}")
done
# Check if GPU is installed
if [[ $PLATFORM == "x86_64" ]]; then
GPU_ATTACHED=(`nvidia-smi -a | grep "Attached GPUs" || true`)
if [ -z $GPU_ATTACHED ]; then
print_warning "No GPU detected! Not setting build args for HAS_GPU"
else
BUILD_ARGS+=("--build-arg" "HAS_GPU="true"")
fi
fi
if [ ${#DOCKERFILES[@]} -gt 0 ]; then
print_info "Resolved the following ${#DOCKERFILES[@]} Dockerfiles for target image: ${TARGET_IMAGE_STR}"
for DOCKERFILE in ${DOCKERFILES[@]}; do
print_info "${DOCKERFILE}"
done
else
docker tag ${BASE_IMAGE_NAME} ${TARGET_IMAGE_NAME}
print_info "Nothing to build, retagged ${BASE_IMAGE_NAME} as ${TARGET_IMAGE_NAME}"
exit 0
fi
# Build image layers
for (( i=${#DOCKERFILES[@]}-1 ; i>=0 ; i-- )); do
DOCKERFILE=${DOCKERFILES[i]}
DOCKERFILE_CONTEXT_DIR=${DOCKERFILE_CONTEXT_DIRS[i]}
IMAGE_NAME=${DOCKERFILE#*"/Dockerfile."}
IMAGE_NAME="${IMAGE_NAME//./-}-image"
# Build the base images in layers first
BASE_IMAGE_ARG=
if [ $i -eq $(( ${#DOCKERFILES[@]} - 1 )) ]; then
if [[ ! -z "${BASE_IMAGE_NAME}" ]] ; then
BASE_IMAGE_ARG="--build-arg BASE_IMAGE="${BASE_IMAGE_NAME}""
fi
fi
if [ $i -lt $(( ${#DOCKERFILES[@]} - 1 )) ]; then
BASE_DOCKERFILE=${DOCKERFILES[i+1]}
BASE_IMAGE_NAME=${BASE_DOCKERFILE#*"/Dockerfile."}
BASE_IMAGE_NAME="${BASE_IMAGE_NAME//./-}-image"
BASE_IMAGE_ARG="--build-arg BASE_IMAGE="${BASE_IMAGE_NAME}""
fi
# The last image should be the target image name
# Use docker context dir script arg only for last image
DOCKER_CONTEXT_ARG=${DOCKERFILE_CONTEXT_DIR}
if [ $i -eq 0 ]; then
IMAGE_NAME=${TARGET_IMAGE_NAME}
if [[ ! -z "${DOCKER_CONTEXT_DIR}" ]]; then
DOCKER_CONTEXT_ARG=${DOCKER_CONTEXT_DIR}
fi
fi
print_warning "Building ${DOCKERFILE} as image: ${IMAGE_NAME} with base: ${BASE_IMAGE_NAME}"
DOCKER_BUILDKIT=${DOCKER_BUILDKIT} docker build -f ${DOCKERFILE} \
--network host \
-t ${IMAGE_NAME} \
${BASE_IMAGE_ARG} \
"${BUILD_ARGS[@]}" \
$@ \
${DOCKER_CONTEXT_ARG}
done

View File

@ -0,0 +1,48 @@
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
ARG SET_LAUNCH_CMD
ARG BASE_IMAGE=nvidia/cuda:12.2.2-runtime-ubuntu22.04
FROM ${BASE_IMAGE} as deploy_base
# Setup entrypoint
COPY deploy-entrypoint.sh /usr/local/bin/scripts/deploy-entrypoint.sh
RUN chmod +x /usr/local/bin/scripts/deploy-entrypoint.sh
ENTRYPOINT [ "/usr/local/bin/scripts/deploy-entrypoint.sh" ]
# Install additional debians
ARG INSTALL_DEBIANS_CSV
RUN --mount=type=cache,target=/var/cache/apt \
if [[ ! -z "${INSTALL_DEBIANS_CSV}" ]]; then \
apt-get update && apt-get install -y ${INSTALL_DEBIANS_CSV//,/ } ; \
fi
# Copy built products into container
COPY staging/ /
# Switch to non-root user
USER ${USERNAME:?}
# -----------
FROM deploy_base as deploy_has_launch_0
# -----------
FROM deploy_base as deploy_has_launch_1
# Default argument
ARG LAUNCH_FILE
ENV LAUNCH_FILE=${LAUNCH_FILE:?}
ARG LAUNCH_PACKAGE
ENV LAUNCH_PACKAGE=${LAUNCH_PACKAGE:?}
CMD ros2 launch $LAUNCH_PACKAGE $LAUNCH_FILE
# -----------
FROM deploy_has_launch_${SET_LAUNCH_CMD} as final

View File

@ -0,0 +1,21 @@
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
ARG BASE_IMAGE=nvidia/cuda:12.2.2-runtime-ubuntu22.04
FROM ${BASE_IMAGE} as deploy_ros_ws
ARG ROS_WS
ENV ROS_WS=${ROS_WS:?}
RUN --mount=type=cache,target=/var/cache/apt \
. /opt/ros/${ROS_DISTRO}/setup.sh && rosdep update --rosdistro ${ROS_DISTRO} \
&& rosdep install -y -r \
--from-path ${ROS_WS}/install \
--rosdistro ${ROS_DISTRO} \
--ignore-src \
--skip-keys "libyaml-cpp-dev fastcdr rti-connext-dds-6.0.1 rti-connext-dds-5.3.1 urdfdom_headers libopencv-dev libopencv-contrib-dev libopencv-imgproc-dev python-opencv python3-opencv"

View File

@ -0,0 +1,28 @@
#!/bin/bash
#####################################################################################
# SPDX-FileCopyrightText: Copyright (c) 2019 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################################################################################
source ${ROS_ROOT:?}/setup.bash
# Source ROS workspace if exists
if [[ ! -z "${ROS_WS}" ]]; then
source ${ROS_WS}/install/setup.bash
fi
set -x
exec "$@"

261
scripts/docker_deploy.sh Executable file
View File

@ -0,0 +1,261 @@
#!/bin/bash -e
#
# Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $ROOT/utils/print_color.sh
# Builds image (ARG MODE=deploy) with base image key, then layers any roots or debians you specify,
# then does rosdep install of a ROS WS if you specify one, then layers on suffix image key, and
# sets a default command to run 'ros2 launch {launch package} {launch file}'
# Example: installs two debians, copies three directories (includes ROS_WS/remaps one), runs package and launch file
# ./docker_deploy.sh -i "libnvvpi3,tensorrt" -d /workspaces/isaac_ros-dev/tests -d /home/nvidia/scripts:/home/admin/scripts -w /workspaces/isaac_ros-dev/ros_ws -b "aarch64.ros2_humble" -p "isaac_ros_image_proc" -f "isaac_ros_image_flip.launch.py"
# Read and parse config file if exists
#
# CONFIG_BASE_IMAGE_KEY (string, can be empty)
if [[ -f "${ROOT}/.isaac_ros_common-config" ]]; then
. "${ROOT}/.isaac_ros_common-config"
fi
# Override with config from user home directory if exists
if [[ -f ~/.isaac_ros_common-config ]]; then
. ~/.isaac_ros_common-config
fi
INCLUDE_DIRS=()
INCLUDE_TARBALLS=()
SET_LAUNCH_CMD=0
CUSTOM_APT_SOURCES=()
VALID_ARGS=$(getopt -o w:d:b:n:s:f:p:i:t:a: --long ros_ws:include_dir:base_image_key:name:suffix_image_key:launch_file:launch_package:install_debians:include_tarball:custom_apt_source -- "$@")
eval set -- "$VALID_ARGS"
while [ : ]; do
case "$1" in
-a | --custom_apt_source)
CUSTOM_APT_SOURCES+=("$2")
shift 2
;;
-b | --base_image_key)
BASE_IMAGE_KEY="$2"
shift 2
;;
-d | --include_dir)
INCLUDE_DIRS+=("$2")
shift 2
;;
-f | --launch_file)
LAUNCH_FILE="$2"
shift 2
;;
-i | --install_debians)
INSTALL_DEBIANS_CSV="$2"
shift 2
;;
-n | --name)
DEPLOY_IMAGE_NAME="$2"
shift 2
;;
-p | --launch_package)
LAUNCH_PACKAGE="$2"
shift 2
;;
-s | --suffix_image_key)
SUFFIX_IMAGE_KEY="$2"
shift 2
;;
-t | --include_tarball)
INCLUDE_TARBALLS+=("$2")
shift 2
;;
-w | --ros_ws)
ROS_WS="$2"
shift 2
;;
--) shift;
break
;;
esac
done
# Check arguments
PLATFORM="$(uname -m)"
# Check that both launch file and package are set, or neither
if [[ ! -z "${LAUNCH_FILE}${LAUNCH_PACKAGE}" ]]; then
if [[ -z "${LAUNCH_FILE}" || -z "${LAUNCH_PACKAGE}" ]]; then
print_error "Launch package (-p/--launch_package) and launch file (-f/--launch_file) must both be specified or both empty."
exit 1
fi
fi
if [[ ! -z "${LAUNCH_FILE}" ]]; then
SET_LAUNCH_CMD=1
fi
if [[ -z "${BASE_IMAGE_KEY}" ]]; then
BASE_IMAGE_KEY="${PLATFORM}.ros2_humble"
print_warning "Base image key not specified, assuming $BASE_IMAGE_KEY"
fi
if [[ -z "${DEPLOY_IMAGE_NAME}" ]]; then
DEPLOY_IMAGE_NAME="isaac_ros_deploy"
print_warning "Deploy image name not specified, assuming $DEPLOY_IMAGE_NAME"
fi
if [[ ${#CUSTOM_APT_SOURCES[@]} -gt 100 ]]; then
print_error "Unable to handle more than 100 custom apt sources."
exit 1
fi
# Always include install directory of ROS workspace
if [[ ! -z "${ROS_WS}" ]]; then
SYMLINKS_IN_INSTALL_SPACE=$(find "${ROS_WS}/install" -type l)
if [ -n "${SYMLINKS_IN_INSTALL_SPACE}" ]; then
print_warning "Found symlinks in install space. Symlinked install spaces are not supported. Please use an isolated or merge install instead. Symlinks:"
print_warning $SYMLINKS_IN_INSTALL_SPACE
fi
# Resolve ROS_WS_DEST from install directory setup.sh
ROS_WS_DEST=/workspaces/isaac_ros-dev
FILE_CONTENT=$(< "${ROS_WS}/install/setup.sh")
REGEX="_colcon_prefix_chain_sh_COLCON_CURRENT_PREFIX=([^[:space:]]*)"
if [[ $FILE_CONTENT =~ $REGEX ]]; then
ROS_WS_DEST="${BASH_REMATCH[1]%/*}"
fi
INCLUDE_DIRS+=( "$ROS_WS/install:${ROS_WS_DEST}/install" )
fi
# Always suffix .user to base image
# If the configured key does not have .user, append it last
if [[ $BASE_IMAGE_KEY != *".user"* ]]; then
BASE_IMAGE_KEY="${BASE_IMAGE_KEY}.user"
fi
# Summarize final arguments for script
print_info "Building deployable image ${DEPLOY_IMAGE_NAME}"
print_info "Base image key: |${BASE_IMAGE_KEY}| / suffix image_key: |${SUFFIX_IMAGE_KEY}|"
if [[ ! -z "${LAUNCH_FILE}" ]]; then
print_info "Entrypoint to launch ${LAUNCH_PACKAGE}/${LAUNCH_FILE}"
fi
if [[ ! -z "${INSTALL_DEBIANS_CSV}" ]]; then
print_info "Installing debians: ${INSTALL_DEBIANS_CSV}"
fi
if [[ ! -z "${ROS_WS}" ]]; then
print_info "Installing ROS workspace at ${ROS_WS} to ${ROS_WS_DEST}"
fi
for INCLUDE_DIR in "${INCLUDE_DIRS[@]}"
do
print_info "Installing directory: ${INCLUDE_DIR}"
done
for INCLUDE_TARBALL in "${INCLUDE_TARBALLS[@]}"
do
print_info "Installing tarball: ${INCLUDE_TARBALL}"
done
for CUSTOM_APT_SOURCE in "${CUSTOM_APT_SOURCES[@]}"
do
print_info "Adding custom apt source: ${CUSTOM_APT_SOURCE}"
done
print_info "Begin building deployable image"
# Setup on-exit cleanup tasks
ON_EXIT=()
function cleanup {
for command in "${ON_EXIT[@]}"
do
$command
done
}
trap cleanup EXIT
pushd . >/dev/null
cd $ROOT
ON_EXIT+=("popd")
# Setup staging temp directory
TEMP_DIR=`mktemp -d -t isaac_ros_deploy_XXXXXXXX`
ON_EXIT+=("rm -Rf ${TEMP_DIR}")
pushd . >/dev/null
ON_EXIT+=("popd")
cd $TEMP_DIR
cp -f $ROOT/deploy/_Dockerfile.deploy ${TEMP_DIR}/Dockerfile.deploy
cp -f $ROOT/deploy/_Dockerfile.deploy_ws ${TEMP_DIR}/Dockerfile.deploy_ws
cp -f $ROOT/deploy/_deploy-entrypoint.sh ${TEMP_DIR}/deploy-entrypoint.sh
mkdir -p ${TEMP_DIR}/staging
# Stage directories
for INCLUDE_DIR in "${INCLUDE_DIRS[@]}"
do
SRC_DIR=${INCLUDE_DIR}
DEST_DIR=${INCLUDE_DIR}
INCLUDE_DIR_REMAP_ARRAY=(${INCLUDE_DIR//:/ })
if [[ ${#INCLUDE_DIR_REMAP_ARRAY[@]} -gt 1 ]]; then
SRC_DIR=${INCLUDE_DIR_REMAP_ARRAY[0]}
DEST_DIR=${INCLUDE_DIR_REMAP_ARRAY[1]}
fi
print_info "Staging $SRC_DIR->$DEST_DIR"
mkdir -p ${TEMP_DIR}/staging/${DEST_DIR#/}
rsync -azL ${SRC_DIR}/ ${TEMP_DIR}/staging/${DEST_DIR#/}
done
# Stage tarballs
for INCLUDE_TARBALL in "${INCLUDE_TARBALLS[@]}"
do
print_info "Staging tarball $INCLUDE_TARBALL"
tar -xzvf $INCLUDE_TARBALL -C ${TEMP_DIR}/staging
done
# Delete all .git files and credentials
find $TEMP_DIR -type d -name ".git" | xargs -d '\n' rm -rf
BASE_DEPLOY_IMAGE_NAME="${DEPLOY_IMAGE_NAME}-base"
INSTALLED_DEPLOY_IMAGE_NAME="${DEPLOY_IMAGE_NAME}-installed"
# Stage custom apt sources
for (( i=0; i<${#CUSTOM_APT_SOURCES[@]}; i++ )) do
printf -v APT_SOURCE_IDX "%02d" $i
CUSTOM_APT_SOURCE_FILE="${TEMP_DIR}/staging/etc/apt/sources.list.d/${APT_SOURCE_IDX}_custom_apt_source"
mkdir -p ${CUSTOM_APT_SOURCE_FILE%/*}
echo "${CUSTOM_APT_SOURCES[$i]}" >> ${CUSTOM_APT_SOURCE_FILE}
done
# Build base image
print_info "Building deploy base image: ${BASE_DEPLOY_IMAGE_NAME} with key ${BASE_IMAGE_KEY}"
$ROOT/build_image_layers.sh --image_key "${BASE_IMAGE_KEY}" --image_name "${BASE_DEPLOY_IMAGE_NAME}" --build_arg "MODE=deploy"
# Install staged files and setup launch command
print_info "Building install image with launch file ${LAUNCH_FILE} in package ${LAUNCH_PACKAGE}"
$ROOT/build_image_layers.sh --image_key "deploy" --image_name "${INSTALLED_DEPLOY_IMAGE_NAME}" --base_image "${BASE_DEPLOY_IMAGE_NAME}" --context_dir "${TEMP_DIR}" \
--build_arg "MODE=deploy" --build_arg "SET_LAUNCH_CMD=${SET_LAUNCH_CMD}" --build_arg "LAUNCH_FILE=${LAUNCH_FILE}" --build_arg "LAUNCH_PACKAGE=${LAUNCH_PACKAGE}" --build_arg "INSTALL_DEBIANS_CSV=${INSTALL_DEBIANS_CSV}"
# Optional, if ROS_WS, install rosdeps
if [[ ! -z "${ROS_WS}" ]]; then
print_info "Building ROS workspace image for path ${ROS_WS}"
PREVIOUS_STAGE="${INSTALLED_DEPLOY_IMAGE_NAME}"
INSTALLED_DEPLOY_IMAGE_NAME="${DEPLOY_IMAGE_NAME}-rosws"
$ROOT/build_image_layers.sh --image_key "deploy_ws" --image_name "${INSTALLED_DEPLOY_IMAGE_NAME}" --base_image "${PREVIOUS_STAGE}" --context_dir "${TEMP_DIR}" --build_arg "MODE=deploy ROS_WS=${ROS_WS_DEST}"
fi
# Optional, build suffix image if specified
if [[ ! -z "${SUFFIX_IMAGE_KEY}" ]]; then
print_info "Building suffix deploy image for key ${SUFFIX_IMAGE_KEY}"
PREVIOUS_STAGE="${INSTALLED_DEPLOY_IMAGE_NAME}"
INSTALLED_DEPLOY_IMAGE_NAME="${DEPLOY_IMAGE_NAME}-suffix"
$ROOT/build_image_layers.sh --image_key "SUFFIX_IMAGE_KEY" --image_name "${INSTALLED_DEPLOY_IMAGE_NAME}" --base_image "${PREVIOUS_STAGE}" --build_arg "MODE=deploy"
fi
# Retag last image
docker tag "${INSTALLED_DEPLOY_IMAGE_NAME}" "${DEPLOY_IMAGE_NAME}"
print_info "DONE, image: ${DEPLOY_IMAGE_NAME}"

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# #
# Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved. # Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.
# #
# NVIDIA CORPORATION and its licensors retain all intellectual property # NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation # and proprietary rights in and to this software, related documentation
@ -8,14 +8,18 @@
# distribution of this software and related documentation without an express # distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited. # license agreement from NVIDIA CORPORATION is strictly prohibited.
set -e
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $ROOT/utils/print_color.sh source $ROOT/utils/print_color.sh
function usage() { function usage() {
print_info "Usage: run_dev.sh" {isaac_ros_dev directory path OPTIONAL} print_info "Usage: run_dev.sh {-d isaac_ros_dev directory path OPTIONAL}"
print_info "Copyright (c) 2021-2022, NVIDIA CORPORATION." print_info "Copyright (c) 2021-2024, NVIDIA CORPORATION."
} }
DOCKER_ARGS=()
# Read and parse config file if exists # Read and parse config file if exists
# #
# CONFIG_IMAGE_KEY (string, can be empty) # CONFIG_IMAGE_KEY (string, can be empty)
@ -24,28 +28,57 @@ if [[ -f "${ROOT}/.isaac_ros_common-config" ]]; then
. "${ROOT}/.isaac_ros_common-config" . "${ROOT}/.isaac_ros_common-config"
fi fi
ISAAC_ROS_DEV_DIR="$1" # Override with config from user home directory if exists
if [[ -z "$ISAAC_ROS_DEV_DIR" ]]; then if [[ -f ~/.isaac_ros_common-config ]]; then
ISAAC_ROS_DEV_DIR_DEFAULTS=("$HOME/workspaces/Go2Py" "/workspaces/Go2Py") . ~/.isaac_ros_common-config
for ISAAC_ROS_DEV_DIR in "${ISAAC_ROS_DEV_DIR_DEFAULTS[@]}"
do
if [[ -d "$ISAAC_ROS_DEV_DIR" ]]; then
break
fi
done
if [[ ! -d "$ISAAC_ROS_DEV_DIR" ]]; then
ISAAC_ROS_DEV_DIR=$(realpath "$ROOT/../")
fi
print_warning "isaac_ros_dev not specified, assuming $ISAAC_ROS_DEV_DIR"
else
if [[ ! -d "$ISAAC_ROS_DEV_DIR" ]]; then
print_error "Specified isaac_ros_dev does not exist: $ISAAC_ROS_DEV_DIR"
exit 1
fi
shift 1
fi fi
# Parse command-line args
IMAGE_KEY=ros2_humble.realsense.go2py
# Pick up config image key if specified
if [[ ! -z "${CONFIG_IMAGE_KEY}" ]]; then
IMAGE_KEY=$CONFIG_IMAGE_KEY
fi
ISAAC_ROS_DEV_DIR="${ISAAC_ROS_WS}"
SKIP_IMAGE_BUILD=0
VERBOSE=0
VALID_ARGS=$(getopt -o hvd:i:ba: --long help,verbose,isaac_ros_dev_dir:,image_key_suffix:,skip_image_build,docker_arg: -- "$@")
eval set -- "$VALID_ARGS"
while [ : ]; do
case "$1" in
-d | --isaac_ros_dev_dir)
ISAAC_ROS_DEV_DIR="$2"
shift 2
;;
-i | --image_key)
IMAGE_KEY="$2"
shift 2
;;
-b | --skip_image_build)
SKIP_IMAGE_BUILD=1
shift
;;
-a | --docker_arg)
DOCKER_ARGS+=("$2")
shift 2
;;
-v | --verbose)
VERBOSE=1
shift
;;
-h | --help)
usage
exit 0
;;
--) shift;
break
;;
esac
done
# Setup on-exit traps
ON_EXIT=() ON_EXIT=()
function cleanup { function cleanup {
for command in "${ON_EXIT[@]}" for command in "${ON_EXIT[@]}"
@ -59,6 +92,28 @@ pushd . >/dev/null
cd $ROOT cd $ROOT
ON_EXIT+=("popd") ON_EXIT+=("popd")
# Fall back if isaac_ros_dev_dir not specified
if [[ -z "$ISAAC_ROS_DEV_DIR" ]]; then
ISAAC_ROS_DEV_DIR_DEFAULTS=("$HOME/workspaces/isaac_ros-dev" "/workspaces/isaac_ros-dev" "/mnt/nova_ssd/workspaces/isaac_ros-dev")
for ISAAC_ROS_DEV_DIR in "${ISAAC_ROS_DEV_DIR_DEFAULTS[@]}"
do
if [[ -d "$ISAAC_ROS_DEV_DIR" ]]; then
break
fi
done
if [[ ! -d "$ISAAC_ROS_DEV_DIR" ]]; then
ISAAC_ROS_DEV_DIR=$(realpath "$ROOT/../")
fi
print_warning "isaac_ros_dev not specified, assuming $ISAAC_ROS_DEV_DIR"
fi
# Validate isaac_ros_dev_dir
if [[ ! -d "$ISAAC_ROS_DEV_DIR" ]]; then
print_error "Specified isaac_ros_dev does not exist: $ISAAC_ROS_DEV_DIR"
exit 1
fi
# Prevent running as root. # Prevent running as root.
if [[ $(id -u) -eq 0 ]]; then if [[ $(id -u) -eq 0 ]]; then
print_error "This script cannot be executed with root privileges." print_error "This script cannot be executed with root privileges."
@ -85,7 +140,7 @@ fi
# Check if git-lfs is installed. # Check if git-lfs is installed.
git lfs &>/dev/null git lfs &>/dev/null
if [[ $? -ne 0 ]] ; then if [[ $? -ne 0 ]] ; then
print_error "git-lfs is not installed. Please make sure git-lfs is installed before you clone the repo." print_error "git-lfs is not insalled. Please make sure git-lfs is installed before you clone the repo."
exit 1 exit 1
fi fi
@ -97,37 +152,14 @@ if [[ $? -eq 0 ]]; then
for (( i=0; i<${#LFS_FILES_STATUS}; i++ )); do for (( i=0; i<${#LFS_FILES_STATUS}; i++ )); do
f="${LFS_FILES_STATUS:$i:1}" f="${LFS_FILES_STATUS:$i:1}"
if [[ "$f" == "-" ]]; then if [[ "$f" == "-" ]]; then
print_error "LFS files are missing. Please re-clone the repo after installing git-lfs." print_error "LFS files are missing. Please re-clone repos after installing git-lfs."
exit 1 exit 1
fi fi
done done
fi fi
# Determine base image key
PLATFORM="$(uname -m)" PLATFORM="$(uname -m)"
# BASE_NAME="isaac_ros_dev-$PLATFORM"
BASE_NAME="go2py-isaac-ros"
CONTAINER_NAME="go2py-isaac-ros-container"
# CONTAINER_NAME="$BASE_NAME-container"
# Remove any exited containers.
if [ "$(docker ps -a --quiet --filter status=exited --filter name=$CONTAINER_NAME)" ]; then
docker rm $CONTAINER_NAME > /dev/null
fi
# Reuse existing container.
if [ "$(docker ps -a --quiet --filter status=running --filter name=$CONTAINER_NAME)" ]; then
print_info "Attaching to running container: $CONTAINER_NAME"
docker exec -i -t -u admin --workdir /workspaces/Go2Py $CONTAINER_NAME /bin/bash $@
exit 0
fi
# Build image
IMAGE_KEY=ros2_humble
if [[ ! -z "${CONFIG_IMAGE_KEY}" ]]; then
IMAGE_KEY=$CONFIG_IMAGE_KEY
fi
BASE_IMAGE_KEY=$PLATFORM.user BASE_IMAGE_KEY=$PLATFORM.user
if [[ ! -z "${IMAGE_KEY}" ]]; then if [[ ! -z "${IMAGE_KEY}" ]]; then
BASE_IMAGE_KEY=$PLATFORM.$IMAGE_KEY BASE_IMAGE_KEY=$PLATFORM.$IMAGE_KEY
@ -138,11 +170,56 @@ if [[ ! -z "${IMAGE_KEY}" ]]; then
fi fi
fi fi
print_info "Building $BASE_IMAGE_KEY base as image: $BASE_NAME using key $BASE_IMAGE_KEY" # Check skip image build from env
$ROOT/build_base_image.sh $BASE_IMAGE_KEY $BASE_NAME '' '' '' if [[ ! -z $SKIP_DOCKER_BUILD ]]; then
SKIP_IMAGE_BUILD=1
fi
if [ $? -ne 0 ]; then # Check skip image build from config
print_error "Failed to build base image: $BASE_NAME, aborting." if [[ ! -z $CONFIG_SKIP_IMAGE_BUILD ]]; then
SKIP_IMAGE_BUILD=1
fi
BASE_NAME="go2py_isaac_ros_dev-$PLATFORM"
if [[ ! -z "$CONFIG_CONTAINER_NAME_SUFFIX" ]] ; then
BASE_NAME="$BASE_NAME-$CONFIG_CONTAINER_NAME_SUFFIX"
fi
CONTAINER_NAME="$BASE_NAME-container"
# Remove any exited containers.
if [ "$(docker ps -a --quiet --filter status=exited --filter name=$CONTAINER_NAME)" ]; then
docker rm $CONTAINER_NAME > /dev/null
fi
# Re-use existing container.
if [ "$(docker ps -a --quiet --filter status=running --filter name=$CONTAINER_NAME)" ]; then
print_info "Attaching to running container: $CONTAINER_NAME"
docker exec -i -t -u admin --workdir /workspaces/isaac_ros-dev $CONTAINER_NAME /bin/bash $@
exit 0
fi
# Summarize launch
print_info "Launching Isaac ROS Dev container with image key ${BASE_IMAGE_KEY}: ${ISAAC_ROS_DEV_DIR}"
# Build imag to launch
if [[ $SKIP_IMAGE_BUILD -ne 1 ]]; then
print_info "Building $BASE_IMAGE_KEY base as image: $BASE_NAME"
$ROOT/build_image_layers.sh --image_key "$BASE_IMAGE_KEY" --image_name "$BASE_NAME"
# Check result
if [ $? -ne 0 ]; then
if [[ -z $(docker image ls --quiet $BASE_NAME) ]]; then
print_error "Building image failed and no cached image found for $BASE_NAME, aborting."
exit 1
else
print_warning "Unable to build image, but cached image found."
fi
fi
fi
# Check image is available
if [[ -z $(docker image ls --quiet $BASE_NAME) ]]; then
print_error "No built image found for $BASE_NAME, aborting."
exit 1 exit 1
fi fi
@ -155,24 +232,16 @@ DOCKER_ARGS+=("-e NVIDIA_DRIVER_CAPABILITIES=all")
DOCKER_ARGS+=("-e FASTRTPS_DEFAULT_PROFILES_FILE=/usr/local/share/middleware_profiles/rtps_udp_profile.xml") DOCKER_ARGS+=("-e FASTRTPS_DEFAULT_PROFILES_FILE=/usr/local/share/middleware_profiles/rtps_udp_profile.xml")
DOCKER_ARGS+=("-e ROS_DOMAIN_ID") DOCKER_ARGS+=("-e ROS_DOMAIN_ID")
DOCKER_ARGS+=("-e USER") DOCKER_ARGS+=("-e USER")
DOCKER_ARGS+=("-e ISAAC_ROS_WS=/workspaces/isaac_ros-dev")
if [[ $PLATFORM == "aarch64" ]]; then if [[ $PLATFORM == "aarch64" ]]; then
DOCKER_ARGS+=("-v /usr/bin/tegrastats:/usr/bin/tegrastats") DOCKER_ARGS+=("-v /usr/bin/tegrastats:/usr/bin/tegrastats")
DOCKER_ARGS+=("-v /tmp/argus_socket:/tmp/argus_socket") DOCKER_ARGS+=("-v /tmp/:/tmp/")
DOCKER_ARGS+=("-v /usr/local/cuda-11.4/targets/aarch64-linux/lib/libcusolver.so.11:/usr/local/cuda-11.4/targets/aarch64-linux/lib/libcusolver.so.11")
DOCKER_ARGS+=("-v /usr/local/cuda-11.4/targets/aarch64-linux/lib/libcusparse.so.11:/usr/local/cuda-11.4/targets/aarch64-linux/lib/libcusparse.so.11")
DOCKER_ARGS+=("-v /usr/local/cuda-11.4/targets/aarch64-linux/lib/libcurand.so.10:/usr/local/cuda-11.4/targets/aarch64-linux/lib/libcurand.so.10")
DOCKER_ARGS+=("-v /usr/local/cuda-11.4/targets/aarch64-linux/lib/libcufft.so.10:/usr/local/cuda-11.4/targets/aarch64-linux/lib/libcufft.so.10")
DOCKER_ARGS+=("-v /usr/local/cuda-11.4/targets/aarch64-linux/lib/libnvToolsExt.so:/usr/local/cuda-11.4/targets/aarch64-linux/lib/libnvToolsExt.so")
DOCKER_ARGS+=("-v /usr/local/cuda-11.4/targets/aarch64-linux/lib/libcupti.so.11.4:/usr/local/cuda-11.4/targets/aarch64-linux/lib/libcupti.so.11.4")
DOCKER_ARGS+=("-v /usr/local/cuda-11.4/targets/aarch64-linux/lib/libcudla.so.1:/usr/local/cuda-11.4/targets/aarch64-linux/lib/libcudla.so.1")
DOCKER_ARGS+=("-v /usr/local/cuda-11.4/targets/aarch64-linux/include/nvToolsExt.h:/usr/local/cuda-11.4/targets/aarch64-linux/include/nvToolsExt.h")
DOCKER_ARGS+=("-v /usr/lib/aarch64-linux-gnu/tegra:/usr/lib/aarch64-linux-gnu/tegra") DOCKER_ARGS+=("-v /usr/lib/aarch64-linux-gnu/tegra:/usr/lib/aarch64-linux-gnu/tegra")
DOCKER_ARGS+=("-v /usr/src/jetson_multimedia_api:/usr/src/jetson_multimedia_api") DOCKER_ARGS+=("-v /usr/src/jetson_multimedia_api:/usr/src/jetson_multimedia_api")
DOCKER_ARGS+=("-v /opt/nvidia/nsight-systems-cli:/opt/nvidia/nsight-systems-cli")
DOCKER_ARGS+=("--pid=host") DOCKER_ARGS+=("--pid=host")
DOCKER_ARGS+=("-v /opt/nvidia/vpi2:/opt/nvidia/vpi2") DOCKER_ARGS+=("-v /usr/share/vpi3:/usr/share/vpi3")
DOCKER_ARGS+=("-v /usr/share/vpi2:/usr/share/vpi2") DOCKER_ARGS+=("-v /dev/input:/dev/input")
# If jtop present, give the container access # If jtop present, give the container access
if [[ $(getent group jtop) ]]; then if [[ $(getent group jtop) ]]; then
@ -183,10 +252,20 @@ if [[ $PLATFORM == "aarch64" ]]; then
fi fi
# Optionally load custom docker arguments from file # Optionally load custom docker arguments from file
DOCKER_ARGS_FILE="$ROOT/.isaac_ros_dev-dockerargs" if [[ -z "${DOCKER_ARGS_FILE}" ]]; then
if [[ -f "$DOCKER_ARGS_FILE" ]]; then DOCKER_ARGS_FILE=".isaac_ros_dev-dockerargs"
print_info "Using additional Docker run arguments from $DOCKER_ARGS_FILE" fi
readarray -t DOCKER_ARGS_FILE_LINES < $DOCKER_ARGS_FILE
# Check for dockerargs file in home directory, then locally in root
if [[ -f ~/${DOCKER_ARGS_FILE} ]]; then
DOCKER_ARGS_FILEPATH=`realpath ~/${DOCKER_ARGS_FILE}`
elif [[ -f "${ROOT}/${DOCKER_ARGS_FILE}" ]]; then
DOCKER_ARGS_FILEPATH="${ROOT}/${DOCKER_ARGS_FILE}"
fi
if [[ -f "${DOCKER_ARGS_FILEPATH}" ]]; then
print_info "Using additional Docker run arguments from $DOCKER_ARGS_FILEPATH"
readarray -t DOCKER_ARGS_FILE_LINES < $DOCKER_ARGS_FILEPATH
for arg in "${DOCKER_ARGS_FILE_LINES[@]}"; do for arg in "${DOCKER_ARGS_FILE_LINES[@]}"; do
DOCKER_ARGS+=($(eval "echo $arg | envsubst")) DOCKER_ARGS+=($(eval "echo $arg | envsubst"))
done done
@ -194,18 +273,19 @@ fi
# Run container from image # Run container from image
print_info "Running $CONTAINER_NAME" print_info "Running $CONTAINER_NAME"
if [[ $VERBOSE -eq 1 ]]; then
set -x
fi
docker run -it --rm \ docker run -it --rm \
--privileged \ --privileged \
--network host \ --network host \
${DOCKER_ARGS[@]} \ ${DOCKER_ARGS[@]} \
-v $ISAAC_ROS_DEV_DIR:/workspaces/Go2Py \ -v $ISAAC_ROS_DEV_DIR:/workspaces/isaac_ros-dev \
-v /dev/*:/dev/* \
-v /etc/localtime:/etc/localtime:ro \ -v /etc/localtime:/etc/localtime:ro \
--name "$CONTAINER_NAME" \ --name "$CONTAINER_NAME" \
--runtime nvidia \ --runtime nvidia \
--user="admin" \ --user="admin" \
--entrypoint /usr/local/bin/scripts/workspace-entrypoint.sh \ --entrypoint /usr/local/bin/scripts/workspace-entrypoint.sh \
--workdir /workspaces/Go2Py \ --workdir /workspaces/isaac_ros-dev \
$@ \
$BASE_NAME \ $BASE_NAME \
/bin/bash /bin/bash