MCAPTraceFileWriter¶
- class osi_utilities.tracefile.mcap_writer.MCAPTraceFileWriter[source]¶
Bases:
TraceFileWriterWriter for MCAP-format OSI trace files (.mcap).
Supports multi-channel writing with schema registration, OSI-compliant file/channel metadata, and FileDescriptorSet-based schemas.
- open(path, metadata=None, *, compression=None, chunk_size=None)[source]¶
Open an MCAP file for writing.
- Parameters:
path (Path) – Path to the output file. Must have .mcap extension.
metadata (dict[str, str] | None) – Optional net.asam.osi.trace file metadata. If None, default metadata is used.
compression (str | None) – Compression algorithm —
"none","lz4", or"zstd". If None, the mcap library default is used.chunk_size (int | None) – Chunk size in bytes. Must be between
MIN_CHUNK_SIZEandMAX_CHUNK_SIZE. If None,DEFAULT_CHUNK_SIZEis used.
- Returns:
True on success, False on failure.
- Return type:
- add_channel(topic, message_class, metadata=None)[source]¶
Register an OSI channel with schema.
- Parameters:
- Returns:
The channel ID.
- Raises:
RuntimeError – If writer is not open or topic already exists.
- Return type:
- write_message(message, topic='')[source]¶
Write a protobuf message to the specified topic channel.
If no channels are registered, auto-creates one using the message type.