diff --git a/docker/Dockerfile.ros2 b/docker/Dockerfile.ros2 index 2e00fc7ec39..34f4fb63bfb 100644 --- a/docker/Dockerfile.ros2 +++ b/docker/Dockerfile.ros2 @@ -1,5 +1,5 @@ # Everything past this stage is to install -# ROS2 Humble +# ROS2 Jazzy/Humble selector # What is the docker name suffix for the base image to load? (defaults to empty string) ARG DOCKER_NAME_SUFFIX="" @@ -9,30 +9,37 @@ FROM isaac-lab-base${DOCKER_NAME_SUFFIX} AS ros2 # Which ROS2 apt package to install ARG ROS2_APT_PACKAGE -# ROS2 Humble Apt installations +# ROS2 Apt installations: choose humble for Ubuntu 22.04, jazzy for 24.04 RUN --mount=type=cache,target=/var/cache/apt \ apt-get update && apt-get install -y --no-install-recommends \ curl \ - # Install ROS2 Humble \ + ca-certificates \ + gnupg \ + lsb-release \ + apt-transport-https \ software-properties-common && \ add-apt-repository universe && \ + # Add ROS2 apt repository keyring 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 $(. /etc/os-release && echo jammy) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null && \ + CODENAME="$(. /etc/os-release && echo $VERSION_CODENAME)" && \ + VERSION_ID="$(. /etc/os-release && echo $VERSION_ID)" && \ + echo "Detected Ubuntu VERSION_ID=${VERSION_ID}, CODENAME=${CODENAME}" && \ + if [ "$VERSION_ID" = "22.04" ]; then ROS_DISTRO="humble"; \ + elif [ "$VERSION_ID" = "24.04" ]; then ROS_DISTRO="jazzy"; \ + else echo "Unsupported Ubuntu version: $VERSION_ID" >&2; exit 1; fi && \ + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $CODENAME main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null && \ apt-get update && apt-get install -y --no-install-recommends \ - ros-humble-${ROS2_APT_PACKAGE} \ - ros-humble-vision-msgs \ - # Install both FastRTPS and CycloneDDS - ros-humble-rmw-cyclonedds-cpp \ - ros-humble-rmw-fastrtps-cpp \ - # This includes various dev tools including colcon - ros-dev-tools && \ - # Install rosdeps for extensions that declare a ros_ws in - # their extension.toml + ros-${ROS_DISTRO}-${ROS2_APT_PACKAGE} \ + ros-${ROS_DISTRO}-vision-msgs \ + ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \ + ros-${ROS_DISTRO}-rmw-fastrtps-cpp \ + ros-dev-tools \ + python3-rosdep && \ + rosdep init || true && rosdep update || true && \ ${ISAACLAB_PATH}/isaaclab.sh -p ${ISAACLAB_PATH}/tools/install_deps.py rosdep ${ISAACLAB_PATH}/source && \ apt -y autoremove && apt clean autoclean && \ rm -rf /var/lib/apt/lists/* && \ - # Add sourcing of setup.bash to .bashrc - echo "source /opt/ros/humble/setup.bash" >> ${HOME}/.bashrc + echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> ${HOME}/.bashrc # Copy the RMW specifications for ROS2 # https://docs.isaacsim.omniverse.nvidia.com/latest/installation/install_ros.html