Skip to content

DockerROS2

Junichi Tokuda edited this page Mar 2, 2023 · 12 revisions

A Docker image for the ISMR Workshop tutorial was set up as follows.

Docker Image

docker-ubuntu-vnc-desktop, a Ubuntu 20.04 container with HTML5 VNC server, seems to be robust and well used by the community. The Dockerfile is available in Github, unlike some of the other similar containers. Also, the Dockerfile is written in a way that it can be built for non-Intel platforms.

ROS 2 can be integrated by replacing the base container with an official ROS 2 container. The forked repository is available in the ROSMED GitHub repository.

The Docker image will be available at Docker Hub.

Building Docker Image (Not needed for end-users)

The Dockerfile repository can be obtained by cloning the repository at GitHub. Please note that '--recursive' option is required to build the image correctly.

$ git clone --recursive https://github.com/rosmed/docker-ubuntu-vnc-desktop-ros2

Please note that that we use the ismr2021 branch for the ISMR 2021 workshop. To swich:

$ cd docker-ubuntu-vnc-desktop-ros2
$ git checkout ismr2021

To build an image, run the following command:

$ docker build . -t rosmed/docker-ubuntu-vnc-desktop-ros2:ismr2021 .

Please note that the colcon build process in this Docker build may fail due to memory shortage. If it fails, consider increasing the memory size assigned to the Docker image. The current Docker file was tested on macOS Big Sur + Docker Desktop 4.01. Six CPUs, 16GB memory, 1GB swap, and 69.6GB disk image were assigned.

To push the image to Docker Hub:

$ docker push rosmed/docker-ubuntu-vnc-desktop-ros2:ismr2021

Running Docker image

If you run the image available in the Docker Hub, pull the image using the following command:

$ docker pull rosmed/docker-ubuntu-vnc-desktop-ros2:ismr2021

To execute the docker image, call the following command:

$ docker run -it --rm -p 6080:80 -p 28944:18944 rosmed/docker-ubuntu-vnc-desktop-ros2:ismr2021

In this example, the web port on the docker container will be mapped to port 6080 on the host computer. It also maps local (host) port 28944 to the guest OS's port 18944 for OpenIGTLink connections (see below). The '--rm' option will remove the container upon termination.

Testing OpenIGTLink Connection

The docker image pulled in the previous section comes with a copy of the OpenIGTLink under /root/igtl, and can be used to test communication between an OpenIGTLink server on the guest OS and a client on the host computer. Before testing OpenIGTLink connection, make sure to install 3D Slicer with SlicerOpenIGTLink extension on the host computer.

Once the Docker image is up and running (see the previous section), open an Web brawser and access:

http://localhost:6080

Once a VNC remote desktop environment should appear on the browser window, click the button on the left end of the task bar at the bottom of the desktop to launch a start menu, and open System Tools -> LXTerminal. From the LXTerminal window, type the following commands (the command prompt may look different):

root@1416df32acf1:~# cd igtl/OpenIGTLink-build/bin/
root@1416df32acf1:~/igtl/OpenIGTLink-build/bin# ./TrackerServer 18944 10

The second command launches a dummy tracking server that waits for a client at TCP port 18944. If the docker is launched with option -p 28944:18944 as described in the previous section, the port is mapped to TCP port 28944 on the host computer.

From the host computer, open the 3D Slicer and choose OpenIGTLinkIF (from the Modules:, choose IGT -> OpenIGTLinkIF), and create a client connector and set the port to 28944. Once the connector is activated, you should see random transformation matrices are displayed on the terminal window on the VNC remote desktop environment. You can also confirm the communication from 3D Slicer, by visualizing the transform node.