grepros 1.3.0
grep for ROS bag files and live topics
Loading...
Searching...
No Matches
McapBag Class Reference
Inheritance diagram for McapBag:
Inheritance graph

Public Member Functions

 __init__ (self, f, mode="r", **__)
 
 __contains__ (self, key)
 
 __next__ (self)
 
 autodetect (cls, f)
 
 close (self)
 
 closed (self)
 
 filename (self)
 
 get_end_time (self)
 
 get_message_class (self, typename, typehash=None)
 
 get_message_count (self, topic_filters=None)
 
 get_message_definition (self, msg_or_type)
 
 get_message_type_hash (self, msg_or_type)
 
 get_qoses (self, topic, typename)
 
 get_start_time (self)
 
 get_topic_info (self, *_, **__)
 
 get_type_and_topic_info (self, topic_filters=None)
 
 mode (self)
 
 open (self)
 
 read_messages (self, topics=None, start_time=None, end_time=None, raw=False)
 
 size (self)
 
 topics (self)
 
 write (self, topic, msg, t=None, raw=False, **__)
 
- Public Member Functions inherited from BaseBag
 __bool__ (self)
 
 __copy__ (self)
 
 __deepcopy__ (self, memo=None)
 
 __enter__ (self)
 
 __exit__ (self, exc_type, exc_value, traceback)
 
 __getitem__ (self, key)
 
 __iter__ (self)
 
 __len__ (self)
 
 __nonzero__ (self)
 
 __str__ (self)
 
 flush (self)
 
 stop_on_error (self)
 
 stop_on_error (self, flag)
 

Public Attributes

 get_fields_and_field_types
 
 SLOT_TYPES
 

Static Public Attributes

str MCAP_MAGIC = b"\x89MCAP\x30\r\n"
 MCAP file header magic start bytes.
 
tuple MODES = ("r", "w")
 Supported opening modes.
 
- Static Public Attributes inherited from BaseBag
 BagMessage = collections.namedtuple("BagMessage", "topic message timestamp")
 Returned from read_messages() as (topic name, ROS message, ROS timestamp object).
 
tuple MODES = ("r", "w", "a")
 Supported opening modes, overridden in subclasses.
 
 next
 
bool STREAMABLE = True
 Whether bag supports reading or writing stream objects, overridden in subclasses.
 
 TopicTuple
 Returned from get_type_and_topic_info() as (typename, message count, connection count, median frequency).
 
 TypesAndTopicsTuple = collections.namedtuple("TypesAndTopicsTuple", ["msg_types", "topics"])
 Returned from get_type_and_topic_info() as ({typename: typehash}, {topic name: TopicTuple}).
 

Detailed Description

MCAP bag interface, providing most of rosbag.Bag interface.

Bag cannot be appended to, and cannot be read and written at the same time
(MCAP API limitation).

Definition at line 41 of file mcap.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ (   self,
  f,
  mode = "r",
**  __ 
)
Opens file and populates metadata.

@param   f         bag file path, or a stream object
@param   mode      return reader if "r" or writer if "w"

Definition at line 55 of file mcap.py.

Member Function Documentation

◆ __contains__()

__contains__ (   self,
  key 
)
Returns whether bag contains given topic.

Reimplemented from BaseBag.

Definition at line 349 of file mcap.py.

◆ __next__()

__next__ (   self)
Retrieves next message from bag as (topic, message, timestamp).

Reimplemented from BaseBag.

Definition at line 354 of file mcap.py.

◆ autodetect()

autodetect (   cls,
  f 
)
Returns whether file is recognizable as MCAP format.

Definition at line 526 of file mcap.py.

◆ close()

close (   self)
Closes the bag file.

Reimplemented from BaseBag.

Definition at line 307 of file mcap.py.

◆ closed()

closed (   self)
Returns whether file is closed.

Reimplemented from BaseBag.

Definition at line 316 of file mcap.py.

◆ filename()

filename (   self)
Returns bag file path.

Reimplemented from BaseBag.

Definition at line 328 of file mcap.py.

◆ get_end_time()

get_end_time (   self)
Returns the end time of the bag, as UNIX timestamp.

Reimplemented from BaseBag.

Definition at line 121 of file mcap.py.

◆ get_message_class()

get_message_class (   self,
  typename,
  typehash = None 
)
Returns ROS message class for typename, or None if unknown type.

@param   typehash  message type definition hash, if any

Reimplemented from BaseBag.

Definition at line 126 of file mcap.py.

◆ get_message_count()

get_message_count (   self,
  topic_filters = None 
)
Returns the number of messages in the bag.

@param   topic_filters  list of topics or a single topic to filter by, if any

Reimplemented from BaseBag.

Definition at line 103 of file mcap.py.

◆ get_message_definition()

get_message_definition (   self,
  msg_or_type 
)
Returns ROS message type definition full text from bag, including subtype definitions.

Reimplemented from BaseBag.

Definition at line 150 of file mcap.py.

◆ get_message_type_hash()

get_message_type_hash (   self,
  msg_or_type 
)
Returns ROS message type MD5 hash.

Reimplemented from BaseBag.

Definition at line 159 of file mcap.py.

◆ get_qoses()

get_qoses (   self,
  topic,
  typename 
)
Returns topic Quality-of-Service profiles as a list of dicts, or None if not available.

Reimplemented from BaseBag.

Definition at line 166 of file mcap.py.

◆ get_start_time()

get_start_time (   self)
Returns the start time of the bag, as UNIX timestamp.

Reimplemented from BaseBag.

Definition at line 116 of file mcap.py.

◆ get_topic_info()

get_topic_info (   self,
_,
**  __ 
)
Returns topic and message type metainfo as {(topic, typename, typehash): count}.

Reimplemented from BaseBag.

Definition at line 171 of file mcap.py.

◆ get_type_and_topic_info()

get_type_and_topic_info (   self,
  topic_filters = None 
)
Returns thorough metainfo on topic and message types.

@param   topic_filters  list of topics or a single topic to filter returned topics-dict by,
                        if any
@return                 TypesAndTopicsTuple(msg_types, topics) namedtuple,
                        msg_types as dict of {typename: typehash},
                        topics as a dict of {topic: TopicTuple() namedtuple}.

Reimplemented from BaseBag.

Definition at line 176 of file mcap.py.

◆ mode()

mode (   self)
Returns file open mode.

Reimplemented from BaseBag.

Definition at line 344 of file mcap.py.

◆ open()

open (   self)
Opens the bag file if not already open.

Reimplemented from BaseBag.

Definition at line 291 of file mcap.py.

◆ read_messages()

read_messages (   self,
  topics = None,
  start_time = None,
  end_time = None,
  raw = False 
)
Yields messages from the bag, optionally filtered by topic and timestamp.

@param   topics      list of topics or a single topic to filter by, if at all
@param   start_time  earliest timestamp of message to return, as ROS time or convertible
                     (int/float/duration/datetime/decimal)
@param   end_time    latest timestamp of message to return, as ROS time or convertible
                     (int/float/duration/datetime/decimal)
@param   raw         if true, then returned messages are tuples of
                     (typename, bytes, typehash, typeclass)
@return              BagMessage namedtuples of 
                     (topic, message, timestamp as rospy/rclpy.Time)

Reimplemented from BaseBag.

Definition at line 216 of file mcap.py.

◆ size()

size (   self)
Returns current file size.

Reimplemented from BaseBag.

Definition at line 334 of file mcap.py.

◆ topics()

topics (   self)
Returns the list of topics in bag, in alphabetic order.

Reimplemented from BaseBag.

Definition at line 322 of file mcap.py.

◆ write()

write (   self,
  topic,
  msg,
  t = None,
  raw = False,
**  __ 
)
Writes out message to MCAP file.

@param   topic   name of topic
@param   msg     ROS1 message
@param   t       message timestamp if not using current ROS time,
                 as ROS time type or convertible (int/float/duration/datetime/decimal)
@param   raw     if true, `msg` is in raw format, (typename, bytes, typehash, typeclass)

Reimplemented from BaseBag.

Definition at line 247 of file mcap.py.

Member Data Documentation

◆ get_fields_and_field_types

get_fields_and_field_types

Definition at line 431 of file mcap.py.

◆ MCAP_MAGIC

str MCAP_MAGIC = b"\x89MCAP\x30\r\n"
static

MCAP file header magic start bytes.

Definition at line 53 of file mcap.py.

◆ MODES

tuple MODES = ("r", "w")
static

Supported opening modes.

Definition at line 50 of file mcap.py.

◆ SLOT_TYPES

SLOT_TYPES

Definition at line 429 of file mcap.py.


The documentation for this class was generated from the following file: