From 7e63f281498e2ea9bd355d3c19007382e3216182 Mon Sep 17 00:00:00 2001 From: Manuel Date: Tue, 14 Dec 2021 11:05:52 +0100 Subject: [PATCH 1/7] Add docker container with ubuntu 20.04 and ros2 foxy Docker container is intented for testing the ros_team_workspace in a clean environment. --- .../ubuntu_20_04_ros2_foxy/Dockerfile | 58 ++++++++++ .../ubuntu_20_04_ros2_foxy/README.md | 18 +++ .../ubuntu_20_04_ros2_foxy/TODO.md | 7 ++ .../ubuntu_20_04_ros2_foxy/bashrc | 103 ++++++++++++++++++ .../ubuntu_20_04_ros2_foxy/build.sh | 7 ++ .../ubuntu_20_04_ros2_foxy/connect_root.sh | 2 + .../ubuntu_20_04_ros2_foxy/connect_user.sh | 2 + .../ubuntu_20_04_ros2_foxy/create.sh | 4 + .../ubuntu_20_04_ros2_foxy/start.sh | 2 + .../ubuntu_20_04_ros2_foxy/stop.sh | 2 + 10 files changed, 205 insertions(+) create mode 100644 test/test_container_docker/ubuntu_20_04_ros2_foxy/Dockerfile create mode 100644 test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md create mode 100644 test/test_container_docker/ubuntu_20_04_ros2_foxy/TODO.md create mode 100644 test/test_container_docker/ubuntu_20_04_ros2_foxy/bashrc create mode 100755 test/test_container_docker/ubuntu_20_04_ros2_foxy/build.sh create mode 100755 test/test_container_docker/ubuntu_20_04_ros2_foxy/connect_root.sh create mode 100755 test/test_container_docker/ubuntu_20_04_ros2_foxy/connect_user.sh create mode 100755 test/test_container_docker/ubuntu_20_04_ros2_foxy/create.sh create mode 100755 test/test_container_docker/ubuntu_20_04_ros2_foxy/start.sh create mode 100755 test/test_container_docker/ubuntu_20_04_ros2_foxy/stop.sh diff --git a/test/test_container_docker/ubuntu_20_04_ros2_foxy/Dockerfile b/test/test_container_docker/ubuntu_20_04_ros2_foxy/Dockerfile new file mode 100644 index 00000000..eadb8e37 --- /dev/null +++ b/test/test_container_docker/ubuntu_20_04_ros2_foxy/Dockerfile @@ -0,0 +1,58 @@ +FROM ubuntu:20.04 + +#Arguments maybe add defaults? +ARG user +ARG uid +ARG gid +ARG home + +# make bash default +SHELL ["/bin/bash", "-c"] + +# install locales +RUN apt-get update -y && apt-get install -y locales + +# Configure user env +ENV TZ=Europe/Berlin +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +# Set the locale to include UTF-8. UTF-8 compatible locales are needed for install +RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \ + locale-gen +ENV LANG en_US.UTF-8 +ENV LANGUAGE en_US:en +ENV LC_ALL en_US.UTF-8 + +# Make sure UTF-8 is supported +RUN locale + +# Install basic utilities +RUN apt-get -y update && apt-get -y install git nano sudo tmux tree vim + +# install ROS2:foxy dependencies +RUN apt-get install -y curl gnupg2 lsb-release +RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg +RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null + +# install ROS2:foxy and things needed for ros development, DEBIAN_FRONTEND is needed to ignore interactive keyboard layout setting while install +RUN apt-get update -y && DEBIAN_FRONTEND=noniteractive apt-get install -y ros-foxy-desktop pip python3-colcon-common-extensions +RUN pip install -U rosdep && \ + rosdep init + +# clone user into docker image, add to sudo users needed for xsharing +# the passwd delet is needed to update /etc/shadow otherwise user cannot use sudo +RUN mkdir -p ${home} && \ + echo "${user}:x:${uid}:${gid}:${user},,,:${home}:/bin/bash" >> /etc/passwd && \ + echo "${user}:x:${uid}:" >> /etc/group && \ + echo "${user} ALL=(ALL) NOPASSWD: ALL" > "/etc/sudoers.d/${user}" && \ + chmod 0440 "/etc/sudoers.d/${user}" && \ + usermod -aG sudo ${user} && \ + passwd -d ${user} && \ + chown ${uid}:${gid} -R ${home} + +# setup environment of ros for usage +COPY bashrc ${home}/.bashrc +RUN echo "source /opt/ros/foxy/setup.bash" >> ${home}/.bashrc + +#switch to user +USER ${user} diff --git a/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md b/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md new file mode 100644 index 00000000..cfca8565 --- /dev/null +++ b/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md @@ -0,0 +1,18 @@ +# Usage of the docker container +Short: +1. Install docker +2. run `./build.sh` +3. run `./create.sh` +4. You can then connect either as root or user by opening a new terminal and run `:/connect_.sh`. +5. If you want to exit simply type `exit` in the console inside the container. +6. If you stop the container with `./stop.sh` or by exiting all instance restart with `./start.sh`. + +## Install docker. +This step depends on the operatingsystem you are using. For instructions have a look [here](https://docs.docker.com/) on the official docs site or google it. +* [Windows](https://docs.docker.com/desktop/windows/install/) +* [Mac](https://docs.docker.com/desktop/mac/install/) +* Linux + - have to look it up. However make sure your user is in the docker group. Check with: `groups`. To add your user to the docker group run: `sudo usermod -aG docker `. + +## container +TODO diff --git a/test/test_container_docker/ubuntu_20_04_ros2_foxy/TODO.md b/test/test_container_docker/ubuntu_20_04_ros2_foxy/TODO.md new file mode 100644 index 00000000..e2b57b83 --- /dev/null +++ b/test/test_container_docker/ubuntu_20_04_ros2_foxy/TODO.md @@ -0,0 +1,7 @@ +# TODO + +## Currently **not** working properly +* [] Auto completion of commands in shell + - [] ros2 commands auto completion + + diff --git a/test/test_container_docker/ubuntu_20_04_ros2_foxy/bashrc b/test/test_container_docker/ubuntu_20_04_ros2_foxy/bashrc new file mode 100644 index 00000000..337f7b60 --- /dev/null +++ b/test/test_container_docker/ubuntu_20_04_ros2_foxy/bashrc @@ -0,0 +1,103 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +[ -z "$PS1" ] && return + +# don't put duplicate lines in the history. See bash(1) for more options +# ... or force ignoredups and ignorespace +HISTCONTROL=ignoredups:ignorespace + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +#force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# some more ls aliases +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' + +# Add an "alert" alias for long running commands. Use like so: +# sleep 10; alert +alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if [ -f /etc/bash_completion ] && ! shopt -oq posix; then + . /etc/bash_completion +fi diff --git a/test/test_container_docker/ubuntu_20_04_ros2_foxy/build.sh b/test/test_container_docker/ubuntu_20_04_ros2_foxy/build.sh new file mode 100755 index 00000000..1c32028c --- /dev/null +++ b/test/test_container_docker/ubuntu_20_04_ros2_foxy/build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +docker build \ + --build-arg user=$USER \ + --build-arg uid=$UID \ + --build-arg gid=$GROUPS \ + --build-arg home=$HOME \ + -t ubuntu_20_04_ros2_foxy . diff --git a/test/test_container_docker/ubuntu_20_04_ros2_foxy/connect_root.sh b/test/test_container_docker/ubuntu_20_04_ros2_foxy/connect_root.sh new file mode 100755 index 00000000..38b0baa8 --- /dev/null +++ b/test/test_container_docker/ubuntu_20_04_ros2_foxy/connect_root.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +docker exec -u root -it ubuntu_20_04_ros2_foxy-instance /bin/bash diff --git a/test/test_container_docker/ubuntu_20_04_ros2_foxy/connect_user.sh b/test/test_container_docker/ubuntu_20_04_ros2_foxy/connect_user.sh new file mode 100755 index 00000000..3bb7e6e6 --- /dev/null +++ b/test/test_container_docker/ubuntu_20_04_ros2_foxy/connect_user.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +docker exec -u $USER -it ubuntu_20_04_ros2_foxy-instance /bin/bash diff --git a/test/test_container_docker/ubuntu_20_04_ros2_foxy/create.sh b/test/test_container_docker/ubuntu_20_04_ros2_foxy/create.sh new file mode 100755 index 00000000..36937796 --- /dev/null +++ b/test/test_container_docker/ubuntu_20_04_ros2_foxy/create.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +xhost +local:docker +docker run --net=host -h ubuntu_20_04_ros2_foxy-docker -e DISPLAY --tmpfs /tmp -v /tmp/.X11-unix/:/tmp/.X11-unix:rw -v $PWD/../../../../ros_team_workspace/:$HOME/workspace/ros_team_workspace:rw --name ubuntu_20_04_ros2_foxy-instance -it ubuntu_20_04_ros2_foxy /bin/bash + diff --git a/test/test_container_docker/ubuntu_20_04_ros2_foxy/start.sh b/test/test_container_docker/ubuntu_20_04_ros2_foxy/start.sh new file mode 100755 index 00000000..e879ee8a --- /dev/null +++ b/test/test_container_docker/ubuntu_20_04_ros2_foxy/start.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +docker start ubuntu_20_04_ros2_foxy-instance diff --git a/test/test_container_docker/ubuntu_20_04_ros2_foxy/stop.sh b/test/test_container_docker/ubuntu_20_04_ros2_foxy/stop.sh new file mode 100755 index 00000000..b7303670 --- /dev/null +++ b/test/test_container_docker/ubuntu_20_04_ros2_foxy/stop.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +docker stop ubuntu_20_04_ros2_foxy-instance From 3cc486eb4c25018159296bc30c715b6ba6dcf216 Mon Sep 17 00:00:00 2001 From: Manuel Date: Tue, 14 Dec 2021 11:24:19 +0100 Subject: [PATCH 2/7] Update README.md to include explanation of volume mount and some cmds --- .../ubuntu_20_04_ros2_foxy/README.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md b/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md index cfca8565..cbd650d4 100644 --- a/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md +++ b/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md @@ -12,7 +12,21 @@ This step depends on the operatingsystem you are using. For instructions have a * [Windows](https://docs.docker.com/desktop/windows/install/) * [Mac](https://docs.docker.com/desktop/mac/install/) * Linux - - have to look it up. However make sure your user is in the docker group. Check with: `groups`. To add your user to the docker group run: `sudo usermod -aG docker `. + - have to look it up. However make sure your user is in the docker group. Check with: `groups`. + To add your user to the docker group run: `sudo usermod -aG docker `. ## container -TODO +The container itself should support forwarding of the x11-session. If this is not working please open an issue on github. +The container itself should clone your `user` inside the docker container. The _ros_team_workspace_ folder is then shared with the docker container and mounted under _~/workspace/ros_team_workspace/_ . + +## some useful docker commands +For complete list of commands have a look at [official docker cli reference](https://docs.docker.com/engine/reference/commandline/cli/). + ++ `docker container ` + + `ls` lists all current active containers + + `ls -a` lists all containers + + `rm ` removes container ++ `docker image ` + + `ls` lists all images + + `rm ` removes image + From a9fd486af60a5f2a4ac2db732be50e27cce36443 Mon Sep 17 00:00:00 2001 From: Manuel Date: Wed, 15 Dec 2021 10:49:49 +0100 Subject: [PATCH 3/7] Restructure README.md --- .../ubuntu_20_04_ros2_foxy/README.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md b/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md index cbd650d4..03ad039b 100644 --- a/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md +++ b/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md @@ -1,4 +1,12 @@ -# Usage of the docker container +# Docker Container + +Ubuntu 20.04 with ROS 2 [Foxy Fitzroy (codename ‘foxy’)](https://docs.ros.org/en/foxy/index.html) installed with x11 forwading. + +## container +The container should support forwarding of the x11-session. If this is not working please open an issue on github. +The container itself should clone your `user` inside the docker container. The _ros_team_workspace_ folder is then shared with the docker container and mounted under _~/workspace/ros_team_workspace/_ inside the container. + +## Usage of the docker container Short: 1. Install docker 2. run `./build.sh` @@ -7,7 +15,7 @@ Short: 5. If you want to exit simply type `exit` in the console inside the container. 6. If you stop the container with `./stop.sh` or by exiting all instance restart with `./start.sh`. -## Install docker. +### Install docker. This step depends on the operatingsystem you are using. For instructions have a look [here](https://docs.docker.com/) on the official docs site or google it. * [Windows](https://docs.docker.com/desktop/windows/install/) * [Mac](https://docs.docker.com/desktop/mac/install/) @@ -15,9 +23,7 @@ This step depends on the operatingsystem you are using. For instructions have a - have to look it up. However make sure your user is in the docker group. Check with: `groups`. To add your user to the docker group run: `sudo usermod -aG docker `. -## container -The container itself should support forwarding of the x11-session. If this is not working please open an issue on github. -The container itself should clone your `user` inside the docker container. The _ros_team_workspace_ folder is then shared with the docker container and mounted under _~/workspace/ros_team_workspace/_ . + ## some useful docker commands For complete list of commands have a look at [official docker cli reference](https://docs.docker.com/engine/reference/commandline/cli/). @@ -29,4 +35,3 @@ For complete list of commands have a look at [official docker cli reference](htt + `docker image ` + `ls` lists all images + `rm ` removes image - From 4c30357c35181819ef5755509235f948b4735cd1 Mon Sep 17 00:00:00 2001 From: Manuel Date: Wed, 15 Dec 2021 11:31:39 +0100 Subject: [PATCH 4/7] Add docker container with ubuntu ros2 and multiple versions --- .../ubuntu_20_04_ros2_foxy/README.md | 2 +- .../ubuntu_20_04_ros2_multi/Dockerfile | 57 ++++++++++ .../ubuntu_20_04_ros2_multi/README.md | 41 +++++++ .../ubuntu_20_04_ros2_multi/TODO.md | 7 ++ .../ubuntu_20_04_ros2_multi/bashrc | 103 ++++++++++++++++++ .../ubuntu_20_04_ros2_multi/build.sh | 7 ++ .../ubuntu_20_04_ros2_multi/connect_root.sh | 2 + .../ubuntu_20_04_ros2_multi/connect_user.sh | 2 + .../ubuntu_20_04_ros2_multi/create.sh | 4 + .../ubuntu_20_04_ros2_multi/start.sh | 2 + .../ubuntu_20_04_ros2_multi/stop.sh | 2 + 11 files changed, 228 insertions(+), 1 deletion(-) create mode 100644 test/test_container_docker/ubuntu_20_04_ros2_multi/Dockerfile create mode 100644 test/test_container_docker/ubuntu_20_04_ros2_multi/README.md create mode 100644 test/test_container_docker/ubuntu_20_04_ros2_multi/TODO.md create mode 100644 test/test_container_docker/ubuntu_20_04_ros2_multi/bashrc create mode 100755 test/test_container_docker/ubuntu_20_04_ros2_multi/build.sh create mode 100755 test/test_container_docker/ubuntu_20_04_ros2_multi/connect_root.sh create mode 100755 test/test_container_docker/ubuntu_20_04_ros2_multi/connect_user.sh create mode 100755 test/test_container_docker/ubuntu_20_04_ros2_multi/create.sh create mode 100755 test/test_container_docker/ubuntu_20_04_ros2_multi/start.sh create mode 100755 test/test_container_docker/ubuntu_20_04_ros2_multi/stop.sh diff --git a/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md b/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md index 03ad039b..7cda4af9 100644 --- a/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md +++ b/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md @@ -1,4 +1,4 @@ -# Docker Container +# Docker Container ubuntu_20_04_ros2_foxy Ubuntu 20.04 with ROS 2 [Foxy Fitzroy (codename ‘foxy’)](https://docs.ros.org/en/foxy/index.html) installed with x11 forwading. diff --git a/test/test_container_docker/ubuntu_20_04_ros2_multi/Dockerfile b/test/test_container_docker/ubuntu_20_04_ros2_multi/Dockerfile new file mode 100644 index 00000000..ee080137 --- /dev/null +++ b/test/test_container_docker/ubuntu_20_04_ros2_multi/Dockerfile @@ -0,0 +1,57 @@ +FROM ubuntu:20.04 + +#Arguments maybe add defaults? +ARG user +ARG uid +ARG gid +ARG home + +# make bash default +SHELL ["/bin/bash", "-c"] + +# install locales +RUN apt-get update -y && apt-get install -y locales + +# Configure user env +ENV TZ=Europe/Berlin +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +# Set the locale to include UTF-8. UTF-8 compatible locales are needed for install +RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \ + locale-gen +ENV LANG en_US.UTF-8 +ENV LANGUAGE en_US:en +ENV LC_ALL en_US.UTF-8 + +# Make sure UTF-8 is supported +RUN locale + +# Install basic utilities +RUN apt-get -y update && apt-get -y install git nano sudo tmux tree vim + +# install ROS2:foxy dependencies +RUN apt-get install -y curl gnupg gnupg2 lsb-release software-properties-common && apt-add-repository universe +RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg +RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null + +# install ROS2:foxy and things needed for ros development, DEBIAN_FRONTEND is needed to ignore interactive keyboard layout setting while install +RUN apt-get update -y && DEBIAN_FRONTEND=noniteractive apt-get install -y ros-foxy-desktop ros-galactic-desktop ros-rolling-desktop pip python3-colcon-common-extensions +RUN pip install -U rosdep && \ + rosdep init + +# clone user into docker image, add to sudo users needed for xsharing +# the passwd delet is needed to update /etc/shadow otherwise user cannot use sudo +RUN mkdir -p ${home} && \ + echo "${user}:x:${uid}:${gid}:${user},,,:${home}:/bin/bash" >> /etc/passwd && \ + echo "${user}:x:${uid}:" >> /etc/group && \ + echo "${user} ALL=(ALL) NOPASSWD: ALL" > "/etc/sudoers.d/${user}" && \ + chmod 0440 "/etc/sudoers.d/${user}" && \ + usermod -aG sudo ${user} && \ + passwd -d ${user} && \ + chown ${uid}:${gid} -R ${home} + +# setup environment of ros for usage +COPY bashrc ${home}/.bashrc + +#switch to user +USER ${user} diff --git a/test/test_container_docker/ubuntu_20_04_ros2_multi/README.md b/test/test_container_docker/ubuntu_20_04_ros2_multi/README.md new file mode 100644 index 00000000..b1551327 --- /dev/null +++ b/test/test_container_docker/ubuntu_20_04_ros2_multi/README.md @@ -0,0 +1,41 @@ +# Docker Container ubuntu_20_04_ros2_multi + +Ubuntu 20.04 with ROS 2 and +* [Foxy Fitzroy (codename ‘foxy’)](https://docs.ros.org/en/foxy/index.html) +* [Galactic Geochelone (codename ‘galactic’)](https://docs.ros.org/en/galactic/index.html) +* [Rolling Ridley (codename ‘rolling’)](https://docs.ros.org/en/rolling/index.html) +installed with x11 forwading. + +## container +The container should support forwarding of the x11-session. If this is not working please open an issue on github. +The container itself should clone your `user` inside the docker container. The _ros_team_workspace_ folder is then shared with the docker container and mounted under _~/workspace/ros_team_workspace/_ inside the container. + +## Usage of the docker container +Short: +1. Install docker +2. run `./build.sh` +3. run `./create.sh` +4. You can then connect either as root or user by opening a new terminal and run `:/connect_.sh`. +5. If you want to exit simply type `exit` in the console inside the container. +6. If you stop the container with `./stop.sh` or by exiting all instance restart with `./start.sh`. + +### Install docker. +This step depends on the operatingsystem you are using. For instructions have a look [here](https://docs.docker.com/) on the official docs site or google it. +* [Windows](https://docs.docker.com/desktop/windows/install/) +* [Mac](https://docs.docker.com/desktop/mac/install/) +* Linux + - have to look it up. However make sure your user is in the docker group. Check with: `groups`. + To add your user to the docker group run: `sudo usermod -aG docker `. + + + +## some useful docker commands +For complete list of commands have a look at [official docker cli reference](https://docs.docker.com/engine/reference/commandline/cli/). + ++ `docker container ` + + `ls` lists all current active containers + + `ls -a` lists all containers + + `rm ` removes container ++ `docker image ` + + `ls` lists all images + + `rm ` removes image diff --git a/test/test_container_docker/ubuntu_20_04_ros2_multi/TODO.md b/test/test_container_docker/ubuntu_20_04_ros2_multi/TODO.md new file mode 100644 index 00000000..e2b57b83 --- /dev/null +++ b/test/test_container_docker/ubuntu_20_04_ros2_multi/TODO.md @@ -0,0 +1,7 @@ +# TODO + +## Currently **not** working properly +* [] Auto completion of commands in shell + - [] ros2 commands auto completion + + diff --git a/test/test_container_docker/ubuntu_20_04_ros2_multi/bashrc b/test/test_container_docker/ubuntu_20_04_ros2_multi/bashrc new file mode 100644 index 00000000..337f7b60 --- /dev/null +++ b/test/test_container_docker/ubuntu_20_04_ros2_multi/bashrc @@ -0,0 +1,103 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +[ -z "$PS1" ] && return + +# don't put duplicate lines in the history. See bash(1) for more options +# ... or force ignoredups and ignorespace +HISTCONTROL=ignoredups:ignorespace + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +#force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# some more ls aliases +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' + +# Add an "alert" alias for long running commands. Use like so: +# sleep 10; alert +alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if [ -f /etc/bash_completion ] && ! shopt -oq posix; then + . /etc/bash_completion +fi diff --git a/test/test_container_docker/ubuntu_20_04_ros2_multi/build.sh b/test/test_container_docker/ubuntu_20_04_ros2_multi/build.sh new file mode 100755 index 00000000..a7d09751 --- /dev/null +++ b/test/test_container_docker/ubuntu_20_04_ros2_multi/build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +docker build \ + --build-arg user=$USER \ + --build-arg uid=$UID \ + --build-arg gid=$GROUPS \ + --build-arg home=$HOME \ + -t ubuntu_20_04_ros2_multi . diff --git a/test/test_container_docker/ubuntu_20_04_ros2_multi/connect_root.sh b/test/test_container_docker/ubuntu_20_04_ros2_multi/connect_root.sh new file mode 100755 index 00000000..fe379970 --- /dev/null +++ b/test/test_container_docker/ubuntu_20_04_ros2_multi/connect_root.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +docker exec -u root -it ubuntu_20_04_ros2_multi-instance /bin/bash diff --git a/test/test_container_docker/ubuntu_20_04_ros2_multi/connect_user.sh b/test/test_container_docker/ubuntu_20_04_ros2_multi/connect_user.sh new file mode 100755 index 00000000..95b309e3 --- /dev/null +++ b/test/test_container_docker/ubuntu_20_04_ros2_multi/connect_user.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +docker exec -u $USER -it ubuntu_20_04_ros2_multi-instance /bin/bash diff --git a/test/test_container_docker/ubuntu_20_04_ros2_multi/create.sh b/test/test_container_docker/ubuntu_20_04_ros2_multi/create.sh new file mode 100755 index 00000000..14f949db --- /dev/null +++ b/test/test_container_docker/ubuntu_20_04_ros2_multi/create.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +xhost +local:docker +docker run --net=host -h ubuntu_20_04_ros2_multi-docker -e DISPLAY --tmpfs /tmp -v /tmp/.X11-unix/:/tmp/.X11-unix:rw -v $PWD/../../../../ros_team_workspace/:$HOME/workspace/ros_team_workspace:rw --name ubuntu_20_04_ros2_multi-instance -it ubuntu_20_04_ros2_multi /bin/bash + diff --git a/test/test_container_docker/ubuntu_20_04_ros2_multi/start.sh b/test/test_container_docker/ubuntu_20_04_ros2_multi/start.sh new file mode 100755 index 00000000..45171cf7 --- /dev/null +++ b/test/test_container_docker/ubuntu_20_04_ros2_multi/start.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +docker start ubuntu_20_04_ros2_multi-instance diff --git a/test/test_container_docker/ubuntu_20_04_ros2_multi/stop.sh b/test/test_container_docker/ubuntu_20_04_ros2_multi/stop.sh new file mode 100755 index 00000000..f05aca21 --- /dev/null +++ b/test/test_container_docker/ubuntu_20_04_ros2_multi/stop.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +docker stop ubuntu_20_04_ros2_multi-instance From fb6aa90f50848632859a7750e8bdee46fe1599bd Mon Sep 17 00:00:00 2001 From: Manuel Date: Mon, 20 Dec 2021 11:37:19 +0100 Subject: [PATCH 5/7] Add bats and helpers as submodul They are not in rosdep rules as of yet, need to be added. Thereafter can be switched to rosdep. For quick start submodules are used. --- .gitmodules | 9 +++++++++ test/bats | 1 + test/test_helper/bats-assert | 1 + test/test_helper/bats-support | 1 + 4 files changed, 12 insertions(+) create mode 100644 .gitmodules create mode 160000 test/bats create mode 160000 test/test_helper/bats-assert create mode 160000 test/test_helper/bats-support diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..b7efcb44 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule "test/bats"] + path = test/bats + url = https://github.com/bats-core/bats-core.git +[submodule "test/test_helper/bats-support"] + path = test/test_helper/bats-support + url = https://github.com/bats-core/bats-support.git +[submodule "test/test_helper/bats-assert"] + path = test/test_helper/bats-assert + url = https://github.com/bats-core/bats-assert.git diff --git a/test/bats b/test/bats new file mode 160000 index 00000000..172580d2 --- /dev/null +++ b/test/bats @@ -0,0 +1 @@ +Subproject commit 172580d2ce19ee33780b5f1df817bbddced43789 diff --git a/test/test_helper/bats-assert b/test/test_helper/bats-assert new file mode 160000 index 00000000..4bdd58d3 --- /dev/null +++ b/test/test_helper/bats-assert @@ -0,0 +1 @@ +Subproject commit 4bdd58d3fbcdce3209033d44d884e87add1d8405 diff --git a/test/test_helper/bats-support b/test/test_helper/bats-support new file mode 160000 index 00000000..d140a650 --- /dev/null +++ b/test/test_helper/bats-support @@ -0,0 +1 @@ +Subproject commit d140a65044b2d6810381935ae7f0c94c7023c8c3 From bc54c7ce7ada52a32c634f2cd5435852736429ea Mon Sep 17 00:00:00 2001 From: Manuel Date: Mon, 20 Dec 2021 17:26:40 +0100 Subject: [PATCH 6/7] Restructure README and TODO. Add x-server access to ./start.sh Moved the explanation of how to use out of subfolders. --- test/test_container_docker/README.md | 35 +++++++++++++++++++ test/test_container_docker/TODO.md | 9 +++++ .../ubuntu_20_04_ros2_foxy/README.md | 35 ++----------------- .../ubuntu_20_04_ros2_foxy/TODO.md | 4 --- .../ubuntu_20_04_ros2_foxy/start.sh | 1 + .../ubuntu_20_04_ros2_foxy/stop.sh | 1 + .../ubuntu_20_04_ros2_multi/README.md | 34 ++---------------- .../ubuntu_20_04_ros2_multi/TODO.md | 3 -- .../ubuntu_20_04_ros2_multi/start.sh | 1 + .../ubuntu_20_04_ros2_multi/stop.sh | 1 + 10 files changed, 52 insertions(+), 72 deletions(-) create mode 100644 test/test_container_docker/README.md create mode 100644 test/test_container_docker/TODO.md diff --git a/test/test_container_docker/README.md b/test/test_container_docker/README.md new file mode 100644 index 00000000..257c6884 --- /dev/null +++ b/test/test_container_docker/README.md @@ -0,0 +1,35 @@ +# Docker Container for testing + +## container +The container should support forwarding of the x11-session. If this is not working please make sure docker is granted access to the x-server by running `./start.sh`. Otherwise open an issue on github. +The container itself should clone your `user` inside the docker container. The _ros_team_workspace_ folder is then shared with the docker container and mounted under _~/workspace/ros_team_workspace/_ inside the container. + +## Usage of the docker container +Short: +1. Install docker +2. run `./build.sh` +3. run `./create.sh` +4. You can then connect either as root or user by opening a new terminal and run `:/connect_.sh`. +5. If you want to exit simply type `exit` in the console inside the container. +6. If you stop the container with `./stop.sh` or by exiting all instance restart with `./start.sh`. + +### Install docker. +This step depends on the operatingsystem you are using. For instructions have a look [here](https://docs.docker.com/) on the official docs site or google it. +* [Windows](https://docs.docker.com/desktop/windows/install/) +* [Mac](https://docs.docker.com/desktop/mac/install/) +* Linux + - have to look it up. However make sure your user is in the docker group. Check with: `groups`. + To add your user to the docker group run: `sudo usermod -aG docker `. + + + +## some useful docker commands +For complete list of commands have a look at [official docker cli reference](https://docs.docker.com/engine/reference/commandline/cli/). + ++ `docker container ` + + `ls` lists all current active containers + + `ls -a` lists all containers + + `rm ` removes container ++ `docker image ` + + `ls` lists all images + + `rm ` removes image diff --git a/test/test_container_docker/TODO.md b/test/test_container_docker/TODO.md new file mode 100644 index 00000000..0c417bee --- /dev/null +++ b/test/test_container_docker/TODO.md @@ -0,0 +1,9 @@ +# TODO +* Automatically add hostname of dockercontainer to /etc/hosts otherwise annoying `sudo: unable to resolve host : Name or service not known` + 127.0.0.1 + + +## Currently **not** working properly +* [] Auto completion of commands in shell + - [] ros2 commands auto completion + diff --git a/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md b/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md index 7cda4af9..b158d237 100644 --- a/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md +++ b/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md @@ -2,36 +2,5 @@ Ubuntu 20.04 with ROS 2 [Foxy Fitzroy (codename ‘foxy’)](https://docs.ros.org/en/foxy/index.html) installed with x11 forwading. -## container -The container should support forwarding of the x11-session. If this is not working please open an issue on github. -The container itself should clone your `user` inside the docker container. The _ros_team_workspace_ folder is then shared with the docker container and mounted under _~/workspace/ros_team_workspace/_ inside the container. - -## Usage of the docker container -Short: -1. Install docker -2. run `./build.sh` -3. run `./create.sh` -4. You can then connect either as root or user by opening a new terminal and run `:/connect_.sh`. -5. If you want to exit simply type `exit` in the console inside the container. -6. If you stop the container with `./stop.sh` or by exiting all instance restart with `./start.sh`. - -### Install docker. -This step depends on the operatingsystem you are using. For instructions have a look [here](https://docs.docker.com/) on the official docs site or google it. -* [Windows](https://docs.docker.com/desktop/windows/install/) -* [Mac](https://docs.docker.com/desktop/mac/install/) -* Linux - - have to look it up. However make sure your user is in the docker group. Check with: `groups`. - To add your user to the docker group run: `sudo usermod -aG docker `. - - - -## some useful docker commands -For complete list of commands have a look at [official docker cli reference](https://docs.docker.com/engine/reference/commandline/cli/). - -+ `docker container ` - + `ls` lists all current active containers - + `ls -a` lists all containers - + `rm ` removes container -+ `docker image ` - + `ls` lists all images - + `rm ` removes image +## How to use +Have a look at README.md in test_container_docker. diff --git a/test/test_container_docker/ubuntu_20_04_ros2_foxy/TODO.md b/test/test_container_docker/ubuntu_20_04_ros2_foxy/TODO.md index e2b57b83..14e6ea19 100644 --- a/test/test_container_docker/ubuntu_20_04_ros2_foxy/TODO.md +++ b/test/test_container_docker/ubuntu_20_04_ros2_foxy/TODO.md @@ -1,7 +1,3 @@ # TODO ## Currently **not** working properly -* [] Auto completion of commands in shell - - [] ros2 commands auto completion - - diff --git a/test/test_container_docker/ubuntu_20_04_ros2_foxy/start.sh b/test/test_container_docker/ubuntu_20_04_ros2_foxy/start.sh index e879ee8a..264049ff 100755 --- a/test/test_container_docker/ubuntu_20_04_ros2_foxy/start.sh +++ b/test/test_container_docker/ubuntu_20_04_ros2_foxy/start.sh @@ -1,2 +1,3 @@ #!/usr/bin/env bash +xhost +local:docker docker start ubuntu_20_04_ros2_foxy-instance diff --git a/test/test_container_docker/ubuntu_20_04_ros2_foxy/stop.sh b/test/test_container_docker/ubuntu_20_04_ros2_foxy/stop.sh index b7303670..df71f6d6 100755 --- a/test/test_container_docker/ubuntu_20_04_ros2_foxy/stop.sh +++ b/test/test_container_docker/ubuntu_20_04_ros2_foxy/stop.sh @@ -1,2 +1,3 @@ #!/usr/bin/env bash +xhost -local:docker docker stop ubuntu_20_04_ros2_foxy-instance diff --git a/test/test_container_docker/ubuntu_20_04_ros2_multi/README.md b/test/test_container_docker/ubuntu_20_04_ros2_multi/README.md index b1551327..7b549f8a 100644 --- a/test/test_container_docker/ubuntu_20_04_ros2_multi/README.md +++ b/test/test_container_docker/ubuntu_20_04_ros2_multi/README.md @@ -6,36 +6,6 @@ Ubuntu 20.04 with ROS 2 and * [Rolling Ridley (codename ‘rolling’)](https://docs.ros.org/en/rolling/index.html) installed with x11 forwading. -## container -The container should support forwarding of the x11-session. If this is not working please open an issue on github. -The container itself should clone your `user` inside the docker container. The _ros_team_workspace_ folder is then shared with the docker container and mounted under _~/workspace/ros_team_workspace/_ inside the container. +## How to use +Have a look at README.md in test_container_docker. -## Usage of the docker container -Short: -1. Install docker -2. run `./build.sh` -3. run `./create.sh` -4. You can then connect either as root or user by opening a new terminal and run `:/connect_.sh`. -5. If you want to exit simply type `exit` in the console inside the container. -6. If you stop the container with `./stop.sh` or by exiting all instance restart with `./start.sh`. - -### Install docker. -This step depends on the operatingsystem you are using. For instructions have a look [here](https://docs.docker.com/) on the official docs site or google it. -* [Windows](https://docs.docker.com/desktop/windows/install/) -* [Mac](https://docs.docker.com/desktop/mac/install/) -* Linux - - have to look it up. However make sure your user is in the docker group. Check with: `groups`. - To add your user to the docker group run: `sudo usermod -aG docker `. - - - -## some useful docker commands -For complete list of commands have a look at [official docker cli reference](https://docs.docker.com/engine/reference/commandline/cli/). - -+ `docker container ` - + `ls` lists all current active containers - + `ls -a` lists all containers - + `rm ` removes container -+ `docker image ` - + `ls` lists all images - + `rm ` removes image diff --git a/test/test_container_docker/ubuntu_20_04_ros2_multi/TODO.md b/test/test_container_docker/ubuntu_20_04_ros2_multi/TODO.md index e2b57b83..786c68bb 100644 --- a/test/test_container_docker/ubuntu_20_04_ros2_multi/TODO.md +++ b/test/test_container_docker/ubuntu_20_04_ros2_multi/TODO.md @@ -1,7 +1,4 @@ # TODO ## Currently **not** working properly -* [] Auto completion of commands in shell - - [] ros2 commands auto completion - diff --git a/test/test_container_docker/ubuntu_20_04_ros2_multi/start.sh b/test/test_container_docker/ubuntu_20_04_ros2_multi/start.sh index 45171cf7..fa07cfcc 100755 --- a/test/test_container_docker/ubuntu_20_04_ros2_multi/start.sh +++ b/test/test_container_docker/ubuntu_20_04_ros2_multi/start.sh @@ -1,2 +1,3 @@ #!/usr/bin/env bash +xhost +local:docker docker start ubuntu_20_04_ros2_multi-instance diff --git a/test/test_container_docker/ubuntu_20_04_ros2_multi/stop.sh b/test/test_container_docker/ubuntu_20_04_ros2_multi/stop.sh index f05aca21..e9417e3a 100755 --- a/test/test_container_docker/ubuntu_20_04_ros2_multi/stop.sh +++ b/test/test_container_docker/ubuntu_20_04_ros2_multi/stop.sh @@ -1,2 +1,3 @@ #!/usr/bin/env bash +xhost -local:docker docker stop ubuntu_20_04_ros2_multi-instance From c34d777cd49743397715d2664ce22506411f6994 Mon Sep 17 00:00:00 2001 From: Manuel Date: Mon, 10 Jan 2022 14:10:24 +0100 Subject: [PATCH 7/7] Clarified file on which to look at --- test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md | 2 +- test/test_container_docker/ubuntu_20_04_ros2_multi/README.md | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md b/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md index b158d237..52782cb5 100644 --- a/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md +++ b/test/test_container_docker/ubuntu_20_04_ros2_foxy/README.md @@ -3,4 +3,4 @@ Ubuntu 20.04 with ROS 2 [Foxy Fitzroy (codename ‘foxy’)](https://docs.ros.org/en/foxy/index.html) installed with x11 forwading. ## How to use -Have a look at README.md in test_container_docker. +Have a look at README.md in `ros_team_workspace/test/test_container_docker` for a detailed description on how to use. diff --git a/test/test_container_docker/ubuntu_20_04_ros2_multi/README.md b/test/test_container_docker/ubuntu_20_04_ros2_multi/README.md index 7b549f8a..934510f6 100644 --- a/test/test_container_docker/ubuntu_20_04_ros2_multi/README.md +++ b/test/test_container_docker/ubuntu_20_04_ros2_multi/README.md @@ -7,5 +7,4 @@ Ubuntu 20.04 with ROS 2 and installed with x11 forwading. ## How to use -Have a look at README.md in test_container_docker. - +Have a look at README.md in `ros_team_workspace/test/test_container_docker` for a detailed description on how to use.