0
$\begingroup$

I am trying to get the following setup by command line, but it is not working (Ros2, Galactic, fastrtps): I would like to setup a set of ROS2 nodes partitioned by multiple discovery servers. I would like to have these discovery-servers on different machines but at the moment let's take the topology of option2 of this document, so consider just one machine. We have 2 discovery server (DS1 and DS2) with a publisher (P) referring to DS1 and a subscriber (S) referring to DS2: P -> DS1 <-> DS2 <- S. My question is "Can I get the servers talking to each other from command line"? According to this page , if I got it right, it is possible prefixing to one of the servers the reference to the other via "export ROS_DISCOVERY_SERVER" (so one server becomes a "client" of the other). All in all, I have the following configuration:

TERMINAL1 (DS1):
source /opt/ros/galactic/setup.sh
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
fastdds discovery -i 0 -l 192.168.1.188 -p 11811

TERMINAL2 (DS2):
source /opt/ros/galactic/setup.sh
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
export ROS_DISCOVERY_SERVER="192.168.1.188:11811"
fastdds discovery -i 1 -l 192.168.1.188 -p 11812

TERMINAL3 (P)
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
export ROS_DISCOVERY_SERVER="192.168.1.188:11811"
ros2 run demo_nodes_cpp talker --ros-args --remap __node:=talker_discovery_server


TERMINAL4 (S):

source /opt/ros/galactic/setup.sh
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
export ROS_DISCOVERY_SERVER="192.168.1.188:11812"
ros2 run demo_nodes_cpp listener --ros-args --remap __node:=listener_discovery_server

If this can not be achieved via shell commands, to my understanding I can take point to an xml config file (like this) via FASTRTPS_DEFAULT_PROFILES_FILE, but then how should I use it? With one server I would just launch "fastdds discovery -i 0" but here there are multiples..

Thanks

$\endgroup$

1 Answer 1

1
$\begingroup$

I think I have found the solution (here for details): when setting the ROS_DISCOVERY_SERVER environmental variable one needs to specify the IP address in the "right slot". So each IP address needs to match the corresponding discovery server id: below a working example with discovery servers on different machines:

MACHINE1-TERMINAL1 (discovery server '0'):
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
export ROS_DISCOVERY_SERVER="192.168.1.188:11811"
fastdds discovery -i 0 -l 192.168.1.188 -p 11811

MACHINE1-TERMINAL2 (discovery server '1'):
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
export ROS_DISCOVERY_SERVER="192.168.1.188:11811;192.168.1.188:11812;"
fastdds discovery -i 1 -l 192.168.1.188 -p 11812

MACHINE1-TERMINAL3 (talker via server '1'):
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
export ROS_DISCOVERY_SERVER=";192.168.1.188:11812;"
ros2 run demo_nodes_cpp talker --ros-args --remap __node:=talker_discovery_server

MACHINE1-TERMINAL4 (listener via server '0'):
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
export ROS_DISCOVERY_SERVER="192.168.1.188:11811;;"
ros2 run demo_nodes_cpp listener --ros-args --remap __node:=listener_discovery_server

MACHINE2-TERMINAL1 (discovery server '2'):
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
export ROS_DISCOVERY_SERVER="192.168.1.188:11811;;192.168.1.248:11813"
fastdds discovery -i 2 -l 192.168.1.248 -p 11813

MACHINE2-TERMINAL2 (listener on MACHINE2):
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
export ROS_DISCOVERY_SERVER=";;192.168.1.248:11813;"
ros2 run demo_nodes_cpp listener --ros-args --remap __node:=listener_discovery_server

However sometimes one of the listener doesn't output anything till I restart the 'related' discovery server: is there an error in the above example or how should one detect/cope with such behaviors when for example working out in the field?

Thanks

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.