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