How to Ctrl-C out of a SMACH state machine? [closed]

Hello,

I have a simple SMACH state machine that moves a robot through a series of waypoints using SimpleActionStates to wrap MoveBaseGoals for each of the waypoints. For example, here is how I define the SimpleActionState for one of the waypoints:

nav_goal = MoveBaseGoal()
nav_goal.target_pose.pose = waypoint
move_base_state = SimpleActionState('move_base', MoveBaseAction, goal=nav_goal,
exec_timeout=rospy.Duration(60.0),
server_wait_timeout=rospy.Duration(30.0))


What I have discovered is that if I type Ctrl-C after the state machine starts running (and the robot is moving between waypoints), there is a delay of 3-4 seconds before the robot stops moving. My on_shutdown() function looks like this:

def shutdown(self):
self.nav_sm.request_preempt()
self.cmd_vel_pub.publish(Twist())


If instead of using SMACH I simply use an actionlib.SimpleActionClient to send MoveBaseGoals directly, I can execute a move_base.cancel_goal() during the on_shutdown() function which stops the robot immediately.

Is there some way I can terminate a SMACH state machine more quickly?

I am using ROS Groovy on Ubuntu 12.04.

Thanks!
patrick

edit retag reopen merge delete