def create_transport(self, topic_name, pub_uri, protocol_params): """ Connect to topic resolved_name on Publisher pub_uri using UDPROS. @param resolved_name str: resolved topic name @type resolved_name: str @param pub_uri: XML-RPC URI of publisher @type pub_uri: str @param protocol_params: protocol parameters to use for connecting @type protocol_params: [XmlRpcLegal] @return: code, message, debug @rtype: (int, str, int) """ #Validate protocol params = [UDPROS, address, port, headers] if type(protocol_params) != list or len(protocol_params) != 4: return 0, "ERROR: invalid UDPROS parameters", 0 if protocol_params[0] != UDPROS: return 0, "INTERNAL ERROR: protocol id is not UDPROS: %s" % id, 0 #TODO: get connection_id and buffer size from params id, dest_addr, dest_port, headers = protocol_params self.init_server() #TODO: parse/validate headers sub = rospy.registration.get_topic_manager().get_subscriber_impl( topic_name) # Create Transport # TODO: create just a single 'connection' instance to represent # all UDP connections. 'connection' can take care of unifying # publication if addresses are the same transport = UDPTransport(protocol, topic_name, sub.receive_callback) # Attach connection to _SubscriberImpl if sub.add_connection(transport): #pass udp connection to handler return 1, "Connected topic[%s]. Transport impl[%s]" % ( topic_name, transport.__class__.__name__), dest_port else: transport.close() return 0, "ERROR: Race condition failure: duplicate topic subscriber [%s] was created" % ( topic_name), 0
def create_transport(self, topic_name, pub_uri, protocol_params): """ Connect to topic resolved_name on Publisher pub_uri using UDPROS. @param resolved_name str: resolved topic name @type resolved_name: str @param pub_uri: XML-RPC URI of publisher @type pub_uri: str @param protocol_params: protocol parameters to use for connecting @type protocol_params: [XmlRpcLegal] @return: code, message, debug @rtype: (int, str, int) """ #Validate protocol params = [UDPROS, address, port, headers] if type(protocol_params) != list or len(protocol_params) != 4: return 0, "ERROR: invalid UDPROS parameters", 0 if protocol_params[0] != UDPROS: return 0, "INTERNAL ERROR: protocol id is not UDPROS: %s"%id, 0 #TODO: get connection_id and buffer size from params id, dest_addr, dest_port, headers = protocol_params self.init_server() #TODO: parse/validate headers sub = rospy.registration.get_topic_manager().get_subscriber_impl(topic_name) # Create Transport # TODO: create just a single 'connection' instance to represent # all UDP connections. 'connection' can take care of unifying # publication if addresses are the same transport = UDPTransport(protocol, topic_name, sub.receive_callback) # Attach connection to _SubscriberImpl if sub.add_connection(transport): #pass udp connection to handler return 1, "Connected topic[%s]. Transport impl[%s]"%(topic_name, transport.__class__.__name__), dest_port else: transport.close() return 0, "ERROR: Race condition failure: duplicate topic subscriber [%s] was created"%(topic_name), 0