Trying out ROS2 Humble Hawksbill using Docker

RoboFoundry
6 min readJun 1, 2022

--

I recently saw the announcement from OpenRobotics about release of new LTS version of ROS2 distro - Humble Hawksbills. I was excited about trying the new version as I have heard it has lots of new improvements and cool new version of Gazebo Ign.

However, I started to test the docker installation on my new Windows 11 laptop with WSL2 installed and immediately realized that ROS2 Humble requires newer version of Ubuntu 22.04 [not the old 20.04 which was required by Foxy]. I had already installed the 20.04 on WSL2 so I didn’t want to install yet another WSL2 Ubuntu for 22.04. I figured I would try to install the Humble on docker container as it would provide so much more flexibility.

However, for all the dead ends and rabbit holes I ran into in exporting the GUI while running in docker container that is running on WSL2 that is running on Windows 11, it became very frustrating. I spent multiple days trying to get that setup working on Windows 11 with WSL2 and some combination of either Windows 11 running docker engine or WSL2 running docker engine to satisfy following requirements:

  1. I should be able to ssh into it [this was not that hard to do but somehow I was not able to make it work via docker-compose, it only worked for me when I ran the container from command line and I’m not a docker expert].
  2. ROS messages are visible to/from my devices running on my LAN [like Raspberry Pi on robot] to/from the docker container
  3. I should be able to launch the GUI apps from within docker container and it should be visible in host machine [I know I can use VNC but I wanted to run it directly using X11]
  4. Avoid having IP conflicts with other machines on network [believe me I learned a lot about different types of docker networks]

These seem like very basic needs for any ROS developer and I’m not being very demanding or anything. After beating my head on various configuration and giving up and restarting several times, I finally got it working on setup below. I just could not get everything to work as I wanted on Windows WSL2 so I gave up that path [the network isolation was too painful to get around for ROS messages given the workarounds mainly dealt with TCP]. There are some really brave souls out there [shout out to Andre Lanouette on his awesome github repo] who have figured it out using Fast DDS and Cyclone DDS configurations but I could not make it work in my setup.

  1. I installed Ubuntu 20.04 bare metal as dual boot on my Windows 11 laptop. It was scary but it worked well. There are a ton of articles on this topic and I simply chose the easy option to install Ubuntu side by side with Windows 11 after shrinking my single SSD hard disk on my laptop
  2. I installed docker engine on the Ubuntu 20.04
  3. Ran the ROS2 Humble in container running on the host Ubuntu 20.04

There were several small tweaks needed for getting all the things I was looking for working. The steps I followed to get it working are documented below.

Step 1

Install Ubuntu 20.04 to dual boot with Windows 11. I followed this article but there are more in reference below.

You can download the desktop Ubuntu 20.04 here.

Step 2

Install docker engine on Ubuntu 20.04 by following official docker instructions here. You can install docker desktop if you like from here.

Try running hello world docker test to make sure it works correctly.

Step 3

Run these commands in terminal on Ubuntu Host.

### on linux hostexport DISPLAY=:1.0xhost +local:docker

I’m not sure if xhost command above is really necessary so you can try running without it. Also, if you are going to do this often, it may be useful to put the export display in your ~/.bashrc file so its always there.

Step 4

Run following command from Ubuntu Host terminal.

The key parameters below that make it all work are -e DISPLAY which basically ensures that the display env variable we exported above is matching with docker container when it comes up.

And the device parameter which will prevents any errors when you launch GUI apps from inside the container.

The last thing to take note of is the net parameter which is basically using the host network in docker container which means it shares the exact same network as the host [doesn’t get its own IP address] so the container can see all the traffic on LAN and there is no IP address conflict either.

docker run -it --net=host --device /dev/dri/ -e DISPLAY=$DISPLAY -v $HOME/.Xauthority:/root/.Xauthority:ro osrf/ros:humble-desktop

If everything works as expected you will land at a command prompt that has logged you into the docker container as root and if you run ros2 command you’ll see that you have ros2 up and running already. If you run echo $ROS_DISTRO it should show you “humble” is running.

$ lsb_release -a# should show something like this
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04 LTS
Release: 22.04
Codename: jammy
$ echo $ROS_DISTROhumble

At this point if you want you can install Gazebo fortress following instructions from here.

And you can test out your GUI apps like rqt or test the new gazebo app.

ign gazebo empty.sdf

And you should see the app popup that looks like this and you should be able to add more solids to the empty world, I have added 3 shapes in mine below.

Interesting thing was I ran the simple talker node within the container and a listener in host and the host was able to listen to the ROS2 messages from the talker. Also, when I ran rqt to from host I was able to see both talker and listener nodes along with chatter topic. In addition, at this point I am able to listen to all the topics being published by RPi on robot from my host machine as well. So it has met most of my requirements I started with.

Someday I promise I’ll go back to the Windows 11 based host and try to fix it and if Microsoft comes up with better option for WSL2 to remove that network isolation with a configuration or parameter, that would make it even more easy.

If you are curious, I’m still going to continue to develop in ROS2 Foxy for a little while until I get more comfortable with Humble and move all the code for my existing robots to Humble and test it out. Foxy will be supported until May 2023 according to this, so we still have a bit of time. Humble is going to be supported until 2027 so its a long time once you make the move. I’ll upgrade my host Ubuntu to 22.04 after I move everything to Humble.

It sure will be a bit sad to say goodbye to good old and trusty Foxy as I started my journey with ROS on ROS2 and Foxy so it will always be special for me!!

Hope that saves you some time. Enjoy!!

References

https://gazebosim.org/docs/fortress/install_ubuntu

https://gazebosim.org/docs/fortress/ros2_integration

--

--