ROS2 nodes can not see one another via network
Hello, I compiled ROS2 on a PC and on TurtleBot3/Raspberry Pi. When I run the talker/listener demos, it turns out that they communicate within the same machines, but across the machines they do not see each other, effectively creating two independent ROS2 instances.
.bashrc on the PC:
export ROS_HOSTNAME=192.168.88.11
export ROS_VERSION=2
export ROS_MASTER_URI=http://$ROS_HOSTNAME:11311
source /home/art/ros2_ws/install/local_setup.bash
.bashrc on Turtlebot/Raspberry Pi:
export ROS_DISTRO=bouncy
export ROS_MASTER_URI=192.168.88.11:11311
export ROS_IP=192.168.88.10
export ROS_HOSTNAME=$ROS_IP
export ROS_VERSION=2
source /home/pi/ros2_ws/install/local_setup.bash
source /home/pi/ros2_turtlebot/install/local_setup.bash
Also, after ros2 daemon start
on the PC, ros2 daemon status
on the Raspberry Pi shows "not running". Is there any problem with the configuration, which makes ROS2 not form a common system?
This question suggests that ROS_MASTER_URI
is used by ROS2, but here it is written that ROS2 does not use a centralized discovery mechanism. Then there is some info that there is no master in ROS2 and that multicast should be enabled, DDS should be configured etc. but I found no example of whether a plain ROS2 installation which uses the default DDS is configured already, if not what should I change in exactly that configuration? Taking into account that multicast is known to have problems via WiFi and a ROS2 user may have no influence on the configuration of a local WiFi network.
By the way, this works in two directions fot the two machines in question:
$ nc -lu -p 5555
$ nc -vzu 192.168.88.<10 or 11> 5555
Connection to 192.168.88.<10 or 11> 5555 port [udp/rplay] succeeded!
A local connection via an Ethernet cable also does not make the nodes see one another. All four interfaces Ethernet, Wifi have the MULTICAST flag.
I cound not find an option in ros2
which would show me the DDS used, its capabilities, possibly its connection logs. Any way of debugging what happens here?
You give two very different IPs for the involved hosts:
137.194.88.10
and192.168.88.11
. Are the networks they are in routed to each other? Because in yournc
example you use137.194.88.10
and137.194.88.11
.No, I am sorry, it is just a mistake. They are all on the same network, the IPs change depending on whether it is a Wifi network or a local Ethernet via a cable (I tested both), but in any case only the last .10 and .11 are different.
Also there is no firewall on both machines (tested with
iptables -L
) so at least in the case of the Ethernet connection, there is no firewall at all.You need to use
ROS_DOMAIN
instead ofROS_MASTER_URI
since in ROS2 there is no master anymore, check here : https://discourse.ros.org/t/how-to-ru...I did not have
ROS_DOMAIN
initially because the docs were saying that it is for an additional isolation. Possibly it changed, but anyway, I haveROS_DOMAIN
already and the problem persists. I compiled a snapshot of ROS2 from git, I will try with some beta instead to see if it helps.First of all: you don't have to set any of these environment variables. Actually
ROS_MASTER_URI
,ROS_HOSTNAME
, andROS_IP
are not even used in ROS 2.Commonly ROS 2 uses DDS for communication which uses UDP multicast packets. You might want to double check that your network supports multicasts. The following command line tool might be helpful for that: https://github.com/ros2/ros2cli/tree/...
Was this resolved? I am having the same issue, and I ran the multicast tool and that works. Not sure what else to try.