class mola::PendingImuBuffer
Overview
Holds IMU observations until the LiDAR scan that needs them is processed.
Which samples a scan gets is decided by their timestamps alone, so it does not matter on which thread, or in which order, the samples were delivered.
#include <ImuScanSync.h> class PendingImuBuffer { public: // methods bool add( double timestamp, const mrpt::obs::CObservationIMU::ConstPtr& imu, double maxAge ); std::vector<mrpt::obs::CObservationIMU::ConstPtr> take_up_to(double upToTime); void clear(); std::size_t size() const; };
Methods
bool add( double timestamp, const mrpt::obs::CObservationIMU::ConstPtr& imu, double maxAge )
Stores one observation, then drops everything older than maxAge seconds relative to the newest sample held. A multimap, so that two readings sharing a timestamp are both kept: which of them is “the” reading for that instant is undecidable, and dropping one would silently discard data the previous code did use.
A reading that is not newer than what has already been consumed is discarded: the pipeline has moved past that instant, so feeding it now would apply IMU data out of chronological order.
Returns:
whether it was stored.
std::vector<mrpt::obs::CObservationIMU::ConstPtr> take_up_to(double upToTime)
Removes and returns every sample with a timestamp not newer than upToTime, in timestamp order. Everything up to upToTime counts as consumed afterwards, including samples that arrive later (see add()).