class documentation

class Blob(Projection):

View In Hierarchy

One fixed-width primitive array carried as a single byte string.

A million-cell grid as one UA array is a million Variants on the wire, and as one ByteString it is one buffer copy. The rest of the message is the generic walk. The element type comes from the ROS2 definition, so int8[], uint8[] and float32[] need no keyword. Signedness is published as a DataType, because a -1 would otherwise reach a plain ByteString as 0xFF.

The recipe never transforms the bytes. Naming a datatype says what they are (a CompressedImage's data really is a JPEG), and then the round trip can no longer be claimed for the author, so the Blob inverts only if an encode is supplied.

Method decode Read the payload as usual, with the named field packed into bytes and capped.
Method shape Walk the message, with the named field rendered as one byte string.
Instance Variable datatype What the bytes are, as a DataType identifier in namespace 0 (ua.ObjectIds.ImagePNG), or None to publish the signedness derived from the element type.
Instance Variable encode A codec whose round trip the author claims. Supplying it is that claim.
Instance Variable field The ROS2 field to carry as bytes.
Property inverse Return the supplied codec, else byte identity; None when a datatype is named without a codec.
Method _datatype_of Return what the variable's bytes say they are.
Method _encode Unpack the byte string back into the elements the field holds.
Method _packed_field Return the named field, having checked that it is a fixed-width primitive array.
def decode(self, message: Message, context: ProjectionContext) -> Mapping[str, object]:

Read the payload as usual, with the named field packed into bytes and capped.

def shape(self, message_type: type[Message], context: ProjectionContext) -> tuple[PlanEntry, ...]:

Walk the message, with the named field rendered as one byte string.

datatype: int | None =

What the bytes are, as a DataType identifier in namespace 0 (ua.ObjectIds.ImagePNG), or None to publish the signedness derived from the element type.

encode: EncodeFunction | None =

A codec whose round trip the author claims. Supplying it is that claim.

field: str =

The ROS2 field to carry as bytes.

@property
inverse: EncodeFunction | None =

Return the supplied codec, else byte identity; None when a datatype is named without a codec.

def _datatype_of(self, field_type: FieldType) -> StandardDataType | ProjectDataType | None:

Return what the variable's bytes say they are.

def _encode(self, message_type: type[Message], values: Mapping[str, object], context: ProjectionContext) -> Message:

Unpack the byte string back into the elements the field holds.

def _packed_field(self, message_type: type[Message]) -> FieldDescription:

Return the named field, having checked that it is a fixed-width primitive array.

Raises
UnprojectableFieldErrorWhen the field is absent, is not repeated, or holds something with no fixed width (a string, or another message).