Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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):
     goalId = GoalID()
     return 'cancel_outcome'

I hope this helps.

Best regards, Teresa