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

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

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

Mac gravatar image

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

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.

Thoughts?

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
7

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

Brian Gerkey gravatar image

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

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:

<launch>
  <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"/>
</launch>

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
3

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

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

Comments

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 -0600 )edit
You can use arguments from the command line. http://www.ros.org/wiki/roslaunch/XML/arg
tfoote gravatar image tfoote  ( 2011-08-12 11:10:59 -0600 )edit
3

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

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

Question Tools

Stats

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

Seen: 1,397 times

Last updated: Dec 08 '11