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
RosCdrCodecDecodeError
Bases: mcap.exceptions.McapError
Raised when a ROS / CDR message cannot be decoded.
RosCdrCodecDecoderFactory
Bases: mcap.decoder.DecoderFactory
Decode 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 Rust mcap_codec decoder); the returned callable then decodes each message into nested dict / sequence / scalar values – numeric arrays/sequences (including octet/uint8) as array.array, and nested/heterogeneous sequences as list (see the module docstring).
RosCdrCodecDecoderFactory.decoder_for()
If the message encoding and schema arguments can be decoded by this decoder factory, returns a callable to decode message bytes.
Parameters
message_encoding strschema Optional[mcap.Return type
UNDECODABLE_MESSAGE
make_ros_cdr_codec_decoder_factory()
Build a decoder factory for the ROS / CDR family, backed by the shared Rust mcap_codec decoder.
Handles ros1msg / ros2msg / ros2idl / omgidl schemas; see RosCdrCodecDecoderFactory.
Return type