From 4954d2c7e4609679c80ee2245cb4b416df44613f Mon Sep 17 00:00:00 2001 From: Johnson Sun Date: Mon, 16 Sep 2024 01:13:20 +0800 Subject: [PATCH 1/7] test: Support global ignore --- tests/lint_comp_template.py | 3 +++ tests/lint_compose.py | 3 +++ tests/lint_dockerfile.py | 3 +++ tests/lint_filenames.py | 6 ++++++ tests/lint_gitignore.py | 3 +++ tests/lint_readme.py | 3 +++ tests/test_all.sh | 1 + 7 files changed, 22 insertions(+) diff --git a/tests/lint_comp_template.py b/tests/lint_comp_template.py index 7afe1ac4..2391c112 100644 --- a/tests/lint_comp_template.py +++ b/tests/lint_comp_template.py @@ -24,6 +24,9 @@ def compare_file_with_template(filepath, targetpath=None, ignored_workspaces=[]) # Skip certain cases intentionally if any(ws in filename for ws in ignored_workspaces): continue + # Global ignore + if any(ws in filename for ws in os.getenv('IGNORED_WORKSPACES', '').split()): + continue logging.debug(f"Checking: '{filename[len(repo_dir)+1:]}'...") content = Path(filename).read_text().splitlines(keepends=True) diff = list(filter(lambda x: x.startswith('- ') or x.startswith('+ ') or x.startswith(' '), difflib.ndiff(template, content))) diff --git a/tests/lint_compose.py b/tests/lint_compose.py index 3255731f..88237288 100644 --- a/tests/lint_compose.py +++ b/tests/lint_compose.py @@ -9,6 +9,9 @@ logging.info("Checking `compose.yaml` files...") for filename in glob.glob(f"{repo_dir}/*_ws/docker/compose*.yaml"): + # Global ignore + if any(ws in filename for ws in os.getenv('IGNORED_WORKSPACES', '').split()): + continue logging.debug(f"Checking: '{filename[len(repo_dir)+1:]}'...") content = Path(filename).read_text() if "version:" in content: diff --git a/tests/lint_dockerfile.py b/tests/lint_dockerfile.py index e5853701..cab03cd5 100644 --- a/tests/lint_dockerfile.py +++ b/tests/lint_dockerfile.py @@ -9,6 +9,9 @@ logging.info("Checking `Dockerfile` files...") for filename in glob.glob(f"{repo_dir}/*_ws/docker/Dockerfile*"): + # Global ignore + if any(ws in filename for ws in os.getenv('IGNORED_WORKSPACES', '').split()): + continue logging.debug(f"Checking: '{filename[len(repo_dir)+1:]}'...") # Skip certain cases intentionally if "ros1_bridge_ws" in filename: diff --git a/tests/lint_filenames.py b/tests/lint_filenames.py index a09b7f98..70fd76f4 100644 --- a/tests/lint_filenames.py +++ b/tests/lint_filenames.py @@ -19,6 +19,9 @@ for filename in DEFAULT_FILES: logging.debug(f"Checking existence of: '{filename}'...") for workspace_path in glob.glob(f"{repo_dir}/*_ws"): + # Global ignore + if any(ws in workspace_path for ws in os.getenv('IGNORED_WORKSPACES', '').split()): + continue if not os.path.isfile(f"{workspace_path}/{filename}"): # Skip certain cases intentionally if filename in (".gitignore", "docker/.bashrc") and os.path.basename(workspace_path) == "ros1_bridge_ws": @@ -37,5 +40,8 @@ for filename in OBSOLETE_FILES: logging.debug(f"Checking non-existence of: '{filename}'...") for workspace_path in glob.glob(f"{repo_dir}/*_ws"): + # Global ignore + if any(ws in workspace_path for ws in os.getenv('IGNORED_WORKSPACES', '').split()): + continue if os.path.isfile(f"{workspace_path}/{filename}"): raise ValueError(f"'{filename}' exists in: '{workspace_path}'") diff --git a/tests/lint_gitignore.py b/tests/lint_gitignore.py index da2a26c6..c93a2e83 100644 --- a/tests/lint_gitignore.py +++ b/tests/lint_gitignore.py @@ -9,6 +9,9 @@ logging.info("Checking `.gitignore` files...") for filename in glob.glob(f"{repo_dir}/*_ws/.gitignore"): + # Global ignore + if any(ws in filename for ws in os.getenv('IGNORED_WORKSPACES', '').split()): + continue logging.debug(f"Checking: '{filename[len(repo_dir)+1:]}'...") content = Path(filename).read_text() if "gazebo" in content: diff --git a/tests/lint_readme.py b/tests/lint_readme.py index 5a8277e3..19eb38f2 100644 --- a/tests/lint_readme.py +++ b/tests/lint_readme.py @@ -9,6 +9,9 @@ logging.info("Checking `README.md` files...") for filename in glob.glob(f"{repo_dir}/*_ws/README.md"): + # Global ignore + if any(ws in filename for ws in os.getenv('IGNORED_WORKSPACES', '').split()): + continue logging.debug(f"Checking: '{filename[len(repo_dir)+1:]}'...") content = Path(filename).read_text() if "ros2-agv-essentials" in content: diff --git a/tests/test_all.sh b/tests/test_all.sh index 2b32c34f..3952858b 100755 --- a/tests/test_all.sh +++ b/tests/test_all.sh @@ -4,6 +4,7 @@ # Reference: https://stackoverflow.com/q/59895 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)" cd $SCRIPT_DIR +# export IGNORED_WORKSPACES="temp_ws tmp_ws" # Loop through all Python files in the current directory for script in *.py; do echo "Running $script..." From 343e3f1d8e95a65dee0694d5577e79e284acdecd Mon Sep 17 00:00:00 2001 From: Johnson Sun Date: Tue, 17 Sep 2024 02:53:15 +0800 Subject: [PATCH 2/7] test: Update test to follow aloha-ws --- tests/diff_base/docker/.bashrc | 24 +++++++++- tests/diff_base/docker/Dockerfile | 61 +++++++++++++++++++----- tests/diff_base/docker/compose.yaml | 72 +++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+), 13 deletions(-) diff --git a/tests/diff_base/docker/.bashrc b/tests/diff_base/docker/.bashrc index a91c4e83..28a04289 100644 --- a/tests/diff_base/docker/.bashrc +++ b/tests/diff_base/docker/.bashrc @@ -1,4 +1,13 @@ {PLACEHOLDER_MULTILINE} +# 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 @@ -10,13 +19,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 ` 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 @@ -26,7 +36,17 @@ if [ ! -f $ROS2_WS/install/setup.bash ]; then fi echo "Workspace built." fi +# Source gazebo environment +{PLACEHOLDER_MULTILINE} +# 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 {PLACEHOLDER_MULTILINE} +# Agree Isaac Sim EULA +# Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_python.html#running-isaac-sim +export OMNI_KIT_ACCEPT_EULA=YES # Source workspace environment source $ROS2_WS/install/setup.bash +echo "Successfully built workspace and configured environment variables." diff --git a/tests/diff_base/docker/Dockerfile b/tests/diff_base/docker/Dockerfile index 6c9c8594..a9242ee3 100644 --- a/tests/diff_base/docker/Dockerfile +++ b/tests/diff_base/docker/Dockerfile @@ -25,7 +25,7 @@ RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloa RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ apt-get update && apt-get upgrade -y \ && rm -rf /var/lib/apt/lists/* -{PLACEHOLDER_MULTILINE} + # Install sudo and create a user with sudo privileges # Ref: https://stackoverflow.com/a/65434659 RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ @@ -57,12 +57,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 < Date: Tue, 17 Sep 2024 04:12:51 +0800 Subject: [PATCH 3/7] feat(template_ws): Update template to follow aloha-ws (with Isaac Sim support) --- template_ws/docker/.bashrc | 23 ++++++++++- template_ws/docker/Dockerfile | 59 ++++++++++++++++++++++----- template_ws/docker/compose.yaml | 72 +++++++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+), 12 deletions(-) diff --git a/template_ws/docker/.bashrc b/template_ws/docker/.bashrc index ed090d4a..af73453e 100644 --- a/template_ws/docker/.bashrc +++ b/template_ws/docker/.bashrc @@ -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 @@ -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 ` 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 @@ -25,6 +35,15 @@ 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 +# Agree Isaac Sim EULA +# Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_python.html#running-isaac-sim +export OMNI_KIT_ACCEPT_EULA=YES # Source workspace environment source $ROS2_WS/install/setup.bash +echo "Successfully built workspace and configured environment variables." diff --git a/template_ws/docker/Dockerfile b/template_ws/docker/Dockerfile index f7173a6f..168fc24d 100644 --- a/template_ws/docker/Dockerfile +++ b/template_ws/docker/Dockerfile @@ -57,12 +57,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 < Date: Tue, 17 Sep 2024 18:46:08 +0800 Subject: [PATCH 4/7] test: Add check to prevent accident copy of PLACEHOLDER --- tests/lint_compose.py | 2 ++ tests/lint_dockerfile.py | 2 ++ tests/lint_gitignore.py | 2 ++ tests/lint_readme.py | 2 ++ 4 files changed, 8 insertions(+) diff --git a/tests/lint_compose.py b/tests/lint_compose.py index 88237288..f204af9c 100644 --- a/tests/lint_compose.py +++ b/tests/lint_compose.py @@ -17,3 +17,5 @@ if "version:" in content: # Ref: https://docs.docker.com/compose/compose-file/04-version-and-name/#version-top-level-element-optional raise ValueError(f"`version` should not exist since it's obsolete: '{filename}'") + if "PLACEHOLDER" in content: + raise ValueError(f"`PLACEHOLDER` should not exist: '{filename}'") diff --git a/tests/lint_dockerfile.py b/tests/lint_dockerfile.py index cab03cd5..63d1c7f6 100644 --- a/tests/lint_dockerfile.py +++ b/tests/lint_dockerfile.py @@ -29,3 +29,5 @@ raise ValueError(f"`RUN apt-get install` should not exist, use with `apt-get update` instead: '{filename}'") if " apt-get install" in content: raise ValueError(f"` apt-get install` should not exist, use with `apt-get update` in the same line instead: '{filename}'") + if "PLACEHOLDER" in content: + raise ValueError(f"`PLACEHOLDER` should not exist: '{filename}'") diff --git a/tests/lint_gitignore.py b/tests/lint_gitignore.py index c93a2e83..0714ed83 100644 --- a/tests/lint_gitignore.py +++ b/tests/lint_gitignore.py @@ -18,3 +18,5 @@ raise ValueError(f"`gazebo` should not exist since it's obsolete: '{filename}'") if "docker/cache" in content: raise ValueError(f"`docker/cache` should not exist since it's obsolete: '{filename}'") + if "PLACEHOLDER" in content: + raise ValueError(f"`PLACEHOLDER` should not exist: '{filename}'") diff --git a/tests/lint_readme.py b/tests/lint_readme.py index 19eb38f2..3c4ecb07 100644 --- a/tests/lint_readme.py +++ b/tests/lint_readme.py @@ -16,3 +16,5 @@ content = Path(filename).read_text() if "ros2-agv-essentials" in content: raise ValueError(f"`ros2-agv-essentials` should not exist, use `ros2-essentials` instead: '{filename}'") + if "PLACEHOLDER" in content: + raise ValueError(f"`PLACEHOLDER` should not exist: '{filename}'") From 38abe8ec5cae4b89cea6063a4a5768535c3a11ed Mon Sep 17 00:00:00 2001 From: Johnson Sun Date: Tue, 17 Sep 2024 18:57:27 +0800 Subject: [PATCH 5/7] refactor: Unify `docker/.bashrc` across all workspaces --- cartographer_ws/docker/.bashrc | 26 ++++++++++++++++++++++++-- gazebo_world_ws/docker/.bashrc | 29 +++++++++++++++++++++++------ husky_ws/docker/.bashrc | 28 +++++++++++++++++++++++++--- kobuki_ws/docker/.bashrc | 26 ++++++++++++++++++++++++-- orbslam3_ws/docker/.bashrc | 28 +++++++++++++++++++++++++--- rtabmap_ws/docker/.bashrc | 26 ++++++++++++++++++++++++-- template_ws/docker/.bashrc | 5 ++++- tests/diff_base/docker/.bashrc | 5 ++++- vlp_ws/docker/.bashrc | 26 ++++++++++++++++++++++++-- 9 files changed, 177 insertions(+), 22 deletions(-) diff --git a/cartographer_ws/docker/.bashrc b/cartographer_ws/docker/.bashrc index ed090d4a..2f0726eb 100644 --- a/cartographer_ws/docker/.bashrc +++ b/cartographer_ws/docker/.bashrc @@ -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 @@ -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 ` 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 @@ -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." diff --git a/gazebo_world_ws/docker/.bashrc b/gazebo_world_ws/docker/.bashrc index 8e92c030..2f0726eb 100644 --- a/gazebo_world_ws/docker/.bashrc +++ b/gazebo_world_ws/docker/.bashrc @@ -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 @@ -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 ` 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 @@ -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." diff --git a/husky_ws/docker/.bashrc b/husky_ws/docker/.bashrc index 1f680580..7065e313 100644 --- a/husky_ws/docker/.bashrc +++ b/husky_ws/docker/.bashrc @@ -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 @@ -9,26 +18,39 @@ 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 ` 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 - colcon build --symlink-install + colcon build --symlink-install --packages-ignore velodyne_gazebo_plugins else colcon build --symlink-install 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 # Source Clearpath robot environment source ~/husky_driver_ws/install/local_setup.bash # Source Clearpath default environment installed by `clearpath_computer_installer.sh` source /etc/clearpath/setup.bash +# 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." diff --git a/kobuki_ws/docker/.bashrc b/kobuki_ws/docker/.bashrc index 2641d9fb..478f54b2 100644 --- a/kobuki_ws/docker/.bashrc +++ b/kobuki_ws/docker/.bashrc @@ -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 @@ -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 ` 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 @@ -25,8 +35,20 @@ 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 # Source kobuki driver workspace environment source ~/kobuki_driver_ws/install/local_setup.bash +# 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." diff --git a/orbslam3_ws/docker/.bashrc b/orbslam3_ws/docker/.bashrc index 0fc8a65e..9a94de6a 100644 --- a/orbslam3_ws/docker/.bashrc +++ b/orbslam3_ws/docker/.bashrc @@ -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 @@ -9,23 +18,36 @@ 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 ` 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 - colcon build --symlink-install + colcon build --symlink-install --packages-ignore velodyne_gazebo_plugins else colcon build --symlink-install 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 source ~/test_ws/install/local_setup.bash +# 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." diff --git a/rtabmap_ws/docker/.bashrc b/rtabmap_ws/docker/.bashrc index ed090d4a..2f0726eb 100644 --- a/rtabmap_ws/docker/.bashrc +++ b/rtabmap_ws/docker/.bashrc @@ -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 @@ -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 ` 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 @@ -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." diff --git a/template_ws/docker/.bashrc b/template_ws/docker/.bashrc index af73453e..2f0726eb 100644 --- a/template_ws/docker/.bashrc +++ b/template_ws/docker/.bashrc @@ -41,8 +41,11 @@ if [ $(arch) == "x86_64" ]; then source /usr/share/gazebo/setup.bash fi # TODO: Source other workspace environments as underlay -# Agree Isaac Sim EULA +# 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 diff --git a/tests/diff_base/docker/.bashrc b/tests/diff_base/docker/.bashrc index 28a04289..fc239929 100644 --- a/tests/diff_base/docker/.bashrc +++ b/tests/diff_base/docker/.bashrc @@ -44,8 +44,11 @@ if [ $(arch) == "x86_64" ]; then fi # TODO: Source other workspace environments as underlay {PLACEHOLDER_MULTILINE} -# Agree Isaac Sim EULA +# 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 diff --git a/vlp_ws/docker/.bashrc b/vlp_ws/docker/.bashrc index d8352e3e..9e7767a4 100644 --- a/vlp_ws/docker/.bashrc +++ b/vlp_ws/docker/.bashrc @@ -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 @@ -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 ` 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 @@ -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." From 13d24f3371a3ccc93890818ee1f745a66984cb33 Mon Sep 17 00:00:00 2001 From: Johnson Sun Date: Tue, 17 Sep 2024 19:10:46 +0800 Subject: [PATCH 6/7] refactor: Unify docker compose files across all workspaces --- cartographer_ws/docker/compose.yaml | 74 +++++++++++++++++++++++++++++ gazebo_world_ws/docker/compose.yaml | 74 +++++++++++++++++++++++++++++ husky_ws/docker/compose.yaml | 74 +++++++++++++++++++++++++++++ kobuki_ws/docker/compose.yaml | 74 +++++++++++++++++++++++++++++ orbslam3_ws/docker/compose.yaml | 74 +++++++++++++++++++++++++++++ rtabmap_ws/docker/compose.yaml | 74 +++++++++++++++++++++++++++++ template_ws/docker/compose.yaml | 8 ++-- tests/diff_base/docker/compose.yaml | 8 ++-- vlp_ws/docker/compose.yaml | 74 +++++++++++++++++++++++++++++ 9 files changed, 528 insertions(+), 6 deletions(-) diff --git a/cartographer_ws/docker/compose.yaml b/cartographer_ws/docker/compose.yaml index cb079eb1..62d0267c 100644 --- a/cartographer_ws/docker/compose.yaml +++ b/cartographer_ws/docker/compose.yaml @@ -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 @@ -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 diff --git a/gazebo_world_ws/docker/compose.yaml b/gazebo_world_ws/docker/compose.yaml index 06a3b140..6cb0eefb 100644 --- a/gazebo_world_ws/docker/compose.yaml +++ b/gazebo_world_ws/docker/compose.yaml @@ -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 gazebo-world-ws: + depends_on: + - volume-instantiation build: context: . dockerfile: Dockerfile @@ -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 diff --git a/husky_ws/docker/compose.yaml b/husky_ws/docker/compose.yaml index 8bb97b10..7bc5176b 100644 --- a/husky_ws/docker/compose.yaml +++ b/husky_ws/docker/compose.yaml @@ -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 husky-ws: + depends_on: + - volume-instantiation build: context: . dockerfile: Dockerfile @@ -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 diff --git a/kobuki_ws/docker/compose.yaml b/kobuki_ws/docker/compose.yaml index 7471d5f6..22be28ab 100644 --- a/kobuki_ws/docker/compose.yaml +++ b/kobuki_ws/docker/compose.yaml @@ -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 kobuki-ws: + depends_on: + - volume-instantiation build: context: . dockerfile: Dockerfile @@ -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 diff --git a/orbslam3_ws/docker/compose.yaml b/orbslam3_ws/docker/compose.yaml index 88a94a74..95a97e48 100644 --- a/orbslam3_ws/docker/compose.yaml +++ b/orbslam3_ws/docker/compose.yaml @@ -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 orbslam3-ws: + depends_on: + - volume-instantiation build: context: . dockerfile: Dockerfile @@ -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 diff --git a/rtabmap_ws/docker/compose.yaml b/rtabmap_ws/docker/compose.yaml index e0392a3c..fe23699b 100644 --- a/rtabmap_ws/docker/compose.yaml +++ b/rtabmap_ws/docker/compose.yaml @@ -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 rtabmap-ws: + depends_on: + - volume-instantiation build: context: . dockerfile: Dockerfile @@ -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 diff --git a/template_ws/docker/compose.yaml b/template_ws/docker/compose.yaml index 168a4d46..71f91389 100644 --- a/template_ws/docker/compose.yaml +++ b/template_ws/docker/compose.yaml @@ -6,6 +6,8 @@ services: 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 @@ -90,7 +92,7 @@ services: source: isaac-sim-cache target: /home/user/.local/lib/python3.10/site-packages/omni/cache # For Isaac Sim standalone volume: - subpath: cache/ov + subpath: standalone/cache/ov - type: volume source: isaac-sim-cache target: /home/user/.cache/pip @@ -115,7 +117,7 @@ services: source: isaac-sim-cache target: /home/user/.local/lib/python3.10/site-packages/omni/logs # For Isaac Sim standalone volume: - subpath: logs + subpath: standalone/logs - type: volume source: isaac-sim-cache target: /home/user/.local/share/ov/data @@ -125,7 +127,7 @@ services: source: isaac-sim-cache target: /home/user/.local/lib/python3.10/site-packages/omni/data # For Isaac Sim standalone volume: - subpath: data + subpath: standalone/data - type: volume source: isaac-sim-cache target: /home/user/Documents diff --git a/tests/diff_base/docker/compose.yaml b/tests/diff_base/docker/compose.yaml index cf4cea07..7f56b391 100644 --- a/tests/diff_base/docker/compose.yaml +++ b/tests/diff_base/docker/compose.yaml @@ -6,6 +6,8 @@ services: 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 @@ -91,7 +93,7 @@ services: source: isaac-sim-cache target: /home/user/.local/lib/python3.10/site-packages/omni/cache # For Isaac Sim standalone volume: - subpath: cache/ov + subpath: standalone/cache/ov - type: volume source: isaac-sim-cache target: /home/user/.cache/pip @@ -116,7 +118,7 @@ services: source: isaac-sim-cache target: /home/user/.local/lib/python3.10/site-packages/omni/logs # For Isaac Sim standalone volume: - subpath: logs + subpath: standalone/logs - type: volume source: isaac-sim-cache target: /home/user/.local/share/ov/data @@ -126,7 +128,7 @@ services: source: isaac-sim-cache target: /home/user/.local/lib/python3.10/site-packages/omni/data # For Isaac Sim standalone volume: - subpath: data + subpath: standalone/data - type: volume source: isaac-sim-cache target: /home/user/Documents diff --git a/vlp_ws/docker/compose.yaml b/vlp_ws/docker/compose.yaml index 364ae7ae..c3da2547 100644 --- a/vlp_ws/docker/compose.yaml +++ b/vlp_ws/docker/compose.yaml @@ -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 vlp-ws: + depends_on: + - volume-instantiation build: context: . dockerfile: Dockerfile @@ -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 From c2da952af0bba09ae6fb168cdf8864d7e3f2d2fa Mon Sep 17 00:00:00 2001 From: Johnson Sun Date: Tue, 17 Sep 2024 19:40:00 +0800 Subject: [PATCH 7/7] refactor: Unify docker files across all workspaces --- cartographer_ws/docker/Dockerfile | 66 ++++++++++++++++++++++------ gazebo_world_ws/docker/Dockerfile | 59 ++++++++++++++++++++----- husky_ws/docker/Dockerfile | 67 ++++++++++++++++++++++------ kobuki_ws/docker/Dockerfile | 68 ++++++++++++++++++++++------- orbslam3_ws/docker/Dockerfile | 67 ++++++++++++++++++++++------ rtabmap_ws/docker/Dockerfile | 72 ++++++++++++++++++++++++------- vlp_ws/docker/Dockerfile | 70 +++++++++++++++++++++++------- 7 files changed, 372 insertions(+), 97 deletions(-) diff --git a/cartographer_ws/docker/Dockerfile b/cartographer_ws/docker/Dockerfile index f6e5178c..e7dd7b17 100644 --- a/cartographer_ws/docker/Dockerfile +++ b/cartographer_ws/docker/Dockerfile @@ -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 < /etc/vulkan/icd.d/nvidia_icd.json < /etc/vulkan/icd.d/nvidia_icd.json < /etc/vulkan/icd.d/nvidia_icd.json < /etc/vulkan/icd.d/nvidia_icd.json < /etc/vulkan/icd.d/nvidia_icd.json < /etc/vulkan/icd.d/nvidia_icd.json <