namespace mrpt::apps::rawlog_ops

Overview

In-memory transformations of rawlogs, shared by rawlog-edit and the GUI tools.

All of them work on a whole mrpt::obs::CRawlog.

Long operations take an optional progress callback, called with a fraction in [0,1]; if it returns false, the operation is aborted and the rawlog is left unchanged.

namespace rawlog_ops {

// typedefs

typedef std::function<bool(double fraction)> progress_callback_t;

// structs

struct CompactStats;

// global functions

size_t decimate(mrpt::obs::CRawlog& rawlog, size_t ratio, const progress_callback_t& progress = {});
size_t losslessDecimate(mrpt::obs::CRawlog& rawlog, size_t ratio, const progress_callback_t& progress = {});
CompactStats compact(mrpt::obs::CRawlog& rawlog, bool onlyOnePerLabel, const progress_callback_t& progress = {});
void toObservationsOnly(mrpt::obs::CRawlog& rawlog, const progress_callback_t& progress = {});

void toSensoryFrames(
    mrpt::obs::CRawlog& rawlog,
    double maxLengthSeconds,
    bool onlyOnePerLabel,
    const progress_callback_t& progress = {}
    );

void sortByTimestamp(mrpt::obs::CRawlog& rawlog, bool useSensorTimestamp = true);
size_t shiftTimestamps(mrpt::obs::CRawlog& rawlog, const std::vector<std::string>& labels, double seconds);
size_t regenerateTimestampsInSensoryFrames(mrpt::obs::CRawlog& rawlog);
bool isObservationsOnly(const mrpt::obs::CRawlog& rawlog);

} // namespace rawlog_ops

Global Functions

size_t decimate(mrpt::obs::CRawlog& rawlog, size_t ratio, const progress_callback_t& progress = {})

Keeps one out of each ratio sensory frames of a SensoryFrame-based rawlog, accumulating the odometry of the discarded steps into the kept actions.

Returns:

The number of sensory frames kept.

size_t losslessDecimate(mrpt::obs::CRawlog& rawlog, size_t ratio, const progress_callback_t& progress = {})

Like decimate(), but no observation is lost: each group of ratio sensory frames is merged into one, with the sensor poses of the earlier observations corrected by the odometry since then.

SensoryFrame-based rawlogs only.

Returns:

The number of sensory frames in the result.

CompactStats compact(mrpt::obs::CRawlog& rawlog, bool onlyOnePerLabel, const progress_callback_t& progress = {})

Compacts a SensoryFrame-based rawlog: consecutive actions are merged into one (their odometry added up), consecutive sensory frames into one, and empty sensory frames are removed.

If onlyOnePerLabel, only the first observation of each sensor label is kept in each sensory frame.

void toObservationsOnly(mrpt::obs::CRawlog& rawlog, const progress_callback_t& progress = {})

Converts a SensoryFrame-based rawlog into an observations-only one, sorted by timestamp.

Odometry actions become CObservationOdometry observations (label “odometry”) with the accumulated odometry.

void toSensoryFrames(
    mrpt::obs::CRawlog& rawlog,
    double maxLengthSeconds,
    bool onlyOnePerLabel,
    const progress_callback_t& progress = {}
    )

Converts an observations-only rawlog into a SensoryFrame-based one, grouping observations into sensory frames up to maxLengthSeconds long, with odometry actions between them computed from the CObservationOdometry observations, if any.

If onlyOnePerLabel, only the first observation of each label is kept in each sensory frame.

void sortByTimestamp(mrpt::obs::CRawlog& rawlog, bool useSensorTimestamp = true)

Sorts an observations-only rawlog by timestamp: the sensor timestamp, or the computer-based one (CObservation::getOriginalReceivedTimeStamp()).

Throws if an observation has no valid timestamp.

size_t shiftTimestamps(
    mrpt::obs::CRawlog& rawlog,
    const std::vector<std::string>& labels,
    double seconds
    )

Shifts the timestamps of the observations with the given sensor labels (all of them, if empty).

Returns:

The number of observations changed.

size_t regenerateTimestampsInSensoryFrames(mrpt::obs::CRawlog& rawlog)

Within each sensory frame, gives the observations without a valid timestamp the first valid one found in the same frame.

Returns:

The number of observations changed.

bool isObservationsOnly(const mrpt::obs::CRawlog& rawlog)

True if the rawlog has no actions or sensory frames.