Connecting Remote ROS 2 Nodes using Docker & VPN

Hi All!

From time to time there are issues users have with connecting remote ROS or ROS 2 powered robots that do not share the same network.

This is why I created an article showing you how to connect ROS 2 nodes running on different hosts in different networks.

Together with this blog post I created an open-source, simple example project, where we run the same ROS 2 nodes, but in different scenarios:

  1. Single host | nodes running on the host system | No VPN
  2. Single host | nodes running in a single Docker container | No VPN
  3. Single host | nodes running in two Docker containers (Docker-Compose) | No VPN
  4. Two remote hosts | nodes running across two hosts in Docker | VPN Client installed inside the container
  5. Two remote hosts | nodes running across two hosts in Docker | VPN Client as a separate Docker container
  6. Two remote hosts | multiple Docker containers - each running a single node | VPN Client as a separate Docker container

The article is a step-by-step journey where I present the advantages and disadvantages of the following setups.

I hope you guys will find it helpful!

All the best,
Dominik

5 Likes

Excellent article, and thank you for documenting this use case!

A question I have is whether it would be possible to retain the use of DDS Autodiscovery between ros2 containers across multiple docker hosts by attaching the containers to a shared virtual network with a common subnet? Thus, one could avoid the need to manually set the HOSTNAME or customize the default DDS configuration files for specific vendors.

I recall being able to achieve something like this using docker swarm: linking two or more docker hosts by joining the nodes via a common swarm, creating a dedicated virtual network in that swarm, then attaching the respective network interfaces to any spawned ROS2 containers. I suppose the same is just as feasible using kubernetes, but the idea of using a simple VPN service, as opposed to resorting to a full blown container orchestration framework, has its own appeal for remote development.

1 Like

Ruffsl, thanks for the kind words about my article!

You asked a good question, because this will be a topic I’m going to cover in the next blog post :slight_smile: . I will show how to combine a container orchestration for easy setup (probably I will base an example on k8s) with P2P VPN for a low latency connection between containers on different hosts (like shown in the article above).

When it comes to a DDS autodiscovery, I will also cover that topic, but still custom DDS configuration will be needed (hosts from the same VPN network will be automatically added).

By using an overlay network provided by docker swarm you can connect docker containers running on hosts in different networks, however the traffic will go through a host running swarm manager. If pings to the host running swarm manager are low, that’s fine, but the higher the traffic the larger the latency, and that central server dependency becomes the weakest link.

My goal in the article was to configure a p2p network, where traffic goes directly between devices, no matter if they are in the same or different networks, without dependency on any proxy server in between.

In the next article I’m going also to connect containers p2p over the internet. Thanks to container orchestrator you will be able to manage the whole system from a central element, keeping inter-container communication decentralized and based on p2p vpn.

1 Like