#NEWLINE# def __init__( self , topic , msg_type = None ) : #NEWLINE# #INDENT# ' Register a subscriber on the specified topic.\n\n        Keyword arguments:\n        topic    -- the name of the topic to register the subscriber on\n        msg_type -- (optional) the type to register the subscriber as.  If not\n        provided, an attempt will be made to infer the topic type\n\n        Throws:\n        TopicNotEstablishedException -- if no msg_type was specified by the\n        caller and the topic is not yet established, so a topic type cannot\n        be inferred\n        TypeConflictException        -- if the msg_type was specified by the\n        caller and the topic is established, and the established type is\n        different to the user-specified msg_type\n\n        ' #NEWLINE# topic_type = get_topic_type ( msg_type ) [ 0 ] #NEWLINE# if ( ( msg_type is None ) and ( topic_type is None ) ) : #NEWLINE# #INDENT# raise TopicNotEstablishedException ( topic ) #NEWLINE# #UNINDENT# if ( msg_type is None ) : #NEWLINE# #INDENT# msg_type = topic_type #NEWLINE# #UNINDENT# msg_class = ros_loader . get_message_class ( msg_type ) #NEWLINE# if ( ( topic_type is not None ) and ( topic_type != msg_class . _type ) ) : #NEWLINE# #INDENT# raise TypeConflictException ( topic , topic_type , msg_class . _type ) #NEWLINE# #UNINDENT# self . subscriptions = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . lock = Lock ( ) #NEWLINE# self . topic = topic #NEWLINE# self . msg_class = msg_class #NEWLINE# self . subscriber = Subscriber ( topic , msg_class , self . callback )