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

ROS2 galactic nodes can't communicate through docker container border

asked 2021-09-22 03:10:44 -0500

stan-g gravatar image

This question is a direct follow up to this one: ROS2-foxy nodes can't communicate through docker container border


Recap in Foxy:

The following does not work

docker run -it --net=host --rm osrf/ros:foxy-desktop ros2 run demo_nodes_cpp talker

In Terminal 2:

docker run -it --net=host --rm osrf/ros:foxy-desktop ros2 run demo_nodes_cpp listener

The resolution was to mount the shared memory into both containers, because of how Fast-DDS works when it believes it's on the same machine:

In terminal 1:

docker run -it --net=host -v /dev/shm:/dev/shm --rm osrf/ros:foxy-desktop ros2 run demo_nodes_cpp talker

In terminal 2:

docker run -it --net=host -v /dev/shm:/dev/shm --rm osrf/ros:foxy-desktop ros2 run demo_nodes_cpp listener

Now back to ROS2 Galactic. AFAIK ROS2 Galactic uses Cyclone DDS, so the shared memory solution does not work anymore.

So what do i have to do to get the following to work?

In Terminal 1:

docker run -it --net=host --rm osrf/ros:galactic-desktop ros2 run demo_nodes_cpp talker

In Terminal 2:

docker run -it --net=host --rm osrf/ros:galactic-desktop ros2 run demo_nodes_cpp listener
edit retag flag offensive close merge delete

Comments

I've kept trying this https://github.com/eclipse-cyclonedds... but this does not seem to work with --net=host. I'll look into it again though.

stan-g gravatar image stan-g  ( 2021-09-22 04:05:21 -0500 )edit

if Fast-RTPS suits your need better.. Keep in your mind that switching the DDS is pretty straight forward! See this great answer from here #post-id-349869

flo gravatar image flo  ( 2021-09-23 15:25:51 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-10-15 16:38:00 -0500

rkent gravatar image

updated 2021-10-16 11:29:52 -0500

gvdhoorn gravatar image

I've been looking into ros2 networking with Docker, and I came across your question. From my research, there are a couple of possible things you could investigate here.

When I run your galactic example, it works for me. But I get this output at first:

1634332658.047513 [0]     talker: using network interface eno1 (udp/192.168.0.59) selected arbitrarily from: eno1, virbr0, docker0, br-275b968cf991

If the nodes used different interfaces, then communication would fail. Mine always seems to default to the ethernet interface which is correct, but the message indicates this is arbitrary. This can be fixed using a config file option NetworkInterfaceAddress for the Cyclone DDS.

As another possible issue, dds implementations can get confused and try to use shared memory with --net=host The --pid=host option has been proposed to fix this. See this question/answer for more details: #q296828.

edit flag offensive delete link more

Comments

@rkent the url in your answer got truncated. You can fix it by editting your answer using the "edit" button at the end of the text.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-10-16 06:37:01 -0500 )edit

OK, fixed the url

rkent gravatar image rkent  ( 2021-10-16 10:16:02 -0500 )edit

We can do even better: you don't need the full URL. Just refer to the Q&A ID.

gvdhoorn gravatar image gvdhoorn  ( 2021-10-16 11:30:12 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2021-09-22 03:10:44 -0500

Seen: 1,289 times

Last updated: Oct 16 '21