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

Launching with parameters (was "How to block until a master is running")

asked 2011-08-11 16:02:08 -0500

Mac gravatar image

updated 2011-08-18 05:22:23 -0500

I have a script that wraps rosbag play (because I need to set some rosparams first). However, if I run my script before my master finishes coming up, my calls to rosparam set fail, and my parameters don't get set (the call to play blocks until the master is up).

Is there a convenient way to block until a master comes up? I could write a miniature node that does it, but I thought I'd ask.

Another possibility: arguably, this is a bug in rosparam; it should either (a) block until it has a master or (b) at least provide a non-zero return code when it dies with "Unable to communicate with master", so I can spinblock it myself.


edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2011-08-12 09:25:22 -0500

Brian Gerkey gravatar image

updated 2011-12-08 12:51:24 -0500

I'm not sure that I fully understand your use case, but you might try roslaunch args. Here's a launch file that sets two params from arguments:

  <arg name="my_integer_param" default="1"/>
  <arg name="my_string_param" default="foobar"/>
  <param name="my_integer_param" value="$(arg my_integer_param)"/>
  <param name="my_string_param" value="$(arg my_string_param)"/>
  <node name="rosplay" pkg="rosbag" type="rosbag" args="play /tmp/mybag.bag"/>

Defaults for the args are given, so you can launch it normally:

roslaunch foo.launch

But you can override them on the command-line, e.g.:

roslaunch foo.launch my_integer_param:=42 my_string_param:=barfoo
edit flag offensive delete link more

answered 2011-08-11 20:11:35 -0500

Ugo gravatar image

I'm using this to wait for a rosmaster:

until rostopic list ; do sleep 1; done
edit flag offensive delete link more

answered 2011-08-11 22:28:54 -0500

Zack gravatar image

just wondering. Would it be more convenient to put all of these in a launch file?

edit flag offensive delete link more


In this case, it wouldn't, unless there's some way to read command-line arguments in roslaunch.
Mac gravatar image Mac  ( 2011-08-12 08:44:59 -0500 )edit
You can use arguments from the command line.
tfoote gravatar image tfoote  ( 2011-08-12 11:10:59 -0500 )edit

Question Tools


Asked: 2011-08-11 16:02:08 -0500

Seen: 1,299 times

Last updated: Dec 08 '11