How do you cancel a navigation goal? [closed]
I'm trying to cancel a move_base goal sent by the explore node. SimpleActionClient.cancel_goal() doesnt seem to work at all, SimpleActionClient.cancel_all_goals() only works intermittently. I've included the code for my goal cancellation node below:
class cancelGoal():
def __init__(self):
self.node_name = "cancel_goal"
rospy.init_node(self.node_name)
self.explore_goal_sub = rospy.Subscriber("/move_base/goal",
MoveBaseActionGoal, self.newGoalHandler)
self.client = actionlib.SimpleActionClient('move_base', MoveBaseAction)
rospy.loginfo("Wating for move_base server.....")
self.client.wait_for_server()
def newGoalHandler(self, new_goal):
self.client.cancel_goal()
self.client.cancel_all_goals() # Try both
rospy.loginfo("Goal cancelled")
For the highlighting: apparently a mix of tabs and leading whitespaces does not work.