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

Why does ROS_HOSTNAME overwrite (parts of) ROS_MASTER_URI?

asked 2013-06-25 22:44:44 -0600

bit-pirate gravatar image

updated 2014-01-28 17:17:02 -0600

ngrennan gravatar image

See this example:

$ export ROS_MASTER_URI=http://my_pc_name:11311
$ export ROS_HOSTNAME=192.168.10.125
$ roscore
... logging to /home/marcus/.ros/log/666dd760-de3b-11e2-a641-f46d04929542/roslaunch-pirate-nest-2653.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://192.168.10.125:40223/
ros_comm version 1.9.46


SUMMARY
========

PARAMETERS
 * /rosdistro
 * /rosversion

NODES

auto-starting new master
process[master]: started with pid [2679]
ROS_MASTER_URI=http://192.168.10.125:11311/

setting /run_id to 666dd760-de3b-11e2-a641-f46d04929542
process[rosout-1]: started with pid [2718]
started core service [/rosout]
^C[rosout-1] killing on exit
[master] killing on exit
shutting down processing monitor...
... shutting down processing monitor complete
done
$ export ROS_MASTER_URI=http://192.168.10.125:11311
$ export ROS_HOSTNAME=my_pc_name
$ roscore
... logging to /home/marcus/.ros/log/75dd2e8a-de3b-11e2-a4fa-f46d04929542/roslaunch-pirate-nest-2820.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://my_pc_name:52467/
ros_comm version 1.9.46


SUMMARY
========

PARAMETERS
 * /rosdistro
 * /rosversion

NODES

auto-starting new master
process[master]: started with pid [2834]
ROS_MASTER_URI=http://my_pc_name:11311/

setting /run_id to 75dd2e8a-de3b-11e2-a4fa-f46d04929542
process[rosout-1]: started with pid [2852]
started core service [/rosout]
^C[rosout-1] killing on exit
[master] killing on exit
shutting down processing monitor...
... shutting down processing monitor complete
done

Is this supposed to happen?

It's not a huge problem, but took me a while to figure it out ...

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2013-08-12 11:39:44 -0600

tfoote gravatar image

It is not overriding the ROS_MASTER_URI, it is telling you what it thinks your ROS_MASTER_URI should be, as that is where the master is listening. The master respects ROS_HOSTNAME when launching and does not follow the ROS_MASTER_URI.

It does try to sanity check ROS_MASTER_URI such as verifying the port number and that it can reach itself at the known address.

$ roscore -p 11111
... logging to /home/tfoote/.ros/log/f523818c-0396-11e3-9904-902b34db2f33/roslaunch-BigFoote-29198.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server <a href="http://BigFoote:40065/">http://BigFoote:40065/</a>
ros_comm version 1.9.47


SUMMARY
========

PARAMETERS
 * /rosdistro
 * /rosversion

NODES

WARNING: ROS_MASTER_URI port [11311] does not match this roscore [11111]
auto-starting new master
process[master]: started with pid [29212]
ROS_MASTER_URI=http://BigFoote:11111/
...

With an invalid hostname

$ ROS_HOSTNAME=invalid roscore -p 11111
... logging to /home/tfoote/.ros/log/63b53302-0397-11e3-9aa5-902b34db2f33/roslaunch-BigFoote-29441.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

Unable to contact my own server at [http://invalid:59015/].
This usually means that the network is not configured properly.

A common cause is that the machine cannot ping itself.  Please check
for errors by running:

    ping invalid

For more tips, please see

    <a href="http://www.ros.org/wiki/ROS/NetworkSetup">http://www.ros.org/wiki/ROS/NetworkSetup</a>

And differently set ROS_MASTER_URI hostname:

$ ROS_MASTER_URI=http://invalid:11111 roscore -p 11111
... logging to /home/tfoote/.ros/log/966bed7c-0397-11e3-90cd-902b34db2f33/roslaunch-BigFoote-29549.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server <a href="http://BigFoote:36475/">http://BigFoote:36475/</a>
ros_comm version 1.9.47


SUMMARY
========

PARAMETERS
 * /rosdistro
 * /rosversion

NODES

WARNING: ROS_MASTER_URI [http://invalid:11111] host is not set to this machine
auto-starting new master
process[master]: started with pid [29564]
ROS_MASTER_URI=http://BigFoote:11111/
...

If there's a difference between what's in your bashrc and what it prints it is a warning sign that you should double check that they resolve to the same machine on all systems.

edit flag offensive delete link more

Comments

I see. Thanks for the insight!

bit-pirate gravatar image bit-pirate  ( 2013-08-12 17:09:36 -0600 )edit
0

answered 2013-06-26 03:56:48 -0600

ROS_HOSTNAME should not be an IP address, it should be a hostname. Setting ROS_HOSTNAME to a IP address, as in your first example, may be confusing things.

edit flag offensive delete link more

Comments

1

If you are having trouble with name resolution, and you need to specify that IP address, try using export ROS_IP=192.168.10.125 instead.

jarvisschultz gravatar image jarvisschultz  ( 2013-06-26 05:02:41 -0600 )edit
1

ROS_HOSTNAME is a superset of ROS_IP and was intended to replace ROS_IP, but it got never removed. See https://code.ros.org/trac/ros/ticket/537 and https://code.ros.org/lurker/attach/4@20121213.083020.617f9034.attach. So, using ROS_HOSTNAME with either a name or IP is fine.

bit-pirate gravatar image bit-pirate  ( 2013-06-26 13:49:14 -0600 )edit

Additionally, my examples show that the problem also occurs, when a name is used in ROS_HOSTNAME.

bit-pirate gravatar image bit-pirate  ( 2013-06-26 13:51:11 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-06-25 22:44:44 -0600

Seen: 5,421 times

Last updated: Aug 12 '13