0
$\begingroup$

Rosanswers logo

I'm trying to run ROS on two machines which are connected to a local network. Both can ping each other.

I started roscore on first machine and set the ROS_MASTER_URI=http://192.168.0.22:11311 to the second machine. When I run rosnode list on the second machine it shows /rosout node. But when I start a node on the second machine it fails saying:

[ERROR] [1477518161.033462327]: [registerPublisher] Failed to contact master at [localhost:11311].  Retrying...

It keeps looking for ros master on the same machine. I don't know why. Both machines are running Ros Indigo.

Any help would be much appreciated.


Originally posted by farhansajjad on ROS Answers with karma: 35 on 2016-10-26

Post score: 2


Original comments

Comment by gvdhoorn on 2016-10-27:
How did you "set the ROS_MASTER_URI=.. exactly?

Can you add the output of echo $ROS_MASTER_URI (from both machines) to your question?

Comment by gvdhoorn on 2016-10-27:
Please also add the output of echo $ROS_IP and echo $ROS_HOSTNAME for both machines to your question. Use the edit button/link to update it.

Comment by gijsje170 on 2016-10-27:
Yea i think you have to use export ROS_IP=192.168.0.22 and also the export ROS_MASTER_URI=http://192.168.0.22:11311 in order to be able to communicate between both machines

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

On each machine, you should export ROS_MASTER_URI = http:// master_ip:11311 and export ROS_HOSTNAME = this_machine_ip. For each terminal, these two environment variables should be set, so it's recomanded that you write them in .bashrc .
The former variable is used to tell this machine where the master(roscore) is. The latter variable is used to tell master where this machine is for registering node.

xx_ip above should be replaced by your ip conf.Hope this answer helps.


Originally posted by SilverBullet with karma: 74 on 2016-10-27

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by gvdhoorn on 2016-10-27:\

export ROS_HOSTNAME = this_machine_ip

No. If you use ROS_HOSTNAME, set it to the hostname of the machine. If you want to use IPs, set ROS_IP.

Also: this is only needed if you don't have a working DNS (ie: can resolve all names of involved hosts to their IPs, using a DNS server or similar)

Comment by SilverBullet on 2016-10-27:
From your error message, I think ROS_MASTER_URI is not set correctly. Maybe you start a new window of terminal without setting variables for the new terminal?

Comment by SilverBullet on 2016-10-27:
Yeah, I think it's better to set ip for ROS_IP and hostname for ROS_HOSTNAME. But both can be used in practice since I've been setting ip for ROS_HOSTNAME and it has been working very well.:)

$\endgroup$

Your Answer

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