Public Member Functions | Properties | Private Member Functions | Private Attributes
rosbag.bag.Bag Class Reference

List of all members.

Public Member Functions

def __enter__
def __exit__
def __init__
def __iter__
def __str__
def close
def filename
def flush
def mode
def options
def read_messages
def reindex
def size
def version
def write

Properties

 chunk_threshold = property(_get_chunk_threshold, _set_chunk_threshold)
 compression = property(_get_compression, _set_compression)

Private Member Functions

def _clear_index
 Implementation ###.
def _close_file
def _create_reader
def _get_chunk_offset
def _get_chunk_threshold
def _get_compression
def _get_connections
def _get_entries
def _get_entries_reverse
def _get_entry
def _get_entry_after
def _get_indexes
def _get_yaml_info
def _has_compressed_chunks
 Internal API ###.
def _open
def _open_append
def _open_read
def _open_write
def _read_message
def _read_version
def _set_chunk_threshold
def _set_compression
def _set_compression_mode
def _start_appending
def _start_writing
def _start_writing_chunk
def _stop_writing
def _stop_writing_chunk
def _uncompressed_size
def _write_chunk_header
def _write_chunk_info_record
def _write_connection_index_record
def _write_connection_record
def _write_file_header_record
def _write_message_data_record

Private Attributes

 _buffer
 _chunk_count
 _chunk_headers
 _chunk_open
 _chunk_threshold
 _chunks
 _compression
 _connection_count
 _connection_indexes
 _connection_indexes_read
 _connections
 _curr_chunk_connection_indexes
 _curr_chunk_data_pos
 _curr_chunk_info
 _curr_compression
 _file
 _file_header_pos
 _filename
 _index_data_pos
 _mode
 _output_file
 _reader
 _skip_index
 _topic_connections
 _version

Detailed Description

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

Definition at line 96 of file bag.py.


Constructor & Destructor Documentation

def rosbag.bag.Bag.__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

Definition at line 100 of file bag.py.


Member Function Documentation

def rosbag.bag.Bag.__enter__ (   self)

Definition at line 166 of file bag.py.

def rosbag.bag.Bag.__exit__ (   self,
  exc_type,
  exc_value,
  traceback 
)

Definition at line 169 of file bag.py.

def rosbag.bag.Bag.__iter__ (   self)

Definition at line 163 of file bag.py.

def rosbag.bag.Bag.__str__ (   self)

Definition at line 403 of file bag.py.

def rosbag.bag.Bag._clear_index (   self) [private]

Implementation ###.

Definition at line 869 of file bag.py.

def rosbag.bag.Bag._close_file (   self) [private]

Definition at line 985 of file bag.py.

def rosbag.bag.Bag._create_reader (   self) [private]
@raise ROSBagException: if the bag version is unsupported

Definition at line 989 of file bag.py.

def rosbag.bag.Bag._get_chunk_offset (   self) [private]

Definition at line 1079 of file bag.py.

def rosbag.bag.Bag._get_chunk_threshold (   self) [private]
Get the chunk threshold to use for writing.

Definition at line 223 of file bag.py.

def rosbag.bag.Bag._get_compression (   self) [private]
Get the compression method to use for writing.

Definition at line 206 of file bag.py.

def rosbag.bag.Bag._get_connections (   self,
  topics = None,
  connection_filter = None 
) [private]
Yield the connections, optionally filtering by topic and/or connection information.

Definition at line 778 of file bag.py.

def rosbag.bag.Bag._get_entries (   self,
  connections = None,
  start_time = None,
  end_time = None 
) [private]
Yield index entries on the given connections in the given time range.

Definition at line 795 of file bag.py.

def rosbag.bag.Bag._get_entries_reverse (   self,
  connections = None,
  start_time = None,
  end_time = None 
) [private]
Yield index entries on the given connections in the given time range in reverse order.

Definition at line 806 of file bag.py.

def rosbag.bag.Bag._get_entry (   self,
  t,
  connections = None 
) [private]
Return the first index entry on/before the given time on the given connections

Definition at line 817 of file bag.py.

def rosbag.bag.Bag._get_entry_after (   self,
  t,
  connections = None 
) [private]
Return the first index entry after the given time on the given connections

Definition at line 836 of file bag.py.

def rosbag.bag.Bag._get_indexes (   self,
  connections 
) [private]
Get the indexes for the given connections.

Definition at line 855 of file bag.py.

def rosbag.bag.Bag._get_yaml_info (   self,
  key = None 
) [private]

Definition at line 585 of file bag.py.

def rosbag.bag.Bag._has_compressed_chunks (   self) [private]

Internal API ###.

Definition at line 756 of file bag.py.

def rosbag.bag.Bag._open (   self,
  f,
  mode,
  allow_unindexed 
) [private]

Definition at line 885 of file bag.py.

def rosbag.bag.Bag._open_append (   self,
  f,
  allow_unindexed 
) [private]

Definition at line 945 of file bag.py.

def rosbag.bag.Bag._open_read (   self,
  f,
  allow_unindexed 
) [private]

Definition at line 898 of file bag.py.

def rosbag.bag.Bag._open_write (   self,
  f 
) [private]

Definition at line 926 of file bag.py.

def rosbag.bag.Bag._read_message (   self,
  position,
  raw = False 
) [private]
Read the message from the given position in the file.

Definition at line 769 of file bag.py.

def rosbag.bag.Bag._read_version (   self) [private]
@raise ROSBagException: if the file is empty, or the version line can't be parsed

Definition at line 1013 of file bag.py.

def rosbag.bag.Bag._set_chunk_threshold (   self,
  chunk_threshold 
) [private]
Set the chunk threshold to use for writing.

Definition at line 227 of file bag.py.

def rosbag.bag.Bag._set_compression (   self,
  compression 
) [private]
Set the compression method to use for writing.

Definition at line 210 of file bag.py.

def rosbag.bag.Bag._set_compression_mode (   self,
  compression 
) [private]

Definition at line 1110 of file bag.py.

def rosbag.bag.Bag._start_appending (   self) [private]

Definition at line 1055 of file bag.py.

def rosbag.bag.Bag._start_writing (   self) [private]

Definition at line 1031 of file bag.py.

def rosbag.bag.Bag._start_writing_chunk (   self,
  t 
) [private]

Definition at line 1072 of file bag.py.

def rosbag.bag.Bag._stop_writing (   self) [private]

Definition at line 1036 of file bag.py.

def rosbag.bag.Bag._stop_writing_chunk (   self) [private]

Definition at line 1085 of file bag.py.

def rosbag.bag.Bag._uncompressed_size (   self) [private]

Definition at line 763 of file bag.py.

def rosbag.bag.Bag._write_chunk_header (   self,
  chunk_header 
) [private]

Definition at line 1153 of file bag.py.

def rosbag.bag.Bag._write_chunk_info_record (   self,
  chunk_info 
) [private]

Definition at line 1180 of file bag.py.

def rosbag.bag.Bag._write_connection_index_record (   self,
  connection_id,
  entries 
) [private]

Definition at line 1163 of file bag.py.

def rosbag.bag.Bag._write_connection_record (   self,
  connection_info 
) [private]

Definition at line 1134 of file bag.py.

def rosbag.bag.Bag._write_file_header_record (   self,
  index_pos,
  connection_count,
  chunk_count 
) [private]

Definition at line 1125 of file bag.py.

def rosbag.bag.Bag._write_message_data_record (   self,
  connection_id,
  t,
  serialized_bytes 
) [private]

Definition at line 1145 of file bag.py.

def rosbag.bag.Bag.close (   self)
Close the bag file.  Closing an already closed bag does nothing.

Definition at line 393 of file bag.py.

def rosbag.bag.Bag.filename (   self)
Get the filename.

Definition at line 178 of file bag.py.

def rosbag.bag.Bag.flush (   self)
Write the open chunk to disk so subsequent reads will read all messages.
@raise ValueError: if bag is closed 

Definition at line 260 of file bag.py.

def rosbag.bag.Bag.mode (   self)
Get the mode.

Definition at line 188 of file bag.py.

def rosbag.bag.Bag.options (   self)
Get the options.

Definition at line 173 of file bag.py.

def rosbag.bag.Bag.read_messages (   self,
  topics = None,
  start_time = None,
  end_time = None,
  connection_filter = None,
  raw = False 
)
Read messages from the bag, optionally filtered by topic, timestamp and connection details.
@param topics: list of topics or a single topic [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 (topic, message, timestamp) tuples 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]

Definition at line 237 of file bag.py.

def rosbag.bag.Bag.reindex (   self)
Reindexes the bag file.  Yields position of each chunk for progress.

Definition at line 386 of file bag.py.

def rosbag.bag.Bag.size (   self)
Get the size in bytes.

Definition at line 193 of file bag.py.

def rosbag.bag.Bag.version (   self)
Get the version.

Definition at line 183 of file bag.py.

def rosbag.bag.Bag.write (   self,
  topic,
  msg,
  t = None,
  raw = False 
)
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 specifed, 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

Definition at line 271 of file bag.py.


Member Data Documentation

Definition at line 123 of file bag.py.

Definition at line 869 of file bag.py.

Definition at line 869 of file bag.py.

Definition at line 869 of file bag.py.

Definition at line 123 of file bag.py.

Definition at line 869 of file bag.py.

Definition at line 123 of file bag.py.

Definition at line 869 of file bag.py.

Definition at line 869 of file bag.py.

Definition at line 869 of file bag.py.

Definition at line 869 of file bag.py.

Definition at line 869 of file bag.py.

Definition at line 869 of file bag.py.

Definition at line 869 of file bag.py.

Definition at line 123 of file bag.py.

Definition at line 123 of file bag.py.

Definition at line 123 of file bag.py.

Definition at line 123 of file bag.py.

Definition at line 123 of file bag.py.

Definition at line 898 of file bag.py.

Definition at line 123 of file bag.py.

Definition at line 123 of file bag.py.

Definition at line 123 of file bag.py.

Definition at line 869 of file bag.py.

Definition at line 123 of file bag.py.


Property Documentation

Definition at line 235 of file bag.py.

Definition at line 219 of file bag.py.


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


rosbag
Author(s): Tim Field, Jeremy Leibs, James Bowman
autogenerated on Fri Aug 28 2015 12:33:52