rosbridge_library.capabilities.fragmentation module

class rosbridge_library.capabilities.fragmentation.Fragmentation(protocol)

Bases: Capability

A capability to fragment outgoing messages into smaller parts.

The Fragmentation capability doesn’t define any incoming operation handlers, but provides methods to fragment outgoing messages.

fragment(message, fragment_size, mid=None)

Fragment a message into smaller parts.

Serializes the provided message, then splits the serialized message according to fragment_size, then sends the fragments.

If the size of the message is less than the fragment size, then the original message is returned rather than a single fragment

Since fragmentation is typically only used for very large messages, this method returns a generator for fragments rather than a list

Parameters:
  • message – the message dict object to be fragmented

  • fragment_size – the max size for the fragments

  • mid – (optional) if provided, the fragment messages will be given this id. Otherwise an id will be auto-generated.

Returns:

A generator of message dict objects representing the fragments

fragmentation_seed = 0