ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

ROS 2 Foxy Communication between Singularity Containers

asked 2021-10-28 07:52:25 -0600

Felix Widmaier gravatar image

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:

  1. 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
  2. Create the following node (as that declares a parameter "foo" and prints it value:

    import rclpy, rclpy.node
    class MinimalParam(rclpy.node.Node):
        def __init__(self):
            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__":
        node = MinimalParam()
  3. Run the node in one container:

    $ ./ros_dashing-ros-base.sif python3
  4. 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).

  5. Repeat Steps 2.-4. with the Foxy image. Here ros2 param does not work. Likewise ros2 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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-11-02 05:15:49 -0600

Felix Widmaier gravatar image

Not really an answer but a workaround:

I still don't know why it is not working with Fast DDS, however, I found out that using Cyclone DDS instead works.

All I had to do was to install the corresponding RMW in the container and configure it to be used:

apt-get install ros-foxy-rmw-cyclonedds-cpp
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp

Note that since Galactic Cyclone DDS is the default, so no need to explicitly configure anything there.

edit flag offensive delete link more

Question Tools



Asked: 2021-10-28 07:52:25 -0600

Seen: 205 times

Last updated: Nov 02 '21