Skip to content

Commit

Permalink
feat(aloha_ws): Create aloha_ws
Browse files Browse the repository at this point in the history
Using the `create_workspace.sh` script, and remove `minimal_pkg`
  • Loading branch information
j3soon committed Aug 19, 2024
1 parent 443c2bb commit 6f8835d
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 0 deletions.
25 changes: 25 additions & 0 deletions aloha_ws/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* Reference: https://aka.ms/devcontainer.json */
{
"name": "aloha-ws",
"dockerComposeFile": "../docker/compose.yaml",
"service": "aloha-ws",
// workspace settings
"workspaceFolder": "/home/ros2-agv-essentials/aloha_ws",
// Vscode extensions
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cpptools-themes",
"twxs.cmake",
"donjayamanne.python-extension-pack",
"eamodio.gitlens",
"mhutchie.git-graph",
"streetsidesoftware.code-spell-checker",
"ms-iot.vscode-ros"
]
}
},
// Lifecycle scripts
"postCreateCommand": "${containerWorkspaceFolder}/.devcontainer/postCreateCommand.sh"
}
6 changes: 6 additions & 0 deletions aloha_ws/.devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sudo apt-get update
sudo rosdep update
# Note: The following commands are commented out to prevent unintended install/builds.
# sudo rosdep install --from-paths src --ignore-src -y
# sudo chown -R user /home/ros2-agv-essentials/
# colcon build
12 changes: 12 additions & 0 deletions aloha_ws/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.vscode

# ROS2 basic directories
/build
/install
/log

# Gazebo cache
docker/cache/*
!docker/cache/.gazebo
docker/cache/.gazebo/*
!docker/cache/.gazebo/.gitkeep
1 change: 1 addition & 0 deletions aloha_ws/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# aloha_ws
5 changes: 5 additions & 0 deletions aloha_ws/docker/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Source global ROS2 environment
source /opt/ros/$ROS_DISTRO/setup.bash
# Source workspace environment
# Note: If you have not built your workspace yet, the following command will fail
source $ROS2_WS/install/setup.bash
2 changes: 2 additions & 0 deletions aloha_ws/docker/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.bashrc
52 changes: 52 additions & 0 deletions aloha_ws/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Base Image : https://hub.docker.com/r/osrf/ros/tags?page=1&name=humble
FROM osrf/ros:humble-desktop-full

LABEL org.opencontainers.image.authors="yuzhong1214@gmail.com"

ARG USERNAME=user
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
#
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get upgrade -y \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y python3-pip \
&& rm -rf /var/lib/apt/lists/*
ENV SHELL /bin/bash

# ********************************************************
# * Anything else you want to do like clean up goes here *
# ********************************************************

# Install common tools
RUN apt-get update && apt-get install -y \
curl \
git \
git-extras \
htop \
net-tools \
tmux \
vim \
wget \
&& rm -rf /var/lib/apt/lists/*

# Install ROS2 RVIZ and Gazebo
RUN apt-get update && apt-get install -y \
ros-$ROS_DISTRO-gazebo-ros-pkgs \
ros-$ROS_DISTRO-rviz2 \
&& rm -rf /var/lib/apt/lists/*

COPY .bashrc /home/$USERNAME/.bashrc

# [Optional] Set the default user. Omit if you want to keep the default as root.
USER $USERNAME
CMD ["/bin/bash"]
Empty file.
53 changes: 53 additions & 0 deletions aloha_ws/docker/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
services:
aloha-ws:
build: .
image: j3soon/ros2-aloha-ws
container_name: ros2-aloha-ws
stdin_open: true
tty: true
privileged: true
command: /bin/bash
network_mode: host
working_dir: /home/ros2-agv-essentials/aloha_ws
environment:
- DISPLAY=${DISPLAY}
# 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
# - https://docs.ros.org/en/humble/Tutorials/Demos/Logging-and-logger-configuration.html#console-output-colorizing
- ROS_LOCALHOST_ONLY=1
- ROS_DOMAIN_ID=42
- ROS2_WS=/home/ros2-agv-essentials/aloha_ws
- RCUTILS_COLORIZED_OUTPUT=1
# If you want to access GPU, please uncomment the lines below.
# Reference : https://docs.docker.com/compose/gpu-support/
# deploy:
# resources:
# reservations:
# devices:
# - driver: nvidia
# count: all
# capabilities: [ gpu ]
volumes:
# Mount local timezone into container. ( Readonly )
# Reference: https://stackoverflow.com/questions/57607381/how-do-i-change-timezone-in-a-docker-container
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
# Mount X11 server
- /tmp/.X11-unix:/tmp/.X11-unix
- $HOME/.Xauthority:/home/user/.Xauthority
# Direct Rendering Infrastructure
- /dev/dri:/dev/dri
# Mount sound card to prevent Gazebo warning.
- /dev/snd:/dev/snd
# Mount Gazebo models directory to reuse models downloaded during first launch.
# Reference: https://answers.ros.org/question/365658
- ./cache/.gazebo:/home/user/.gazebo
# Mounting the following directories will forbid direct deletion.
# Consider mount these directories only if the build process is slow.
# "source=${localWorkspaceFolder}/../cache/humble/build,target=/home/ws/build,type=bind",
# "source=${localWorkspaceFolder}/../cache/humble/install,target=/home/ws/install,type=bind",
# "source=${localWorkspaceFolder}/../cache/humble/log,target=/home/ws/log,type=bind"
# Mount workspace
- ../..:/home/ros2-agv-essentials

0 comments on commit 6f8835d

Please sign in to comment.