Go to the documentation of this file.00001
00002 import roslib; roslib.load_manifest('rfnserver')
00003 import rospy
00004 from rfnserver import RFNServer
00005
00006 class LoopServer:
00007 def __init__(self):
00008 self.server = RFNServer("loop_topic", self.loop_function)
00009
00010
00011 self.server.add_frame("../frames/looping.yaml")
00012 self.server.add_lexical_unit("../lu/loop_looping.yaml")
00013 self.server.register_with_frame("looping")
00014 self.server.start()
00015
00016 def loop_function(self, filled_semantic_frame):
00017 r = rospy.Rate(2)
00018 i = 0
00019 p = self.server.is_preempt_requested()
00020 while ((not p) and
00021 (not rospy.is_shutdown())):
00022 rospy.loginfo("Loop " + str(i) + "! Preempt request?: " + str(p))
00023 i = i + 1
00024 r.sleep()
00025 p = self.server.is_preempt_requested()
00026 if p:
00027 rospy.loginfo("Preempted!")
00028 self.server.set_preempted()
00029 else:
00030 rospy.loginfo("Killed!")
00031 self.server.set_aborted()
00032 rospy.sleep(0.5)
00033 return
00034
00035
00036
00037 def main():
00038 rospy.init_node('loop_node')
00039 server = LoopServer()
00040 rospy.spin()
00041
00042 if __name__ == '__main__':
00043 main()
00044
00045
00046
00047