mcap_ros1.reader module

Deprecated since version 0.7.0: For similar functionality, instantiate mcap.reader.McapReader with a mcap_ros1.decoder.DecoderFactory instance, eg:

>>> from mcap.reader import make_reader
>>> from mcap_ros1.decoder import DecoderFactory
>>> reader = make_reader(open("ros1.mcap", "rb"), decoder_factories=[DecoderFactory()])
>>> for schema_, channel_, message_, ros1_msg in reader.iter_decoded_messages():
>>>     print(ros1_msg)
String(data="hello")
String(data="goodbye")
class mcap_ros1.reader.McapROS1Message(ros_msg: Any, message: Message, channel: Channel, schema: Schema)[source]

Bases: object

Contains a single ROS message and associated metadata.

Deprecated since version 0.7.0: use the tuple yielded from mcap.reader.McapReader.iter_decoded_messages instead.

Variables:
  • ros_msg – the decoded ROS1 message.

  • sequence_count – the message sequence count if included in the MCAP, or 0 otherwise.

  • topic – the topic that the message was published on.

  • channel_metadata – the metadata associated with this ROS1 topic, if any.

  • log_time_ns – the time this message was logged by the recorder, as a POSIX nanosecond timestamp.

  • log_time_ns – the time this message was published, as a POSIX nanosecond timestamp.

channel: Channel
channel_metadata: Dict[str, str]
property log_time: datetime

The timestamp representing when this message was logged by the recorder.

log_time_ns: int
property publish_time: datetime

The timestamp representing when this message was published.

publish_time_ns: int
ros_msg: Any
schema: Schema
sequence_count: int
topic: str
mcap_ros1.reader.read_ros1_messages(source: str | bytes | PathLike[str] | McapReader | IO[bytes], topics: Iterable[str] | None = None, start_time: int | datetime | None = None, end_time: int | datetime | None = None, log_time_order: bool = True, reverse: bool = False) Iterator[McapROS1Message][source]

High-level generator that reads ROS1 messages from an MCAP file.

Deprecated since version 0.7.0: Use mcap_ros1.decoder.DecoderFactory with mcap.reader.McapReader instead.

Parameters:
  • source – some source of MCAP file data. Supply a stream of bytes, an McapReader instance, or the path to a valid MCAP file in the filesystem.

  • topics – an optional list of topics to read from the MCAP file.

  • start_time – if not None, messages logged before this time will not be included.

  • end_time – if not None, messages logged at this timestamp or after will not be included.

  • log_time_order – if True, messages will be yielded in ascending log time order. If False, messages will be yielded in the order they appear in the MCAP file.

  • reverse – if both log_time_order and reverse are True, messages will be yielded in descending log time order.

Yields:

an McapROS1Message instance for each ROS1 message in the MCAP file.

Note

this generator assumes the source MCAP conforms to the ros1 MCAP profile. If you need to decode ROS1 messages from a file containing other encodings, use the mcap.reader.McapReader.iter_messages() function to iterate through Message records in your MCAP, and decode the ROS1 messages with the mcap_ros1.decoder.Decoder class.