Robotics StackExchange | Archived questions

How do you cancel a navigation goal?

I'm trying to cancel a movebase goal sent by the explore node. SimpleActionClient.cancelgoal() doesnt seem to work at all, SimpleActionClient.cancelallgoals() 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")

Asked by Tadhg Fitzgerald on 2013-03-19 12:41:47 UTC

Comments

For the highlighting: apparently a mix of tabs and leading whitespaces does not work.

Asked by felix k on 2013-03-19 23:50:31 UTC

Answers