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

rosparam: Can't set parameters on Master, via launch file

asked 2012-10-01 02:49:15 -0500

dbworth gravatar image

updated 2014-01-28 17:13:48 -0500

ngrennan gravatar image

(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?

.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
6

answered 2012-10-01 03:35:13 -0500

Lorenz gravatar image

updated 2012-10-01 04:26:27 -0500

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.

edit flag offensive delete link more

Comments

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?

SivamPillai gravatar image SivamPillai  ( 2012-10-01 04:19:01 -0500 )edit

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.

SivamPillai gravatar image SivamPillai  ( 2012-10-01 05:16:41 -0500 )edit
1

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.

Lorenz gravatar image Lorenz  ( 2012-10-01 05:21:00 -0500 )edit

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

SivamPillai gravatar image SivamPillai  ( 2012-10-01 05:30:49 -0500 )edit

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.

Lorenz gravatar image Lorenz  ( 2012-10-01 05:32:51 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2012-10-01 02:49:15 -0500

Seen: 3,792 times

Last updated: Oct 01 '12