Package rospy :: Module topics :: Class Topic

Class Topic

source code

object --+
         |
        Topic
Known Subclasses:

Base class of Publisher and Subscriber

Instance Methods
 
__init__(self, name, data_class, reg_type)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
int
get_num_connections(self)
get the number of connections to other ROS nodes for this topic.
source code
 
unregister(self)
unpublish/unsubscribe from topic.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, name, data_class, reg_type)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • name (str) - graph resource name of topic, e.g. 'laser'.
  • data_class (Message @param reg_type Registration.PUB or Registration.SUB) - message class for serialization
  • reg_type (str)
Raises:
  • ValueError - if parameters are invalid
Overrides: object.__init__

get_num_connections(self)

source code 

get the number of connections to other ROS nodes for this topic. For a Publisher, this corresponds to the number of nodes subscribing. For a Subscriber, the number of publishers.

Returns: int
number of connections

unregister(self)

source code 

unpublish/unsubscribe from topic. Topic instance is no longer valid after this call. Additional calls to unregister() have no effect.