roboto.formats.mcap.decoded_message
Module Contents
DecodedMessage
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 Anyfields collections.accessor_cache Optional[roboto.DecodedMessage.is_path_match()
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 strAttribute path to check (e.g., “pose.position”).
field_path strTarget field path (e.g., “pose.position.x”).
Returns
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")
# FalseDecodedMessage.to_dict()
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
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}