0
$\begingroup$

I'm using ROS2 Iron in Docker on my robot. The problem is that nodes can't communicate with each other. What have been done:

  1. I've run two containers in Docker with Ros Iron:
# On Robot via ssh twice
$ docker run --privileged -it --runtime nvidia --network=host ros:iron /bin/bash
  1. In both containers I've installed ros-iron-demo-nodes-cpp
# On Robot in both Docker containers
$ apt update && apt install -y ros-iron-demo-nodes-cpp
  1. Then I've run talker node in one container
# On Robot in the first container
$ source /opt/ros/iron/setup.bash
$ ros2 run demo_nodes_cpp talker
[INFO] [1720527552.878652747] [talker]: Publishing: 'Hello World: 1'
[INFO] [1720527553.878610512] [talker]: Publishing: 'Hello World: 2'
[INFO] [1720527554.878595492] [talker]: Publishing: 'Hello World: 3'
[INFO] [1720527555.878651697] [talker]: Publishing: 'Hello World: 4'
[INFO] [1720527556.878624129] [talker]: Publishing: 'Hello World: 5'
...
  1. In second container I've checked that ros2 can see chatter topic:
# On Robot in the second container
$ ros2 topic list
/chatter
/parameter_events
/rosout
  1. I've run listener node in second container:
# On robot in the second container
$ ros2 run demo_nodes_cpp listener

But there was no any output from this command.

  1. Then I stopped the listener node and tried to verify that second container can "hear" first container:
# On robot in the second container
$ ros2 topic echo /chatter

There was no output.

  1. After that on my laptop I've run this commands:
# On my laptop
$ ros2 topic list
/chatter
/parameter_events
/rosout
$ ros2 topic echo /chatter
data: 'Hello World: 299'
---
data: 'Hello World: 300'
---
data: 'Hello World: 301'
---
data: 'Hello World: 302'
---
...

And as you can see I've got output on my laptop. Technical information:

  1. Both robot and my laptop are in the same local network
  2. Local variables on Robot in both containers are the same:
# On Robot in both containers
$ printenv | grep -i ROS
ROS_VERSION=2
ROS_PYTHON_VERSION=3
AMENT_PREFIX_PATH=/opt/ros/iron
ROS_AUTOMATIC_DISCOVERY_RANGE=SUBNET
PYTHONPATH=/opt/ros/iron/lib/python3.10/site-packages
LD_LIBRARY_PATH=/opt/ros/iron/lib/aarch64-linux-gnu:/opt/ros/iron/lib
PATH=/opt/ros/iron/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ROS_DISTRO=iron
  1. Local variables on my laptop:
# On my laptop
$ printenv | grep -i ROS
ROS_VERSION=2
ROS_PYTHON_VERSION=3
ROS_DOMAIN_ID=0
AMENT_PREFIX_PATH=/opt/ros/iron
ROS_AUTOMATIC_DISCOVERY_RANGE=SUBNET
PYTHONPATH=/opt/ros/iron/lib/python3.10/site-packages
_colcon_cd_root=/opt/ros/iron/
LD_LIBRARY_PATH=/opt/ros/iron/opt/rviz_ogre_vendor/lib:/opt/ros/iron/lib/x86_64-linux-gnu:/opt/ros/iron/lib
PATH=/opt/ros/iron/bin:/home/<my_name>//.local/bin:/home/<my_name>//.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/snap/bin
ROS_DISTRO=iron

So the question is how to fix that my containers can't communicate with each other?

$\endgroup$

1 Answer 1

1
$\begingroup$

Solution found:

To solve this problem it's necessary to start containers with this mount flag: -v /dev/shm:/dev/shm. This also doesn't break possibility to communicate with nodes on robot from my laptop.

There is also another way to fix it, it fully described here: https://github.com/eProsima/Fast-DDS/issues/1698#issuecomment-778039676

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.