class mola::Synchronizer

Overview

A sliding window buffer to collect synchronized observations. Observations are of types derived from mrpt::obs::CObservation, and must have correctly defined sensorLabel and timestamp. Different sensors must have different sensorLabel.

Observations are added to the synchronizer with add(), which inserts the observation into the sliding window buffer. Entries older than parameters.window_length are deleted.

Whenever the user wants to check if a group of synchronized observations is ready to be retrieved, the method getObservationGroup() must be called. This method takes the oldest synchronized group, returns it, and removes it from the buffer.

The user can select two policies to determine when a group of observations is complete:

  • Minimum number of observations. This is the default behavior. See parameters.minimum_observation_count.

  • A specific list of sensor labels, that is, named observations. To enable this behavior, fill in parameters.expected_observation_labels.

#include <Synchronizer.h>

class Synchronizer
{
public:
    // typedefs

    typedef std::map<std::string, std::shared_ptr<mrpt::obs::CObservation>> NamedObservationSet;

    // structs

    struct Parameters;

    // fields

    Parameters parameters;

    // methods

    void add(const std::shared_ptr<mrpt::obs::CObservation>& obs);
    std::optional<NamedObservationSet> getObservationGroup();
    void clear();
};

Methods

void add(const std::shared_ptr<mrpt::obs::CObservation>& obs)

Inserts the observation into the sliding window buffer. Read Synchronizer

std::optional<NamedObservationSet> getObservationGroup()

Retrieves (and removes from the buffer) the oldest set of synchronized observations. If none is ready, std::nullopt is returned.

void clear()

Reset the buffer to an empty state