0
$\begingroup$

Rosanswers logo

Hi there!

I can't find a way to kill an action server I have created using smach and its action server wrapper. Once the action server is started (my_action_server_wrapper.run_server()), I'm not able to kill it using "ctrl + c".

I tried "try + except" without luck. Currently I'm starting a second instance with the same name, what makes the first one stop. But this is not really a suitable solution.

Thanks for your help!


Originally posted by bit-pirate on ROS Answers with karma: 2062 on 2013-01-30

Post score: 3

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

my_action_server_wrapper.run_server() is a non-blocking call that starts the server (including a background thread, which is why your program isn't exiting). If you'd like to be able to ctrl-c your program, then you need something to wait in the main thread, handle the signal, and then signal rospy to shutdown.

Just add the following after your call to my_action_server_wrapper.run_server():

rospy.spin()

This will block until you ctrl-c your program, at which point it will call rospy.signal_shutdown(). For more on this, see the rospy documentation on Initialization and Shutdown.


Originally posted by jbohren with karma: 5809 on 2013-01-30

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by bit-pirate on 2013-01-30:
Yeha! Things can be so easy - what a pleasure! :-) Thanks a lot!

Comment by bit-pirate on 2013-01-30:
PS: This information and "fix" might be a good addition to the tutorial, since I guess most people would like to shutdown their server from time to time. ;-)

Comment by jbohren on 2013-01-31:
Done. http://www.ros.org/wiki/smach/Tutorials/Wrapping%20a%20SMACH%20Container%20With%20actionlib?action=diff&rev1=21&rev2=22

$\endgroup$

Your Answer

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