MultiTraceReader¶
- class osi_utilities.tracefile.readers.multi.MultiTraceReader(decoder_mode='precompiled', skip_incompatible_messages=True, log_incompatible_messages=True)[source]¶
Bases:
TraceReaderReader for multi-channel OSI trace files (.mcap).
Supports multi-channel reading with topic-based filtering, schema-based message type detection, and metadata access.
Incompatible message handling:
Controlled by
set_skip_incompatible_messages(...).If enabled (default), incompatible messages are skipped.
If disabled, incompatible messages are surfaced as
ReadResult(status=ReadStatus.INCOMPATIBLE, ...).
Logging behavior for incompatible messages is controlled independently by
set_log_incompatible_messages(...).- set_decoder_mode(decoder_mode)[source]¶
Set protobuf decoding strategy.
Supported values: -
precompiled: decode OSI schemas via precompiledosi3classes -mcap-contained: decode via schema descriptor sets embedded in MCAP- Parameters:
decoder_mode (str)
- Return type:
None
- set_topic_message_types(topic_message_types)[source]¶
Set expected message types per topic.
- Parameters:
topic_message_types (dict[str, MessageType | str | None]) – Mapping of topic name to expected message type. Entries with
Noneremove expectations for that topic.- Return type:
None
- set_log_incompatible_messages(log_messages)[source]¶
Configure whether incompatible messages should be logged.
- Parameters:
log_messages (bool) – If True (default), incompatible messages are logged. If False, incompatible messages are not logged.
- Return type:
None
- set_skip_incompatible_messages(skip)[source]¶
Configure whether incompatible messages should be skipped.
Incompatible messages are non-matching encoding/schema/message-type cases. Actual decode/read errors are always surfaced as
ReadStatus.ERRORand are never skipped by this setting.- Parameters:
skip (bool)
- Return type:
None
- read_message()[source]¶
Read the next message from the MCAP file.
- Returns:
ReadStatus.OKfor a valid decoded messageReadStatus.INCOMPATIBLEfor incompatible messages whenset_skip_incompatible_messages(False)is configuredReadStatus.ERRORfor runtime read/decode failures
- Return type:
Noneon EOF; otherwise aReadResultwith status
- has_next()[source]¶
Check if there are more messages to read.
Peeks ahead in the iterator to give an accurate answer.
- Return type:
- get_channel_specification(topic)[source]¶
Return ChannelSpecification for a specific OSI-compatible topic.
Returns None when the topic is missing or not a supported OSI schema.
- Parameters:
topic (str)
- Return type:
ChannelSpecification | None
- list_channel_specifications()[source]¶
Return ChannelSpecification objects for all OSI-compatible topics.
- Return type:
- get_message_type_for_topic(topic)[source]¶
Return the MessageType for a given topic based on its schema.
- Parameters:
topic (str)
- Return type:
MessageType | None