Skip to content

Commit

Permalink
refactor(gazebo_world_ws): Sync style with latest template
Browse files Browse the repository at this point in the history
  • Loading branch information
j3soon committed Aug 22, 2024
1 parent b5cc9ad commit 4a710c8
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 15 deletions.
6 changes: 3 additions & 3 deletions gazebo_world_ws/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "gazebo-world-ws",
"dockerComposeFile": "../docker/compose.yaml",
"service": "gazebo-world-ws",
// workspace settings
// Workspace settings
"workspaceFolder": "/home/ros2-essentials/gazebo_world_ws",
// Vscode extensions
"customizations": {
Expand All @@ -19,5 +19,5 @@
"ms-iot.vscode-ros"
]
}
},
}
}
}
3 changes: 2 additions & 1 deletion gazebo_world_ws/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Visual Studio Code
.vscode

# ROS2 basic directories
/build
/install
/log
/log
11 changes: 9 additions & 2 deletions gazebo_world_ws/docker/.bashrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Check if the architecture is aarch64
if [ $(arch) == "aarch64" ]; then
echo "Architecture is aarch64, which is not supported by Gazebo. Exiting..."
exit
exit 1
fi
# Source global ROS2 environment
source /opt/ros/$ROS_DISTRO/setup.bash
Expand All @@ -21,8 +21,15 @@ if [ ! -f $ROS2_WS/install/setup.bash ]; then
cd $ROS2_WS
# Ref: https://docs.ros.org/en/humble/Tutorials/Intermediate/Rosdep.html
rosdep install --from-paths src --ignore-src -y -r
colcon build --symlink-install
# 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
colcon build --symlink-install
else
colcon build --symlink-install
fi
echo "Workspace built."
fi
# TODO: Source other workspace environments as underlay
# Source workspace environment
source $ROS2_WS/install/setup.bash
10 changes: 6 additions & 4 deletions gazebo_world_ws/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Base Image : https://hub.docker.com/r/osrf/ros/tags?page=1&name=humble
# Base Image: https://hub.docker.com/r/osrf/ros/tags?page=1&name=humble
FROM osrf/ros:humble-desktop-full AS amd64
# Base Image : https://hub.docker.com/r/arm64v8/ros/tags?page=1&name=humble
# Base Image: https://hub.docker.com/r/arm64v8/ros/tags?page=1&name=humble
FROM arm64v8/ros:humble AS arm64

# Use docker automatic platform args to select the base image.
Expand Down Expand Up @@ -86,8 +86,10 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
# && rm -rf /var/lib/apt/lists/*

USER $USERNAME
COPY .bashrc /home/$USERNAME/.bashrc
# 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 []
CMD ["/bin/bash"]
CMD ["/bin/bash"]
16 changes: 11 additions & 5 deletions gazebo_world_ws/docker/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
version: '3'
services:
gazebo-world-ws:
build:
context: .
dockerfile: Dockerfile
# TODO: Specify the target platform to build the image, otherwise it will build for the host platform.
# Reference: https://docs.docker.com/compose/compose-file/build/#platforms
# platforms:
# - "linux/arm64"
image: j3soon/ros2-gazebo-world-ws
container_name: ros2-gazebo-world-ws
stdin_open: true
Expand All @@ -16,7 +19,6 @@ services:
environment:
# Set X11 server environment variable for existing display.
- DISPLAY=$DISPLAY
# TODO: Set ros2 environment variables.
# References:
# - https://docs.ros.org/en/humble/Concepts/Intermediate/About-Domain-ID.html
# - https://docs.ros.org/en/humble/Tutorials/Beginner-CLI-Tools/Configuring-ROS2-Environment.html
Expand All @@ -27,9 +29,10 @@ services:
# Domain ID is set to 0 to allow communication through ros1_bridge.
- RCUTILS_COLORIZED_OUTPUT=1
- ROS2_WS=/home/ros2-essentials/gazebo_world_ws
# TODO: Add more environment variables here.
# TODO: Uncomment the lines below to enable GPU support.
# # Reference: https://docs.docker.com/compose/gpu-support/
# deploy:
# # Reference : https://docs.docker.com/compose/gpu-support/
# resources:
# reservations:
# devices:
Expand All @@ -50,14 +53,17 @@ services:
- /dev/dri:/dev/dri
# Mount sound card to prevent Gazebo warning.
- /dev/snd:/dev/snd
# Uncomment the line below and comment out the two entries above to enable USB support.
# Mount shared memory for ROS2 communication.
- /dev/shm:/dev/shm
# TODO: Uncomment the line below and comment out the three entries above to enable USB support.
# - /dev:/dev
# Mount Gazebo models directory to reuse models downloaded during first launch.
# Reference: https://answers.ros.org/question/365658
# Note that this volume is shared among all workspaces.
- gazebo-cache:/home/user/.gazebo
# 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
name: ros2-gazebo-cache
1 change: 1 addition & 0 deletions tests/diff_base/docker/.bashrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{PLACEHOLDER_MULTILINE}
# Source global ROS2 environment
source /opt/ros/$ROS_DISTRO/setup.bash
# Optionally perform apt update if it has not been executed yet
Expand Down

0 comments on commit 4a710c8

Please sign in to comment.