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

Why does ROS need a Hostname?

asked 2012-12-11 14:42:30 -0600

coldogga gravatar image

updated 2014-01-28 17:14:32 -0600

ngrennan gravatar image

Currently I have two computers, one running a service 'TIME_SPAM' which endlessly sends UNIX timestamps to any subscribers. On a client PC, using the command 'ROS_MASTER_URI="hxxp://10.230.82.244:11311/" rostopic echo TIMEPAM' (Note: Changed from a http link as my karma is insufficient to post links) only works if I have added a hostname entry which resolves to that PC in /etc/hosts (currently it's '10.230.82.244 linaro-ubuntu-desktop'), if I comment the line out, the command no longer works, despite the fact that I'm passing it a direct IP address.

There are many obvious advantages to using Hostnames for lookups, but this becomes problematic if you do not own or control the network and are unable to setup static IP's and/or a DNS server..

Is there a reason for this, if not, where do I submit a bug report/feature request?

EDIT: The more I think about this problem, the more I consider it to be a bug - Consider this scenario:

I have a server with the IP 10.1.1.1 and the hostname 'server', on the server I execute this script: http://paste2.org/p/2599990.

On a client, if I attempt to execute the command 'ROS_MASTER_URI="http://10.1.1.1:11311/" rostopic echo TIMESPAM' it connects to the server, but does not display any data (this is different from an invalid host address, as it complains with 'could not connect to host').

Then, on the client, if I add an entry into /etc/hosts such that the hostname 'server' is bound to 10.1.1.1, a fresh execution of the command 'ROS_MASTER_URI="http://10.1.1.1:11311/" rostopic echo TIMESPAM' will immediately work correctly.

This appears to be an issue with the client needing to know the hostname of the server, despite the fact I'm passing the IP address as the URI - and the behavior of the issue may lead somebody to assume that the problem is elsewhere in the system.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2012-12-11 20:44:06 -0600

Lorenz gravatar image

The short answer is that you are not forced to use ROS_HOSTNAME and hostnames but you can also use IP addresses in ROS_MASTER_URI and the ROS_IP variable. If you have a dynamic IP address, you have to change ROS_IP whenever your IP changed and you will have to restart all your nodes.

And here the longer explanation of the why:

There are technical reasons for requiring either a hostname or an ip address.

Let's consider a simple example: computer A runs the core and subscribes to topic with node node_1. Computer B runs node_2 with a publisher for topic.

When the nodes are started up, they first register at the core (the ros::init call does that). To find the master, they use the ROS_MASTER_URI. For negotiating topic connections, each node provides an XMLRPC server. When registering at the master, nodes basically store the URI of this server. For that, the ROS_HOSTNAME and ROS_IP variables are used.

With the advertise call in node_2, it will communicate with the core again to register a publisher for topic.

The subscribe call in node_1 will also communicate with the core to find out which nodes are already publishing topic and the answer will be the address of node_2 that was used when it registered at the core. Note that if the publisher registers after the subscriber, the subscriber node is notified by the core using an XMLRPC call to node_1's local XMLRPC server. Finally, node_1 will directly connect to node_2 and establish the topic connection using the information about node_2's XMLRPC server stored in the core.

edit flag offensive delete link more

Comments

Please see edit above, your explanation is informative, but suggests EITHER a hostname OR ip address. Because of this, along with the above mentioning, I believe this is a bug and have raised it on trac https://code.ros.org/trac/ros/ticket/4071

coldogga gravatar image coldogga  ( 2012-12-13 11:37:03 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2012-12-11 14:42:30 -0600

Seen: 6,997 times

Last updated: Dec 13 '12