roboto.formats.mcap.ros_cdr_decoder_factory#
MCAP decoder factory for the whole ROS / CDR message family.
Exposes an mcap.decoder.DecoderFactory that decodes every ROS-flavored
binary message Roboto reads – ros1msg (the unaligned ROS1 wire) and the CDR
schema languages ros2msg / ros2idl / omgidl – by delegating to the
shared Rust decoder (the mcap_codec extension built from roboto-mcap-codec,
the same decoder the ingestion action uses). One factory backs them all because
RosCdrCodec dispatches internally on the schema encoding, so a decode fix lands
once and benefits every encoding (and ingest stats) together.
The decoder parses the schema once per schema id and decodes each payload into nested
dict / sequence / scalar values: numeric arrays and sequences – including
octet/uint8 sequences – come back as the compact array.array (one C
buffer rather than a list of boxed Python objects); nested/heterogeneous sequences
(arrays of structs, arrays of sequences, the outer dimension of a multidimensional
array) are plain list; enums are int; unions are
{"$discriminator", <active arm>}; Time / Duration members surface with
their schema-verbatim names (ROS2 {"sec", "nanosec"}, ROS1 {"sec", "nsec"}); and
absent @optional members are omitted. This dict representation is what
roboto.formats.mcap.accessor walks, so the same projection machinery serves
every encoding. Callers that need JSON-serializable output (array.array is not
JSON-native) should convert at the edge, e.g. via array.tolist().
JSON channels are not handled here.
They keep their own JsonDecoderFactory,
which preserves json.loads semantics (None for null fields, plain lists, arbitrary-precision ints)
where this decoder’s materialization is deliberately CDR-shaped.
Module Contents#
- exception roboto.formats.mcap.ros_cdr_decoder_factory.RosCdrCodecDecodeError#
Bases:
mcap.exceptions.McapErrorRaised when a ROS / CDR message cannot be decoded.
- class roboto.formats.mcap.ros_cdr_decoder_factory.RosCdrCodecDecoderFactory#
Bases:
mcap.decoder.DecoderFactoryDecode ROS / CDR messages (
ros1msg/ros2msg/ros2idl/omgidl).Supply an instance to
mcap.reader.make_reader(). The schema is parsed once per schema id (by the shared Rustmcap_codecdecoder); the returned callable then decodes each message into nesteddict/ sequence / scalar values – numeric arrays/sequences (including octet/uint8) asarray.array, and nested/heterogeneous sequences aslist(see the module docstring).- decoder_for(message_encoding, schema)#
If the message encoding and schema arguments can be decoded by this decoder factory, returns a callable to decode message bytes.
- Parameters:
message_encoding (str)
schema (Optional[mcap.records.Schema])
- Return type:
Optional[Callable[[bytes], Any]]
- roboto.formats.mcap.ros_cdr_decoder_factory.UNDECODABLE_MESSAGE#
- roboto.formats.mcap.ros_cdr_decoder_factory.make_ros_cdr_codec_decoder_factory()#
Build a decoder factory for the ROS / CDR family, backed by the shared Rust
mcap_codecdecoder.Handles
ros1msg/ros2msg/ros2idl/omgidlschemas; seeRosCdrCodecDecoderFactory.- Return type: