ROS python script is not exiting after ctrl-C
I am trying to reset model poses in gazebo on the even "rospy.on_shutdown()". Below is the piece of code I have in my script.
rospy.on_shutdown(self.stopOnShutdown)
def stopOnShutdown(self):
time.sleep(1)
reset_world = rospy.ServiceProxy('/gazebo/reset_world', Empty)
reset_world()
print "exiting..."
sys.exit(0)
But, when I press Ctrl-C, the models in the gazebo are reset but the script doesn't stop running.
Not an answer, but you should really be using
rospy
'sTime
class instead of the built-intime
module.rospy.Time
works seamlessly with simulated Clock time.See http://wiki.ros.org/rospy/Overview/Ti...
When are you pressinc Ctrl+C and expecting it to quit but it doesn't? During the sleep() or during the reset_world()?
It is resetting the world. But it keeps on printing "exiting..." over and over even after pressing ctrl-C.
Have you tried removing the sys.exit() call? This might indeed create a loop