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 roslib; roslib.load_manifest(PKG)
00033 import rospy
00034
00035 import sys
00036
00037 from actionlib.simple_action_server import SimpleActionServer
00038 from actionlib.msg import TestAction,TestFeedback
00039
00040
00041 class RefSimpleServer (SimpleActionServer):
00042
00043 def __init__(self,name):
00044 action_spec=TestAction
00045 SimpleActionServer.__init__(self,name,action_spec,self.goal_callback, False);
00046 self.start()
00047 rospy.loginfo("Creating SimpleActionServer [%s]\n", name);
00048
00049
00050 def goal_callback(self,goal):
00051
00052 rospy.loginfo("Got goal %d", int(goal.goal))
00053 if goal.goal == 1:
00054 self.set_succeeded(None, "The ref server has succeeded");
00055 elif goal.goal == 2:
00056 self.set_aborted(None, "The ref server has aborted");
00057
00058 elif goal.goal == 3:
00059 self.set_aborted(None, "The simple action server can't reject goals");
00060
00061
00062 elif goal.goal == 4:
00063 self.set_aborted(None, "Simple server can't save goals");
00064
00065
00066 elif goal.goal == 5:
00067 self.set_aborted(None, "Simple server can't save goals");
00068
00069 elif goal.goal == 6:
00070 self.set_aborted(None, "Simple server can't save goals");
00071
00072
00073
00074 elif goal.goal == 7:
00075 self.set_aborted(None, "Simple server can't save goals");
00076
00077 elif goal.goal == 8:
00078 self.set_aborted(None, "Simple server can't save goals");
00079
00080 elif goal.goal == 9:
00081 rospy.sleep(1);
00082 rospy.loginfo("Sending feedback")
00083 self.publish_feedback(TestFeedback(9));
00084 rospy.sleep(1);
00085 self.set_succeeded(None, "The ref server has succeeded");
00086
00087
00088 else:
00089 pass
00090
00091 if __name__=="__main__":
00092 rospy.init_node("ref_simple_server");
00093 ref_server = RefSimpleServer("reference_simple_action");
00094
00095 rospy.spin();
00096
00097
00098