cras_bag_tools package

Submodules

cras_bag_tools.topic_set module

Efficient data structure to hold a static set of topics with super-fast is-in-set queries.

The querying is done using expressions like topic in set or topic not in set.

class cras_bag_tools.topic_set.TopicSet(items=None)

Bases: object

Efficient data structure to hold a static set of topics with super-fast is-in-set queries.

Build the data structure. Adding items later is not supported.

Parameters:items (Iterable[AnyStr]|None) – The topics to search.

cras_bag_tools.tqdm_bag module

Bag file reader that shows progressbars when loading index or reading messages.

class cras_bag_tools.tqdm_bag.TqdmBag(f, mode='r', compression='none', chunk_threshold=786432, allow_unindexed=False, options=None, skip_index=False)

Bases: rosbag.bag.Bag

Drop-in replacement for rosbag.bag.Bag which shows nice progressbars when loading index and reading messages.

Open a bag file. The mode can be ‘r’, ‘w’, or ‘a’ for reading (default), writing or appending. The file will be created if it doesn’t exist when opened for writing or appending; it will be truncated when opened for writing. Simultaneous reading and writing is allowed when in writing or appending mode. @param f: filename of bag to open or a stream to read from @type f: str or file @param mode: mode, either ‘r’, ‘w’, or ‘a’ @type mode: str @param compression: compression mode, see U{rosbag.Compression} for valid modes @type compression: str @param chunk_threshold: minimum number of uncompressed bytes per chunk @type chunk_threshold: int @param allow_unindexed: if True, allow opening unindexed bags @type allow_unindexed: bool @param options: the bag options (currently: compression and chunk_threshold) @type options: dict @param skip_index: if True, don’t read the connection index records on open [2.0+] @type skip_index: bool @raise ValueError: if any argument is invalid @raise ROSBagException: if an error occurs opening file @raise ROSBagFormatException: if bag format is corrupted

read_index()

Force reading index if it was skipped in the constructor.

read_messages(topics=None, start_time=None, end_time=None, connection_filter=None, raw=False, return_connection_header=False)

Read messages from the bag, optionally filtered by topic, timestamp and connection details. @param topics: list of topics or a single topic. if an empty list is given all topics will be read [optional] @type topics: list(str) or str @param start_time: earliest timestamp of message to return [optional] @type start_time: U{genpy.Time} @param end_time: latest timestamp of message to return [optional] @type end_time: U{genpy.Time} @param connection_filter: function to filter connections to include [optional] @type connection_filter: function taking (topic, datatype, md5sum, msg_def, header) and returning bool @param raw: if True, then generate tuples of (datatype, (data, md5sum, position), pytype) @type raw: bool @return: generator of BagMessage(topic, message, timestamp) namedtuples for each message in the bag file @rtype: generator of tuples of (str, U{genpy.Message}, U{genpy.Time}) [not raw] or (str, (str, str, str, tuple, class), U{genpy.Time}) [raw]

Module contents