rosbridge_library.capabilities.fragmentation module

class rosbridge_library.capabilities.fragmentation.Fragmentation(protocol: 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: dict[str, Any] | bytes, fragment_size: int, mid: str | None = None) Iterable[dict[str, Any] | bytes]

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:

An iterable of ROSBridge messages, either a single message or multiple fragments.

fragmentation_seed = 0