rosbridge_library.capabilities.subscribe module

class rosbridge_library.capabilities.subscribe.Subscribe(protocol)

Bases: Capability

finish()

Notify this capability that the client is finished.

Tells the capability that it’s time to free up resources.

publish(topic, message, fragment_size=None, compression='none')

Publish a message to the client.

Parameters:
  • topic – The topic to publish the message on

  • message – A ROS message wrapped by OutgoingMessage

  • fragment_size – (optional) If provided, fragment the serialized message into msgs with payloads not greater than this value

  • compression – (optional) compress the message. valid values are ‘png’ and ‘none’

subscribe(msg)
subscribe_msg_fields = ((True, 'topic', <class 'str'>), (False, 'type', <class 'str'>), (False, 'throttle_rate', <class 'int'>), (False, 'fragment_size', <class 'int'>), (False, 'queue_length', <class 'int'>), (False, 'compression', <class 'str'>))
topics_glob = None
unsubscribe(msg)
unsubscribe_msg_fields = (True, 'topic', <class 'str'>)
class rosbridge_library.capabilities.subscribe.Subscription(client_id, topic, publish, node_handle)

Bases: object

Keeps track of the clients multiple calls to subscribe.

Chooses the most appropriate settings to send messages.

is_empty()

Return True if there are no subscriptions currently.

on_msg(msg)

Handle incoming messages.

Raw callback called by subscription manager for all incoming messages.

Incoming messages are passed to the message handler which may drop, buffer, or propagate the message.

subscribe(sid=None, msg_type=None, throttle_rate=0, queue_length=0, fragment_size=None, compression='none')

Add another client’s subscription request.

If there are multiple calls to subscribe, the values actually used for queue_length, fragment_size, compression and throttle_rate are chosen to encompass all subscriptions’ requirements

Parameters:
  • sid – The subscription id from the client

  • msg_type – The type of the message to subscribe to

  • throttle_rate – The minimum time (in ms) allowed between messages being sent. If multiple subscriptions, the lower of these is used

  • queue_length – The number of messages that can be buffered. If multiple subscriptions, the lower of these is used

  • fragment_size – None if no fragmentation, or the maximum length of allowed outgoing messages

  • compression – “none” if no compression, or some other value if compression is to be used (current valid values are ‘png’)

unregister()

Unsubscribe this subscription and clean up resources.

unsubscribe(sid=None)

Unsubscribe this particular client’s subscription.

Parameters:

sid – The individual subscription id. If None, all are unsubscribed

update_params()

Update the parameters of the message handler based on current subscriptions.

Determine the ‘lowest common denominator’ params to satisfy all subscribed clients.