Skip to content

Commit ba4ec45

Browse files
authored
Merge pull request #101 from j3soon/feat/stretch3
Hello Robot Stretch 3 (basic differential drive control)
2 parents 42e003f + a9e1166 commit ba4ec45

368 files changed

Lines changed: 28475 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,5 @@ nav:
225225
- delto-gripper-ws/index.md
226226
- go2-ws/index.md
227227
- h1-ws/index.md
228+
- stretch3-ws/index.md
228229
- dependencies.md
1.17 MB
Binary file not shown.

docs/stretch3-ws/index.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Hello Robot Stretch 3
2+
3+
[![GitHub code](https://img.shields.io/badge/code-blue?logo=github&label=github)](https://github.com/j3soon/ros2-essentials/tree/main/stretch3_ws)
4+
[![build](https://img.shields.io/github/actions/workflow/status/j3soon/ros2-essentials/build-stretch3-ws.yaml?label=build)](https://github.com/j3soon/ros2-essentials/actions/workflows/build-stretch3-ws.yaml)
5+
[![GitHub last commit](https://img.shields.io/github/last-commit/j3soon/ros2-essentials?path=stretch3_ws)](https://github.com/j3soon/ros2-essentials/commits/main/stretch3_ws)
6+
7+
[![DockerHub image](https://img.shields.io/badge/dockerhub-j3soon/ros2--stretch3--ws-important.svg?logo=docker)](https://hub.docker.com/r/j3soon/ros2-stretch3-ws/tags)
8+
![Docker image arch](https://img.shields.io/badge/arch-amd64-blueviolet)
9+
![Docker image version](https://img.shields.io/docker/v/j3soon/ros2-stretch3-ws)
10+
![Docker image size](https://img.shields.io/docker/image-size/j3soon/ros2-stretch3-ws)
11+
12+
> Please note that this workspace is only tested in simulation.
13+
14+
## 🐳 Start Container
15+
16+
> Make sure your system meets the [system requirements](https://j3soon.github.io/ros2-essentials/#system-requirements) and have followed the [setup instructions](https://j3soon.github.io/ros2-essentials/#setup) before using this workspace.
17+
18+
Run the following commands in a Ubuntu desktop environment. If you are using a remote server, make sure you're using a terminal within a remote desktop session (e.g., VNC) instead of SSH (i.e., don't use `ssh -X` or `ssh -Y`).
19+
20+
```sh
21+
cd ~/ros2-essentials/stretch3_ws/docker
22+
docker compose build
23+
xhost +local:docker
24+
docker compose up -d
25+
# The initial build will take a while, please wait patiently.
26+
```
27+
28+
> If your user's UID is `1000`, you may replace the `docker compose build` command with `docker compose pull`.
29+
30+
The commands in the following sections assume that you are inside the Docker container:
31+
32+
```sh
33+
# in a new terminal
34+
docker exec -it ros2-stretch3-ws bash
35+
```
36+
37+
If the initial build somehow failed, run:
38+
39+
```sh
40+
rm -r build install
41+
colcon build --symlink-install
42+
```
43+
44+
Once you have finished testing, you can stop and remove the container with:
45+
46+
```sh
47+
docker compose down
48+
```
49+
50+
> If you encountered unexpected issues when using Isaac Sim, see [Known Issues](../docker-modules/isaac-sim.md#known-issues) for more details.
51+
52+
### Isaac Sim Keyboard Control
53+
54+
Run `~/isaacsim/isaac-sim.sh` and open `/home/ros2-essentials/stretch3_ws/isaacsim/assets/stretch3_og_wasd.usda` in Isaac Sim, and then press Play and use WASD to control the robot.
55+
56+
<video controls>
57+
<source src="assets/stretch3_og_wasd.mp4" type="video/mp4">
58+
Your browser does not support the video tag.
59+
</video>
60+
61+
### Known Issues
62+
63+
If the robot moves too fast, it will become a bit unstable and starts rotating. This may be due to the tool causing mass inbalance.
64+
65+
### References
66+
67+
- [Stretch Docs](https://docs.hello-robot.com/0.3/)
68+
- [Stretch 3 Hardware Guide - Stretch Docs](https://docs.hello-robot.com/0.3/hardware/hardware_guide_stretch_3)
69+
- [Hello Robot GitHub](https://github.com/hello-robot)
70+
- [hello-robot/stretch_urdf](https://github.com/hello-robot/stretch_urdf)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* Reference: https://aka.ms/devcontainer.json */
2+
{
3+
"name": "TODO",
4+
"dockerComposeFile": "../docker/compose.yaml",
5+
"service": "stretch3-ws",
6+
// Workspace settings
7+
"workspaceFolder": "/home/ros2-essentials/stretch3_ws",
8+
// Vscode extensions
9+
"customizations": {
10+
"vscode": {
11+
"extensions": [
12+
"ms-vscode.cpptools",
13+
"ms-vscode.cpptools-themes",
14+
"twxs.cmake",
15+
"donjayamanne.python-extension-pack",
16+
"eamodio.gitlens",
17+
"mhutchie.git-graph",
18+
"streetsidesoftware.code-spell-checker",
19+
"ms-iot.vscode-ros"
20+
]
21+
}
22+
}
23+
}

stretch3_ws/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Visual Studio Code
2+
.vscode
3+
4+
# ROS2 basic directories
5+
/build
6+
/install
7+
/log
8+
9+
# Hard Links
10+
/docker/modules

stretch3_ws/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# ROS 2 Essentials Workspace
2+
3+
Please visit <https://j3soon.github.io/ros2-essentials/> for documentation.

stretch3_ws/docker/.bashrc

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Setup paths in `~/.profile` to allow unified environment variable across login/non-login shells
2+
# set PATH so it includes user's private bin if it exists
3+
if [ -d "$HOME/bin" ] ; then
4+
PATH="$HOME/bin:$PATH"
5+
fi
6+
# set PATH so it includes user's private bin if it exists
7+
if [ -d "$HOME/.local/bin" ] ; then
8+
PATH="$HOME/.local/bin:$PATH"
9+
fi
10+
11+
# Source global ROS2 environment
12+
source /opt/ros/$ROS_DISTRO/setup.bash
13+
# Source colcon-argcomplete
14+
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash
15+
# Optionally perform apt update if it has not been executed yet
16+
if [ -z "$( ls -A '/var/lib/apt/lists' )" ]; then
17+
echo "apt-get update has not been executed yet. Running sudo apt-get update..."
18+
sudo apt-get update
19+
fi
20+
# Optionally perform rosdep update if it has not been executed yet
21+
if [ ! -d $HOME/.ros/rosdep/sources.cache ]; then
22+
echo "rosdep update has not been executed yet. Running rosdep update..."
23+
rosdep update --rosdistro $ROS_DISTRO
24+
cd $ROS2_WS
25+
# Ref: https://docs.ros.org/en/humble/Tutorials/Intermediate/Rosdep.html
26+
rosdep install --from-paths src --ignore-src -y -r
27+
fi
28+
# Optionally build the workspace if it has not been built yet
29+
if [ ! -f $ROS2_WS/install/setup.bash ]; then
30+
echo "Workspace has not been built yet. Building workspace..."
31+
cd $ROS2_WS
32+
# TODO: If command `arch` outputs `aarch64`, consider adding `--packages-ignore <package>` to ignore x86 packages
33+
# Ref: https://docs.ros.org/en/humble/Tutorials/Beginner-Client-Libraries/Creating-Your-First-ROS2-Package.html
34+
if [ $(arch) == "aarch64" ]; then
35+
colcon build --symlink-install
36+
else
37+
colcon build --symlink-install
38+
fi
39+
echo "Workspace built."
40+
fi
41+
# Source gazebo environment
42+
# Ref: https://classic.gazebosim.org/tutorials?tut=ros2_installing&cat=connect_ros#InstallGazebo
43+
if [ $(arch) == "x86_64" ]; then
44+
source /usr/share/gazebo/setup.bash
45+
fi
46+
# TODO: Source other workspace environments as underlay
47+
# Source workspace environment
48+
source $ROS2_WS/install/setup.bash
49+
echo "Successfully built workspace and configured environment variables."

stretch3_ws/docker/.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*
2+
!.bashrc
3+
!modules

stretch3_ws/docker/Dockerfile

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# Base Image: https://hub.docker.com/_/ubuntu/tags?name=22.04
2+
FROM ubuntu:22.04 AS amd64
3+
# Base Image: https://hub.docker.com/_/ubuntu/tags?name=22.04
4+
FROM ubuntu:22.04 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+
# Keep downloaded packages for caching purposes
13+
# Ref: https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/reference.md#example-cache-apt-packages
14+
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
15+
16+
# Upgrade packages
17+
# Ref: https://pythonspeed.com/articles/security-updates-in-docker/
18+
# Ref: https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/reference.md#example-cache-apt-packages
19+
# Ref: https://github.com/moby/buildkit/issues/1673#issuecomment-1264502398
20+
# Ref: https://github.com/moby/buildkit/issues/1673#issuecomment-1987107404
21+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
22+
apt-get update && apt-get upgrade -y \
23+
&& rm -rf /var/lib/apt/lists/*
24+
25+
# Install common tools
26+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
27+
apt-get update && apt-get install -y \
28+
curl \
29+
git \
30+
git-lfs \
31+
htop \
32+
iputils-ping \
33+
jq \
34+
nano \
35+
net-tools \
36+
netcat-openbsd \
37+
nmap \
38+
p7zip-full \
39+
tmux \
40+
tree \
41+
unzip \
42+
vim \
43+
wget \
44+
zip \
45+
&& rm -rf /var/lib/apt/lists/*
46+
47+
# Install Python pip
48+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
49+
apt-get update && apt-get install -y \
50+
python3-pip \
51+
&& rm -rf /var/lib/apt/lists/*
52+
53+
# ROS version configuration
54+
ARG ROS_DISTRO=humble
55+
ENV ROS_DISTRO=$ROS_DISTRO
56+
# Copy and run ROS installation script
57+
COPY modules/install_ros.sh /tmp/install_ros.sh
58+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
59+
/tmp/install_ros.sh && rm /tmp/install_ros.sh
60+
# Set the CycloneDDS configuration file
61+
ENV CYCLONEDDS_URI=/home/user/cyclonedds.xml
62+
63+
# Setup the required capabilities for the container runtime
64+
# Ref: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/docker-specialized.html#driver-capabilities
65+
ENV NVIDIA_VISIBLE_DEVICES=all
66+
ENV NVIDIA_DRIVER_CAPABILITIES=all
67+
68+
# Install GUI debugging tools and configure Vulkan
69+
COPY modules/install_x11_opengl_vulkan.sh /tmp/install_x11_opengl_vulkan.sh
70+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
71+
/tmp/install_x11_opengl_vulkan.sh && rm /tmp/install_x11_opengl_vulkan.sh
72+
73+
# Install CUDA Toolkit (not installed by default)
74+
ARG CUDA_TOOLKIT_VERSION=""
75+
# Copy and run CUDA Toolkit installation script
76+
COPY modules/install_cuda_toolkit.sh /tmp/install_cuda_toolkit.sh
77+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
78+
/tmp/install_cuda_toolkit.sh && rm /tmp/install_cuda_toolkit.sh
79+
# Ref: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/#post-installation-actions
80+
ENV PATH="${PATH}:/usr/local/cuda-${CUDA_TOOLKIT_VERSION}/bin"
81+
ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/cuda-${CUDA_TOOLKIT_VERSION}/lib64"
82+
83+
# Arguments for the default user
84+
ARG USERNAME=user
85+
ARG USER_UID=1000
86+
87+
# Install sudo and create a user with sudo privileges
88+
# Ref: https://stackoverflow.com/a/65434659
89+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
90+
apt-get update && apt-get install -y sudo \
91+
&& useradd -m -s /bin/bash -u $USER_UID -G sudo $USERNAME \
92+
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
93+
&& rm -rf /var/lib/apt/lists/*
94+
95+
USER $USERNAME
96+
97+
# Create user bin directories specified in `~/.profile`
98+
# Together with .bashrc, this allows invoking executables in the same shell after installing to either location
99+
RUN mkdir /home/$USERNAME/bin
100+
RUN mkdir -p /home/$USERNAME/.local/bin
101+
102+
# Create cache directories with correct ownership to avoid permission issues after volume mount
103+
RUN mkdir -p /home/$USERNAME/.cache/pip
104+
# Create Gazebo cache directory with correct ownership to avoid permission issues after volume mount
105+
RUN mkdir /home/$USERNAME/.gazebo
106+
107+
# Isaac Sim version configuration
108+
ARG ISAAC_SIM_VERSION=5.0.0
109+
# Ref: https://isaac-sim.github.io/IsaacLab/v2.2.1/source/setup/installation/binaries_installation.html
110+
ENV ISAACSIM_PATH="/home/$USERNAME/isaacsim"
111+
# Copy and run Isaac Sim installation script
112+
COPY --chown=$USERNAME:$USERNAME \
113+
modules/install_isaac_sim.sh /tmp/install_isaac_sim.sh
114+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
115+
--mount=type=cache,target=/home/$USERNAME/.cache/pip,sharing=private,uid=$USER_UID,gid=$USER_UID \
116+
/tmp/install_isaac_sim.sh && rm /tmp/install_isaac_sim.sh
117+
# Set Isaac Sim environment variables
118+
# Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_python.html#running-isaac-sim
119+
# Ref: https://github.com/NVIDIA-Omniverse/IsaacSim-dockerfiles/blob/e3c09375c2d110b39c3fab3611352870aa3ce6ee/Dockerfile.2023.1.0-ubuntu22.04#L49-L53
120+
ENV OMNI_USER=admin
121+
ENV OMNI_PASS=admin
122+
ENV OMNI_KIT_ACCEPT_EULA=YES
123+
# Ref: https://isaac-sim.github.io/IsaacLab/v2.2.1/source/setup/installation/binaries_installation.html
124+
ENV ISAACSIM_PYTHON_EXE="${ISAACSIM_PATH}/python.sh"
125+
126+
# Set TERM to prevent Isaac Lab error during docker build:
127+
# 'ansi+tabs': unknown terminal type.
128+
ENV TERM=xterm-256color
129+
# Isaac Lab version configuration
130+
ARG ISAAC_LAB_VERSION=2.2.1
131+
# Ref: https://isaac-sim.github.io/IsaacLab/v2.2.1/source/policy_deployment/00_hover/hover_policy.html
132+
ENV ISAACLAB_PATH="/home/$USERNAME/IsaacLab"
133+
COPY --chown=$USERNAME:$USERNAME \
134+
modules/install_isaac_lab.sh /tmp/install_isaac_lab.sh
135+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
136+
--mount=type=cache,target=/home/$USERNAME/.cache/pip,sharing=private,uid=$USER_UID,gid=$USER_UID \
137+
/tmp/install_isaac_lab.sh && rm /tmp/install_isaac_lab.sh
138+
139+
# Isaac ROS version configuration
140+
ARG ISAAC_ROS=""
141+
ENV ISAAC_ROS_WS="/home/$USERNAME/workspaces/isaac_ros-dev/"
142+
# Copy and run Isaac ROS installation script
143+
COPY --chown=$USERNAME:$USERNAME \
144+
modules/install_isaac_ros.sh /tmp/install_isaac_ros.sh
145+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
146+
/tmp/install_isaac_ros.sh && rm /tmp/install_isaac_ros.sh
147+
# Ref: https://nvidia-isaac-ros.github.io/getting_started/dev_env_setup.html
148+
149+
# Install custom tools
150+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
151+
sudo apt-get update && sudo apt-get install -y \
152+
git-extras \
153+
&& sudo rm -rf /var/lib/apt/lists/*
154+
155+
# Cartographer configuration
156+
ARG CARTOGRAPHER=""
157+
COPY --chown=$USERNAME:$USERNAME \
158+
modules/install_cartographer.sh /tmp/install_cartographer.sh
159+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
160+
/tmp/install_cartographer.sh && rm /tmp/install_cartographer.sh
161+
162+
# rtabmap configuration
163+
ARG RTABMAP=""
164+
COPY --chown=$USERNAME:$USERNAME \
165+
modules/install_rtabmap.sh /tmp/install_rtabmap.sh
166+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
167+
/tmp/install_rtabmap.sh && rm /tmp/install_rtabmap.sh
168+
169+
# TODO: Add more commands here
170+
COPY --chown=$USERNAME:$USERNAME \
171+
.bashrc /home/$USERNAME/.bashrc
172+
# TODO: Copy additional files here
173+
ENTRYPOINT []
174+
CMD ["/bin/bash"]

0 commit comments

Comments
 (0)