0
$\begingroup$

Rosanswers logo

Hello,

I'm writing some automated test scripts. I'd like to run a launch script with a bag file, which works fine. But when the rosbag play completes I would like roslaunch to exit so my script can load up a new bag file and rerun roslaunch with the test.launch file. Is there an elegant way to cause all ros nodes and roscore to exit when a bag file is finished? I was thinking of making another script to monitor when rosbag finished and then execute a rosnode kill, but I thought there might be a better way.

Thanks, Jason


Originally posted by Jason LaPenta on ROS Answers with karma: 41 on 2012-01-25

Post score: 2


Original comments

Comment by kwc on 2012-01-25:
This is tangential, but you may want to look into using rostest to bring your test fixture up and down using roslaunch files

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

If you're running all your nodes from the same launch file as the bag, just add required="true" to the node tag for rosbag. This will cause the entire roslaunch to die when rosbag terminates.


Originally posted by Dan Lazewatsky with karma: 9115 on 2012-01-25

This answer was ACCEPTED on the original site

Post score: 9


Original comments

Comment by tfoote on 2012-02-02:
When you get a good/the best answer please use the checkbox to the left to mark it as answered. I've done so for you this time.

Comment by Jason LaPenta on 2012-01-25:
this appears to work perfectly, thanks

Comment by Roger Yau on 2015-11-06:
typo: required = 'true'

$\endgroup$
0
$\begingroup$

Rosanswers logo

I haven't tried this, but perhaps something like this:

rosbag play foo.bag; rosnode kill -a

Originally posted by JeffRousseau with karma: 1607 on 2012-01-25

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by fivef on 2014-10-22:
rosnode kill -a kind of works but sometimes not all nodes get killed

$\endgroup$

Your Answer

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