Unable to use domain change with ROS2 foxy
Baerenstark2 opened this issue · 5 comments
I am trying to work work with SOSS on ROS2 foxy using an Ubunto 20.04 VM. After successfully building (see PR#47) i tried the ros2 domain change example (sample_ros2_domain_change.yaml). I was unable to get the system to work using a comman line Publisher in a terminal with the ROS_DOMAIN_ID set to 5 ros2 topic pub -n "soss_5" -r 1 string_topic std_msgs/String "{data: \"Hello, ID 10\"}"
and a simple listener node I created. Since i was unsure what the problem was i tried the example on ROS2 Crystal on a Ubunot 18.04 VM, were it worked fine.
From observing the behavier i noticed that in my Crystal workspace the execution of sample_ros2_domain_change.yaml created one Node (soss_5) as a subscriberin Domain ID 5 and a Node (soss_10) as a publisher in Domain ID 10. In the foxy workspace the example also creates two nodes(soss_5 as the subscriber and soss_10 as the publisher) but both nodes are created in the default DOMAIN_ID 0.
My guess would be that there is a difference how nodes for a specific DOMAIN_ID are created in Crystal and foxy. In the file packages/ros2/src/SystemHandle.cpp starting from line 122 seems to be were the domain ID is set for the created nodes, but I am not sure.
Does somebody know how to get the domain Change working on foxy or can help locate/fix the bug causing the nodes to be created in the default domain?
Hi there! Has there been any follow-up for this issue? I have been facing the same issues and verified that it works on crystal
.
These are the steps I used to build and test in docker containers ros:foxy-ros-base-focal
and ros:crystal-ros-base-bionic
, https://gist.github.com/aaronchongth/2c2641fe1473e41b713a9e1dda070b23
In Foxy, most RMW implementations moved away from "one node per process" to "many nodes per process" (see design doc). This is to say that trying to set a domain ID per node no longer makes sense. Instead, we should think about the domain ID for the process (well, more specifically the "context"). I'm guessing this is the reason the domain change code is not working as expected.
I'll see if I can tweak the implementation to get it to work and report back.
Okay, I can confirm what I suspected is the issue is correct. If I move the call to rclcpp::init after setting the ROS_DOMAIN_ID environment variable, the nodes show up a different domain. The problem now is that both nodes are using the same context and so end up on the same domain. We can avoid this by maintaining different contexts for each node.
I've proposed a fix in #53
Good afternoon,
This was fixed and it is now part of our new 3.0.0 release for the Integration Service. The ROS 2 System Handle is prepared to support Foxy on its 3.0.0 version and Galactic has already been included as a supported ROS 2 distro in the main branch and will be part of the forthcoming Integration Service 3.1.0 release!