roboto.formats.mcap.decoded_message#
Module Contents#
- class roboto.formats.mcap.decoded_message.DecodedMessage(msg, fields, accessor_cache=None)#
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 may be one of several types: - A dictionary when the message data is encoded as JSON - A dynamically created class when the message data is encoded as ROS1, ROS2 (CDR), or other binary formats
This class abstracts away the differences between these formats and provides consistent access to message data through a dictionary interface, filtering the output based on the specified fields.
- Parameters:
msg (Any)
fields (collections.abc.Sequence[roboto.formats.fields.FieldSelection])
accessor_cache (Optional[roboto.formats.mcap.accessor.AccessorCache])
- static is_path_match(attrib, field_path)#
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:
True if the attribute matches or is a parent of the field path.
- Return type:
bool
Examples
>>> 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
- 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.
- Return type:
dict
Examples
>>> # 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}