ROS 2 Foxy Communication between Singularity Containers
When running Foxy in Singularity containers, utilities like ros2 node
and ros2 param
are not working for me. This was not a problem with Dashing, so it is something that changed between the two versions.
See the following minimal example:
Build Singularity images from the Docker images:
singularity pull docker://ros:dashing-ros-base # -> ros_dashing-ros-base.sif singularity pull docker://ros:foxy-ros-base # -> ros_foxy-ros-base.sif
Create the following node (as
node.py
) that declares a parameter "foo" and prints it value:# node.py import rclpy, rclpy.node class MinimalParam(rclpy.node.Node): def __init__(self): super().__init__("minimal_param_node") self.timer = self.create_timer(2, self.timer_callback) self.declare_parameter("foo", 42) def timer_callback(self): foo = self.get_parameter("foo").get_parameter_value().integer_value self.get_logger().info("foo: %s" % foo) if __name__ == "__main__": rclpy.init() node = MinimalParam() rclpy.spin(node)
Run the node in one container:
$ ./ros_dashing-ros-base.sif python3 node.py
In a different terminal run
$ ./ros_dashing-ros-base.sif ros2 param list $ ./ros_dashing-ros-base.sif ros2 param set /minimal_param_node foo 13
This results in the node being listed with its parameter and the value of the print in the first terminal changing to 13 (just as expected).
Repeat Steps 2.-4. with the Foxy image. Here
ros2 param
does not work. Likewiseros2 node list
is not showing the node. Interestingly,ros2 service
is still working, though.
I saw discussions about similar issues in Docker where the problem is that Fast-DDS now uses shared memory by default and the problem is solved by either changing the configuration to use UDP or binding /dev/shm
into the containers.
However, Singularity already binds /dev
by default and I am using shared memory between containers without problem in other (non-ROS) applications. Further using UDP instead did not change the behaviour for me.
Any idea what could be the problem and how to solve it?