Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
grepros.plugins.mcap.McapBag Class Reference
Inheritance diagram for grepros.plugins.mcap.McapBag:
Inheritance graph
[legend]

Public Member Functions

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

Public Attributes

 get_fields_and_field_types
 
 SLOT_TYPES
 

Static Public Attributes

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

Private Member Functions

def _decode_message (self, message, channel, schema)
 
def _make_message_class (self, schema, message, generate=True)
 
def _patch_message (self, message, typename, typehash)
 
def _patch_message_class (self, cls, typename, typehash)
 
def _populate_meta (self)
 

Private Attributes

 __copy__
 
 __deepcopy__
 
 __module__
 
 _decoder
 
 _end_time
 
 _field_subtypes
 
 _fields_and_field_types
 
 _file
 
 _filename
 
 _iterer
 
 _mode
 
 _opened
 
 _qoses
 
 _reader
 
 _schemas
 
 _schematypes
 
 _start_time
 
 _temporal_ctors
 
 _topics
 
 _ttinfo
 
 _type_subtypes
 
 _typedefs
 
 _typefields
 
 _types
 
 _writer
 

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__()

def grepros.plugins.mcap.McapBag.__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__()

def grepros.plugins.mcap.McapBag.__contains__ (   self,
  key 
)
Returns whether bag contains given topic.

Reimplemented from grepros.api.BaseBag.

Definition at line 347 of file mcap.py.

◆ __next__()

def grepros.plugins.mcap.McapBag.__next__ (   self)
Retrieves next message from bag as (topic, message, timestamp).

Reimplemented from grepros.api.BaseBag.

Definition at line 352 of file mcap.py.

◆ _decode_message()

def grepros.plugins.mcap.McapBag._decode_message (   self,
  message,
  channel,
  schema 
)
private
Returns ROS message deserialized from binary data.

@param   message  mcap.records.Message instance
@param   channel  mcap.records.Channel instance for message
@param   schema   mcap.records.Schema instance for message type

Definition at line 359 of file mcap.py.

◆ _make_message_class()

def grepros.plugins.mcap.McapBag._make_message_class (   self,
  schema,
  message,
  generate = True 
)
private
Returns message type class, generating if not already available.

@param   schema    mcap.records.Schema instance for message type
@param   message   mcap.records.Message instance
@param   generate  generate message class dynamically if not available

Definition at line 381 of file mcap.py.

◆ _patch_message()

def grepros.plugins.mcap.McapBag._patch_message (   self,
  message,
  typename,
  typehash 
)
private
Patches MCAP ROS2 message with expected attributes and methods, recursively.

@param   message   ROS message instance as returned from mcap_ros2.decoder
@param   typename  ROS message type name, like "std_msgs/Bool"
@param   typehash  ROS message type hash
@return            original message patched, or new instance if ROS2 temporal type

Definition at line 436 of file mcap.py.

◆ _patch_message_class()

def grepros.plugins.mcap.McapBag._patch_message_class (   self,
  cls,
  typename,
  typehash 
)
private
Patches MCAP ROS2 message class with expected attributes and methods, recursively.

@param   cls       ROS message class as returned from mcap_ros2.decoder
@param   typename  ROS message type name, like "std_msgs/Bool"
@param   typehash  ROS message type hash
@return            patched class

Definition at line 406 of file mcap.py.

◆ _populate_meta()

def grepros.plugins.mcap.McapBag._populate_meta (   self)
private
Populates bag metainfo.

Definition at line 472 of file mcap.py.

◆ autodetect()

def grepros.plugins.mcap.McapBag.autodetect (   cls,
  f 
)
Returns whether file is readable as MCAP format.

Definition at line 519 of file mcap.py.

◆ close()

def grepros.plugins.mcap.McapBag.close (   self)
Closes the bag file.

Reimplemented from grepros.api.BaseBag.

Definition at line 305 of file mcap.py.

◆ closed()

def grepros.plugins.mcap.McapBag.closed (   self)
Returns whether file is closed.

Reimplemented from grepros.api.BaseBag.

Definition at line 314 of file mcap.py.

◆ filename()

def grepros.plugins.mcap.McapBag.filename (   self)
Returns bag file path.

Reimplemented from grepros.api.BaseBag.

Definition at line 326 of file mcap.py.

◆ get_end_time()

def grepros.plugins.mcap.McapBag.get_end_time (   self)
Returns the end time of the bag, as UNIX timestamp.

Reimplemented from grepros.api.BaseBag.

Definition at line 121 of file mcap.py.

◆ get_message_class()

def grepros.plugins.mcap.McapBag.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 grepros.api.BaseBag.

Definition at line 126 of file mcap.py.

◆ get_message_count()

def grepros.plugins.mcap.McapBag.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 grepros.api.BaseBag.

Definition at line 103 of file mcap.py.

◆ get_message_definition()

def grepros.plugins.mcap.McapBag.get_message_definition (   self,
  msg_or_type 
)
Returns ROS message type definition full text from bag, including subtype definitions.

Reimplemented from grepros.api.BaseBag.

Definition at line 150 of file mcap.py.

◆ get_message_type_hash()

def grepros.plugins.mcap.McapBag.get_message_type_hash (   self,
  msg_or_type 
)
Returns ROS message type MD5 hash.

Reimplemented from grepros.api.BaseBag.

Definition at line 159 of file mcap.py.

◆ get_qoses()

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

Reimplemented from grepros.api.BaseBag.

Definition at line 166 of file mcap.py.

◆ get_start_time()

def grepros.plugins.mcap.McapBag.get_start_time (   self)
Returns the start time of the bag, as UNIX timestamp.

Reimplemented from grepros.api.BaseBag.

Definition at line 116 of file mcap.py.

◆ get_topic_info()

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

Definition at line 171 of file mcap.py.

◆ get_type_and_topic_info()

def grepros.plugins.mcap.McapBag.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 grepros.api.BaseBag.

Definition at line 176 of file mcap.py.

◆ mode()

def grepros.plugins.mcap.McapBag.mode (   self)
Returns file open mode.

Reimplemented from grepros.api.BaseBag.

Definition at line 342 of file mcap.py.

◆ open()

def grepros.plugins.mcap.McapBag.open (   self)
Opens the bag file if not already open.

Reimplemented from grepros.api.BaseBag.

Definition at line 291 of file mcap.py.

◆ read_messages()

def grepros.plugins.mcap.McapBag.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)

Definition at line 216 of file mcap.py.

◆ size()

def grepros.plugins.mcap.McapBag.size (   self)
Returns current file size.

Reimplemented from grepros.api.BaseBag.

Definition at line 332 of file mcap.py.

◆ topics()

def grepros.plugins.mcap.McapBag.topics (   self)
Returns the list of topics in bag, in alphabetic order.

Reimplemented from grepros.api.BaseBag.

Definition at line 320 of file mcap.py.

◆ write()

def grepros.plugins.mcap.McapBag.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 grepros.api.BaseBag.

Definition at line 247 of file mcap.py.

Member Data Documentation

◆ __copy__

grepros.plugins.mcap.McapBag.__copy__
private

Definition at line 430 of file mcap.py.

◆ __deepcopy__

grepros.plugins.mcap.McapBag.__deepcopy__
private

Definition at line 431 of file mcap.py.

◆ __module__

grepros.plugins.mcap.McapBag.__module__
private

Definition at line 426 of file mcap.py.

◆ _decoder

grepros.plugins.mcap.McapBag._decoder
private

Definition at line 78 of file mcap.py.

◆ _end_time

grepros.plugins.mcap.McapBag._end_time
private

Definition at line 75 of file mcap.py.

◆ _field_subtypes

grepros.plugins.mcap.McapBag._field_subtypes
private

Definition at line 72 of file mcap.py.

◆ _fields_and_field_types

grepros.plugins.mcap.McapBag._fields_and_field_types
private

Definition at line 428 of file mcap.py.

◆ _file

grepros.plugins.mcap.McapBag._file
private

Definition at line 76 of file mcap.py.

◆ _filename

grepros.plugins.mcap.McapBag._filename
private

Definition at line 83 of file mcap.py.

◆ _iterer

grepros.plugins.mcap.McapBag._iterer
private

Definition at line 80 of file mcap.py.

◆ _mode

grepros.plugins.mcap.McapBag._mode
private

Definition at line 63 of file mcap.py.

◆ _opened

grepros.plugins.mcap.McapBag._opened
private

Definition at line 82 of file mcap.py.

◆ _qoses

grepros.plugins.mcap.McapBag._qoses
private

Definition at line 69 of file mcap.py.

◆ _reader

grepros.plugins.mcap.McapBag._reader
private

Definition at line 77 of file mcap.py.

◆ _schemas

grepros.plugins.mcap.McapBag._schemas
private

Definition at line 67 of file mcap.py.

◆ _schematypes

grepros.plugins.mcap.McapBag._schematypes
private

Definition at line 68 of file mcap.py.

◆ _start_time

grepros.plugins.mcap.McapBag._start_time
private

Definition at line 74 of file mcap.py.

◆ _temporal_ctors

grepros.plugins.mcap.McapBag._temporal_ctors
private

Definition at line 73 of file mcap.py.

◆ _topics

grepros.plugins.mcap.McapBag._topics
private

Definition at line 64 of file mcap.py.

◆ _ttinfo

grepros.plugins.mcap.McapBag._ttinfo
private

Definition at line 81 of file mcap.py.

◆ _type_subtypes

grepros.plugins.mcap.McapBag._type_subtypes
private

Definition at line 71 of file mcap.py.

◆ _typedefs

grepros.plugins.mcap.McapBag._typedefs
private

Definition at line 66 of file mcap.py.

◆ _typefields

grepros.plugins.mcap.McapBag._typefields
private

Definition at line 70 of file mcap.py.

◆ _types

grepros.plugins.mcap.McapBag._types
private

Definition at line 65 of file mcap.py.

◆ _writer

grepros.plugins.mcap.McapBag._writer
private

Definition at line 79 of file mcap.py.

◆ get_fields_and_field_types

grepros.plugins.mcap.McapBag.get_fields_and_field_types

Definition at line 429 of file mcap.py.

◆ MCAP_MAGIC

string grepros.plugins.mcap.McapBag.MCAP_MAGIC = b"\x89MCAP\x30\r\n"
static

MCAP file header magic start bytes.

Definition at line 53 of file mcap.py.

◆ MODES

tuple grepros.plugins.mcap.McapBag.MODES = ("r", "w")
static

Supported opening modes.

Definition at line 50 of file mcap.py.

◆ SLOT_TYPES

grepros.plugins.mcap.McapBag.SLOT_TYPES

Definition at line 427 of file mcap.py.


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


grepros
Author(s): Erki Suurjaak
autogenerated on Sat Jan 6 2024 03:11:30