Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 PKG = 'actionlib'
00032 import rospy
00033
00034 from actionlib.simple_action_server import SimpleActionServer
00035 from actionlib.msg import TestAction, TestFeedback
00036
00037
00038 class RefSimpleServer (SimpleActionServer):
00039
00040 def __init__(self, name):
00041 action_spec = TestAction
00042 SimpleActionServer.__init__(
00043 self, name, action_spec, self.goal_callback, False)
00044 self.start()
00045 rospy.loginfo("Creating SimpleActionServer [%s]\n", name)
00046
00047 def goal_callback(self, goal):
00048 rospy.loginfo("Got goal %d", int(goal.goal))
00049 if goal.goal == 1:
00050 self.set_succeeded(None, "The ref server has succeeded")
00051 elif goal.goal == 2:
00052 self.set_aborted(None, "The ref server has aborted")
00053 elif goal.goal == 3:
00054 self.set_aborted(None, "The simple action server can't reject goals")
00055 elif goal.goal == 4:
00056 self.set_aborted(None, "Simple server can't save goals")
00057 elif goal.goal == 5:
00058 self.set_aborted(None, "Simple server can't save goals")
00059 elif goal.goal == 6:
00060 self.set_aborted(None, "Simple server can't save goals")
00061 elif goal.goal == 7:
00062 self.set_aborted(None, "Simple server can't save goals")
00063 elif goal.goal == 8:
00064 self.set_aborted(None, "Simple server can't save goals")
00065 elif goal.goal == 9:
00066 rospy.sleep(1)
00067 rospy.loginfo("Sending feedback")
00068 self.publish_feedback(TestFeedback(9))
00069 rospy.sleep(1)
00070 self.set_succeeded(None, "The ref server has succeeded")
00071 else:
00072 pass
00073
00074
00075 if __name__ == "__main__":
00076 rospy.init_node("ref_simple_server")
00077 ref_server = RefSimpleServer("reference_simple_action")
00078
00079 rospy.spin()