Recording Data

This article was written for version 2.0.9 of Core. Click here for the most recent version of the help center.

PolySync Core is able to record the incoming sensor data, and allows you to replay the data on any other system. Using Studio or command line tools, you can command nodes to start and stop the recording of incoming data.

Both methods use the same underlying logic to record data: the application populates a ps_rnr_msg with the desired state and publishes the message to the bus, which active nodes receive and respond to.

This article details the steps to prepare the system, and then command active runtime nodes to record the incoming sensor data.

1. Recording data with PolySync Core

Each host in a PolySync Core runtime has a unified rnr_logs directory where data is written to. This is defined in the SDF Configurator in the “RnR Logs” directory, and by default is located in ~/.local/share/polysync/rnr_logs.

In a single host system, all data is recorded and written to the same location. Runtime nodes record data on the local host they are executing on in a distributed system.

1.1 Nodes that support record and replay

Custom nodes cannot automatically record and replay data. They must use PolySync APIs to manage logfile data, for example the PolySync-provided nodes.

PolySync-provided nodes each implement file reading and writing routines using the PolySync Logfile API. The nodes also need to listen for the ps_rnr_msg, which uses the Record & Replay API to instruct nodes regarding what files they should open, and when to start/stop recording and replaying data.

Applications like Studio’s replay module implement the Record & Replay API to instruct nodes which directory to record data to, and at what time to start writing data to the disk (now, or in the near future).

1.2 Exporting recorded data

Once a logfile session has been recorded using Studio or the command line tools, the logfile session can be exported from the current system, allowing it to be replayed on any other system.

To replay the recorded data on another system, check out this exporting recorded data article.

2. Commanding record on the command line

There are two different command line tools that allow you to command active runtime nodes to start and stop the recording of data. There’s an example written in C and another written in C++.

This section will show you how to build, run, and effectively use the C rnr_control example.

The example can be cloned from the C repo and built using make:

$ git clone git@github.com:PolySync/PolySync-Core-C-Examples.git
$ cd PolySync-Core-C-Examples/rnr_control
$ sudo apt-get install libglib2.0-dev  # this is required for this example to build, documented in the examples README.md file
$ make

The binary is named polysync-rnr-control-c.

2.1 Starting nodes in hardware mode

Before you can record data on the system, nodes must be running in the hardware mode. See the Runtime section for an article detailing how to start sensor and hardware nodes in hardware mode.

2.2 Commanding active nodes to record data

Before nodes are commanded to record data, it’s best to check the system state to ensure nodes are in a known-good state. Active nodes can be seen in Studio’s system state module.

The polysync-rnr-control-c application uses the -t flag to indicate the desination for the logged data, referred to as a logfile session. The logfile session will contain one plog file for each active sensor at the time of recording. The -w flag tells the application that we want to record data (opposed to replaying data).

To begin recording data to session 1001, use the command:

$ polysync-rnr-control-c -w -t 1001

It’s important to note that the rnr_control application has no knowledge of the nodes on the PolySync bus. It’s simply packaging and publishing a ps_rnr_msg that active nodes subscribe and react to.

2.3 Commanding active nodes to stop recording data

To command nodes to stop recording data, you will need to pass the -q flag. At any time, issue the following command to end the logfile session:

$ polysync-rnr-control-c -q

Nodes will continue to parse sensor data, but they will stop recording and writing data to the logfile session.

Congratulations! You’ve successfully commanded nodes to record data from the command line.

3. Commanding record with studio

Studio has a record module to initiate, monitor, and stop the recording of active nodes. The record module will show up in the logfile management section of Studio when there are one or more nodes running in hardware mode.

All of the tools you need are located in the lower-left corner of Studio.

Studio system state and logfile management recording tools

3.1 Starting nodes in hardware mode

Before you can record data on the system, nodes must be running in hardware mode.

To command nodes into hardware mode, press the Icon button.

For more detailed instructions, see the Runtime section for an article detailing how to start sensor and hardware nodes in hardware mode.

3.2 Start recording data

Before nodes are commanded to record data, it’s best to check the system state to ensure nodes are in a known-good state. Active nodes can be seen in Studio’s system state module.

To begin recording data, press the Icon button. The record module will name the logfile session based on the UTC timestamp of the moment the record button is pressed.

If you cannot see the Icon button, then the system is not operating in hardware mode.

The elapased recording time will show in the logfile management area.

3.3 Command active nodes to stop recording data

When you’ve finished recording your data or scenario, press the Icon button.

Next steps

Congratulations! You’ve successfully commanded nodes to record data from the Studio record module.

The logfile session is now available in Studio’s logfile management area.

The logfile session can be replayed on the local system or exported from Studio, which allows you to import and replay your data on any other PolySync system.