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

Public Member Functions

def __contains__ (self, key)
 
def __init__ (self, filename, mode="a", *_, **__)
 
def __next__ (self)
 
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, counts=True, ensure_types=True)
 
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, qoses=None, **__)
 
- 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 stop_on_error (self)
 
def stop_on_error (self, flag)
 
def write (self, topic, msg, t=None, raw=False, **kwargs)
 

Static Public Attributes

string CREATE_SQL
 ROS2 bag SQLite schema. More...
 
bool STREAMABLE = False
 Whether bag supports reading or writing stream objects, overridden in subclasses. 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 _ensure_counts (self)
 
def _ensure_open (self, populate=False)
 
def _ensure_topics (self)
 
def _ensure_types (self, topics=None)
 
def _has_table (self, name)
 

Private Attributes

 _counts
 
 _db
 
 _filename
 
 _iterer
 
 _mode
 
 _qoses
 
 _stop_on_error
 
 _topics
 
 _ttinfo
 

Detailed Description

ROS2 bag reader and writer (SQLite format), providing most of rosbag.Bag interface.

Definition at line 91 of file ros2.py.

Constructor & Destructor Documentation

◆ __init__()

def grepros.ros2.ROS2Bag.__init__ (   self,
  filename,
  mode = "a",
_,
**  __ 
)
@param   filename  bag file path to open
@param   mode      file will be overwritten if "w"

Definition at line 121 of file ros2.py.

Member Function Documentation

◆ __contains__()

def grepros.ros2.ROS2Bag.__contains__ (   self,
  key 
)
Returns whether bag contains given topic.

Reimplemented from grepros.api.BaseBag.

Definition at line 448 of file ros2.py.

◆ __next__()

def grepros.ros2.ROS2Bag.__next__ (   self)
Retrieves next message from bag as (topic, message, timestamp).

Reimplemented from grepros.api.BaseBag.

Definition at line 453 of file ros2.py.

◆ _ensure_counts()

def grepros.ros2.ROS2Bag._ensure_counts (   self)
private
Populates local counts values from database, if not already available.

Definition at line 481 of file ros2.py.

◆ _ensure_open()

def grepros.ros2.ROS2Bag._ensure_open (   self,
  populate = False 
)
private
Opens bag database if not open, populates schema if specified.

Definition at line 460 of file ros2.py.

◆ _ensure_topics()

def grepros.ros2.ROS2Bag._ensure_topics (   self)
private
Populates local topic struct from database, if not already available.

Definition at line 472 of file ros2.py.

◆ _ensure_types()

def grepros.ros2.ROS2Bag._ensure_types (   self,
  topics = None 
)
private
Populates local type definitions and classes from database, if not already available.

@param   topics  selected topics to ensure types for, if not all

Definition at line 494 of file ros2.py.

◆ _has_table()

def grepros.ros2.ROS2Bag._has_table (   self,
  name 
)
private
Returns whether specified table exists in database.

Definition at line 512 of file ros2.py.

◆ close()

def grepros.ros2.ROS2Bag.close (   self)
Closes the bag file.

Reimplemented from grepros.api.BaseBag.

Definition at line 405 of file ros2.py.

◆ closed()

def grepros.ros2.ROS2Bag.closed (   self)
Returns whether file is closed.

Reimplemented from grepros.api.BaseBag.

Definition at line 415 of file ros2.py.

◆ filename()

def grepros.ros2.ROS2Bag.filename (   self)
Returns bag file path.

Reimplemented from grepros.api.BaseBag.

Definition at line 427 of file ros2.py.

◆ get_end_time()

def grepros.ros2.ROS2Bag.get_end_time (   self)
Returns the end time of the bag, as UNIX timestamp, or None if bag empty.

Reimplemented from grepros.api.BaseBag.

Definition at line 171 of file ros2.py.

◆ get_message_class()

def grepros.ros2.ROS2Bag.get_message_class (   self,
  typename,
  typehash = None 
)
Returns ROS2 message type class, or None if unknown message type for bag.

Reimplemented from grepros.api.BaseBag.

Definition at line 252 of file ros2.py.

◆ get_message_count()

def grepros.ros2.ROS2Bag.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 143 of file ros2.py.

◆ get_message_definition()

def grepros.ros2.ROS2Bag.get_message_definition (   self,
  msg_or_type 
)
Returns ROS2 message type definition full text, including subtype definitions.

Returns None if unknown message type for bag.

Reimplemented from grepros.api.BaseBag.

Definition at line 263 of file ros2.py.

◆ get_message_type_hash()

def grepros.ros2.ROS2Bag.get_message_type_hash (   self,
  msg_or_type 
)
Returns ROS2 message type MD5 hash, or None if unknown message type for bag.

Reimplemented from grepros.api.BaseBag.

Definition at line 276 of file ros2.py.

◆ get_qoses()

def grepros.ros2.ROS2Bag.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 238 of file ros2.py.

◆ get_start_time()

def grepros.ros2.ROS2Bag.get_start_time (   self)
Returns the start time of the bag, as UNIX timestamp, or None if bag empty.

Reimplemented from grepros.api.BaseBag.

Definition at line 161 of file ros2.py.

◆ get_topic_info()

def grepros.ros2.ROS2Bag.get_topic_info (   self,
  counts = True,
  ensure_types = True 
)
Returns topic and message type metainfo as {(topic, typename, typehash): count}.

Can skip retrieving message counts, as this requires a full table scan.
Can skip looking up message type classes, as those might be unavailable in ROS2 environment.

@param   counts        whether to return actual message counts instead of None
@param   ensure_types  whether to look up type classes instead of returning typehash as None

Definition at line 181 of file ros2.py.

◆ get_type_and_topic_info()

def grepros.ros2.ROS2Bag.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 197 of file ros2.py.

◆ mode()

def grepros.ros2.ROS2Bag.mode (   self)
Returns file open mode.

Reimplemented from grepros.api.BaseBag.

Definition at line 443 of file ros2.py.

◆ open()

def grepros.ros2.ROS2Bag.open (   self)
Opens the bag file if not already open.

Reimplemented from grepros.api.BaseBag.

Definition at line 400 of file ros2.py.

◆ read_messages()

def grepros.ros2.ROS2Bag.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 any
@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).
             If message type unavailable, returns None for hash and class.
@return              BagMessage namedtuples of
             (topic, message, timestamp as rclpy.time.Time)

Reimplemented from grepros.api.BaseBag.

Definition at line 283 of file ros2.py.

◆ size()

def grepros.ros2.ROS2Bag.size (   self)
Returns current file size in bytes (including journaling files).

Reimplemented from grepros.api.BaseBag.

Definition at line 433 of file ros2.py.

◆ topics()

def grepros.ros2.ROS2Bag.topics (   self)
Returns the list of topics in bag, in alphabetic order.

Reimplemented from grepros.api.BaseBag.

Definition at line 421 of file ros2.py.

◆ write()

def grepros.ros2.ROS2Bag.write (   self,
  topic,
  msg,
  t = None,
  raw = False,
  qoses = None,
**  __ 
)
Writes a message to the bag.

@param   topic  name of topic
@param   msg    ROS2 message
@param   t      message timestamp if not using wall time, as ROS time or convertible
        (int/float/duration/datetime/decimal)
@param   qoses  topic Quality-of-Service settings, if any, as a list of dicts

Definition at line 356 of file ros2.py.

Member Data Documentation

◆ _counts

grepros.ros2.ROS2Bag._counts
private

Definition at line 133 of file ros2.py.

◆ _db

grepros.ros2.ROS2Bag._db
private

Definition at line 130 of file ros2.py.

◆ _filename

grepros.ros2.ROS2Bag._filename
private

Definition at line 137 of file ros2.py.

◆ _iterer

grepros.ros2.ROS2Bag._iterer
private

Definition at line 135 of file ros2.py.

◆ _mode

grepros.ros2.ROS2Bag._mode
private

Definition at line 131 of file ros2.py.

◆ _qoses

grepros.ros2.ROS2Bag._qoses
private

Definition at line 134 of file ros2.py.

◆ _stop_on_error

grepros.ros2.ROS2Bag._stop_on_error
private

Definition at line 138 of file ros2.py.

◆ _topics

grepros.ros2.ROS2Bag._topics
private

Definition at line 132 of file ros2.py.

◆ _ttinfo

grepros.ros2.ROS2Bag._ttinfo
private

Definition at line 136 of file ros2.py.

◆ CREATE_SQL

string grepros.ros2.ROS2Bag.CREATE_SQL
static
Initial value:
= """
CREATE TABLE IF NOT EXISTS messages (
id INTEGER PRIMARY KEY,
topic_id INTEGER NOT NULL,
timestamp INTEGER NOT NULL,
data BLOB NOT NULL
);
CREATE TABLE IF NOT EXISTS topics (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
type TEXT NOT NULL,
serialization_format TEXT NOT NULL,
offered_qos_profiles TEXT NOT NULL
);
CREATE INDEX IF NOT EXISTS timestamp_idx ON messages (timestamp ASC);
PRAGMA journal_mode=WAL;
PRAGMA synchronous=NORMAL;
"""

ROS2 bag SQLite schema.

Definition at line 98 of file ros2.py.

◆ STREAMABLE

bool grepros.ros2.ROS2Bag.STREAMABLE = False
static

Whether bag supports reading or writing stream objects, overridden in subclasses.

Definition at line 95 of file ros2.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