bag-record

Synopsis

bag-record [OPTIONS] -o OUTPUT [URI1] [URI2 ...]

Description

The bag-record program can be used to capture certain RSB events in a running system and store them into a log file for later analysis, further processing or replay.

See also

Common Commandline Options
The usual RSB-related commandline options are accepted.
IDL-related Commandline Options
The usual IDL-related commandline options are accepted.
--output-file OUTPUT, -o OUTPUT

Write captured events to file OUTPUT. The file format is determined based on the file type (which is determined based on the file extension).

Tip

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

--force

Should OUTPUT be overwritten in case it already exists?

-timestamp NAME

Use the timestamp named NAME to index events in the created log file. The default timestamp is “send”.

--channel-allocation SPEC, -a SPEC

Allocate channels for received events in the output bag file according to the strategy designated by SPEC which has to be of the form:

KIND KEY1 VALUE1 KEY2 VALUE2 ...

where keys and values depend on KIND and are optional in most cases. The default channel allocation strategy is scope-and-type.

The following strategies are currently supported:

scope-and-type

This strategy allocates a separate channel for each combination of scope and wire schema as events are received: the channel allocation for a given combination is performed when the first event exhibiting that combination is received. Channel names produced by this strategy are of the form SCOPE:TYPE where SCOPE is the scope string of the event‘s scope and TYPE is the wire schema string, i.e. a string designating the type of the event payload (See Types).

For example, an event on scope /foo/bar/ with a protocol buffer payload and wire schema .rst.vision.Image would be stored in a channel called /foo/bar/:.rst.vision.Image.

Examples:

-a scope-and-type

Tip

Use the common --help-for channel-strategies or common --help-for all options to display the full help text, including available strategies and their respective parameters, for this item.

--flush-strategy SPEC

Flush buffers (e.g. event and indices) according strategy designated by SPEC which has to be of one of the forms:

KIND KEY1 VALUE1 KEY2 VALUE2 ...
OR (SPEC) (SPEC) ...
AND (SPEC) (SPEC) ...
NOT (SPEC)

where keys and values depend on KIND and are optional in most cases. The default flushing strategy is property-limit :property :length/bytes :limit 33554432 which corresponds to flushing buffers once they reach a size of 32 MB.

Examples:

--flush-strategy 'property-limit :property :length/bytes :limit 16777216'

Flush buffers once they reach a size of 16 MB.

--flush-strategy 'property-limit :property :length/entries :limit 100'

Flush buffers once they reach 100 entries.

--flush-strategy 'property-limit :property :time-to-last-write :limit 5'

Flush buffers when the most recent write was 5 or more seconds ago.

--flush-strategy 'or (:property-limit :property :time-to-last-write :limit 5)
                     (:property-limit :property :length/bytes :limit 33554432)'

Flush buffers when they reach a size of 32 MB or the most recent write was 5 or more seconds ago.

Tip

Use the common --help-for flush-strategies or common --help-for all options to display the full help text, including available strategies and their respective parameters, for this item.

--control-uri URI, -c URI

Expose an RPC interface for remote-controlling the recording process under URI. See Remote Control for details.

Important

Supplying this option causes bag-record to start in a suspended state. The recording has to be started using the start().

Recording Events

Some general remarks regarding recording of RSB events using bag-record:

  • The specified output file into which events should be recorded, should not already exist
    • If an empty file of the given name exists, it will be used for recording
    • If a non-empty file of the given name exists, it will be extended as long as it does not already contain any of the channels being recorded
  • The recording process can be terminated gracefully by sending one of SIGINT and SIGTERM to the bag-record process

Tip

For details regarding the URI syntax involved in transport and channel specifications, see URIs.

Remote Control

bag-record can expose an RPC interface that allows starting, stopping and terminating the recording process. This feature is enabled using the --control-uri commandline option. An URI has to be supplied as an argument of the option to configure the scope and transport through which the RPC interface should be exposed. The interface consists of the following methods:

start()

Restart recording - initially or after it has been stopped.

stop()

Stop recording allowing it to be restarted later.

terminate()

Terminate the recording process and the program.

Examples

  • $ bag-record -o /tmp/nao.tide
                 'spread:/nao/vision/top?name=4803'
                 'spread:/nao/audio/all?name=4803'
                 'spread:/nao/proprioception?name=4803'
    

    The resulting log file will (unless a different channel allocation is specified) contain one channel for each of the three RSB scopes.

  • $ bag-record -c 'spread:/control' -o /tmp/everything.tide spread:
    

    The above command starts a bag-record process configured to record events into the log file /tmp/everything.tide. Since the --control-uri commandline option has been used, bag-record does not record immediately after starting, but wait for instructions via RPC . Therefore, without terminating the above bag-record process, the call program can be used to issue commands:

    $ call 'spread:/control/start()' # start recording
    [...]
    $ call 'spread:/control/stop()' # stop recording
    $ call 'spread:/control/terminate()' # terminate bag-record
    
  • $ bag-record --output-file    /tmp/nao.tide
                 --on-error       continue
                 --flush-strategy '(:property-limit :property :time-to-last-write :limit 1)'
                 'socket:/camera1'
    

    The above example demonstrates non-default error and flushing behavior: bag-record is instructed to continue in case of errors and flush buffers every second. Something like this could make sense when the recorded data is hard to produce.