Class ImuMeasurementBuffer

Class Documentation

class vio_common::ImuMeasurementBuffer

This buffering class can be used to store a history of IMU measurements.

It allows to retrieve a list of measurements up to a given timestamp. The data is stored in the order it is added. So make sure to add it in correct time-wise order.

Public Types

enum QueryResult


enumerator kDataAvailable

Query was successful and the data is available.

enumerator kDataNotYetAvailable

The required data is not (yet) available.

The query timestamp is above the last IMU sample’s time.

enumerator kDataNeverAvailable

The queried timestamp lies before the first IMU sample in the buffer.

This request will never succeed considering chronological ordering of the buffer input data.

enumerator kQueueShutdown

Queue shutdown.

Public Functions

inline explicit ImuMeasurementBuffer(int64_t buffer_length_ns)
inline ~ImuMeasurementBuffer()
inline void shutdown()

Shutdown the queue and release all blocked waiters.

inline size_t size() const
inline void clear()
inline void addMeasurement(int64_t timestamp_nanoseconds, const vio::ImuData &imu_measurement)

Add IMU measurement in IMU frame.

(Ordering: accelerations [m/s^2], angular velocities [rad/s])

inline void addMeasurements(const Eigen::Matrix<int64_t, 1, Eigen::Dynamic> &timestamps_nanoseconds, const Eigen::Matrix<double, 6, Eigen::Dynamic> &imu_measurements)
QueryResult getImuDataInterpolatedBorders(int64_t timestamp_from, int64_t timestamp_to, Eigen::Matrix<int64_t, 1, Eigen::Dynamic> *imu_timestamps, Eigen::Matrix<double, 6, Eigen::Dynamic> *imu_measurements) const

Return a list of the IMU measurements between the specified timestamps.

The IMU values get interpolated if the queried timestamp does not match a measurement. The return code signals if the buffer does not contain data up to the requested timestamp. In this case the output matrices will be of size 0.


Was data removed from the buffer?

  • [in] timestamp_from: Try to get the IMU measurements from this time [ns].

  • [in] timestamp_to: Try to get the IMU measurements up this time [ns].

  • [out] imu_timestamps: List of timestamps. [ns]

  • [out] imu_measurements: List of IMU measurements. (Order: [acc, gyro])

QueryResult getImuDataInterpolatedBordersBlocking(int64_t timestamp_ns_from, int64_t timestamp_ns_to, int64_t wait_timeout_nanoseconds, Eigen::Matrix<int64_t, 1, Eigen::Dynamic> *imu_timestamps, Eigen::Matrix<double, 6, Eigen::Dynamic> *imu_measurements) const

Try to pop the requested IMU measurements for the duration of wait_timeout_nanoseconds.

If the requested data is still not available when timeout has been reached, the method will return false and no data will be removed from the buffer.

bool getNewestTime(int64_t *timestamp_ns) const

Return the newest and oldest timestamp present in the buffer.

bool getOldestTime(int64_t *timestamp_ns) const

Public Members