Bag-cat » History » Version 9

« Previous - Version 9/10 (diff) - Next » - Current version
J. Moringen, 12/13/2011 06:43 PM
fixed link to rsb:Tools#Logger


bag-cat

Introduction

Like UNIX cat, the bag-cat program makes a stream of data available on its standard output stream. Unlike UNIX cat, the data is obtained by processing log files.

See bag-record for recording and bag-play for replaying events from log files.

Obtaining bag-cat

Binaries of the bag-cat program can be downloaded from the continuous integration server for versions 0.4, 0.5 and the current trunk version of the Robotics Service Bus:

  • bag-cat is not available in the 0.4 version

After the download, the bag-cat file has to be made executable in most cases. This can be done for example by executing

chmod +x bag-cat

in the download directory.

Checking Versions and Displaying Help

Version and help information is displayed when the --version and --help[-for all] commandline options are specified:

./bag-cat --version
./bag-cat --help
./bag-cat --help-for all

The output of --help[-for all] includes a list of supported file formats.

Printing the Contents of Log Files

When invoked with a log file, bag-cat prints the contents of one or more channels to its standard output stream. This is probably most useful for channels containing textual data, since binary content usually requires a form of decoding.

Example:

bag-cat isr.tide | head
<sr db_start="80" db_utt="80" />
<sr db_start="45" db_utt="46" />
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><speech_hyp [...]
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><speech_hyp [...]
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><speech_hyp [...]
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><speech_hyp [...]
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><speech_hyp [...]
<speech_hyp xmlns:bxml="http://www.sleepycat.com/2002/dbxml" [...]
<TIMESTAMP>1290275288296</TIMESTAMP>

Selecting Channels for Playback

The default behavior of bag-cat is to print the contents of all channels found in the given file. However, when only a subset of the recorded channels should be printed, the --channel (-c) commandline option can be used to select channels. The following example prints the contents all channels matching one of the regular expressions "hyp" and "param".

bag-cat -c 'hyp' -c 'param' /tmp/nao.tide

Controlling the Output Format

Like the logger, bag-cat supports different output formats. These are controlled using the --style option.

Example:

$ bag-cat --style 'programmable :template "${create} ${data}\\n"' mydata.tide
2011-12-13T17:03:25.533535+01:00 #(98 108 117 98)
2011-12-13T17:03:25.534054+01:00 #(98 108 117 98)
2011-12-13T17:03:25.534121+01:00 #(98 108 117 98)
[...]

Caveats

  • Individual entries can no longer be distinguished (unless some in-band properties permit this)
  • If multiple channels are printed, the channel from which a given part of the output originated is no longer apparent (unless some in-band properties allow determining this)
  • Printing channels which contain binary to a terminal content may mess up the terminal and cause all sorts of mayhem