Class MCAPSink

Inheritance Relationships

Base Type

Class Documentation

class MCAPSink : public DataTamer::DataSinkBase

The MCAPSink is an implementation of DataSinkBase that will save the data as MCAP file (https://mcap.dev/)

Public Functions

explicit MCAPSink(std::string const &filepath, bool do_compression = false)

MCAPSink. IMPORTANT: if you want the recorder to be more robust to crash/segfault, set do_compression to false. Compression is safe if your application is closing cleanly.

Parameters:
  • filepath – path of the file to be saved. Should have extension “.mcap”

  • do_compression – if true, compress the data on the fly.

~MCAPSink() override
virtual void addChannel(std::string const &channel_name, Schema const &schema) override

addChannel will register a schema into the sink. That schema will be recognized by its hash.

Parameters:
virtual bool storeSnapshot(const Snapshot &snapshot) override

storeSnapshot contains the code to execute when popping a snapshot from the queue.

Parameters:

snapshot – data to be pushed into the sink.

Returns:

true if processed successfully

void setMaxTimeBeforeReset(std::chrono::seconds reset_time)

After a certain amount of time, the MCAP file will be reset and overwritten. Default value is 600 seconds (10 minutes) To disable this feature, use a time of 0 seconds. WARNING: this can consume a large amount of disk space very quickly.

void setCreateNewFileOnReset(bool create_new_file)

When resetting the MCAP recording (see setMaxTimeBeforeReset), if create_new_file is true then the filename will be incremented and then saved instead of overwriting the previous file.

void stopRecording()

Stop recording and save the file.

void restartRecording(std::string const &filepath, bool do_compression = false)

restartRecording saves the current file (unless we did it already, calling stopRecording) and start recording into a new one. Note that all the registered channels and their schemas will be copied into the new file.

Parameters:
  • filepath – file path of the new file (should be “.mcap” extension)

  • do_compression – if true, compress the data on the fly. WARNING: if this is called with the same filename as previously, the file counter will be reset, too.