PickNik: Docker for MoveIt and ROS Tech Talk 07.19.2021
PickNik's Brennard Pierce and Vatan Aksoy Tezer review how you can use Docker for MoveIt and ROS applications. They review what Docker is, and some built in scripts for execution
PickNik: Docker for MoveIt and ROS Tech Talk 07.19.2021
1.
Docker
Good development methods
19July 2021
Brennard Pierce / Vatan Aksoy Tezer
PickNik Robotics
bren.pierce@picknik.ai / vatan@picknik.ai
2.
Outline
● What isdocker? (Vatan)
○ Why use docker containers at all?
○ Containers and Images
● Real world advantages for robots? (Bren)
○ For development
○ On real robot
○ CI / Github Actions
○ Pickenv
● Demos
○ Docker command line utilities and getting
started
What is docker?
●Originated from LXC (Linux
Containers)
● Basically a container provider
● OS is virtualized instead of the
hardware (VM)
● Extremely Lightweight
● Native Performance
● Containers share the same host, thus
they can be in MBs of size!
● Can I run Linux docker on other
platforms (Windows, MAC)?
○ Yes, but there is actually a linux VM in
the background on these platforms.
5.
Containers vs Images
●A Dockerfile:
○ Defines the necessary actions that
is going to be used for creating an
image
● A Docker image is:
○ Immutable
○ Contains the source code, libraries,
dependencies, tools etc.
● A Docker container is:
○ Mutable runtime environment
6.
Where to GetDocker Images?
https://github.blog/2021-06-21-github-packages-
container-registry-generally-available/
https://hub.docker.com/
https://hub.docker.com/r/osrf/ros/
https://hub.docker.com/_/ros
https://hub.docker.com/u/moveit
For Development
● 1container per project.
○ Each project has isolated with regard to the
packages / workspace.
○ You can easily switch between each project.
● Identical workspace.
○ Everyone in the project is developing from
identical software version. Including CI
● 1 dev to figure out installation.
○ For example Realsense / android studio /
tensorflow
● Quick to clean project
○ Easy to test packages
○ Can easily delete container and test what
packages you really need / package updates.
● Fast update of project workspace
○ If there are new packages / changes to the
underlining project. You can pull the new
image quickly.
● Mount you home folder + users +groups
Pull Push
10.
CI / GitActions. ● Github can produce a image per PR
○ Easy to test PR’s locally or on robot
● CI takes less time
○ have all the software pre-installed.
● AWS robot maker
○ You can now send docker images to AWS so
you can run test in parallel.
○ Can run you simulation on multi cores.
● Make a new dev image
○ Using github action we can check to see if
there are new packages and rebuild the
underlying image.
Pull
Push
11.
Docker on thereal robot ● Easy to deploy code
○ Push pull a docker image
● Easy to version control whole system
○ You can version the docker image and pull
the complete system
○ The “Native” linux can have minimal
packages
○ No real need for “salt” / “Ansible”
● Dev can push directly onto robot
● You can develop on your laptop can push to robot.
~1min to push / run
● Every easy to downgrade / test in field
○ As your not changing the native OS you can
switch very easily between software versions.
12.
Example Dockerfile
FROM moveit/moveit2:foxy-source# Inherit from readily available MoveIt 2 docker
# Make tutorial workspace
WORKDIR /root/ws_tutorial
SHELL ["/bin/bash", "-c"]
# Clone MoveIt 2 tutorial repos
RUN git clone https://github.com/ros-planning/moveit2_tutorials
src/moveit2_tutorials -b main &&
vcs import src < src/moveit2_tutorials/moveit2_tutorials.repos
# Install dependencies and build moveit2_tutorials
RUN apt-get update && rosdep update &&
source /opt/ros/foxy/setup.bash &&
source /root/ws_moveit/install/setup.bash &&
rosdep install -r --from-paths src --ignore-src --rosdistro foxy -y &&
colcon build --event-handlers desktop_notification- status- --cmake-args -
DCMAKE_BUILD_TYPE=Release
# Cleanup and reducing image size
RUN rm -rf /var/lib/apt/lists/*
Docker Workflow
# Pullmoveit/moveit2:foxy-source image from dockerhub
docker pull moveit/moveit2:foxy-source
# Push the same docker image to private registry-host on port 5000
docker image push registry-host:5000/moveit/moveit2:foxy-source/
# Build a docker image from a given Dockerfile and tags it as
moveit/moveit2:tutorial
docker build --tag moveit/moveit2:tutorial - < Dockerfile
# Create an interactive container with the given image and runs /bin/bash
docker run -it --name tutorial-container moveit/moveit2:tutorial /bin/bash
# Create an image from the container
docker container commit tutorial-container techtalk:tutorial
# Save a docker image into a tar
docker save moveit/moveit2:foxy-source > moveit2_foxy.tar
# Load a docker image from tarball
docker load < moveit2_foxy.tar
15.
Frequently Used ContainerCommands
# Create an interactive container with the given image and runs
/bin/bash (Only the first time!)
docker run -it --name tutorial-container
moveit/moveit2:tutorial /bin/bash
# Start an existing container
docker start tutorial-container
# Shoot an interactive terminal in the running container
docker exec -it tutorial-container /bin/bash
# Stop the container
docker stop tutorial-container
# Remove the container (will delete everything inside it)
docker container rm tutorial-container
16.
How to makecontainers more useful?
xhost +local:root &> /dev/null # Give root access for displays
docker run -it --privileged # Joysticks and all connected devices
--net=host # Internet
--gpus all # GPU
--env=NVIDIA_VISIBLE_DEVICES=all
--env=NVIDIA_DRIVER_CAPABILITIES=all
--env=DISPLAY # Display
--env=QT_X11_NO_MITSHM=1
-v "/tmp/.X11-unix:/tmp/.X11-unix"
-v "$VOLUME:$VOLUME:rw" # Mount Custom Volumes
--name "$CONTAINER_NAME"
"$IMAGE_NAME"
/bin/bash
xhost -local:root 1>/dev/null 2>&1
17.
Whoa! Some Documentation
DockerInstallation: https://docs.docker.com/engine/install/ubuntu/
Docker Post Install: https://docs.docker.com/engine/install/linux-postinstall/
nvidia-docker2 Installation: https://docs.nvidia.com/datacenter/cloud-native/container-
toolkit/install-guide.html
Docker Documentation: https://docs.docker.com/engine/reference/run/