MCAPTraceFileReader

class osi_utilities.tracefile.mcap_reader.MCAPTraceFileReader[source]

Bases: TraceFileReader

Reader for MCAP-format OSI trace files (.mcap).

Supports multi-channel reading with topic-based filtering, schema-based message type detection, and metadata access.

open(path)[source]

Open an MCAP trace file.

Parameters:

path (Path) – Path to the .mcap file.

Returns:

True on success, False on failure.

Return type:

bool

set_topics(topics)[source]

Filter reading to specific topics.

Parameters:

topics (list[str]) – List of topic names to read. If empty, reads all topics.

Return type:

None

set_skip_non_osi_msgs(skip)[source]

Configure whether to skip non-OSI messages.

Parameters:

skip (bool) – If True, silently skip messages with unrecognized schemas. If False (default), they are skipped with a warning.

Return type:

None

read_message()[source]

Read the next message from the MCAP file.

Returns:

ReadResult on success, None if no more messages.

Return type:

ReadResult | None

has_next()[source]

Check if there are more messages.

Note: May return True even if only non-OSI messages remain.

Return type:

bool

close()[source]

Close the MCAP file.

Return type:

None

get_available_topics()[source]

Return list of available topic names in the file.

Return type:

list[str]

get_file_metadata()[source]

Return file-level metadata entries.

Return type:

list[dict]

get_channel_metadata(topic)[source]

Return metadata for a specific channel/topic.

Parameters:

topic (str)

Return type:

dict[str, str] | None

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