Codec Reference#

This page summarizes the built-in field codecs. For constructor signatures and implementation details, see Python API.

Numeric Codecs#

integer / varint

Encodes an integer bounded by min_value and max_value using the number of bits required for that range. Values outside the configured range are clipped.

fixedint

Encodes an integer with an explicit num_bits width. Set signed to encode signed values.

uint8, uint16, uint32, uint64

Fixed-width unsigned integer aliases.

int8, int16, int32, int64

Fixed-width signed integer aliases.

egint

Encodes an integer with exponential-Golomb coding. This is useful when smaller values are much more common than large values.

Floating-Point Codecs#

float

Quantizes a floating-point value between min_value and max_value with the configured decimal precision. Encoded values are lossy and decode to the represented decimal value.

linspace_float / linspace

Quantizes a floating-point value into a fixed number of evenly spaced values between min_value and max_value. Configure exactly one of resolution, num_values, or num_bits.

float32 and float64

Encodes IEEE 754 binary floating-point values with 32 or 64 bits. These are less compact than quantized float codecs but preserve ordinary float semantics.

Boolean, String, and Bytes Codecs#

bool / boolean

Encodes a Python boolean as one bit.

string / ascii

Encodes an ASCII string with a length prefix and a maximum configured length. Strings longer than max_length are truncated unless the codec is configured to fail on overflow.

bytes

Encodes bytes with a length prefix and max_length bound.

string_enum

Encodes one string selected from a configured set of allowed values.

Container Codecs#

dict / dictionary

Encodes a nested Python dictionary using a nested fields mapping.

msg / ros_msg

Encodes a nested ROS message. ros_type identifies the message class, and fields can override or limit the fields encoded from that message.

variable_len_array

Encodes a list with a length prefix. max_length controls the largest representable list. element_type and element_params configure the element codec.

fixed_len_array

Encodes a fixed number of elements. The encoded bitstream does not include a length field, so the decoder always reads length elements.

optional

Encodes a boolean presence field. When true, the configured target_fields are encoded immediately after the presence bit.

Special-Purpose Codecs#

pad / padding

Reserves a fixed number of zero bits. Padding decodes to None.

time / rostime

Encodes ROS time values with configured seconds and nanoseconds ranges.

ccl_latlon and ccl_latlon_bcd

Encodes latitude and longitude values using compact formats compatible with CCL-style acoustic messages.

lzma

Compresses a byte-oriented payload with LZMA before encoding it with a length bound.

Metadata Codecs#

Metadata aliases such as src, dest, toa, and snr_in are not ordinary payload codecs. They copy values between decoded messages and packet metadata. See Codec Aliases for the complete alias table.