mcap_ros2.writer module¶
- exception mcap_ros2.writer.McapROS2WriteError[source]¶
Bases:
McapError
Raised if a ROS2 message cannot be encoded to CDR with a given schema.
- class mcap_ros2.writer.Writer(output: str | IO[Any] | BufferedWriter, chunk_size: int = 1048576, compression: CompressionType = CompressionType.ZSTD, enable_crcs: bool = True)[source]¶
Bases:
object
- finish()[source]¶
Finishes writing to the MCAP stream. This must be called before the stream is closed.
- register_msgdef(datatype: str, msgdef_text: str) Schema [source]¶
Write a Schema record for a ROS2 message definition.
- write_message(topic: str, schema: Schema, message: Any, log_time: int | None = None, publish_time: int | None = None, sequence: int = 0)[source]¶
Write a ROS2 Message record, automatically registering a channel as needed.
- Parameters:
topic – The topic of the message.
message – The message to write.
log_time – The time at which the message was logged as a nanosecond UNIX timestamp. Will default to the current time if not specified.
publish_time – The time at which the message was published as a nanosecond UNIX timestamp. Will default to
log_time
if not specified.sequence – An optional sequence number.