Skip to content

Commit 0a04aa5

Browse files
committed
refactor(isaac_sim_ws): Sync style with latest template
1 parent 51fbb5f commit 0a04aa5

File tree

9 files changed

+194
-84
lines changed

9 files changed

+194
-84
lines changed
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* Reference: https://aka.ms/devcontainer.json */
22
{
3-
"name": "isaac-sim-ws",
3+
"name": "Isaac Sim",
44
"dockerComposeFile": "../docker/compose.yaml",
55
"service": "isaac-sim-ws",
6-
// workspace settings
7-
"workspaceFolder": "/home/ros2-agv-essentials/isaac_sim_ws",
6+
// Workspace settings
7+
"workspaceFolder": "/home/ros2-essentials/isaac_sim_ws",
88
// Vscode extensions
99
"customizations": {
1010
"vscode": {
@@ -19,7 +19,5 @@
1919
"ms-iot.vscode-ros"
2020
]
2121
}
22-
},
23-
// Lifecycle scripts
24-
"postCreateCommand": "${containerWorkspaceFolder}/.devcontainer/postCreateCommand.sh"
25-
}
22+
}
23+
}

isaac_sim_ws/.devcontainer/postCreateCommand.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

isaac_sim_ws/.gitignore

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1+
# Visual Studio Code
12
.vscode
23

34
# ROS2 basic directories
45
/build
56
/install
67
/log
7-
8-
# Gazebo cache
9-
docker/cache/*
10-
!docker/cache/.gazebo
11-
docker/cache/.gazebo/*
12-
!docker/cache/.gazebo/.gitkeep

isaac_sim_ws/docker/.bashrc

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# Source global ROS2 environment
22
source /opt/ros/$ROS_DISTRO/setup.bash
3+
# Optionally perform apt update if it has not been executed yet
4+
if [ -z "$( ls -A '/var/lib/apt/lists' )" ]; then
5+
echo "apt-get update has not been executed yet. Running sudo apt-get update..."
6+
sudo apt-get update
7+
fi
8+
# Optionally perform rosdep update if it has not been executed yet
9+
if [ ! -d $HOME/.ros/rosdep/sources.cache ]; then
10+
echo "rosdep update has not been executed yet. Running rosdep update..."
11+
rosdep update
12+
fi
13+
# Optionally build the workspace if it has not been built yet
14+
if [ ! -f $ROS2_WS/install/setup.bash ]; then
15+
echo "Workspace has not been built yet. Building workspace..."
16+
cd $ROS2_WS
17+
# Ref: https://docs.ros.org/en/humble/Tutorials/Intermediate/Rosdep.html
18+
rosdep install --from-paths src --ignore-src -y -r
19+
# TODO: If command `arch` outputs `aarch64`, consider adding `--packages-ignore <package>` to ignore x86 packages
20+
# Ref: https://docs.ros.org/en/humble/Tutorials/Beginner-Client-Libraries/Creating-Your-First-ROS2-Package.html
21+
if [ $(arch) == "aarch64" ]; then
22+
colcon build --symlink-install
23+
else
24+
colcon build --symlink-install
25+
fi
26+
echo "Workspace built."
27+
fi
28+
# TODO: Source other workspace environments as underlay
329
# Source workspace environment
4-
# Note: If you have not built your workspace yet, the following command will fail
530
source $ROS2_WS/install/setup.bash

isaac_sim_ws/docker/Dockerfile

Lines changed: 111 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,44 @@
1-
FROM nvcr.io/nvidia/isaac-sim:4.1.0
1+
# Base Image: https://catalog.ngc.nvidia.com/orgs/nvidia/containers/isaac-sim/tags
2+
FROM nvcr.io/nvidia/isaac-sim:4.1.0 AS amd64
3+
# Base Image: https://catalog.ngc.nvidia.com/orgs/nvidia/containers/isaac-sim/tags
4+
FROM nvcr.io/nvidia/isaac-sim:4.1.0 AS arm64
5+
6+
# Use docker automatic platform args to select the base image.
7+
# It may be `arm64` or `amd64` depending on the platform.
8+
# Ref: https://docs.docker.com/reference/dockerfile/#automatic-platform-args-in-the-global-scope
9+
FROM $TARGETARCH
10+
ARG TARGETARCH
11+
12+
# Arguments for the default user
13+
ARG USERNAME=user
14+
ARG USER_UID=1000
15+
16+
# Keep downloaded packages for caching purposes
17+
# Ref: https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/reference.md#example-cache-apt-packages
18+
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
19+
20+
# Upgrade packages
21+
# Ref: https://pythonspeed.com/articles/security-updates-in-docker/
22+
# Ref: https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/reference.md#example-cache-apt-packages
23+
# Ref: https://github.com/moby/buildkit/issues/1673#issuecomment-1264502398
24+
# Ref: https://github.com/moby/buildkit/issues/1673#issuecomment-1987107404
25+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
26+
apt-get update && apt-get upgrade -y \
27+
&& rm -rf /var/lib/apt/lists/*
228

329
# Ref: https://github.com/j3soon/docker-ros-humble-desktop-full/blob/master/Dockerfile
430

531
# ros-core
632
# Ref: https://github.com/osrf/docker_images/blob/master/ros/humble/ubuntu/jammy/ros-core/Dockerfile
733
# setup timezone
8-
RUN echo 'Etc/UTC' > /etc/timezone && \
34+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
35+
echo 'Etc/UTC' > /etc/timezone && \
936
# ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime && \
10-
apt-get update && \
11-
apt-get install -q -y --no-install-recommends tzdata && \
37+
apt-get update && apt-get install -q -y --no-install-recommends tzdata && \
1238
rm -rf /var/lib/apt/lists/*
1339
# install packages
14-
RUN apt-get update && apt-get install -q -y --no-install-recommends \
40+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
41+
apt-get update && apt-get install -q -y --no-install-recommends \
1542
dirmngr \
1643
gnupg2 \
1744
&& rm -rf /var/lib/apt/lists/*
@@ -24,14 +51,16 @@ ENV LANG C.UTF-8
2451
ENV LC_ALL C.UTF-8
2552
ENV ROS_DISTRO humble
2653
# install ros2 packages
27-
RUN apt-get update && apt-get install -y --no-install-recommends \
28-
ros-humble-ros-core=0.10.0-1* \
54+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
55+
apt-get update && apt-get install -y --no-install-recommends \
56+
ros-$ROS_DISTRO-ros-core=0.10.0-1* \
2957
&& rm -rf /var/lib/apt/lists/*
3058

3159
# ros-base
3260
# Ref: https://github.com/osrf/docker_images/blob/master/ros/humble/ubuntu/jammy/ros-base/Dockerfile
3361
# install bootstrap tools
34-
RUN apt-get update && apt-get install --no-install-recommends -y \
62+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
63+
apt-get update && apt-get install --no-install-recommends -y \
3564
build-essential \
3665
git \
3766
python3-colcon-common-extensions \
@@ -50,51 +79,105 @@ RUN colcon mixin add default \
5079
https://raw.githubusercontent.com/colcon/colcon-metadata-repository/master/index.yaml && \
5180
colcon metadata update
5281
# install ros2 packages
53-
RUN apt-get update && apt-get install -y --no-install-recommends \
54-
ros-humble-ros-base=0.10.0-1* \
82+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
83+
apt-get update && apt-get install -y --no-install-recommends \
84+
ros-$ROS_DISTRO-ros-base=0.10.0-1* \
5585
&& rm -rf /var/lib/apt/lists/*
5686

5787
# ros-desktop
5888
# Ref: https://github.com/osrf/docker_images/blob/master/ros/humble/ubuntu/jammy/desktop/Dockerfile
5989
# install ros2 packages
60-
RUN apt-get update && apt-get install -y --no-install-recommends \
61-
ros-humble-desktop=0.10.0-1* \
90+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
91+
apt-get update && apt-get install -y --no-install-recommends \
92+
ros-$ROS_DISTRO-desktop=0.10.0-1* \
6293
&& rm -rf /var/lib/apt/lists/*
6394

6495
# ros-desktop-full
6596
# Ref: https://github.com/osrf/docker_images/blob/master/ros/humble/ubuntu/jammy/desktop-full/Dockerfile
6697
# install ros2 packages
67-
RUN apt-get update && apt-get install -y --no-install-recommends \
68-
ros-humble-desktop-full=0.10.0-1* \
69-
&& rm -rf /var/lib/apt/lists/*
70-
71-
# Isaac Sim ROS 2 Optional Dependencies
72-
# Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_ros.html#running-native-ros
73-
RUN apt-get update && apt-get install -y --no-install-recommends \
74-
ros-humble-vision-msgs \
75-
ros-humble-ackermann-msgs \
98+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
99+
apt-get update && apt-get install -y --no-install-recommends \
100+
ros-$ROS_DISTRO-desktop-full=0.10.0-1* \
76101
&& rm -rf /var/lib/apt/lists/*
77102

78-
# Reset isaac sim docker image entrypoint
79-
ENTRYPOINT []
80-
81103
# ros-core
82104
# Ref: https://github.com/osrf/docker_images/blob/master/ros/humble/ubuntu/jammy/ros-core/Dockerfile
83105
# setup entrypoint
84106
# COPY ./thirdparty/ros_entrypoint.sh /
85107
# ENTRYPOINT ["/ros_entrypoint.sh"]
86-
CMD ["bash"]
108+
# CMD ["bash"]
109+
110+
# Install sudo and create a user with sudo privileges
111+
# Ref: https://stackoverflow.com/a/65434659
112+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
113+
apt-get update && apt-get install -y sudo \
114+
&& useradd -m -s /bin/bash -u $USER_UID -G sudo $USERNAME \
115+
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
116+
&& rm -rf /var/lib/apt/lists/*
87117

88118
# Install common tools
89-
RUN apt-get update && apt-get install -y \
119+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
120+
apt-get update && apt-get install -y \
90121
curl \
91122
git \
92-
git-extras \
93123
htop \
124+
iputils-ping \
125+
nano \
94126
net-tools \
95127
tmux \
128+
tree \
129+
unzip \
96130
vim \
97131
wget \
132+
zip \
98133
&& rm -rf /var/lib/apt/lists/*
99134

100-
COPY .bashrc /root/.bashrc
135+
# Install Python pip
136+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
137+
apt-get update && apt-get install -y \
138+
python3-pip \
139+
&& rm -rf /var/lib/apt/lists/*
140+
141+
# Install custom tools
142+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
143+
apt-get update && apt-get install -y \
144+
git-extras \
145+
&& rm -rf /var/lib/apt/lists/*
146+
147+
# Install ROS2 Gazebo packages for amd64
148+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
149+
if [ "$TARGETARCH" = "amd64" ]; then \
150+
apt-get update && apt-get install -y \
151+
ros-$ROS_DISTRO-gazebo-ros-pkgs \
152+
ros-$ROS_DISTRO-gazebo-ros2-control \
153+
&& rm -rf /var/lib/apt/lists/*; \
154+
fi
155+
156+
# Install ROS2 RVIZ and other custom ROS2 packages
157+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
158+
apt-get update && apt-get install -y \
159+
ros-$ROS_DISTRO-rviz2 \
160+
&& rm -rf /var/lib/apt/lists/*
161+
162+
# TODO: Add more commands here
163+
# For example, to install additional packages, uncomment the following lines and add the package names
164+
# RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
165+
# apt-get update && apt-get install -y \
166+
# $OTHER_PACKAGES \
167+
# && rm -rf /var/lib/apt/lists/*
168+
# Isaac Sim ROS 2 Optional Dependencies
169+
# Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_ros.html#running-native-ros
170+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
171+
apt-get update && apt-get install -y --no-install-recommends \
172+
ros-$ROS_DISTRO-vision-msgs \
173+
ros-$ROS_DISTRO-ackermann-msgs \
174+
&& rm -rf /var/lib/apt/lists/*
175+
176+
USER $USERNAME
177+
# Create Gazebo cache directory with correct ownership to avoid permission issues after volume mount
178+
RUN mkdir /home/$USERNAME/.gazebo
179+
# TODO: Run additional commands as non-root user here
180+
COPY .bashrc /home/$USERNAME/.bashrc
181+
# TODO: Copy additional files here
182+
ENTRYPOINT []
183+
CMD ["/bin/bash"]

isaac_sim_ws/docker/cache/.gazebo/.gitkeep

Whitespace-only changes.

isaac_sim_ws/docker/compose.yaml

Lines changed: 48 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
1-
version: '3'
21
services:
32
isaac-sim-ws:
4-
build: .
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
# TODO: Specify the target platform to build the image, otherwise it will build for the host platform.
7+
# Reference: https://docs.docker.com/compose/compose-file/build/#platforms
8+
# platforms:
9+
# - "linux/arm64"
510
image: j3soon/ros2-isaac-sim-ws
611
container_name: ros2-isaac-sim-ws
712
stdin_open: true
813
tty: true
9-
privileged: true
14+
# TODO: Comment the line below if the workspace don't need to communicate through `/dev/*` devices.
15+
# privileged: true
1016
command: /bin/bash
1117
network_mode: host
12-
working_dir: /home/ros2-agv-essentials/isaac_sim_ws
18+
working_dir: /home/ros2-essentials/isaac_sim_ws
1319
environment:
14-
# Environment vars for isaac sim
15-
# Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_container.html#container-deployment
16-
- ACCEPT_EULA=Y
17-
# - PRIVACY_CONSENT=Y # Data collection is optional.
18-
# Set X11 display
20+
# Set X11 server environment variable for existing display.
1921
- DISPLAY=$DISPLAY
20-
# Set ros2 environment variables.
2122
# References:
2223
# - https://docs.ros.org/en/humble/Concepts/Intermediate/About-Domain-ID.html
2324
# - https://docs.ros.org/en/humble/Tutorials/Beginner-CLI-Tools/Configuring-ROS2-Environment.html
2425
# - https://docs.ros.org/en/humble/Tutorials/Demos/Logging-and-logger-configuration.html#console-output-colorizing
25-
- ROS_LOCALHOST_ONLY=1
26-
- ROS_DOMAIN_ID=42
27-
- ROS2_WS=/home/ros2-agv-essentials/isaac_sim_ws
26+
- ROS_LOCALHOST_ONLY=0
27+
# Localhost only is disabled by default to allow communication with external devices.
28+
- ROS_DOMAIN_ID=0
29+
# Domain ID is set to 0 to allow communication through ros1_bridge.
2830
- RCUTILS_COLORIZED_OUTPUT=1
29-
# Reference : https://docs.docker.com/compose/gpu-support/
31+
- ROS2_WS=/home/ros2-essentials/isaac_sim_ws
32+
# TODO: Add more environment variables here.
33+
# Environment vars for isaac sim
34+
# Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_container.html#container-deployment
35+
- ACCEPT_EULA=Y
36+
# TODO: Uncomment the lines below to enable GPU support.
37+
# Reference: https://docs.docker.com/compose/gpu-support/
3038
deploy:
3139
resources:
3240
reservations:
@@ -35,32 +43,39 @@ services:
3543
count: all
3644
capabilities: [ gpu ]
3745
volumes:
38-
# Mounts for isaac sim
39-
- ~/docker/isaac-sim/cache/kit:/isaac-sim/kit/cache:rw
40-
- ~/docker/isaac-sim/cache/ov:/root/.cache/ov:rw
41-
- ~/docker/isaac-sim/cache/pip:/root/.cache/pip:rw
42-
- ~/docker/isaac-sim/cache/glcache:/root/.cache/nvidia/GLCache:rw
43-
- ~/docker/isaac-sim/cache/computecache:/root/.nv/ComputeCache:rw
44-
- ~/docker/isaac-sim/logs:/root/.nvidia-omniverse/logs:rw
45-
- ~/docker/isaac-sim/data:/root/.local/share/ov/data:rw
46-
- ~/docker/isaac-sim/documents:/root/Documents:rw
47-
# Mount local timezone into container. ( Readonly )
46+
# Mount local timezone into container.
4847
# Reference: https://stackoverflow.com/questions/57607381/how-do-i-change-timezone-in-a-docker-container
4948
- /etc/timezone:/etc/timezone:ro
5049
- /etc/localtime:/etc/localtime:ro
5150
# Mount X11 server
5251
- /tmp/.X11-unix:/tmp/.X11-unix
53-
# Direct Rendering Infrastructure
52+
# X11-unix is mounted to allow GUI applications to display on host.
53+
- $HOME/.Xauthority:/home/user/.Xauthority
54+
# Xauthority is mounted to allow X11 forwarding for remote display.
55+
# Mount Direct Rendering Infrastructure (DRI) for hardware acceleration support such as OpenGL.
5456
- /dev/dri:/dev/dri
5557
# Mount sound card to prevent Gazebo warning.
5658
- /dev/snd:/dev/snd
59+
# Mount shared memory for ROS2 communication.
60+
- /dev/shm:/dev/shm
61+
# TODO: Uncomment the line below and comment out the three entries above to enable USB support.
62+
# - /dev:/dev
5763
# Mount Gazebo models directory to reuse models downloaded during first launch.
5864
# Reference: https://answers.ros.org/question/365658
59-
- ./cache/.gazebo:/home/user/.gazebo
60-
# Mounting the following directories will forbid direct deletion.
61-
# Consider mount these directories only if the build process is slow.
62-
# "source=${localWorkspaceFolder}/../cache/humble/build,target=/home/ws/build,type=bind",
63-
# "source=${localWorkspaceFolder}/../cache/humble/install,target=/home/ws/install,type=bind",
64-
# "source=${localWorkspaceFolder}/../cache/humble/log,target=/home/ws/log,type=bind"
65-
# Mount workspace
66-
- ../..:/home/ros2-agv-essentials
65+
# Note that this volume is shared among all workspaces.
66+
- gazebo-cache:/home/user/.gazebo
67+
# TODO: Add more volume mounts here.
68+
# Mounts for isaac sim
69+
- ~/docker/isaac-sim/cache/kit:/isaac-sim/kit/cache:rw
70+
- ~/docker/isaac-sim/cache/ov:/root/.cache/ov:rw
71+
- ~/docker/isaac-sim/cache/pip:/root/.cache/pip:rw
72+
- ~/docker/isaac-sim/cache/glcache:/root/.cache/nvidia/GLCache:rw
73+
- ~/docker/isaac-sim/cache/computecache:/root/.nv/ComputeCache:rw
74+
- ~/docker/isaac-sim/logs:/root/.nvidia-omniverse/logs:rw
75+
- ~/docker/isaac-sim/data:/root/.local/share/ov/data:rw
76+
- ~/docker/isaac-sim/documents:/root/Documents:rw
77+
# Mount root workspace to allow easy access to all workspaces.
78+
- ../..:/home/ros2-essentials
79+
volumes:
80+
gazebo-cache:
81+
name: ros2-gazebo-cache

tests/diff_base/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloa
2525
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
2626
apt-get update && apt-get upgrade -y \
2727
&& rm -rf /var/lib/apt/lists/*
28-
28+
{PLACEHOLDER_MULTILINE}
2929
# Install sudo and create a user with sudo privileges
3030
# Ref: https://stackoverflow.com/a/65434659
3131
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \

0 commit comments

Comments
 (0)