Workshops

ROS with Docker on Windows 10

I recently started to deepdive in the world of Robotics Engineers. To be at my best i’m installing and configuring several devices and ofcourse my development environment. I’ll make these posts to share the knowledge and to archive mine. In this post I’m setting up a Ros master on docker with the catking workspace folder and logs folder mounted to my Windows 10 laptop.

Docker

I’m using Docker because the comfort of an isolated application environment. Maybe my Windows installation is configured a specific way due to installing multiple IDE’s and/or platform engines. And I don’t want to influence my ROS installation.

I’ve installed Docker by downloading the installer from their main website: https://docs.docker.com/docker-for-windows/install/ .

Ofcourse I already searched for the official docker ros repository which can be found here: https://registry.hub.docker.com/_/ros/ . There are several possibilities per distrubution of ROS which can be pulled. Which one suits your needs depends on what you want.

ROS metapackages

I’m focusing on ROS Noetic so i’ll be focusing on that distro. The official docker releases are:

  1. ros-core: bare minimum ROS installation
  2. ros-base: basic tools and libraries are also installed.
  3. ros1-bridge: tools and libraries to run hybrid ROS1 and ROS2 and bridge messages between them.

However this is also stated on the docker hub website, but there are a few more flavors or also called metapackages:

  1. robot – on top of ros-base adds ROS libraries for any robot hardware.
  2. perception – on top of ros-base adds some image and vision libraries.
  3. desktop – on top of robot and viz adds tutorials and roslint.
  4. desktop-full – the full ros experience – on top of desktop, perception and simulators and added a simtutorial.
  5. simulators – on top of robot adds gazebo packages and rqt plugins.
  6. viz – on top of ros_base adds rviz library and rqt plugins.

These are the names on metapackage level which you could specify to suit your needs. For example, if you pull noetic-robot then you’ll automatically get the ros-core and ros-base metapackages. Because these are interlinked.

More information about the metapackages can be found here: https://github.com/ros/metapackages/tree/noetic-devel . The distributions are found as branch names.

The metapackage dockerfiles are in the OSRF profile of Docker Hub: https://hub.docker.com/r/osrf/ros/.

Run ROS Docker image on Windows

I’m more familiar with Docker as a former Java Software Engineer. The Docker command which I used on my Windows machine makes use of some mounts which make it possible for me to interact with the workspace and log folders, however it can be enhanced to get more interaction.

docker run --name ros --net=host -v "C:/ros/logs/.ros/:/root/.ros/" -v "C:/ros/catkin_ws/:/home/catkin_ws/" -it ros:noetic-robot

Explanation of the command:

–name : this gives your running docker image a name which it is linked to, so I can type a shorter or more explainatory command: e.g. docker start ros.

— net : which type of netwerk is used, you can specify host to share it’s host networking namespace and it’s not isolated from the docker host ( in this case your laptop). *For the expert, the published port command (-p) is discarded when –net=host is used.

-v : volume mounts are used to mount a folder on your machine to the docker instance. This is done in the specific order of “my-machine”:”docker-machine”.

-it : interactive session with the running docker instance. don’t forget the t parameter as you won’t get to read the output of your command and lose the session. The i stands for interactive and t for tty ( pseudo terminal) which you’ll need when you want a standard terminal like interaction with your docker instance.

However this wil start a interaction pseudo terminal(TTY) and you’ll drop right into the docker session. Which is fine because we need to make some actions directly. To begin with ros you’ll need to execute the command ‘source ros_entrypoint.sh‘ . This will setup the ros environment. After this I’ll close my docker image and check if it keeps running by running the command ‘docker ps‘. If it needs to be manually started you can execute: ‘docker start ros‘ and for stopping ‘docker stop ros‘.

After this the docker image has started and works like a charm. Well done.

Configure ROS within the running Docker image

After this the catkin workspace wasn’t created yet so I started a bash to the docker image to prepare my workspace folder as a catkin workspace. To get the bash from this running docker image I used the bash command, ‘docker exec -it ros bash‘.

I navigate to the catkin_ws folder which I also mounted on my docker setup, /home/catkin_ws/. When I’m in this location I use the command ‘catkin_make‘. This will setup the catkin workspace folder and if executed correctly you’ll see a src and devel folder.

Also when you start ros with the command ‘roscore‘ there are some logs being filled with content like:

Starting ROS Master Node
XML-RPC server binding to 0.0.0.0:11311

This is then also visible in your laptop in the mounted folder, this way you can also look into your logs when the docker image suddenly stops because of an error or unexpected behaviour. Note that 11311 is the default port of the ROS Master node.

Conclusion

Now you know how to setup a docker image of ROS and interact with it. Choose your metapackages with great joy and good luck with it!

Leave a Reply

Your email address will not be published. Required fields are marked *