function_unit.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # coding=utf-8
00003 
00004 __author__ = "Minglong Li"
00005 
00006 import rospy
00007 import node
00008 import send
00009 import receive
00010 from std_msgs.msg import String
00011 
00012 class FunctionUnit(node.Node, receive.Receive, send.Send):
00013     def __init__(self, node_name):
00014         #node.__init__(self)
00015         super(FunctionUnit, self).__init__()
00016         self._node_name = node_name
00017 
00018     def init_node(self):
00019         rospy.init_node(self._node_name)
00020 
00021     def spin(self):
00022         rospy.spin()    
00023 
00024     def run(self):
00025         pass
00026         #rospy.init_node(self._node_name)
00027         #send1 = send.Send('hello_world', String)
00028         #receive1 = receive.Receive('hello_world_2', String, self.on_received1)#把FunctionUnit中的函数名,
00029         #rospy.spin()
00030         
00031     def create_receive(self, topic, msg_type, on_received):
00032         return receive.Receive(topic, msg_type, on_received)
00033      
00034     def create_send(self, topic, msg_type):   
00035         return send.Send(topic, msg_type)
00036 
00037     def rebuild_receive(self, receive, old_msg_type, new_topic):
00038         receive.unregister()
00039         del receive
00040         return receive.Receive(new_topic, old_msg_type, on_received)#怎么把之前的回调函数传进来?传回调函数对象的时候应该在后面实例化的时候。
00041     '''
00042     def on_received1(self, msg):
00043         print "message received"
00044         print msg
00045         #receive1.start()
00046         #MARK:test hello
00047     '''
00048 #Only by inheriting can we rewrite the method of parent class
00049 '''    
00050     def receive1.on_received(msg):
00051         print "On_received method start!"
00052         print msg.data
00053 '''


micros_mars_task_alloc
Author(s): Minglong Li , Xiaodong Yi , Yanzhen Wang , Zhongxuan Cai
autogenerated on Mon Jul 1 2019 19:55:03