Skip to content

Commit

Permalink
Adds ROS2 Humble to Dockerfile (#443)
Browse files Browse the repository at this point in the history
# Description

This adds a ROS2 Humble installation to the Dockerfile. It also adds
several relevant environment variables.

## Type of change

- New feature (non-breaking change which adds functionality)

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./orbit.sh --format`
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have run all the tests with `./orbit.sh --test` and they pass
- [ ] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

---------

Signed-off-by: Hunter Hansen <[email protected]>
Co-authored-by: James Smith <[email protected]>
  • Loading branch information
hhansen-bdai and jsmith-bdai authored Mar 21, 2024
1 parent 83d62e2 commit 95a4927
Show file tree
Hide file tree
Showing 9 changed files with 303 additions and 109 deletions.
4 changes: 4 additions & 0 deletions docker/.env → docker/.env.base
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
###
# General settings
###

# Accept the NVIDIA Omniverse EULA by default
ACCEPT_EULA=Y
# NVIDIA Isaac Sim version to use (e.g. 2023.1.1, 2023.1.0-hotfix.1)
Expand Down
11 changes: 11 additions & 0 deletions docker/.env.ros2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
###
# ROS2 specific settings
###
# Set the version of the ROS2 apt package to install (ros-base, desktop, desktop-full)
ROS2_APT_PACKAGE=ros-base
# Se t ROS2 middleware implementation to use (e.g. rmw_fastrtps_cpp, rmw_cyclonedds_cpp)
RMW_IMPLEMENTATION=rmw_fastrtps_cpp
# Path to fastdds.xml file to use (only needed when using fastdds)
FASTRTPS_DEFAULT_PROFILES_FILE=${DOCKER_USER_HOME}/.ros/fastdds.xml
# Path to cyclonedds.xml file to use (only needed when using cyclonedds)
CYCLONEDDS_URI=${DOCKER_USER_HOME}/.ros/cyclonedds.xml
15 changes: 15 additions & 0 deletions docker/.ros/cyclonedds.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<CycloneDDS xmlns="https://cdds.io/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://cdds.io/config https://raw.githubusercontent.com/eclipse-cyclonedds/cyclonedds/master/etc/cyclonedds.xsd">
<Domain id="any">
<General>
<Interfaces>
<NetworkInterface autodetermine="true"/>
</Interfaces>
<AllowMulticast>true</AllowMulticast>
</General>
<Discovery>
<ParticipantIndex>auto</ParticipantIndex>
<MaxAutoParticipantIndex>120</MaxAutoParticipantIndex>
</Discovery>
</Domain>
</CycloneDDS>
27 changes: 27 additions & 0 deletions docker/.ros/fastdds.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?>

<license>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.</license>


<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles" >
<transport_descriptors>
<transport_descriptor>
<transport_id>UdpTransport</transport_id>
<type>UDPv4</type>
</transport_descriptor>
</transport_descriptors>

<participant profile_name="udp_transport_profile" is_default_profile="true">
<rtps>
<userTransports>
<transport_id>UdpTransport</transport_id>
</userTransports>
<useBuiltinTransports>false</useBuiltinTransports>
</rtps>
</participant>
</profiles>
10 changes: 6 additions & 4 deletions docker/Dockerfile → docker/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# Base image
ARG ISAACSIM_VERSION
FROM nvcr.io/nvidia/isaac-sim:${ISAACSIM_VERSION}
FROM nvcr.io/nvidia/isaac-sim:${ISAACSIM_VERSION} AS base

# Set default RUN shell to bash
SHELL ["/bin/bash", "-c"]
Expand All @@ -20,16 +20,18 @@ LABEL description="Dockerfile for building and running the Orbit framework insid
# Arguments
# Path to Isaac Sim root folder
ARG ISAACSIM_PATH
# Path to the Docker User Home
# Home dir of docker user, typically '/root'
ARG DOCKER_USER_HOME

# Set environment variables
ENV LANG=C.UTF-8
ENV DEBIAN_FRONTEND=noninteractive
# Path to orbit directory
ENV ORBIT_PATH=/workspace/orbit

# Install dependencies and remove cache
RUN apt-get update && apt-get install -y --no-install-recommends \
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -y --no-install-recommends \
build-essential \
cmake \
git \
Expand Down Expand Up @@ -66,7 +68,7 @@ RUN touch /bin/nvidia-smi && \

# installing Orbit dependencies
# use pip caching to avoid reinstalling large packages
RUN --mount=type=cache,target=/${DOCKER_USER_HOME}/.cache/pip \
RUN --mount=type=cache,target=${DOCKER_USER_HOME}/.cache/pip \
${ORBIT_PATH}/orbit.sh --install --extra

# aliasing orbit.sh and python for convenience
Expand Down
34 changes: 34 additions & 0 deletions docker/Dockerfile.ros2
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Everything past this stage is to install
# ROS2 Humble
FROM orbit-base AS ros2

# Which ROS2 apt package to install
ARG ROS2_APT_PACKAGE
# Home of the docker user, generally /root
ARG DOCKER_USER_HOME

# ROS2 Humble Apt installations
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -y --no-install-recommends \
curl \
# Install ROS2 Humble \
software-properties-common && \
add-apt-repository universe && \
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 && \
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 && \
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

# Copy the RMW specifications for ROS2
# https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_ros.html#enabling-the-ros-bridge-extension
COPY docker/.ros/ ${DOCKER_USER_HOME}/.ros/
45 changes: 36 additions & 9 deletions docker/container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,24 @@ case $mode in
start)
echo "[INFO] Building the docker image and starting the container in the background..."
pushd ${SCRIPT_DIR} > /dev/null 2>&1
docker compose --file docker-compose.yaml up --detach --build --remove-orphans
# The second argument is interpreted as the profile to use.
# We will select the base profile by default.
# This will also determine the .env file that is loaded
if [ -z "$2" ]; then
add_profiles="--profile base"
add_envs="--env-file .env.base"
else
profile="$2"
add_profiles="--profile $profile"
# We have to load multiple .env files here in order to combine
# them for the args from base required for extensions, (i.e. DOCKER_USER_HOME)
add_envs="--env-file .env.base --env-file .env.$profile"
fi
# We have to build the base image as a separate step,
# in case we are building a profile which depends
# upon
docker compose --file docker-compose.yaml --env-file .env.base build orbit-base
docker compose --file docker-compose.yaml $add_profiles $add_envs up --detach --build --remove-orphans
popd > /dev/null 2>&1
;;
enter)
Expand Down Expand Up @@ -124,7 +141,17 @@ case $mode in
stop)
echo "[INFO] Stopping the launched docker container..."
pushd ${SCRIPT_DIR} > /dev/null 2>&1
docker compose --file docker-compose.yaml down
if [ -z "$2" ]; then
add_profiles="--profile base"
add_envs="--env-file .env.base"
else
profile="$2"
add_profiles="--profile $profile"
# We have to load multiple .env files here in order to combine
# them for the args from base required for ROS2, (i.e. DOCKER_USER_HOME)
add_envs="--env-file .env.base --env-file .env.$profile"
fi
docker compose --file docker-compose.yaml $add_profiles $add_envs down
popd > /dev/null 2>&1
;;
push)
Expand All @@ -133,10 +160,10 @@ case $mode in
fi
# Check if Docker version is greater than 25
check_docker_version
# Check if .env file exists
if [ -f $SCRIPT_DIR/.env ]; then
# Check if .env.base file exists
if [ -f $SCRIPT_DIR/.env.base ]; then
# source env file to get cluster login and path information
source $SCRIPT_DIR/.env
source $SCRIPT_DIR/.env.base
# clear old exports
sudo rm -r -f /$SCRIPT_DIR/exports
mkdir -p /$SCRIPT_DIR/exports
Expand All @@ -147,21 +174,21 @@ case $mode in
tar -cvf /$SCRIPT_DIR/exports/orbit.tar orbit.sif
scp /$SCRIPT_DIR/exports/orbit.tar $CLUSTER_LOGIN:$CLUSTER_SIF_PATH/orbit.tar
else
echo "[Error]: ".env" file not found."
echo "[Error]: ".env.base" file not found."
fi
;;
job)
# Check if .env file exists
if [ -f $SCRIPT_DIR/.env ]; then
if [ -f $SCRIPT_DIR/.env.base ]; then
# Sync orbit code
echo "[INFO] Syncing orbit code..."
source $SCRIPT_DIR/.env
source $SCRIPT_DIR/.env.base
rsync -rh --exclude="*.git*" --filter=':- .dockerignore' /$SCRIPT_DIR/.. $CLUSTER_LOGIN:$CLUSTER_ORBIT_DIR
# execute job script
echo "[INFO] Executing job script..."
ssh $CLUSTER_LOGIN "cd $CLUSTER_ORBIT_DIR && sbatch $CLUSTER_ORBIT_DIR/docker/cluster/submit_job.sh" "$CLUSTER_ORBIT_DIR" "${@:2}"
else
echo "[Error]: ".env" file not found."
echo "[Error]: ".env.base" file not found."
fi
;;
*)
Expand Down
Loading

0 comments on commit 95a4927

Please sign in to comment.