ROS 2 remote connection through VPN

I’m having some issue with my robot ecosystem and the remote connection.
The ecosystem is composed by:

  • A drone where is running ROS 2 foxy connected to a router
  • The router where is enabled a connection to a VPN net
  • A ROS 2 foxy remote host connected to the same VPN net of the router

Based on these info, the drone is not directly connected to the VPN, the router will bridge remote connection from host connected to the same VPN net of the router.

In this VPN net the router and the remote host have, for ex, an ip class like this 10.10.10.x, instead the drone in the router net has an ip class like this 192.168.10.X

For ROS 1 the thing was easy having the ROS_MASTER on the drone, so I set on the drone the ROS_MASTER_URI, ROS_HOST_NAME and ROS_IP to its own ip, for ex,
On the remote host ROS_MASTER_URI to and ROS_HOST_NAME and ROS_IP to the VPN ip of the host, for ex,
Thanks to this configuration, with ROS 1 i can do everything from the remote host (echo topic, call services, use rviz to visualize PCL and laser,…)

The thing on ROS 2 is not working, even if i set the ROS_DOMAIN to the same number on both, drone and remote host, i can’t echo topics created on the drone and other stuff to manage it.
What I’m worrying about is that the remote host and the drone are not under the same ip class so the udp broadcast of the ROS 2 on the drone doesn’t reach the remote host which is actually on another ip class
Instead on ROS 1 the thing works cause I give the address of the master and it s reachable through the VPN thanks to the bridging of the router.
Of course I can ping and ssh connect to the drone from the remote host without problems

Do you have any advise/suggestion to make it work?
I’m not doing anything special on the drone, I just launch a couple of ROS 2 packages for PCL and lidar managing, nothing more

I tried the following to understand if there’s a blocking firewall on the port, so on the drone I run

nc -u -l 7650

and on the remote host i run

nc -u 7650

and if I type a string on the remote host terminal where I run nc i can get that string on the drone terminal where I run nc

with ROS 1, it is server client model with rosmaster, it works with routing table. this is because discovery process work via rosmaster.

but ROS 2, what you do here is to connect 2 different LAN, in this case discovery process does not work. since it uses UDP multicast for the endpoint discovery, drone cannot discover the remote host at all. (if discovery does not work, there is no way that peer to peer communication works.)

i think we could have a couple of approaches here,

  • remote host and drone are in the same VPN. i am not sure what VPN solution that you use. but if VPN supports multicast, they should be able to do the discovery and p2p communication should work.
  • use Fast DDS Discovery Server replace of rosmaster.

i would take 2nd option, since you did not use VPN for the drone intentionally. 2nd option is similar solution with ROS 1 rosmaster, so could be the option.

hope this helps,

You could give Husarnet a try:

1 Like