Skip to content

Commit

Permalink
Merge pull request #60 from j3soon/update-template
Browse files Browse the repository at this point in the history
Update template/linting and unify workspaces to include Isaac Sim
  • Loading branch information
j3soon authored Sep 20, 2024
2 parents e073938 + c2da952 commit a2bf2d6
Show file tree
Hide file tree
Showing 34 changed files with 1,385 additions and 142 deletions.
26 changes: 24 additions & 2 deletions cartographer_ws/docker/.bashrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# Setup paths in `~/.profile` to allow unified environment variable across login/non-login shells
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
# Source global ROS2 environment
source /opt/ros/$ROS_DISTRO/setup.bash
# Optionally perform apt update if it has not been executed yet
Expand All @@ -9,13 +18,14 @@ fi
if [ ! -d $HOME/.ros/rosdep/sources.cache ]; then
echo "rosdep update has not been executed yet. Running rosdep update..."
rosdep update
cd $ROS2_WS
# Ref: https://docs.ros.org/en/humble/Tutorials/Intermediate/Rosdep.html
rosdep install --from-paths src --ignore-src -y -r
fi
# Optionally build the workspace if it has not been built yet
if [ ! -f $ROS2_WS/install/setup.bash ]; then
echo "Workspace has not been built yet. Building workspace..."
cd $ROS2_WS
# Ref: https://docs.ros.org/en/humble/Tutorials/Intermediate/Rosdep.html
rosdep install --from-paths src --ignore-src -y -r
# TODO: If command `arch` outputs `aarch64`, consider adding `--packages-ignore <package>` to ignore x86 packages
# Ref: https://docs.ros.org/en/humble/Tutorials/Beginner-Client-Libraries/Creating-Your-First-ROS2-Package.html
if [ $(arch) == "aarch64" ]; then
Expand All @@ -25,6 +35,18 @@ if [ ! -f $ROS2_WS/install/setup.bash ]; then
fi
echo "Workspace built."
fi
# Source gazebo environment
# Ref: https://classic.gazebosim.org/tutorials?tut=ros2_installing&cat=connect_ros#InstallGazebo
if [ $(arch) == "x86_64" ]; then
source /usr/share/gazebo/setup.bash
fi
# TODO: Source other workspace environments as underlay
# Set Isaac Sim environment variables
# Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_python.html#running-isaac-sim
# Ref: https://github.com/NVIDIA-Omniverse/IsaacSim-dockerfiles/blob/e3c09375c2d110b39c3fab3611352870aa3ce6ee/Dockerfile.2023.1.0-ubuntu22.04#L49-L53
export OMNI_USER=admin
export OMNI_PASS=admin
export OMNI_KIT_ACCEPT_EULA=YES
# Source workspace environment
source $ROS2_WS/install/setup.bash
echo "Successfully built workspace and configured environment variables."
66 changes: 53 additions & 13 deletions cartographer_ws/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,39 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
python3-pip \
&& rm -rf /var/lib/apt/lists/*

# Install custom tools
# Install GUI debugging tools
# - `x11-apps` and `x11-utils` for `xeyes` and `xdpyinfo`
# Ref: https://packages.debian.org/sid/x11-apps
# Ref: https://packages.debian.org/sid/x11-utils
# - `mesa-utils` for `glxgears` and `glxinfo`
# Ref: https://wiki.debian.org/Mesa
# - `vulkan-tools` for `vkcube` and `vulkaninfo`
# Ref: https://docs.vulkan.org/tutorial/latest/02_Development_environment.html#_vulkan_packages
# Ref: https://gitlab.com/nvidia/container-images/vulkan/-/blob/master/docker/Dockerfile.ubuntu
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
apt-get update && apt-get install -y \
git-extras \
x11-apps x11-utils \
mesa-utils \
libgl1 vulkan-tools \
&& rm -rf /var/lib/apt/lists/*

# Setup the required capabilities for the container runtime
# Ref: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/docker-specialized.html#driver-capabilities
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=all

# Install Vulkan config files
# Ref: https://gitlab.com/nvidia/container-images/vulkan
RUN cat > /etc/vulkan/icd.d/nvidia_icd.json <<EOF
{
"file_format_version" : "1.0.0",
"ICD": {
"library_path": "libGLX_nvidia.so.0",
"api_version" : "1.3.194"
}
}
EOF

# Install ROS2 Gazebo packages for amd64
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
if [ "$TARGETARCH" = "amd64" ]; then \
Expand All @@ -80,23 +107,36 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
ros-$ROS_DISTRO-rviz2 \
&& rm -rf /var/lib/apt/lists/*

USER $USERNAME

# Create Gazebo cache directory with correct ownership to avoid permission issues after volume mount
RUN mkdir /home/$USERNAME/.gazebo

# Install Isaac Sim (requires Python 3.10)
# Note that installing Isaac Sim with pip is experimental, keep this in mind when unexpected error occurs
# TODO: Remove the note above when it is no longer experimental
# Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_python.html#installation-using-pip
RUN --mount=type=cache,target=/home/user/.cache/pip,sharing=private \
if [ "$TARGETARCH" = "amd64" ]; then \
python3 -V | grep "Python 3.10" \
&& pip install isaacsim==4.1.0.0 --extra-index-url https://pypi.nvidia.com \
&& pip install isaacsim-extscache-physics==4.1.0.0 isaacsim-extscache-kit==4.1.0.0 isaacsim-extscache-kit-sdk==4.1.0.0 --extra-index-url https://pypi.nvidia.com; \
fi

# Install custom tools
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
sudo apt-get update && sudo apt-get install -y \
git-extras \
&& sudo rm -rf /var/lib/apt/lists/*

# TODO: Add more commands here
# For example, to install additional packages, uncomment the following lines and add the package names
# RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
# apt-get update && apt-get install -y \
# $OTHER_PACKAGES \
# && rm -rf /var/lib/apt/lists/*
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
apt-get update && apt-get install -y \
sudo apt-get update && sudo apt-get install -y \
ros-$ROS_DISTRO-cartographer \
ros-$ROS_DISTRO-turtlebot3* \
ros-$ROS_DISTRO-rqt-robot-steering \
&& rm -rf /var/lib/apt/lists/*
&& sudo rm -rf /var/lib/apt/lists/*

USER $USERNAME
# Create Gazebo cache directory with correct ownership to avoid permission issues after volume mount
RUN mkdir /home/$USERNAME/.gazebo
# TODO: Run additional commands as non-root user here
COPY .bashrc /home/$USERNAME/.bashrc
# TODO: Copy additional files here
ENTRYPOINT []
Expand Down
74 changes: 74 additions & 0 deletions cartographer_ws/docker/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
services:
volume-instantiation:
# Ref: https://github.com/moby/moby/issues/47842#issuecomment-2249050939
image: ubuntu:22.04
container_name: ros2-volume-instantiation
command: bash -c "
mkdir -p /isaac-sim/cache/{kit,ov,pip,glcache,computecache} &&
mkdir -p /isaac-sim/{logs,data,documents} &&
mkdir -p /isaac-sim/standalone/cache/ov &&
mkdir -p /isaac-sim/standalone/{logs,data} &&
chown -R 1000:1000 /isaac-sim"
volumes:
- isaac-sim-cache:/isaac-sim
cartographer-ws:
depends_on:
- volume-instantiation
build:
context: .
dockerfile: Dockerfile
Expand Down Expand Up @@ -61,9 +75,69 @@ services:
# Reference: https://answers.ros.org/question/365658
# Note that this volume is shared among all workspaces.
- gazebo-cache:/home/user/.gazebo
# Mount Isaac Sim cache directories.
# Reference: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_container.html#container-deployment
# Note that this volume is shared among all workspaces.
- type: volume
source: isaac-sim-cache
target: /isaac-sim/kit/cache
volume:
subpath: cache/kit
- type: volume
source: isaac-sim-cache
target: /home/user/.cache/ov
volume:
subpath: cache/ov
- type: volume
source: isaac-sim-cache
target: /home/user/.local/lib/python3.10/site-packages/omni/cache # For Isaac Sim standalone
volume:
subpath: standalone/cache/ov
- type: volume
source: isaac-sim-cache
target: /home/user/.cache/pip
volume:
subpath: cache/pip
- type: volume
source: isaac-sim-cache
target: /home/user/.cache/nvidia/GLCache
volume:
subpath: cache/glcache
- type: volume
source: isaac-sim-cache
target: /home/user/.nv/ComputeCache
volume:
subpath: cache/computecache
- type: volume
source: isaac-sim-cache
target: /home/user/.nvidia-omniverse/logs
volume:
subpath: logs
- type: volume
source: isaac-sim-cache
target: /home/user/.local/lib/python3.10/site-packages/omni/logs # For Isaac Sim standalone
volume:
subpath: standalone/logs
- type: volume
source: isaac-sim-cache
target: /home/user/.local/share/ov/data
volume:
subpath: data
- type: volume
source: isaac-sim-cache
target: /home/user/.local/lib/python3.10/site-packages/omni/data # For Isaac Sim standalone
volume:
subpath: standalone/data
- type: volume
source: isaac-sim-cache
target: /home/user/Documents
volume:
subpath: documents
# TODO: Add more volume mounts here.
# Mount root workspace to allow easy access to all workspaces.
- ../..:/home/ros2-essentials
volumes:
gazebo-cache:
name: ros2-gazebo-cache
isaac-sim-cache:
name: ros2-isaac-sim-cache
29 changes: 23 additions & 6 deletions gazebo_world_ws/docker/.bashrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Check if the architecture is aarch64
if [ $(arch) == "aarch64" ]; then
echo "Architecture is aarch64, which is not supported by Gazebo. Exiting..."
exit 1
# Setup paths in `~/.profile` to allow unified environment variable across login/non-login shells
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
# Source global ROS2 environment
source /opt/ros/$ROS_DISTRO/setup.bash
Expand All @@ -14,13 +18,14 @@ fi
if [ ! -d $HOME/.ros/rosdep/sources.cache ]; then
echo "rosdep update has not been executed yet. Running rosdep update..."
rosdep update
cd $ROS2_WS
# Ref: https://docs.ros.org/en/humble/Tutorials/Intermediate/Rosdep.html
rosdep install --from-paths src --ignore-src -y -r
fi
# Optionally build the workspace if it has not been built yet
if [ ! -f $ROS2_WS/install/setup.bash ]; then
echo "Workspace has not been built yet. Building workspace..."
cd $ROS2_WS
# Ref: https://docs.ros.org/en/humble/Tutorials/Intermediate/Rosdep.html
rosdep install --from-paths src --ignore-src -y -r
# TODO: If command `arch` outputs `aarch64`, consider adding `--packages-ignore <package>` to ignore x86 packages
# Ref: https://docs.ros.org/en/humble/Tutorials/Beginner-Client-Libraries/Creating-Your-First-ROS2-Package.html
if [ $(arch) == "aarch64" ]; then
Expand All @@ -30,6 +35,18 @@ if [ ! -f $ROS2_WS/install/setup.bash ]; then
fi
echo "Workspace built."
fi
# Source gazebo environment
# Ref: https://classic.gazebosim.org/tutorials?tut=ros2_installing&cat=connect_ros#InstallGazebo
if [ $(arch) == "x86_64" ]; then
source /usr/share/gazebo/setup.bash
fi
# TODO: Source other workspace environments as underlay
# Set Isaac Sim environment variables
# Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_python.html#running-isaac-sim
# Ref: https://github.com/NVIDIA-Omniverse/IsaacSim-dockerfiles/blob/e3c09375c2d110b39c3fab3611352870aa3ce6ee/Dockerfile.2023.1.0-ubuntu22.04#L49-L53
export OMNI_USER=admin
export OMNI_PASS=admin
export OMNI_KIT_ACCEPT_EULA=YES
# Source workspace environment
source $ROS2_WS/install/setup.bash
echo "Successfully built workspace and configured environment variables."
59 changes: 49 additions & 10 deletions gazebo_world_ws/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,39 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
python3-pip \
&& rm -rf /var/lib/apt/lists/*

# Install custom tools
# Install GUI debugging tools
# - `x11-apps` and `x11-utils` for `xeyes` and `xdpyinfo`
# Ref: https://packages.debian.org/sid/x11-apps
# Ref: https://packages.debian.org/sid/x11-utils
# - `mesa-utils` for `glxgears` and `glxinfo`
# Ref: https://wiki.debian.org/Mesa
# - `vulkan-tools` for `vkcube` and `vulkaninfo`
# Ref: https://docs.vulkan.org/tutorial/latest/02_Development_environment.html#_vulkan_packages
# Ref: https://gitlab.com/nvidia/container-images/vulkan/-/blob/master/docker/Dockerfile.ubuntu
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
apt-get update && apt-get install -y \
git-extras \
x11-apps x11-utils \
mesa-utils \
libgl1 vulkan-tools \
&& rm -rf /var/lib/apt/lists/*

# Setup the required capabilities for the container runtime
# Ref: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/docker-specialized.html#driver-capabilities
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=all

# Install Vulkan config files
# Ref: https://gitlab.com/nvidia/container-images/vulkan
RUN cat > /etc/vulkan/icd.d/nvidia_icd.json <<EOF
{
"file_format_version" : "1.0.0",
"ICD": {
"library_path": "libGLX_nvidia.so.0",
"api_version" : "1.3.194"
}
}
EOF

# Install ROS2 Gazebo packages for amd64
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
if [ "$TARGETARCH" = "amd64" ]; then \
Expand All @@ -80,17 +107,29 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
ros-$ROS_DISTRO-rviz2 \
&& rm -rf /var/lib/apt/lists/*

# TODO: Add more commands here
# For example, to install additional packages, uncomment the following lines and add the package names
# RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
# apt-get update && apt-get install -y \
# $OTHER_PACKAGES \
# && rm -rf /var/lib/apt/lists/*

USER $USERNAME

# Create Gazebo cache directory with correct ownership to avoid permission issues after volume mount
RUN mkdir /home/$USERNAME/.gazebo
# TODO: Run additional commands as non-root user here

# Install Isaac Sim (requires Python 3.10)
# Note that installing Isaac Sim with pip is experimental, keep this in mind when unexpected error occurs
# TODO: Remove the note above when it is no longer experimental
# Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_python.html#installation-using-pip
RUN --mount=type=cache,target=/home/user/.cache/pip,sharing=private \
if [ "$TARGETARCH" = "amd64" ]; then \
python3 -V | grep "Python 3.10" \
&& pip install isaacsim==4.1.0.0 --extra-index-url https://pypi.nvidia.com \
&& pip install isaacsim-extscache-physics==4.1.0.0 isaacsim-extscache-kit==4.1.0.0 isaacsim-extscache-kit-sdk==4.1.0.0 --extra-index-url https://pypi.nvidia.com; \
fi

# Install custom tools
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
sudo apt-get update && sudo apt-get install -y \
git-extras \
&& sudo rm -rf /var/lib/apt/lists/*

# TODO: Add more commands here
COPY .bashrc /home/$USERNAME/.bashrc
# TODO: Copy additional files here
ENTRYPOINT []
Expand Down
Loading

0 comments on commit a2bf2d6

Please sign in to comment.