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

Running ROS across multiple machines [closed]

asked 2012-07-12 10:48:34 -0500

antonella gravatar image

updated 2012-07-13 07:05:21 -0500

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 (machine_1_ip)

Machine2 has the IP (machine_2_ip)

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

Machine1 /etc/hosts has the entry: Machine2

Machine2 /etc/hosts has the entry: Machine1

I can ping between the machines just fine.

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


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


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

Then, I run the following launch file:


  <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="" />

  <env name="ROS_MASTER_URI" value="http://Machine1:11311" />


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!

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by SL Remy
close date 2017-07-21 00:23:46.246221


Where did the cinemaster ros master line come from?

Daniel Stonier gravatar image Daniel Stonier  ( 2012-07-12 11:53:30 -0500 )edit

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).

antonella gravatar image antonella  ( 2012-07-12 12:26:59 -0500 )edit

What exactly do you see when you run "rostopic info" on the topic (from each machine) when all the nodes are running?

SL Remy gravatar image SL Remy  ( 2012-07-14 18:12:11 -0500 )edit

4 Answers

Sort by ยป oldest newest most voted

answered 2012-07-16 13:10:13 -0500

antonella gravatar image

updated 2012-07-17 08:59:19 -0500

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:


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


export ROS_HOSTNAME=Machine1  
export ROS_MASTER_URI=http://machine_1_ip:11311
export ROS_IP=machine_2_ip
edit flag offensive delete link more


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

tfoote gravatar image tfoote  ( 2012-08-09 22:47:12 -0500 )edit

answered 2012-07-12 19:07:14 -0500

MarkyMark2012 gravatar image

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

edit flag offensive delete link more


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?

antonella gravatar image antonella  ( 2012-07-13 07:52:47 -0500 )edit

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
starwars2079 gravatar image starwars2079  ( 2021-07-15 07:41:28 -0500 )edit

answered 2014-08-05 23:32:27 -0500

ttuuttuututu gravatar image

hi, I just meet the same problem. Have you solved the problem?

edit flag offensive delete link more


The original author posted a very detailed answer indicating that they have solved the problem.

ahendrix gravatar image ahendrix  ( 2014-08-06 00:01:32 -0500 )edit

answered 2017-04-06 07:26:15 -0500

cakiva gravatar image

Hey, I had a similar problem. Can you have your own network configuration on your computer where you manually configure the IP addresses? That was the case with my computers. The solution was on the computer where the master master ran to change the IP address to which we refer everyone (ROS_MASTER_URI) to be the first address in the configuration.

(Network connections-> choseyour connection-> edit-> IPv4 settings-> up this IP to top of the list)

thanks to michele

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2012-07-12 10:48:34 -0500

Seen: 9,868 times

Last updated: Apr 06 '17