def __init__(self, node_name, port): """Create the NetNode object. Registers the methods in this NetNode instance as callbacks for the CmdListener object. This is an 'inversion of control' in some respects. Params: node_name - The name of the ROS node. port - The port to send/receive commands on """ #Create network communication object self.listener = CmdListener('', port) #Add listeners self.listener.add_connect_listener(self.on_connect) self.listener.add_data_listener(self.on_data) self.listener.add_dc_listener(self.on_dc) self.node_name = node_name #Create publishers/service proxies for communicating with the #control node. self.get_inputs_srv = rospy.ServiceProxy( '/oark_control_node/get_inputs', GetInputs) self._command_pub = rospy.Publisher('/oark_control_node/command', Command, latch=True, queue_size=10) self.disconnected_srv = rospy.ServiceProxy( '/oark_control_node/disconnected', Empty) self.connected_srv = rospy.ServiceProxy('/oark_control_node/connected', Connected)