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

How to kill a smach state machine inside an ActionServerWrapper

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

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
3

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

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

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.

edit flag offensive delete link more

Comments

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

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

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 -0600 )edit

Question Tools

Stats

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

Seen: 1,508 times

Last updated: Jan 30 '13