Configuration Schema#
Codec configuration files are YAML mappings. Each field name maps to a field
configuration, and each field configuration needs a codec key unless it is
created by ROS field inference.
field_name:
codec: string
max_length: 16
Common Field Keys#
codecCodec alias used to encode the field. See Codec Aliases.
fieldsNested field mapping for
dictandmsgcodecs.min_valueandmax_valueNumeric bounds used by integer and quantized float codecs.
precisionNumber of decimal places preserved by the
floatcodec.resolutionStep size for
linspace_floatvalues.linspace_floatcan also be configured withnum_valuesornum_bitsinstead.num_bitsFixed bit width for
fixedintandpadding.max_lengthMaximum number of characters, bytes, or array elements for variable-length codecs.
lengthNumber of elements for
fixed_len_array.element_typeCodec alias used for array elements.
element_paramsNested configuration passed to the element codec for an array.
nullableWhen true on
variable_len_array, an empty list is encoded as a single absent/present bit.target_fieldsField mapping controlled by an
optionalfield.ros_typeROS message type for
msgfields. ROS 1 and ROS 2 type names are accepted.
Structured Fields#
Nested dictionaries use fields:
status:
codec: dict
fields:
mode:
codec: uint8
label:
codec: string
max_length: 12
Nested ROS messages use ros_type and may optionally provide fields:
point:
codec: msg
ros_type: geometry_msgs/Point
fields:
x:
codec: float32
y:
codec: float32
z:
codec: float32
Arrays#
Variable-length arrays include a length prefix:
samples:
codec: variable_len_array
max_length: 8
element_type: uint16
Fixed-length arrays omit the length prefix:
orientation:
codec: fixed_len_array
length: 4
element_type: float32
Array element codecs that require their own settings use element_params:
names:
codec: variable_len_array
max_length: 4
element_type: string
element_params:
max_length: 16
Arrays of ROS messages use element_type: msg:
points:
codec: variable_len_array
max_length: 5
element_type: msg
element_params:
ros_type: geometry_msgs/Point
fields:
x:
codec: float32
y:
codec: float32
z:
codec: float32
Top-Level Options#
ltcodecs.dict_codec.DictCodec and
ltcodecs.ros_message_codec.RosMessageCodec accept an optional
checksum argument. Supported values are crc8 and crc32.
codec = ltcodecs.DictCodec(fields, checksum="crc32")
The checksum is appended after the payload and validated during decoding.