class Subscriber(Topic):
Constructor: Subscriber(name, data_class, callback, callback_args, ...)
Class for registering as a subscriber to a specified topic, where the messages are of a given type.
Method | __init__ |
Constructor. |
Method | unregister |
unpublish/unsubscribe from topic. Topic instance is no longer valid after this call. Additional calls to unregister() have no effect. |
Instance Variable | callback |
Undocumented |
Instance Variable | callback |
Undocumented |
Inherited from Topic
:
Method | get |
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. @return: number of connections @rtype: int... |
Instance Variable | data |
Undocumented |
Instance Variable | impl |
Undocumented |
Instance Variable | md5sum |
Undocumented |
Instance Variable | name |
Undocumented |
Instance Variable | reg |
Undocumented |
Instance Variable | resolved |
Undocumented |
Instance Variable | type |
Undocumented |
Constructor.
NOTE: for the queue_size and buff_size parameters, rospy does not attempt to do intelligent merging between multiple Subscriber instances for the same topic. As they share the same underlying transport, multiple Subscribers to the same topic can conflict with one another if they set these parameters differently.
@param name: graph resource name of topic, e.g. 'laser'. @type name: str @param data_class: data type class to use for messages,
e.g. std_msgs.msg.String
@type data_class: L{Message} class @param callback: function to call ( fn(data)) when data is
received. If callback_args is set, the function must accept the callback_args as a second argument, i.e. fn(data, callback_args). NOTE: Additional callbacks can be added using add_callback().
@type callback: fn(msg, cb_args) @param callback_args: additional arguments to pass to the
callback. This is useful when you wish to reuse the same callback for multiple subscriptions.
@type callback_args: any @param queue_size: maximum number of messages to receive at
a time. This will generally be 1 or None (infinite, default). buff_size should be increased if this parameter is set as incoming data still needs to sit in the incoming buffer before being discarded. Setting queue_size buff_size to a non-default value affects all subscribers to this topic in this process.
@type queue_size: int @param buff_size: incoming message buffer size in bytes. If
queue_size is set, this should be set to a number greater than the queue_size times the average message size. Setting buff_size to a non-default value affects all subscribers to this topic in this process.
@type buff_size: int @param tcp_nodelay: if True, request TCP_NODELAY from
publisher. Use of this option is not generally recommended in most cases as it is better to rely on timestamps in message data. Setting tcp_nodelay to True enables TCP_NODELAY for all subscribers in the same python process.
@type tcp_nodelay: bool @raise ROSException: if parameters are invalid