0
$\begingroup$

Rosanswers logo

I am attempting to run ROS across multiple machines. To test if everything is working, I'm trying to run a publisher on one machine, and subscribe to the published messages on the other machine. My setup is as follows:

Machine1 has the IP 192.168.1.101 (machine_1_ip)

Machine2 has the IP 192.168.1.111 (machine_2_ip)

I have edited the /etc/hosts file on each machine to reflect this:

Machine1 /etc/hosts has the entry: 192.168.1.111 Machine2

Machine2 /etc/hosts has the entry: 192.168.1.101 Machine1

I can ping between the machines just fine.

I set up the ROS_MASTER_URI and ROS_MASTER_IP on 1 and 2:

Machine1:

export ROS_MASTER_URI=http://Machine1:11311
export ROS_IP=machine_1_ip 

Machine2:

export ROS_MASTER_URI=http://machine_1_ip:11311
export ROS_IP=machine_2_ip

Then, I run the following launch file:

<launch>

  <machine name="Machine1" address="machine_1_ip" ros-root="$(env ROS_ROOT)"
     ros-package-path="$(env ROS_PACKAGE_PATH)" user="mach1user" default="true" />
 
  <machine name="Machine2" address="machine_2_ip" ros-root="$(env ROS_ROOT)"
     ros-package-path="$(env ROS_PACKAGE_PATH)" user="mach2user" />

  <node name="master_node" pkg="master_node" type="Master.py" />
  
  <env name="ROS_MASTER_URI" value="http://Machine1:11311" />

</launch>

master_node is running a simple publisher that I want to subscribe to from Machine2. The publisher publishes a series of strings.

From Machine2, I can run rosnode/rostopic/rosservice list and see everything that's running on Machine1 (including the topic I want to subscribe to). However, when I run a subscriber on Machine2, it stops at the line that is supposed to subscribe. It doesn't give an error, it just sits there until I kill it (and it doesn't give an error after I kill it either).

I am fairly new to ROS, but I've read up on all the multiple machines and network setup stuff. I'm really not sure what's going wrong. Any help would be much appreciated! Thanks!


Originally posted by antonella on ROS Answers with karma: 259 on 2012-07-12

Post score: 10


Original comments

Comment by Daniel Stonier on 2012-07-12:
Where did the cinemaster ros master line come from?

Comment by antonella on 2012-07-12:
Sorry about that. I was changing the names to make them more "universal" but I forgot that one. It should be Machine1 (our master machine).

Comment by SL Remy on 2012-07-14:
What exactly do you see when you run "rostopic info" on the topic (from each machine) when all the nodes are running?

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

looks like your URI. should be export ROS_MASTER_URI=http://Machine1:11311 - check case too on both machines. So long as your hosts file is correct shouldn't be a problem


Originally posted by MarkyMark2012 with karma: 1834 on 2012-07-12

This answer was NOT ACCEPTED on the original site

Post score: 2


Original comments

Comment by antonella on 2012-07-13:
I tried that and the same problem is still happening. I think the problem is the subscriber on the remote machine isn't entering its callback function, but I don't know why. The same subscriber run on the local machine works just fine. Is it possibly a problem with the subscriber's namespace?

Comment by starwars2079 on 2021-07-15:
Actually I think the following is the correct way to set up the connections:

  1. make sure all computers inside the network can be ping by each other by NAME. This is achieved by add name to /etc/hosts

  2. Then on each computer, you need to tell what the name of that computer is Computer1 export ROS_HOSTNAME=computer1

Computer2 export ROS_HOSTNAME=computer2

  1. Then set the ros master uri Computer 1 export ROS_MASTER_URI=http://computer1:11311

Computer 2 export ROS_MASTER_URI=http://computer1:11311

  1. ROS_IP I am not quite sure about how it works, but seems irrelevant
$\endgroup$
0
$\begingroup$

Rosanswers logo

It turns out it was a problem with the ROS_HOSTNAME variable. Somehow, certain processes on the master were running under a different hostname than others. Considering this, I'm not sure why the client was still able to see/ping all the nodes, because it seems like it would have been looking in the wrong place (i.e. under a different master process). (?)

Anyway, now I just run export ROS_HOSTNAME=Machine1 before the setup steps above (on both Machine1 and Machine2) and everything seems to work fine. So now the setup process is:

Machine1:

export ROS_HOSTNAME=Machine1    
export ROS_MASTER_URI=http://Machine1:11311
export ROS_IP=machine_1_ip

Machine2:

export ROS_HOSTNAME=Machine1  
export ROS_MASTER_URI=http://machine_1_ip:11311
export ROS_IP=machine_2_ip

Originally posted by antonella with karma: 259 on 2012-07-16

This answer was ACCEPTED on the original site

Post score: 5


Original comments

Comment by tfoote on 2012-08-09:
You're lucky the ROS_IP is overriding the ROS_HOSTNAME. You should be setting ROS_HOSTNAME to the resolvable hostname to identify each individual computer. See http://www.ros.org/wiki/ROS/NetworkSetup

$\endgroup$

Your Answer

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