0
$\begingroup$

Rosanswers logo

Hi there,

I have got a question about running ROS on several machines. I currently have 4 systems:

Robot: 192.168.1.1
PC1: 192.168.1.2
PC2: 192.168.1.3
PC3: 192.168.1.4

Roscore/Rosmaster is running on the Robot and on all PCs I have set "export ROS_MASTER_URI=http://192.168.1.1:11311". Further more, all PCs can ping each other and it is possible to establish ssh connections.

Here comes the strange thing I do not understand: I can enter "rostopic list" on each PC, and I can see the topics that are running in the roscore on the robot. But when I enter "rostopic echo /someTopic", it only works for PC2. On PC1 and PC3 I don't receive any data. Why can I see the topics but can't receive/send messages?

The tutorial about ROS remote says, that it is only necessary that the PCs can ping each other and that nothing else except "ROS_MASTER_URI" needs to be configured.

Does anyone know why this is happening?

regards psei


Originally posted by psei on ROS Answers with karma: 318 on 2013-10-14

Post score: 5

$\endgroup$

5 Answers 5

0
$\begingroup$

Rosanswers logo

The actual problem here is network resolution. Seeing the topics only shows you one direction of communication. Every computer needs to be able to talk to (test e.g. by ping) each other (from/to) using whatever name this is known by to ROS. That's what the ROS_IP settings are for.


Originally posted by dornhege with karma: 31395 on 2013-10-14

This answer was ACCEPTED on the original site

Post score: 7


Original comments

Comment by tfoote on 2013-10-14:
Take a look at: http://wiki.ros.org/ROS/NetworkSetup

Comment by autonomy on 2013-10-15:
I've run into the same issue and every time it was caused by messed up /etc/hosts file and/or lack of the ROS_IP export. If one does not export ROS_IP on the publishing PC, it should be possible to list the topics but you won't be able to establish a connection. This should be the answer.

Comment by evk02 on 2014-03-15:
I'm sorry, but I had the same issue and ROS_IP was set properly, it didn't make a difference. What made a difference is the /etc/hosts file on the remote PC having the hostname and ip of the master PC.

Comment by pfontana96 on 2021-06-09:
I know this is an old post, but I'm facing kind of the same problem. I'm completely sure the machines can communicate with each other as I can subscribe to simple topics. For example running this on the robot board:

rostopic pub /robot/str std_msgs/String "Hello there"

I can retrieve the message on my PC with:

rostopic echo /robot/str

The problem arises when the topics are of type sensor_msgs/Image. I have a stereo camera that publishes a RGB image as well as a depth one. If I run rviz within the robot (I have to connect a monitor to it), I'm able to see both. However, when I try to visualize them from my remote PC, I'm not able to (I keep receiving as if there is no data).

Thank you all!

$\endgroup$
0
$\begingroup$

Rosanswers logo

Hi everyone and thanks for your answers. I tried several things like setting ROS_IP, ROS_HOSTNAME, etc.... but I could not get it running.

What finally solved my problem was adding all PCs with their hostnames and IP Adresses to the "/etc/hosts" file. Since then, everything works fine.


Originally posted by psei with karma: 318 on 2013-10-14

This answer was NOT ACCEPTED on the original site

Post score: 11


Original comments

Comment by evk02 on 2014-03-15:
I had the same issue. All ROS_IP, ROS_MASTER_URI settings were fine, I did see the topics but when subscribed no message came through. It was because the node running roscore had a hostname and that hostname was not added to the /etc/host file or the remote PC. I have added the hostname and the topics immediately started to show their data on the remote PC.

Comment by mycal on 2015-03-20:
Thanks for posting an answer to your problem. Could you be more specific about what you did, though? You added IP addresses to /etc/hosts, but what did you do then? Just refer to the strings in ~/.bashrc? I'm having the same problem and any help would be wonderful.

Comment by Clancy on 2015-04-03:
This worked for me. Just add the publishing computer to the /etc/hosts file in the same format as the localhost is added.

Comment by Tristan9497 on 2021-11-07:
Thanks man! I just spend the entire day trying everything!

$\endgroup$
0
$\begingroup$

Rosanswers logo

The lack of data means that your client can see the ROS master, but cannot connect to the topics on the remote machine. The cause is that the services on the remote machine are not accepting remote connections, only local. This is determined by the ROS_IP variable.

So, to use ROS over network, you need do two two things:

On the machine running roscore, you need to make sure that your services listen on any port. When no port is set, localhost (127.0.0.1) is used. So, you should select the IP of your machine on the internal network, or listen on any interface:

export ROS_IP=0.0.0.0 # Listen on any interface

OR

export ROS_IP=192.168.1.1 # Listen on 192.168.1.1

On the machine running roscore, you needn't worry about ROS_MASTER_URI or ROS_HOSTNAME.

On the client machine, not running roscore, there's two things you need to do. First, you need to make sure that ROS nodes are able to connect to the master by specifying ROS_MASTER_URI:

export ROS_MASTER_URI=192.168.1.1:11311

Second, you need to make sure that nodes running on the remote machine can also access topics published on the local machine, by setting ROS_IP to something different than 127.0.0.1, so:

export ROS_IP=0.0.0.0 # To listen on any interface


Originally posted by MadEgg with karma: 43 on 2013-10-21

This answer was NOT ACCEPTED on the original site

Post score: 4

$\endgroup$
0
$\begingroup$

Rosanswers logo

I solved my problem by adding both machines' hostname to /etc/hosts. refer to https://husarion.com/tutorials/ros-tutorials/5-running-ros-on-multiple-machines/


Details:

You can use roswtf to see what's happening. For me I got this error on my client machine:

ERROR: Unknown host [robot-desktop] for node [***]

where "robot-desktop" is the hostname of the master machine. If this ERROR occurs, you need to add the hostname of both machines to /etc/hosts like this:

X.X.X.X master-hostname

X.X.X.X client-hostname

You can run hostname in terminal to see the hostname of the machine.


Originally posted by houjiawei11 with karma: 11 on 2020-05-22

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$
0
$\begingroup$

Rosanswers logo

Disable Firewall worked for me

Use below cmd to disable Firewall (refer)

$ sudo ufw disable

Originally posted by quanghai with karma: 31 on 2021-07-04

This answer was NOT ACCEPTED on the original site

Post score: 3


Original comments

Comment by Jibran on 2021-12-21:
Yeah, I tried everything else in the other answers. But ultimately this helped.

$\endgroup$

Your Answer

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