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

asked 2013-04-13 16:21:03 -0500

Pi Robot gravatar image

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.header.frame_id = 'map'
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):
    rospy.loginfo("Stopping the robot...")
    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 flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2015-11-06 16:14:59.932926

Comments

2

Did you ever figure out how to ctrl-c out of a smach state in progress? Maybe some of the details are out of date above, but in Jade I've just started using smach_ros and I can't ctrl-c out of a SimpleActionState.

lucasw gravatar imagelucasw ( 2016-05-27 15:28:17 -0500 )edit