Ask Your Question

How to kill a smach state machine inside an ActionServerWrapper

asked 2013-01-30 16:43:05 -0500

bit-pirate gravatar image

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!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-01-30 18:00:51 -0500

jbohren gravatar image

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():


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.

edit flag offensive delete link more


Yeha! Things can be so easy - what a pleasure! :-) Thanks a lot!

bit-pirate gravatar image bit-pirate  ( 2013-01-30 18:20:12 -0500 )edit

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. ;-)

bit-pirate gravatar image bit-pirate  ( 2013-01-30 18:22:42 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-01-30 16:43:05 -0500

Seen: 1,081 times

Last updated: Jan 30 '13