Skip to content
Roboto
Esc
↑↓navigate↵open⌘Jpreview
On this page

roboto.formats.mcap.decoded_message

Module Contents

DecodedMessage

class roboto.formats.mcap.decoded_message.DecodedMessage(msg, fields, accessor_cache=None)#View Source

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]

DecodedMessage.is_path_match()

static is_path_match(attrib, field_path)#View Source

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

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

to_dict()#View Source

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

# 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}

Was this page helpful?