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

pausing inside .launch file?

asked 2011-07-15 15:53:09 -0600

JoeRomano gravatar image

updated 2011-07-16 13:03:22 -0600

kwc gravatar image

Is there any way to add a sleep (delay or pause) to a .launch file between statements?

In my current code I need to kill several default PR2 controllers, change some rosparams, then reload these same controllers. However, this all happens so fast in my launch file that it seems to cause problems.

edit retag flag offensive close merge delete

6 Answers

Sort by ยป oldest newest most voted
1

answered 2011-07-17 04:09:21 -0600

JoeRomano gravatar image

Thanks for the help guys.

I've noticed that execution does happen serially, but I still don't think these solutions will solve the problem I am seeing. Allow me to add some additional detail:

Step 1: A user logs on to the system (in this case the pr2) and launches the basic robot communication nodes (in this case the l/r_arm_controller nodes). I definitely don't want to modify these scripts.

Step 2: A user decides to run my code by launching my launch file. I need to change some of the settings for the l/r_arm_controller_nodes, and the only way I've found to do this is to use pr2_controller_manager to kill the node, reload the param_server params with new values, and then use pr2_controller_manager respawn these nodes. I am pretty sure the l/r_arm_controller only reads the param_server when it is launched, so I need to actually kill it, change params, and respawn in this fashion.

The problem: Adding the commands to kill and spawn the controller in the same launch file does not result in the controller getting spawned properly. It looks like kill/spawn are executed in sequence so quickly that the pr2_controller_manager somehow doesn't deal with it properly. If I could add in a pause between kill and spawn in my launch file I believe this wouldn't be an issue.

edit flag offensive delete link more

Comments

You cannot be sure that nodes are really launched serially. See the roslaunch XML documentation. However, if you really want to start nodes serially, in particular if it is something like killing/spawning controllers, why don't you put them into a shell script and execute the script from roslaunch?
Lorenz gravatar image Lorenz  ( 2011-07-17 04:14:11 -0600 )edit
Right, that is the current approach I am using. I was just wondering, as indicated by the title of the post, if there was a way to pause inside of a launch script. But, seeing as how you really can't guarantee things are executed serially, that is probably a moot point.
JoeRomano gravatar image JoeRomano  ( 2011-07-17 04:18:00 -0600 )edit
4

answered 2011-07-16 02:03:48 -0600

dornhege gravatar image

I assume this will not be possible as roslaunch does not even guarantee any order of the process startup.

What about just choosing your parameters from the start?

edit flag offensive delete link more
1

answered 2011-07-17 09:03:28 -0600

No, but you can add a pause to starting an individual node by putting it behind a shell script. If you were to write a bash script with a sleep and then another call to launch it would have the same effect.

However, if I were you I'd work out the problem causing the timing issue rather than add in a pause.

edit flag offensive delete link more
1

answered 2014-04-24 02:38:04 -0600

koenlek gravatar image

I have figured out a way to do it! I built a script (as suggested above by some) that nicely enables you to delay parts of your launch file. See my answer here, which includes clear instructions and the script: http://answers.ros.org/question/51474...

edit flag offensive delete link more
0

answered 2011-07-17 03:55:34 -0600

Lorenz gravatar image

If you just need to change parameters, I guess this could be achieved with roslaunch. While roslaunch doesn't guarantee the order in which nodes are started up, it processes machine declarations and parameters serially, before executing nodes.

This allows you to overwrite previous parameter definitions later inside the same launch file. More specifically, you could create a launch file and first include the original robot launch file. Later in the file, you could re-define some parameters. This should overwrite the original parameter settings before any node is started up.

edit flag offensive delete link more
0

answered 2011-07-16 03:56:26 -0600

JoeRomano gravatar image

Unfortunately I don't think it is possible to easily change the parameters of the running controllers. They launch with the robot, and changing that behavior would be more trouble than just stopping and restarting them. I've broken it up into two launch files, one to kill the existing controllers, and one to set the params and restart them. Not ideal, but it seems like the simplest solution if I can't do it in one .launch.

edit flag offensive delete link more

Comments

I meant to change the parameters to your settings before the start (i.e. change the param files).
dornhege gravatar image dornhege  ( 2011-07-16 05:14:51 -0600 )edit

Question Tools

Stats

Asked: 2011-07-15 15:53:09 -0600

Seen: 7,804 times

Last updated: Apr 24 '14