0
$\begingroup$

Rosanswers logo

(ROS Fuerte)

I've setup and tested 2 PCs to talk across a network. There's a client node and a master node. Both can ping each other via hostname.

I'm starting the client using a launch file that includes:

<env name="ROS_MASTER_URI" value="http://master_pc:11311" />
<rosparam name="test" value"foo" />

but this parameter is not getting added to the Parameter Server on the master PC.

Only if I set the environment variable in bash:

export ROS_MASTER_URI=http://master_pc:11311

and then run the launch file does the test parameter get added to the Param Server.

ROS_IP and ROS_HOSTNAME are not set anywhere.

Can anyone please suggest why?

.


Originally posted by dbworth on ROS Answers with karma: 1103 on 2012-10-01

Post score: 2

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The roslaunch process will use the ROS_MASTER_URI settings of the environment variable as it was set in the shell that executed roslaunch. Setting it using env inside roslaunch will only affect nodes that are started up, not the roslaunch process itself. Since roslaunch is responsible for setting parameters, the shell variable, not the env tag will be used.

Edit: To explain a little more, roslaunch works as follows. It first parses a launch file and collects an ordered list of parameters to set. Then it sets all parameters on the parameter server. Finally, it starts up all nodes on the corresponding machines. For each node, it sets up the environment, i.e. it applies the env tags. That means, the env tag is only applied for newly started nodes. The roslaunch process itself however uses the shell environment in which it was started up.

I would say it is normally a bad idea to set the ROS_MASTER_URI in roslaunch files because roslaunch passes the URI setting to its nodes anyway. This also works when using roslaunch's machine tags. This page might be helpful.


Originally posted by Lorenz with karma: 22731 on 2012-10-01

This answer was ACCEPTED on the original site

Post score: 6


Original comments

Comment by SivamPillai on 2012-10-01:
Hi can you explain a bit more on this. Even I've tried to understand this concept but I was not able to accept why ROS_MASTER_URI could not be set from a launch file. Is there a tutorial about this?

Comment by SivamPillai on 2012-10-01:
In that case is there an alternative way of setting the ROS_MASTER_URI globally? I want this to happen straight in a single instruction like roslaunch instead of having to manually execute it.

Comment by Lorenz on 2012-10-01:
People most often put it into their ~/.bashrc since the master uri does not change too often, at least in a single robot scenario. You normally will need the same master uri setting in several terminals and not just in one roslaunch process, e.g. to use tools like rostopic, rosnode or rviz.

Comment by SivamPillai on 2012-10-01:
Well I think I'll do the same as well... I had done that previously but for some cases where I was working without the Robot I had to remove it again! So I asked. But thanks for all that information

Comment by Lorenz on 2012-10-01:
For quickly changing the master uri, you can write short shell functions or aliasws in your .bashrc that you execute manually right after opening a new terminal.

$\endgroup$

Your Answer

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