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

fastdss discovery-server 50% operational in docker

asked 2022-07-26 04:17:48 -0500

updated 2022-07-26 04:19:43 -0500

I'm having issues with ROS2 discovery. I managed to dumb down the problem to the dockerfile below:

version: "3.3"
services:
  discovery-server:
    image: ros:humble
    environment:
      RMW_IMPLEMENTATION: rmw_fastrtps_cpp
    network_mode: host
    command: /bin/bash -c 'source /opt/ros/humble/setup.bash && fastdds discovery -i 0'
  talker:
    image: ros:humble
    environment:
      RMW_IMPLEMENTATION: rmw_fastrtps_cpp
      ROS_DISCOVERY_SERVER: 127.0.0.1:11811
    network_mode: host
    command: /bin/bash -c 'apt-get update -qq && apt-get install -qqy ros-humble-demo-nodes-cpp && source /opt/ros/humble/setup.bash && ros2 run demo_nodes_cpp talker'
  listener:
    image: ros:humble
    environment:
      RMW_IMPLEMENTATION: rmw_fastrtps_cpp
      ROS_DISCOVERY_SERVER: 127.0.0.1:11811
    network_mode: host
    command: /bin/bash -c 'apt-get update -qq && apt-get install -qqy ros-humble-demo-nodes-cpp && source /opt/ros/humble/setup.bash && ros2 run demo_nodes_cpp listener'

This file seems to be working on my (Mint 20.3) PC, but not on the robot (Ubuntu-server 20.04). I tested two other ubuntu setups: ubuntu 20.04 desktop works and ubuntu 22.04 server does not. Not sure if the versions are relevant, because well, docker?

What could be wrong with the setup above?

Note that the example above also breaks on a ros:galactic image with ros-galactic-rmw-fastrtps-cpp installed.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-08-02 00:14:33 -0500

EduardoPonz gravatar image

Give it a try to set Docker IPC mode to host:

version: "3.3"
services:
  discovery-server:
    image: ros:humble
    environment:
      RMW_IMPLEMENTATION: rmw_fastrtps_cpp
    network_mode: host
    ipc: host
    command: /bin/bash -c 'source /opt/ros/humble/setup.bash && fastdds discovery -i 0'
  talker:
    image: ros:humble
    environment:
      RMW_IMPLEMENTATION: rmw_fastrtps_cpp
      ROS_DISCOVERY_SERVER: 127.0.0.1:11811
    network_mode: host
    ipc: host
    command: /bin/bash -c 'apt-get update -qq && apt-get install -qqy ros-humble-demo-nodes-cpp && source /opt/ros/humble/setup.bash && ros2 run demo_nodes_cpp talker'
  listener:
    image: ros:humble
    environment:
      RMW_IMPLEMENTATION: rmw_fastrtps_cpp
      ROS_DISCOVERY_SERVER: 127.0.0.1:11811
    network_mode: host
    ipc: host
    command: /bin/bash -c 'apt-get update -qq && apt-get install -qqy ros-humble-demo-nodes-cpp && source /opt/ros/humble/setup.bash && ros2 run demo_nodes_cpp listener'

TL;DR

You are running into a limitation of the default SHM transport. To try to identify whether two nodes are running in the same host machine, Fast DDS relies on the available network interfaces. Since your compose sets the network_mode to host, all three container instances will have the exact same network interfaces, and therefore Fast DDS will think that your three nodes are running on the same host, so it will default to the SHM transport. However, since you have container isolation, the nodes do not share the same shared memory segments, thus communication fails. The easiest for you would be to set the IPC mode to host as well (I have verified that this solves the problem locally).

edit flag offensive delete link more

Comments

Yes, this works. Thank you.

Curious: does this mean that this solution is also more performant than not using network_mode: host? As in that case upd would be used instead of shared memory.

Timple86 gravatar image Timple86  ( 2022-08-03 02:42:28 -0500 )edit

Yes, exactly! If you do not use host network mode, then Fast DDS will use UDPv4, so you'll lose performance.

EduardoPonz gravatar image EduardoPonz  ( 2022-08-03 03:01:02 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2022-07-26 04:17:48 -0500

Seen: 540 times

Last updated: Aug 02 '22