ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

ROS communication works only in one direction

asked 2018-10-12 01:57:32 -0500

alsora gravatar image

updated 2018-10-12 14:25:38 -0500


I'm using ROS Kinetic and I have a strange issue.

I want to run one node in a Docker container on my pc and one node on a RaspberryPi. The problem is that if I publish messages from the pc, no message is received on the Raspberry. Interestingly if I publish from the Raspberry I receive messages on the pc.

I tried to run the ROS master both on the pc as well as on the Raspberry. In the .bashrc file of both devices I have the following lines

  export ROS_MASTER_URI=http://masterhost:11311
  export ROS_HOSTNAME=localhost

Where localhost is the ip address of the specific device and masterhost is equal to the localhost of the device running the master.

Do you know why this could happen?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-10-12 03:03:06 -0500

Delb gravatar image

The pc and the raspberry shouldn't have the same configuration. They have to have the same ROS_MASTER_URI but their ROS_HOSTNAME (or ROS_IP) should be their own.

You should have in the .bashrc:

  • On the pc :

export ROS_MASTER_URI=http://PC_IP_ADDRESS:11311


  • On the rapsberry :

export ROS_MASTER_URI=http://PC_IP_ADDRESS:11311


See #q272065 for a much more detailled answer.

edit flag offensive delete link more


Note that a complicating factor here could be the Docker setup. Docker by default uses NAT (ie: masquerading), so it's not always as straightforward as setting ROS_IP and ROS_MASTER_URI to get things to work.

gvdhoorn gravatar image gvdhoorn  ( 2018-10-12 04:34:42 -0500 )edit

Does the masqueradidng change the ROS_MASTER_URI ? If not, is it possible to replacePC_IP_ADDRESS for the ROS_MASTER_URI by RASPBERRY_IP_ADDRESS to prevent the issue ?

Delb gravatar image Delb  ( 2018-10-12 04:42:15 -0500 )edit

Docker creates a "virtual network" by default, so depending on where you run your master you'll have to update the ROS_MASTER_URI yes (and most likely the routing configuration of the involved hosts). But the more difficult issue is that NAT will "hide" nodes running inside your container.

gvdhoorn gravatar image gvdhoorn  ( 2018-10-12 04:46:06 -0500 )edit

@Delb the ROS_HOSTNAME is different across devices, It was not clear from my question.

alsora gravatar image alsora  ( 2018-10-12 14:19:11 -0500 )edit

@gvdhoorn You are right, the error is due to the Docker setup. I'm running the container with the --privileged and --net=host flags. From ifconfig inside Docker, I see the docker and wlan interfaces. I am using the wlan inet address in the exported env variables

alsora gravatar image alsora  ( 2018-10-12 14:23:35 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-10-12 01:57:32 -0500

Seen: 488 times

Last updated: Oct 12 '18