class documentation

Bag serialize messages to and from a single file on disk using the bag format.

Method __enter__ Undocumented
Method __exit__ Undocumented
Method __init__ 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...
Method __iter__ Undocumented
Method __str__ Undocumented
Method close Close the bag file. Closing an already closed bag does nothing.
Method flush Write the open chunk to disk so subsequent reads will read all messages. @raise ValueError: if bag is closed
Method get_compression_info Returns information about the compression of the bag @return: generator of CompressionTuple(compression, uncompressed, compressed) describing the
Method get_end_time Returns the end time of the bag. @return: a timestamp of the end of the bag @rtype: float, timestamp in seconds, includes fractions of a second
Method get_message_count Returns the number of messages in the bag. Can be filtered by Topic @param topic_filters: One or more topics to filter by @type topic_filters: Could be either a single str or a list of str. @return: The number of messages in the bag, optionally filtered by topic @rtype: int...
Method get_start_time Returns the start time of the bag. @return: a timestamp of the start of the bag @rtype: float, timestamp in seconds, includes fractions of a second
Method get_type_and_topic_info Coallates info about the type and topics in the bag.
Method read_messages 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...
Method reindex Reindexes the bag file. Yields position of each chunk for progress.
Method set_encryptor Undocumented
Method write Write a message to the bag. @param topic: name of topic @type topic: str @param msg: message to add to bag, or tuple (if raw) @type msg: Message or tuple of raw message data @param t: ROS time of message publication, if None specified, use current time [optional] @type t: U{genpy...
Class Variable chunk_threshold Undocumented
Class Variable compression Undocumented
Property filename Get the filename.
Property mode Get the mode.
Property options Get the options.
Property size Get the size in bytes.
Property version Get the version.
Method _clear_index Undocumented
Method _close_file Undocumented
Method _create_reader @raise ROSBagException: if the bag version is unsupported
Method _get_chunk_offset Undocumented
Method _get_chunk_threshold Get the chunk threshold to use for writing.
Method _get_compression Get the compression method to use for writing.
Method _get_connections Yield the connections, optionally filtering by topic and/or connection information.
Method _get_entries Yield index entries on the given connections in the given time range.
Method _get_entries_reverse Yield index entries on the given connections in the given time range in reverse order.
Method _get_entry Return the first index entry on/before the given time on the given connections
Method _get_entry_after Return the first index entry after the given time on the given connections
Method _get_indexes Get the indexes for the given connections.
Method _get_yaml_info Undocumented
Method _is_file Undocumented
Method _open Undocumented
Method _open_append Undocumented
Method _open_read Undocumented
Method _open_write Undocumented
Method _read_message Read the message from the given position in the file.
Method _read_version @raise ROSBagException: if the file is empty, or the version line can't be parsed
Method _set_chunk_threshold Set the chunk threshold to use for writing.
Method _set_compression Set the compression method to use for writing.
Method _set_compression_mode Undocumented
Method _start_appending Undocumented
Method _start_writing Undocumented
Method _start_writing_chunk Undocumented
Method _stop_writing Undocumented
Method _stop_writing_chunk Undocumented
Method _write_chunk_header Undocumented
Method _write_chunk_info_record Undocumented
Method _write_connection_index_record Undocumented
Method _write_connection_record Undocumented
Method _write_file_header_record Undocumented
Method _write_message_data_record Undocumented
Instance Variable _buffer Undocumented
Instance Variable _chunk_count Undocumented
Instance Variable _chunk_headers Undocumented
Instance Variable _chunk_open Undocumented
Instance Variable _chunk_threshold Undocumented
Instance Variable _chunks Undocumented
Instance Variable _compression Undocumented
Instance Variable _connection_count Undocumented
Instance Variable _connection_indexes Undocumented
Instance Variable _connection_indexes_read Undocumented
Instance Variable _connections Undocumented
Instance Variable _curr_chunk_connection_indexes Undocumented
Instance Variable _curr_chunk_data_pos Undocumented
Instance Variable _curr_chunk_info Undocumented
Instance Variable _curr_compression Undocumented
Instance Variable _encryptor Undocumented
Instance Variable _file Undocumented
Instance Variable _file_header_pos Undocumented
Instance Variable _filename Undocumented
Instance Variable _index_data_pos Undocumented
Instance Variable _mode Undocumented
Instance Variable _output_file Undocumented
Instance Variable _reader Undocumented
Instance Variable _skip_index Undocumented
Instance Variable _topic_connections Undocumented
Instance Variable _version Undocumented
Property _has_compressed_chunks Undocumented
Property _uncompressed_size Undocumented
def __enter__(self):

Undocumented

def __exit__(self, exc_type, exc_value, traceback):

Undocumented

def __init__(self, f, mode='r', compression=Compression.NONE, chunk_threshold=768*1024, allow_unindexed=False, options=None, skip_index=False):

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

def __iter__(self):

Undocumented

def __str__(self):

Undocumented

def close(self):

Close the bag file. Closing an already closed bag does nothing.

def flush(self):

Write the open chunk to disk so subsequent reads will read all messages. @raise ValueError: if bag is closed

def get_compression_info(self):

Returns information about the compression of the bag @return: generator of CompressionTuple(compression, uncompressed, compressed) describing the

type of compression used, size of the uncompressed data in Bytes, size of the compressed data in Bytes. If no compression is used then uncompressed and compressed data will be equal.

@rtype: generator of CompressionTuple of (str, int, int)

def get_end_time(self):

Returns the end time of the bag. @return: a timestamp of the end of the bag @rtype: float, timestamp in seconds, includes fractions of a second

def get_message_count(self, topic_filters=None):

Returns the number of messages in the bag. Can be filtered by Topic @param topic_filters: One or more topics to filter by @type topic_filters: Could be either a single str or a list of str. @return: The number of messages in the bag, optionally filtered by topic @rtype: int

def get_start_time(self):

Returns the start time of the bag. @return: a timestamp of the start of the bag @rtype: float, timestamp in seconds, includes fractions of a second

def get_type_and_topic_info(self, topic_filters=None):

Coallates info about the type and topics in the bag.

Note, it would be nice to filter by type as well, but there appear to be some limitations in the current architecture that prevent that from working when more than one message type is written on the same topic.

@param topic_filters: specify one or more topic to filter by. @type topic_filters: either a single str or a list of str. @return: generator of TypesAndTopicsTuple(types{key:type name, val: md5hash},

topics{type: msg type (Ex. "std_msgs/String"),
message_count: the number of messages of the particular type, connections: the number of connections, frequency: the data frequency, key: type name, val: md5hash}) describing the types of messages present

and information about the topics

@rtype: TypesAndTopicsTuple(dict(str, str),
TopicTuple(str, int, int, float, str, str))
def read_messages(self, 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]

def reindex(self):

Reindexes the bag file. Yields position of each chunk for progress.

def set_encryptor(self, encryptor=None, param=None):

Undocumented

def write(self, topic, msg, t=None, raw=False, connection_header=None):

Write a message to the bag. @param topic: name of topic @type topic: str @param msg: message to add to bag, or tuple (if raw) @type msg: Message or tuple of raw message data @param t: ROS time of message publication, if None specified, use current time [optional] @type t: U{genpy.Time} @param raw: if True, msg is in raw format, i.e. (msg_type, serialized_bytes, md5sum, pytype) @type raw: bool @raise ValueError: if arguments are invalid or bag is closed

chunk_threshold =

Undocumented

compression =

Undocumented

@property
filename =

Get the filename.

@property
mode =

Get the mode.

@property
options =

Get the options.

@property
size =

Get the size in bytes.

@property
version =

Get the version.

def _clear_index(self):

Undocumented

def _close_file(self):

Undocumented

def _create_reader(self):

@raise ROSBagException: if the bag version is unsupported

def _get_chunk_offset(self):

Undocumented

def _get_chunk_threshold(self):

Get the chunk threshold to use for writing.

def _get_compression(self):

Get the compression method to use for writing.

def _get_connections(self, topics=None, connection_filter=None):

Yield the connections, optionally filtering by topic and/or connection information.

def _get_entries(self, connections=None, start_time=None, end_time=None):

Yield index entries on the given connections in the given time range.

def _get_entries_reverse(self, connections=None, start_time=None, end_time=None):

Yield index entries on the given connections in the given time range in reverse order.

def _get_entry(self, t, connections=None):

Return the first index entry on/before the given time on the given connections

def _get_entry_after(self, t, connections=None):

Return the first index entry after the given time on the given connections

def _get_indexes(self, connections):

Get the indexes for the given connections.

def _get_yaml_info(self, key=None):

Undocumented

def _is_file(self, f):

Undocumented

def _open(self, f, mode, allow_unindexed):

Undocumented

def _open_append(self, f, allow_unindexed):

Undocumented

def _open_read(self, f, allow_unindexed):

Undocumented

def _open_write(self, f):

Undocumented

def _read_message(self, position, raw=False, return_connection_header=False):

Read the message from the given position in the file.

def _read_version(self):

@raise ROSBagException: if the file is empty, or the version line can't be parsed

def _set_chunk_threshold(self, chunk_threshold):

Set the chunk threshold to use for writing.

def _set_compression(self, compression):

Set the compression method to use for writing.

def _set_compression_mode(self, compression):

Undocumented

def _start_appending(self):

Undocumented

def _start_writing(self):

Undocumented

def _start_writing_chunk(self, t):

Undocumented

def _stop_writing(self):

Undocumented

def _stop_writing_chunk(self):

Undocumented

def _write_chunk_header(self, chunk_header):

Undocumented

def _write_chunk_info_record(self, chunk_info):

Undocumented

def _write_connection_index_record(self, connection_id, entries):

Undocumented

def _write_connection_record(self, connection_info, encrypt):

Undocumented

def _write_file_header_record(self, index_pos, connection_count, chunk_count):

Undocumented

def _write_message_data_record(self, connection_id, t, serialized_bytes):

Undocumented

_buffer =

Undocumented

_chunk_count: int =

Undocumented

_chunk_headers: dict =

Undocumented

_chunk_open: bool =

Undocumented

_chunk_threshold =

Undocumented

_chunks: list =

Undocumented

_compression =

Undocumented

_connection_count: int =

Undocumented

_connection_indexes: dict =

Undocumented

_connection_indexes_read: bool =

Undocumented

_connections: dict =

Undocumented

_curr_chunk_connection_indexes: dict =

Undocumented

_curr_chunk_data_pos =

Undocumented

_curr_chunk_info =

Undocumented

_curr_compression =

Undocumented

_encryptor =

Undocumented

_file =

Undocumented

_file_header_pos =

Undocumented

_filename =

Undocumented

_index_data_pos =

Undocumented

_mode: str =

Undocumented

_output_file =

Undocumented

_reader =

Undocumented

_skip_index =

Undocumented

_topic_connections: dict =

Undocumented

_version =

Undocumented

@property
_has_compressed_chunks =

Undocumented

@property
_uncompressed_size =

Undocumented