ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Now that I think about it, your incorrect use of rospy.Rate.sleep()
may be the cause. So try this:
rate.sleep()
calls into rospy.sleep(0.1)
callsrate = rospy.Rate(2)
rate.sleep()
at the very end of your while loop, after the try/except block and in-line with itSee if that changes anything. Sleep calls listen for Ctrl+C interrupts. Your loop timing will be all out of whack due to using a loop sleep twice, which may be causing the sleeps to not catch interrupts.
2 | No.2 Revision |
Now that I think about it, your incorrect use of rospy.Rate.sleep()
may be the cause. So try this:
rate.sleep()
calls into rospy.sleep(0.1)
callsrate = rospy.Rate(2)
rate.sleep()
at the very end of your while loop, after the try/except block and in-line with itSee if that changes anything. Sleep calls listen for Ctrl+C interrupts. Your loop timing will be all out of whack due to using a loop sleep twice, which may be causing the sleeps to not catch interrupts. interrupts.
3 | No.3 Revision |
Now that I think about it, your incorrect use of rospy.Rate.sleep()
may be the cause. So try this:
rate.sleep()
calls into rospy.sleep(0.1)
callsrate = rospy.Rate(2)
rate.sleep()
at the very end of your while loop, after the try/except block and in-line with itSee if that changes anything. Sleep calls listen for Ctrl+C interrupts. Your loop timing will be all out of whack due to using a loop sleep twice, which may be causing the sleeps to not catch interrupts.
EDIT:
Actually, let me alter that a little bit. You don't want a rospy.Rate.sleep()
call at all here, because its loop timing will be dependent on user input (not good). So just use another rospy.sleep(1)
or something at the end of your loop to catch Ctrl+C interrupts.
4 | No.4 Revision |
Now that I think about it, your incorrect use of rospy.Rate.sleep()
may be the cause. So try this:
rate.sleep()
calls into rospy.sleep(0.1)
callsrate = rospy.Rate(2)
rate.sleep()
at the very end of your while loop, after the try/except block and in-line with itSee if that changes anything. Sleep calls listen for Ctrl+C interrupts. Your loop timing will be all out of whack due to using a loop sleep twice, which may be causing the sleeps to not catch interrupts.
EDIT:
Actually, let me alter that a little bit. You don't want a rospy.Rate.sleep()
call at all here, because its loop timing will be dependent on user input (not good). So just use another rospy.sleep(1)
or something at the end of your loop to catch Ctrl+C interrupts.
EDIT 2 (answer):
The problem may lie in the fact that ROS is handling signals itself, and so a KeyboardInterrupt is never actually raised. Try setting disable_signals=True
in your node initialization, like rospy.init_node('commander', anonymous=True, disable_signals=True)
. Disabling signals won't cause any major issues. ROS just uses SIGINT to shut down nodes itself, preventing users to have to explicitly look for and catch KeyboardInterrupt exceptions etc. You're basically doing the same thing yourself.