In addition to bag-cat and bag-play, RSBag provides a simple client API for working with log files. Analyzing, visualizing and transforming recorded data are the primary use-cases for this API.
See also
This section assumes a working installation of RSBag including at least one of the client APIs.
The RSBag client API for Python is provided by the rsbag module. To use the module
import rsbag
All subsequent listings assume this.
(ql:quickload '(:cl-rsbag :cl-rsbag-tidelog))
Note
The client API presented here only takes care of making available the contents of log files, not the interpretation of this data. Depending on the kind of data, it may be necessary to load and/or register RSB converters to access the data in a convenient form. See Sending and Receiving Custom Data Types for details.
Processing data in log files starts with opening the respective log file.
Log files are opened using the rsbag.openBag() function. This function returns a Bag object implementing the context manager protocol:
1 2 3 | with rsbag.openBag('/media/local_data/foo.tide',
channels = [ 'vision' ]) as bag:
pass
|
(rsbag:with-bag (bag "/media/local_data/foo.tide" :direction :input)
(rsbag:bag-channel bag "vision"))
Events are accessed using the rsbag.Bag.events and rsbag.Bag.items properties. Both behave like ordinary Python sequences:
1 2 3 4 5 | with rsbag.openBag('/media/local_data/foo.tide',
channels = [ 'vision' ]) as bag:
print len(bag.events)
for e in bag.events:
print (e.scope, e.metaData.createTime, e.data.width, e.data.height)
|
(rsbag:with-bag (bag "/media/local_data/foo.tide" :direction :input)
(values
(length (rsbag:bag-channel bag "vision"))
(subseq (rsbag:bag-channel bag "vision") 5 10)))