utils.py
Go to the documentation of this file.
1 import rospy
2 import actionlib
3 from task_executor.msg import *
4 
5 class TestTaskAction(object):
6  """
7  Creates the action servers the example tasks require.
8  """
9  def __init__(self, expected_action_duration=rospy.Duration(1)):
10  self.expected_action_duration = expected_action_duration
11  self.task_server = actionlib.SimpleActionServer('test_task', TestExecutionAction, execute_cb = self.execute, auto_start = False)
12 
13  def execute(self, goal):
14  print 'called with goal %s'%goal.some_goal_string
15  target = rospy.get_rostime() + self.expected_action_duration
16 
17  while not rospy.is_shutdown() and rospy.get_rostime() < target and not self.task_server.is_preempt_requested():
18  rospy.sleep(0.1)
19 
20  if self.task_server.is_preempt_requested():
21  print "done preempted"
22  self.task_server.set_preempted()
23  else:
24  print "done normal"
25  self.task_server.set_succeeded()
26 
27  def start(self):
28  self.task_server.start()


task_executor
Author(s): Nick Hawes
autogenerated on Tue Mar 17 2015 20:08:13