---
sidebar:
  hidden: true
title: roboto.formats.mcap.decoded_message
---
## Module Contents

### DecodedMessage

```python
class roboto.formats.mcap.decoded_message.DecodedMessage(
    msg: Any,
    fields: collections.abc.Sequence[roboto.formats.fields.FieldSelection],
    accessor_cache: Optional[roboto.formats.mcap.accessor.AccessorCache] = None,
)
```

`from roboto.formats.mcap.decoded_message import DecodedMessage`

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

Facade for values returned from message decoders.

Provides a unified interface for working with decoded messages regardless of their original encoding format or source. Handles the conversion of decoded message data into dictionary format suitable for analysis and processing.

A decoded message is a nested `dict` / sequence / scalar value: JSON channels and the shared `mcap_codec` decoder (which handles the ROS1, ROS2/CDR, and IDL encodings) both materialize to `dict`, so one dictionary interface serves every encoding.

This class filters that decoded value down to the specified fields and presents it through a consistent dictionary interface.

**Parameters**

- **msg** (`Any`)
- **fields** (`collections.abc.Sequence[roboto.formats.fields.FieldSelection]`)
- **accessor_cache** (`Optional[roboto.formats.mcap.accessor.AccessorCache]`)

#### DecodedMessage.is_path_match()

```python
@staticmethod
def is_path_match(attrib: str, field_path: str) -> bool
```

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

Check if an attribute path matches or is a parent of a field path.

Determines whether a given attribute path should be included when filtering message data based on the specified fields.

**Parameters**

- **attrib** (`str`): Attribute path to check (e.g., "pose.position").
- **field_path** (`str`): Target field path (e.g., "pose.position.x").

**Returns**

- `bool`: True if the attribute matches or is a parent of the field path.

**Usage**

```python
DecodedMessage.is_path_match("pose", "pose.position.x")
# True
DecodedMessage.is_path_match("pose.position", "pose.position.x")
# True
DecodedMessage.is_path_match("pose.position.x", "pose.position.x")
# True
DecodedMessage.is_path_match("velocity", "pose.position.x")
# False
```

#### DecodedMessage.to_dict()

```python
def to_dict() -> dict
```

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

Convert the decoded message to a dictionary format.

Extracts and organizes message data into a dictionary structure, including only the attributes that match the specified fields.

**Returns**

- `dict`: Dictionary containing the filtered message data with attribute names as keys.

**Usage**

```python
# Assuming fields include "pose.position.x" and "velocity"
decoded_msg = DecodedMessage(ros_message, fields)
data_dict = decoded_msg.to_dict()
print(data_dict)
# {'pose': {'position': {'x': 1.5}}, 'velocity': 2.0}
```
