I have a problem in communicating between 2 ros2 environments :one running on a docker container hosted on a macos and the second one running directly on a Linux. I set up the env ROS_DOMAIN_ID=5 for both. I set up as well the port when running the docker container together with an IP address with the same subnet as the Linux pc. They are both connect to the same network. The problem is that I cannot ping the docker container, hence I cannot communicate in between the ros2 setups. I am almost sure that the problem is the network but I do not know how to solve it. Anyone had this problem? Thanks.
The docker runs on a ros:foxy image.
2
Answers
You can try using discovery server, this should make the two visible to each other.
I’m pretty certain that your problem should be with the network, as you suggested. I don’t know much about networks to guide you through this. But I had a similar situation and I can share how I managed to solve the problem.
First, you have to be able to ping one system from the other, to ensure both are connected to the same network.
Second, you have to deal with the discovery step of the DDS in ROS2. ROS2 has some implementations of DDS available out of the box, Fast DDS is the default and the simplest but it lacks in performance, especially at the discovery, so I recommend you to try other implementations. (It can be handy to test the different implementations using the tool suggested by @Alesof)
Third, you’ll have to set the same ROS_DOMAIN_ID in both systems for them to be able to share the same ROS topics/services. (In simple terms ROS_DOMAIN_ID is used as a filter! It’s better to only set some value when you have the communication working properly)
Depending on your systems/network if you manage to solve the first step I think you will be good to go.
In my case, I had containers inside two separate host Linux computers. The first one was a desktop and the second one was an NVIDIA Jetson. I had network setup to host in all the containers, so the container and the hosts share the same IP and act like just one. And I’ve used the Cyclone DDS to solve the discovery problem.