test.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import roslib; roslib.load_manifest('continuous_ops_test_task')
00004 import rospy
00005 import optparse
00006 import actionlib
00007 from continuous_ops_msgs.msg import *
00008 
00009 class Task():
00010     def __init__(self, ns):
00011         self.actionserver = actionlib.SimpleActionServer(ns, TaskAction, self.execute_cb)
00012         self.name = ns
00013 
00014     def execute_cb(self, goal):
00015         while not rospy.is_shutdown():
00016             rospy.loginfo('Testing task %s is running'%self.name)
00017             if self.actionserver.is_preempt_requested():
00018                 if self.name == 'eitan_ns':
00019                     rospy.loginfo('Will refuse to preempt')
00020                 else:
00021                     rospy.loginfo('Starting to preempt task')
00022                     rospy.sleep(5)
00023                     self.actionserver.set_preempted()
00024                     rospy.loginfo('Task Preempted')
00025             rospy.sleep(1.0)
00026 
00027 
00028 def main():
00029     rospy.init_node('task_task')
00030     parser = optparse.OptionParser()
00031     (options, args) = parser.parse_args()
00032     ns = args[0]
00033     task = Task(ns)
00034     rospy.spin()    
00035 
00036 
00037 if __name__ == '__main__':
00038     main()


continuous_ops_test_task
Author(s): Wim Meeussen
autogenerated on Fri Dec 6 2013 19:58:42