Cancel rospy action with Ctrl+C
Hi to everyone, i'm using a class in which some methods call actions as SimpleActionClient. I create a node in the same executable i create the class instance and leave if the signal handling. When i press ctrl+c , the executable stops but the action is completed anyway. The code is:
self.__move_base_action = actionlib.SimpleActionClient('/sweepee/move_base', MoveBaseAction)
.....
try:
while True:
self.__move_base_action.wait_for_server()
goal = MoveBaseGoal()
goal.target_pose.header.frame_id = "map_sweepee"
print("moving to : ",pos_in[0], pos_in[1], pos_in[2], pos_in[3])
goal.target_pose.header.stamp = rospy.Time.now()
goal.target_pose.pose.position.x = pos_in[0]
goal.target_pose.pose.position.y = pos_in[1]
goal.target_pose.pose.orientation.z = pos_in[2]
goal.target_pose.pose.orientation.w = pos_in[3]
self.__move_base_action.send_goal(goal)
wait = self.__move_base_action.wait_for_result()
if not wait:
self.__move_base_action.cancel_all_goals()
rospy.logerr("Action server interrupted!")
return False
else:
return self.__move_base_action.get_result()
except KeyboardInterrupt:
self.__move_base_action.cancel_all_goals()
return False
The code actually executes the line: self.__move_base_action.cancel_all_goals() but the action is not stopping. Any idea on why? Thanks