Skip to content

Commit

Permalink
Merge pull request #50 from j3soon/refactor/unify-workspace-style
Browse files Browse the repository at this point in the history
Unify workspace style
  • Loading branch information
j3soon authored Aug 22, 2024
2 parents 161585b + ea75147 commit 76d494a
Show file tree
Hide file tree
Showing 79 changed files with 1,472 additions and 590 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-cartographer-ws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build Docker Image for cartographer-ws
on:
push:
branches:
- "master"
- "main"
paths:
- .github/workflows/build-cartographer-ws.yaml
- cartographer_ws/docker/Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-husky-ws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build Docker Image for husky-ws
on:
push:
branches:
- "master"
- "main"
paths:
- .github/workflows/build-husky-ws.yaml
- husky_ws/docker/Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-kobuki-ws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build Docker Image for kobuki-ws
on:
push:
branches:
- "master"
- "main"
paths:
- .github/workflows/build-kobuki-ws.yaml
- kobuki_ws/docker/Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-orbslam3-ws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build Docker Image for orbslam3-ws
on:
push:
branches:
- "master"
- "main"
paths:
- .github/workflows/build-orbslam3-ws.yaml
- orbslam3_ws/docker/Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-ros1-bridge-ws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build Docker Image for ros1-bridge-ws
on:
push:
branches:
- "master"
- "main"
paths:
- .github/workflows/build-ros1-bridge-ws.yaml
- ros1_bridge_ws/docker/Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-rtabmap-ws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build Docker Image for rtabmap-ws
on:
push:
branches:
- "master"
- "main"
paths:
- .github/workflows/build-rtabmap-ws.yaml
- rtabmap_ws/docker/Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-template-ws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build Docker Image for template-ws
on:
push:
branches:
- "master"
- "main"
paths:
- .github/workflows/build-template-ws.yaml
- template_ws/docker/Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-vlp-ws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build Docker Image for vlp-ws
on:
push:
branches:
- "master"
- "main"
paths:
- .github/workflows/build-vlp-ws.yaml
- vlp_ws/docker/Dockerfile
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Lint filenames
run: python tests/lint_filenames.py
- name: Run tests
run: tests/test_all.sh
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ The following Docker images can be pulled by `docker pull <IMAGE_NAME>` or by `d

Pulling the pre-built Docker images can bypass the time-consuming building process (for both docker compose & devcontainers).

| Docker Image | Description | amd64 | arm64 |
|--------------|-------------|-------|-------|
| [j3soon/ros2-template-ws](https://hub.docker.com/r/j3soon/ros2-template-ws/tags) | [`./template_ws`](./template_ws) | ✔️ ||
| [j3soon/ros2-orbslam3-ws](https://hub.docker.com/r/j3soon/ros2-orbslam3-ws/tags) | [`./orbslam3_ws`](./orbslam3_ws) | ✔️ ||
| [j3soon/ros2-rtabmap-ws](https://hub.docker.com/r/j3soon/ros2-rtabmap-ws/tags) | [`./rtabmap_ws`](./rtabmap_ws) | ✔️ ||
| [j3soon/ros2-ros1-bridge-ws](https://hub.docker.com/r/j3soon/ros2-ros1-bridge-ws/tags) | [`./ros1_bridge_ws`](./ros1_bridge_ws) | ✔️ ||
| [j3soon/ros2-ros1-bridge-build-ws](https://hub.docker.com/r/j3soon/ros2-ros1-bridge-build-ws/tags) | [`./ros1_bridge_ws`](./ros1_bridge_ws) | ✔️ ||
| [j3soon/ros2-cartographer-ws](https://hub.docker.com/r/j3soon/ros2-cartographer-ws/tags) | [`./cartographer_ws`](./cartographer_ws) | ✔️ ||
| [j3soon/ros2-husky-ws](https://hub.docker.com/r/j3soon/ros2-husky-ws/tags) | [`./husky_ws`](./husky_ws) | ✔️ | ✔️ |
| [j3soon/ros2-kobuki-ws](https://hub.docker.com/r/j3soon/ros2-kobuki-ws/tags) | [`./kobuki_ws`](./kobuki_ws) | ✔️ | ✔️ |
| [j3soon/ros2-vlp-ws](https://hub.docker.com/r/j3soon/ros2-vlp-ws/tags) | [`./vlp_ws`](./vlp_ws) | ✔️ | ✔️ |
| Docker Image | Description | amd64 | arm64 | Notes |
|--------------|-------------|-------|-------|-------|
| [j3soon/ros2-template-ws](https://hub.docker.com/r/j3soon/ros2-template-ws/tags) | [`./template_ws`](./template_ws) | ✔️ || |
| [j3soon/ros2-orbslam3-ws](https://hub.docker.com/r/j3soon/ros2-orbslam3-ws/tags) | [`./orbslam3_ws`](./orbslam3_ws) | ✔️ || |
| [j3soon/ros2-rtabmap-ws](https://hub.docker.com/r/j3soon/ros2-rtabmap-ws/tags) | [`./rtabmap_ws`](./rtabmap_ws) | ✔️ || |
| [j3soon/ros2-ros1-bridge-ws](https://hub.docker.com/r/j3soon/ros2-ros1-bridge-ws/tags) | [`./ros1_bridge_ws`](./ros1_bridge_ws) | ✔️ || Skip linting |
| [j3soon/ros2-ros1-bridge-build-ws](https://hub.docker.com/r/j3soon/ros2-ros1-bridge-build-ws/tags) | [`./ros1_bridge_ws`](./ros1_bridge_ws) | ✔️ || Skip linting |
| [j3soon/ros2-cartographer-ws](https://hub.docker.com/r/j3soon/ros2-cartographer-ws/tags) | [`./cartographer_ws`](./cartographer_ws) | ✔️ || |
| [j3soon/ros2-husky-ws](https://hub.docker.com/r/j3soon/ros2-husky-ws/tags) | [`./husky_ws`](./husky_ws) | ✔️ | ✔️ | Support real husky |
| [j3soon/ros2-kobuki-ws](https://hub.docker.com/r/j3soon/ros2-kobuki-ws/tags) | [`./kobuki_ws`](./kobuki_ws) | ✔️ | ✔️ | Support real kobuki |
| [j3soon/ros2-vlp-ws](https://hub.docker.com/r/j3soon/ros2-vlp-ws/tags) | [`./vlp_ws`](./vlp_ws) | ✔️ | ✔️ | Support real vlp |

## Contributors

Expand Down
19 changes: 8 additions & 11 deletions cartographer_ws/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/* Reference: https://aka.ms/devcontainer.json */
{
"name": "ROS2 and Catorgrapher Container",
"name": "Catographer",
"dockerComposeFile": "../docker/compose.yaml",
"service": "ros2-cartographer",

// workspace settings
"workspaceFolder": "/home/ros2-agv-essentials/cartographer_ws",

"service": "cartographer-ws",
// Workspace settings
"workspaceFolder": "/home/ros2-essentials/cartographer_ws",
// Vscode extensions
"customizations": {
"vscode": {
Expand All @@ -16,11 +14,10 @@
"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: 0 additions & 6 deletions cartographer_ws/.devcontainer/postCreateCommand.sh

This file was deleted.

7 changes: 3 additions & 4 deletions cartographer_ws/.gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Visual Studio Code
.vscode

# ROS2 basic directories
/build
/install
/log
docker/cache/*
!docker/cache/.gazebo
docker/cache/.gazebo/*
!docker/cache/.gazebo/.gitkeep
6 changes: 3 additions & 3 deletions cartographer_ws/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ git clone https://github.com/j3soon/ros2-essentials.git
```

```bash
cd ros2-agv-essentials/cartographer_ws/docker
cd ros2-essentials/cartographer_ws/docker
docker compose pull
docker compose up -d --build
```
Expand All @@ -18,7 +18,7 @@ docker compose up -d --build

```sh
docker attach ros2-cartographer-ws
cd /home/ros2-agv-essentials/cartographer_ws
cd /home/ros2-essentials/cartographer_ws
```
- Open the turtlebot simulation in `tmux`

Expand All @@ -41,7 +41,7 @@ docker compose up -d --build

```sh
docker attach ros2-cartographer-ws
cd /home/ros2-agv-essentials/cartographer_ws
cd /home/ros2-essentials/cartographer_ws
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro humble -y
colcon build
Expand Down
27 changes: 26 additions & 1 deletion cartographer_ws/docker/.bashrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Source global ROS2 environment
source /opt/ros/$ROS_DISTRO/setup.bash
# Optionally perform apt update if it has not been executed yet
if [ -z "$( ls -A '/var/lib/apt/lists' )" ]; then
echo "apt-get update has not been executed yet. Running sudo apt-get update..."
sudo apt-get update
fi
# Optionally perform rosdep update if it has not been executed yet
if [ ! -d $HOME/.ros/rosdep/sources.cache ]; then
echo "rosdep update has not been executed yet. Running rosdep update..."
rosdep update
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
colcon build --symlink-install
else
colcon build --symlink-install
fi
echo "Workspace built."
fi
# TODO: Source other workspace environments as underlay
# Source workspace environment
# Note: If you have not built your workspace yet, the following command will fail
source $ROS2_WS/install/setup.bash
101 changes: 77 additions & 24 deletions cartographer_ws/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,50 +1,103 @@
# Base Image : https://hub.docker.com/r/osrf/ros/tags?page=1&name=humble
FROM osrf/ros:humble-desktop-full
# 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
FROM arm64v8/ros:humble AS arm64

# Use docker automatic platform args to select the base image.
# It may be `arm64` or `amd64` depending on the platform.
# Ref: https://docs.docker.com/reference/dockerfile/#automatic-platform-args-in-the-global-scope
FROM $TARGETARCH
ARG TARGETARCH

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

# Arguments for the default user
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 \

# Keep downloaded packages for caching purposes
# Ref: https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/reference.md#example-cache-apt-packages
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

# Upgrade packages
# Ref: https://pythonspeed.com/articles/security-updates-in-docker/
# Ref: https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/reference.md#example-cache-apt-packages
# Ref: https://github.com/moby/buildkit/issues/1673#issuecomment-1264502398
# Ref: https://github.com/moby/buildkit/issues/1673#issuecomment-1987107404
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
apt-get update && apt-get upgrade -y \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y python3-pip \

# 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 \
apt-get update && apt-get install -y sudo \
&& useradd -m -s /bin/bash -u $USER_UID -G sudo $USERNAME \
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
&& rm -rf /var/lib/apt/lists/*
ENV SHELL /bin/bash

# Install common tools
RUN apt-get update && apt-get install -y \
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
apt-get update && apt-get install -y \
curl \
git \
git-extras \
htop \
iputils-ping \
nano \
net-tools \
tmux \
tree \
unzip \
vim \
wget \
zip \
&& rm -rf /var/lib/apt/lists/*

# Install Python pip
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
apt-get update && apt-get install -y \
python3-pip \
&& rm -rf /var/lib/apt/lists/*

# Install turtlebot3, RVIZ, Gazebo and Cartographer
RUN apt-get update && apt-get install -y \
ros-$ROS_DISTRO-gazebo-ros-pkgs \
# Install custom tools
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
apt-get update && apt-get install -y \
git-extras \
&& rm -rf /var/lib/apt/lists/*

# Install ROS2 Gazebo packages for amd64
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
if [ "$TARGETARCH" = "amd64" ]; then \
apt-get update && apt-get install -y \
ros-$ROS_DISTRO-gazebo-ros-pkgs \
ros-$ROS_DISTRO-gazebo-ros2-control \
&& rm -rf /var/lib/apt/lists/*; \
fi

# Install ROS2 RVIZ and other custom ROS2 packages
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
apt-get update && apt-get install -y \
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/*
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
apt-get update && apt-get install -y \
ros-$ROS_DISTRO-cartographer \
ros-$ROS_DISTRO-turtlebot3* \
ros-$ROS_DISTRO-rqt-robot-steering \
&& rm -rf /var/lib/apt/lists/*

COPY .bashrc /home/$USERNAME/.bashrc

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 []
CMD ["/bin/bash"]
Empty file.
Loading

0 comments on commit 76d494a

Please sign in to comment.