-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
265 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
FROM ros:iron | ||
|
||
# Arguments | ||
ARG user | ||
ARG uid | ||
ARG home | ||
ARG workspace | ||
ARG shell | ||
|
||
# Basic Utilities | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
RUN apt-get update -y \ | ||
&& apt-get install -y apt-utils auto-apt-proxy \ | ||
&& apt-get install -y \ | ||
build-essential \ | ||
curl \ | ||
gdb \ | ||
gnupg2 \ | ||
htop \ | ||
iproute2 \ | ||
iputils-ping \ | ||
ipython3 \ | ||
jq \ | ||
less \ | ||
libncurses5-dev \ | ||
locales \ | ||
ranger \ | ||
screen \ | ||
ssh \ | ||
sudo \ | ||
synaptic \ | ||
tig \ | ||
tmux \ | ||
tree \ | ||
uvcdynctrl \ | ||
vim \ | ||
vlc \ | ||
wget \ | ||
x11-apps \ | ||
zsh | ||
|
||
# Setup locale | ||
RUN echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen \ | ||
&& locale-gen \ | ||
&& update-locale LANG=en_US.UTF-8 \ | ||
&& ln -s /usr/bin/python3 /usr/bin/python | ||
|
||
ENV LANG en_US.UTF-8 | ||
ENV LANGUAGE en_US:en | ||
ENV LC_ALL en_US.UTF-8 | ||
|
||
# Setup and prioritize packages.bit-bots.de repository | ||
RUN apt update -y \ | ||
&& apt upgrade -y --allow-downgrades | ||
|
||
# Additional custom dependencies | ||
RUN apt-get install -y \ | ||
espeak \ | ||
ffmpeg \ | ||
libespeak-dev \ | ||
libfmt-dev \ | ||
librange-v3-dev \ | ||
librostest-dev \ | ||
libtf-conversions-dev \ | ||
liburdfdom-dev \ | ||
libyaml-cpp-dev \ | ||
llvm \ | ||
protobuf-compiler \ | ||
python3-colcon-common-extensions \ | ||
python3-colcon-ed \ | ||
python3-construct \ | ||
python3-pip \ | ||
python3-protobuf \ | ||
python3-pybind11 \ | ||
python3-rosdep \ | ||
radeontop \ | ||
ros-iron-camera-calibration \ | ||
ros-iron-camera-info-manager \ | ||
ros-iron-controller-manager \ | ||
ros-iron-desktop \ | ||
ros-iron-diagnostic-aggregator \ | ||
ros-iron-effort-controllers \ | ||
ros-iron-gazebo-msgs \ | ||
ros-iron-image-proc \ | ||
ros-iron-joint-state-broadcaster \ | ||
ros-iron-joint-state-publisher-gui \ | ||
ros-iron-joint-trajectory-controller \ | ||
ros-iron-joy-linux \ | ||
ros-iron-moveit-planners-ompl \ | ||
ros-iron-moveit-ros \ | ||
ros-iron-moveit-simple-controller-manager \ | ||
ros-iron-nav2-bringup \ | ||
# ros-iron-plotjuggler-ros containing plotjuggler ros plugins | ||
# build currently fails and is not available as a package so we | ||
# have to manually install plotjuggler and plotjuggler-msgs | ||
# https://github.com/PlotJuggler/plotjuggler-ros-plugins/issues/59 | ||
ros-iron-plotjuggler \ | ||
ros-iron-plotjuggler-msgs \ | ||
ros-iron-position-controllers \ | ||
ros-iron-rmw-cyclonedds-cpp \ | ||
ros-iron-robot-localization \ | ||
ros-iron-rot-conv \ | ||
ros-iron-rqt-robot-monitor \ | ||
ros-iron-soccer-vision-2d-msgs \ | ||
ros-iron-soccer-vision-3d-rviz-markers \ | ||
ros-iron-test-msgs \ | ||
ros-iron-tf-transformations \ | ||
ros-iron-transmission-interface \ | ||
ros-iron-velocity-controllers \ | ||
&& pip3 install pip -U \ | ||
&& python3 -m pip install git+https://github.com/ruffsl/colcon-clean | ||
|
||
# Mount the user's home directory | ||
VOLUME "${home}" | ||
|
||
# Clone user into docker image and set up X11 sharing | ||
RUN echo "${user}:x:${uid}:${uid}:${user},,,:${home}:${shell}" >> /etc/passwd \ | ||
&& echo "${user}:*::0:99999:0:::" >> /etc/shadow \ | ||
&& echo "${user}:x:${uid}:" >> /etc/group \ | ||
&& echo "${user} ALL=(ALL) NOPASSWD: ALL" >> "/etc/sudoers" | ||
|
||
# Switch to user | ||
USER "${user}" | ||
# This is required for sharing Xauthority | ||
ENV QT_X11_NO_MITSHM=1 | ||
# Switch to the workspace | ||
WORKDIR ${workspace} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
## rosdocked | ||
|
||
🐳 ❤️ 🤖 | ||
|
||
Run ROS 2 within Docker on any platform with a shared username, home directory, and X11. | ||
|
||
This enables you to build and run a persistent ROS workspace as long as | ||
you can run Docker images. | ||
|
||
Note that any changes made outside of your home directory from within the Docker environment will not persist. If you want to add additional binary packages or remove some of the dependencies that are currently installed, change the Dockerfile accordingly and rebuild. | ||
|
||
For more info on Docker see here: https://docs.docker.com/engine/installation/linux/ubuntulinux/ | ||
|
||
### Install Docker | ||
|
||
Install Docker on your system, add your user to the `docker` group (`sudo usermod -aG docker $USER`), log out and in again and start and enable the docker service (`sudo systemctl start docker && sudo systemctl enable docker`). | ||
|
||
### Build | ||
|
||
This will create the image with your user/group ID and home directory. | ||
|
||
``` | ||
./build | ||
``` | ||
|
||
### Run | ||
|
||
This will start the docker image. | ||
|
||
``` | ||
./start | ||
``` | ||
|
||
This will connect a shell to the docker image | ||
|
||
``` | ||
./connect | ||
``` | ||
|
||
A video device is shared with the container. This video device can be set in the `run` script and will appear in the container as `/dev/video0`. | ||
|
||
The Docker image will use your own shell configuration. To provide different settings inside and outside of the container, you can make use of the `$DOCKER` environment variable that is set to `1` inside of the docker image. To make use of this put something like | ||
|
||
``` | ||
if [[ -n "$DOCKER" ]]; then | ||
# Settings for inside of the docker | ||
export PROMPT="DOCKER $PROMPT" # Prefix the prompt with DOCKER | ||
# source workspace, etc. | ||
else | ||
# Settings for outside of the docker | ||
fi | ||
``` | ||
|
||
in your `.bashrc` or `.zshrc`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
set -eEou pipefail | ||
|
||
IMAGE_NAME=bitbots-dev-iron | ||
WORKSPACE=${ROS_WORKSPACE:-$HOME} | ||
|
||
# Build the docker image | ||
docker build \ | ||
--pull \ | ||
--network=host \ | ||
--build-arg user=$USER \ | ||
--build-arg uid=$UID \ | ||
--build-arg home=$HOME \ | ||
--build-arg workspace=$WORKSPACE \ | ||
--build-arg shell=$SHELL \ | ||
-t $IMAGE_NAME \ | ||
$@ \ | ||
- < Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
set -eEou pipefail | ||
|
||
IMAGE_NAME=ros-iron | ||
CONTAINER_NAME=`docker ps --filter status=running --filter ancestor=$IMAGE_NAME --format "{{.Names}}"` | ||
|
||
if [[ -z $CONTAINER_NAME ]]; then | ||
echo "Container not running, starting it" | ||
DIR=`dirname $0` | ||
bash -c "$DIR/start" | ||
fi | ||
|
||
CONTAINER_NAME=`docker ps --filter status=running --filter ancestor=$IMAGE_NAME --format "{{.Names}}"` | ||
|
||
if [[ -z $@ ]]; then | ||
docker exec -it $CONTAINER_NAME $SHELL | ||
else | ||
docker exec -it $CONTAINER_NAME "$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bash | ||
set -eEou pipefail | ||
|
||
IMAGE_NAME=ros-iron | ||
VIDEO_DEVICE=/dev/video0 | ||
# Get the group number of the video group, docker groups may differ | ||
VIDEO_GROUP=`stat -c "%g" $VIDEO_DEVICE` | ||
|
||
# Test whether a running container exists | ||
CONTAINER_NAME=`docker ps --filter status=running --filter ancestor=$IMAGE_NAME --format "{{.Names}}"` | ||
if [[ -n $CONTAINER_NAME ]]; then | ||
echo "Container already running, connect with ./connect or stop it with ./stop" | ||
exit 1 | ||
fi | ||
|
||
# Test whether a stopped container exists | ||
CONTAINER_NAME=`docker ps --filter status=exited --filter ancestor=$IMAGE_NAME --format "{{.Names}}"` | ||
if [[ -n $CONTAINER_NAME ]]; then | ||
echo "Resuming stopped container" | ||
docker start $CONTAINER_NAME > /dev/null | ||
else | ||
# Run the container with shared X11 | ||
docker run -d \ | ||
--net=host \ | ||
--add-host=$HOSTNAME:127.0.1.1 \ | ||
-e SHELL \ | ||
-e DISPLAY \ | ||
-e DOCKER=1 \ | ||
-v "$HOME:$HOME:rw" \ | ||
-v "/tmp/.X11-unix:/tmp/.X11-unix:rw" \ | ||
--device=$VIDEO_DEVICE:/dev/video0 \ | ||
--group-add=$VIDEO_GROUP \ | ||
--cap-add=SYS_PTRACE \ | ||
--security-opt seccomp=unconfined \ | ||
--name "rosdocked_iron" \ | ||
-it $IMAGE_NAME > /dev/null # Do not print container id | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
IMAGE_NAME=ros-iron | ||
CONTAINER_NAME=`docker ps --filter status=running --filter ancestor=$IMAGE_NAME --format "{{.Names}}"` | ||
|
||
if [[ -z $CONTAINER_NAME ]]; then | ||
echo "The container is not running" | ||
else | ||
docker stop $CONTAINER_NAME > /dev/null # Do not print container name | ||
fi |