Skip to content

driving_swarm_docker

Moritz Marquardt edited this page Apr 28, 2021 · 10 revisions

Repository-Link.

Description

This repository is for getting started quicker and developing more easily for Driving Swarm. It utilises docker to deploy (multiple) instances of ROS-environments, both for development (with a virtualized desktop) and for running simulations e.g. on a server for faster performance.

Rviz in XFCE Gazebo in XFCE Terminals in XFCE Theia

Setup

  • Install docker
  • Advanced: Clone the repo (using git) for using advanced setup or developing your own image
  • Advanced: For using docker-compose you will have to install it (on the subsystem)
  • GPU-Support: Have a somewhat recent version of Mesa, or, if using nvidia's proprietary driver, see here
  • Use either the quick method or the method using docker-compose

On Windows

  • Install the Windows Subsystem for Linux 2 (WSL2
  • Install docker on WSL2
  • Replace the $PWD in the command with %cd%
  • Following the default steps, you can just access your dev-environment with your browser

With a nvidia-GPU

  • Install nvidia-docker and replace the docker run-command with nvidia-docker run --gpus all
  • (Windows) you have to follow this guide and then use docker from within WSL2 (untested)

Usage

In general the supplied Docker images / Dockerfiles either create a virtualized workspace (clone and then build) or mount a directory (commonly ./workspace) into the container.

Mounting the workspace has the advantage of being able to make local changes (without a running docker container) and e.g. change a *.repos-file to include different repositories before executing.

The most important helper script when working in the containers is the setup-workspace.sh (or sewo) script that downloads all dependencies and builds the project workspace.

Images

This repository includes several dockerfiles for different use-cases:

  • Image ready for use:
    • development - for developing for Driving Swarm by accessing a virtualised desktop and the Theia code editor
  • Additionally, images for building upon:
    • base - for base packages and environment setup including GPU-support, based on the official ROS-image
    • turtlebot - for providing specific turtlebot3-packages and the latest gazebo-version, based on turtlebot:slim
    • turtlebot:slim - for providing specific turtlebot3-packages without gazebo, based on base

Volumes & Files

There are some important folders and files in the container's virtual filesystem:

  • /home/docker/workspace contains all your project files.
  • /home/docker/.ssh contains the SSH keys needed for e.g. Git.
  • /home/docker/workspace/*.repos are the VCS repo files for your project dependencies.
  • /home/docker/workspace/src/*/.workspacerc gets executed on each setup-workspace.sh call (and thus also on container start), and can be used to for example symlink the .repos file or install dependencies.

Development-Quickstart

This will get the pre-built development-image from https://hub.docker.com. Run the following command to start the development container with the directory ./workspace mounted as ~/workspace:

docker run --name ros-development -d -h ros-development \
  --device=/dev/dri \
  -p 127.0.0.1:1800:1800 \
  -p 127.0.0.1:1900:1900 \
  -p 127.0.0.1:5900:5900 \
  -v "$PWD/workspace:/home/docker/workspace" \
  ovgudrivingswarm/development
  • To stop the container, run docker stop ros-development
  • To restart it, run docker start ros-development
  • To remove it completely, stop it and then run docker rm ros-development.

You can now access Theia (an IDE-like code editor) with your browser at http://127.0.0.1:1900 and a virtual desktop environment at http://127.0.0.1:1800/?autoconnect=true&bell=false&resize=scale&show_dot=true.

You can also use any VNC client like Remmina at 127.0.0.1:5900 to connect to the virtual desktop.

docker-compose

For using more advanced options (via the docker-compose.yml-file) or deploying containers on a server, you should use docker-compose

To start a docker-container named image:

mkdir my-awesome-project && cd my-awesome-project
wget https://raw.githubusercontent.com/ovgu-FINken/driving_swarm_docker/master/docker-compose.standalone.yml -O docker-compose.yml
docker-compose up
  • Add -d in the last line to start and detach
  • To access a shell in a running container, you can use docker-compose exec rosdev bash

For development you can access Theia (an IDE-like code editor) with your browser at http://127.0.0.1:1900. and a virtual desktop environment at http://127.0.0.1:1800/?autoconnect=true&bell=false&resize=scale&show_dot=true.

You can also use any VNC client like Remmina at 127.0.0.1:5900 to connect to the virtual desktop.

Using make and manual builds

Manually building will take quite an amount of time (it is necessary for developing your own dockerfiles however).

To build a specific image (using docker-compose under the hood) use:

git clone [email protected]:ovgu-FINken/driving_swarm_docker.git
cd driving_swarm_docker
make build-<base|turtlebot-slim|turtlebot|development>

Develop and Deploy your own image

If you want to customise images (add new packages by default etc.) or e. g. add new tools to be launched with `development` you will have to develop your own image.

Developing your own image includes writing your own dockerfile:

  • For a general overview look here
  • For best practices here
  • You can build upon the provided dockerfiles with FROM ovgudrivingswarm/image:latest, for an overview of images look above

Entrypoint scripts are most commonly used for setting up environment variables etc. and the executing a script, supplied as an argument.

We provide several (entrypoint-) shell-scripts which are used in the repo's dockerfiles / for using in your dockerfiles:

  • /entrypoint.sh in base/ - An entrypoint script for setting up GPU-support, ssh-keys and the ros-environment
  • /usr/local/bin/setup-workspace.sh in base/ - An entrypoint script for cloning the workspace from *.repos-files (or creating a default file) in the workspace, then installing dependencies and building it
  • /usr/local/bin/setup-desktop.sh in development/ - The script for starting

Known Issues, Bugs and Workarounds

Issues

  • High CPU-load (with e.g. gazebo)
    • To test if you have GPU-support enabled and working, try running glxheads to check your renderer-string
    • If it says llvmpipe, GPU-support is not working (if it says Intel / AMD / Nvidia, it works)

Caveats

  • Did not test nvidia-GPU-support on WSL2 yet

  • Nothing else yet 😅

Help