ros / ros_comm

ROS communications-related packages, including core client libraries (roscpp, rospy, roslisp) and graph introspection tools (rostopic, rosnode, rosservice, rosparam).
http://wiki.ros.org/ros_comm
765 stars 912 forks source link

roscore ignoring ROS_MASTER_URI ? #2311

Open msadowski opened 1 year ago

msadowski commented 1 year ago

Hi!

I've been breaking my head over this for a good couple of hours now. Usually, when setting ROS I would assign variables:

ROS_MASTER_URI=...
ROS_IP

But, interestingly, on this new machine I'm testing on (running Melodic) the ROS_MASTER_URI is ignored when running roscore:

root@ca-na-p1:/home/ros# echo $ROS_MASTER_URI
http://10.150.4.18:11311
root@ca-na-p1:/home/ros# echo $ROS_IP
10.150.4.18
root@ca-na-p1:/home/ros# echo $ROS_HOSTNAME

root@ca-na-p1:/home/ros# roscore
... logging to /root/.ros/log/14829656-9827-11ed-8db6-270f44d84b3b/roslaunch-ca-na-p1-31365.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://ca-na-p1:39837/

The address of the roscore used seems to be http://ca-na-p1:39837/

If I set ROS_HOSTNAME it seems to be taken into the account:

root@ca-na-p1:/home/ros# export ROS_HOSTNAME=wtf
root@ca-na-p1:/home/ros# roscore
... logging to /root/.ros/log/b2afe96e-9827-11ed-8db6-270f44d84b3b/roslaunch-ca-na-p1-31447.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

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

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

Am I missing anything? Setting ROS_MASTER_URI always seemed to work for me and I have no idea where roscore is taking the name of the machine from really. The value is the same as $HOSTNAME, but modifying the $HOSTNAME value did not change the value used by ROS.

Any tips would be appreciated!

peci1 commented 1 year ago

I think you misread the logs.

started roslaunch server http://ca-na-p1:39837/

This reports a roslaunch server, not roscore. roscore does correctly take the ROS_MASTER_URI into account.

The roslaunch server is an implementation detail (roscore internally uses roslaunch to launch itself). The roslaunch endpoint you see in the log is probably only used for launching the /rosout node, thus using any locally resolvable address is okay.