ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

How to cancel a move_base goal using smach SimpleActionState?

asked 2016-04-29 05:20:06 -0500

tseco gravatar image

Hello,

I am using smach with a SimpleActionState to send navigation goals to move_base with:

StateMachine.add('GO_TO_DOCKING_ZONE',SimpleActionState('move_base',MoveBaseAction, goal_cb = goal_callback, result_cb=goToDocking_result_cb),transitions = {'succeeded':'IR_MONITOR'})

And I would like to cancel this goal. I know that the way to do that is with cancel_goal function, but I do not how to call it using smach.

Any suggestions?

Best regards,

Teresa

edit retag flag offensive close merge delete

Comments

Hello Teresa, I have the same question, I want to cancel a goal when the robot "finds" something, did you get any solution?

mcamp gravatar image mcamp  ( 2016-11-30 13:41:00 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2016-12-01 03:13:31 -0500

tseco gravatar image

Hello! I got a solution, perhaps it is not the best one but it works.

I added a generic state to the smach state machine:

StateMachine.add('CANCEL', CancelGoal(),  transitions={'cancel_outcome':'cancel_aborted'})

The CancelGoal function implemented consits of publishing an empty goal in the /move_base/cancel topic:

class CancelGoal(smach.State):
  def  __init__(self):
    smach.State.__init__(self, outcomes=['cancel_outcome'])
    self.cancel_pub = rospy.Publisher('move_base/cancel', GoalID, queue_size=10)

  def execute(self, userdata):
     setCancelState(True)
     goalId = GoalID()
     self.cancel_pub.publish(goalId)    
     return 'cancel_outcome'

I hope this helps.

Best regards, Teresa

edit flag offensive delete link more

Comments

Its not working. Any update? This cmd worksnrostopic pub /move_base/cancel actionlib_msgs/GoalID -- {} but from python script the goal is not cancled.

dinesh gravatar image dinesh  ( 2021-09-25 13:41:11 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2016-04-29 05:20:06 -0500

Seen: 1,492 times

Last updated: Dec 01 '16