How can I restart rospy after pressing Ctrl-C? (Python, Bash)
Hello,
I searched through the rospy section of the tutorials but I can't find out simply how to restart rospy after it has been shutdown. I made a code that runs a routine, then asks if the user wants to restart the routine. If i press yes, it will restart successfully if the routine was complete. But if I press ctrl-C within the routine to interrupt it, it asks if the user wants to restart the routine, and then if you choose Yes, it will run the loop again except rospy is no longer running, so nothing happens. I put test messages in my code in order to verify that the loop is indeed running again, and I found that the sections where I run "while not rospy.is_shutdown" all fail to run. Therefore I know that rospy is shutting down as soon as I press ctrl-C. How can I either prevent shutdown or restart rospy after pressing ctrl-C?
Here is the form of my code:
def robot_exec():
# Initialize Rospy
rospy.init_node('my_robot_exec')
# List of robot arm poses:
*many_many_lines_of_position_vectors*
# List of robot gripper poses:
*open_position*
*close_position*
while 1:
#*Call function that moves the robot arm(s) to a position on the list using publisher*
#*Call function that moves the robot gripper(s) to a position on the list using publisher*
#*continue calling functions many times until the desired routine is complete*
n = raw_input("Restart the routine? (Y/N)")
if n.strip() == 'n' or 'N':
break
elif n.strip() == 'y' or 'Y':
continue
else:
print "Invalid input. Exiting..."
break