__init__(self,
name,
data_class,
callback=None,
callback_args=None,
queue_size=None,
buff_size=65536,
tcp_nodelay=False)
(Constructor)
| source code
|
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.
- Parameters:
name (str) - graph resource name of topic, e.g. 'laser'.
data_class (Message class) - data type class to use for messages, e.g. std_msgs.msg.String
callback (fn(msg, cb_args)) - 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().
callback_args (any) - additional arguments to pass to the callback. This is useful when
you wish to reuse the same callback for multiple subscriptions.
queue_size (int) - 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.
buff_size (int) - 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.
tcp_nodelay (bool) - 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.
- Raises:
- Overrides:
object.__init__
|