---
sidebar:
  hidden: true
title: 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`](/docs/reference/python-sdk/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`](/docs/reference/python-sdk/roboto/formats/mcap/json_decoder_factory#roboto.formats.mcap.json_decoder_factory.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

```python
exception roboto.formats.mcap.ros_cdr_decoder_factory.RosCdrCodecDecodeError
```

`from roboto.formats.mcap.ros_cdr_decoder_factory import RosCdrCodecDecodeError`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/formats/mcap/ros_cdr_decoder_factory.py#L75-L76)

Bases: `mcap.exceptions.McapError`

Raised when a ROS / CDR message cannot be decoded.

### RosCdrCodecDecoderFactory

```python
class roboto.formats.mcap.ros_cdr_decoder_factory.RosCdrCodecDecoderFactory
```

`from roboto.formats.mcap.ros_cdr_decoder_factory import RosCdrCodecDecoderFactory`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/formats/mcap/ros_cdr_decoder_factory.py#L79-L182)

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()

```python
def decoder_for(
    message_encoding: str,
    schema: Optional[mcap.records.Schema],
) -> Optional[Callable[[bytes], Any]]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/formats/mcap/ros_cdr_decoder_factory.py#L92-L101)

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]`)

**Returns**

- `Optional[Callable[[bytes], Any]]`

### UNDECODABLE_MESSAGE

```python
roboto.formats.mcap.ros_cdr_decoder_factory.UNDECODABLE_MESSAGE
```

`from roboto.formats.mcap.ros_cdr_decoder_factory import UNDECODABLE_MESSAGE`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/formats/mcap/ros_cdr_decoder_factory.py#L72-L72)

### make_ros_cdr_codec_decoder_factory()

```python
def roboto.formats.mcap.ros_cdr_decoder_factory.make_ros_cdr_codec_decoder_factory() -> RosCdrCodecDecoderFactory
```

`from roboto.formats.mcap.ros_cdr_decoder_factory import make_ros_cdr_codec_decoder_factory`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/formats/mcap/ros_cdr_decoder_factory.py#L185-L191)

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`](/reference/python-sdk/roboto/formats/mcap/ros_cdr_decoder_factory#roboto.formats.mcap.ros_cdr_decoder_factory.RosCdrCodecDecoderFactory).

**Returns**

- `RosCdrCodecDecoderFactory`
