TraceFileWriter

class osi_utilities.tracefile.writer.TraceFileWriter[source]

Bases: ABC

Abstract base class for writing OSI trace files.

Supports context manager protocol.

Usage:

with BinaryTraceFileWriter() as writer:
    writer.open(Path("output.osi"))
    writer.write_message(ground_truth_msg)
abstractmethod open(path)[source]

Open a trace file for writing.

Parameters:

path (Path) – Path to the output file.

Returns:

True if the file was opened successfully, False otherwise.

Return type:

bool

abstractmethod write_message(message, topic='')[source]

Write a protobuf message to the trace file.

Parameters:
  • message (Message) – The protobuf message to write.

  • topic (str) – Channel topic name (used by MCAP writer, ignored by single-channel writers).

Returns:

True if the message was written successfully, False otherwise.

Return type:

bool

abstractmethod close()[source]

Close the trace file and finalize writing.

Return type:

None