g2o
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members
g2o::DataQueue Class Reference

a simple queue to store data and retrieve based on a timestamp More...

#include <data_queue.h>

Public Types

typedef std::map< double, RobotData * > Buffer
 

Public Member Functions

void add (RobotData *rd)
 
RobotDatafindClosestData (double timestamp) const
 
RobotDatabefore (double timestamp) const
 
RobotDataafter (double timestamp) const
 
const Bufferbuffer () const
 

Protected Attributes

Buffer _buffer
 

Detailed Description

a simple queue to store data and retrieve based on a timestamp

Definition at line 41 of file data_queue.h.

Member Typedef Documentation

◆ Buffer

typedef std::map<double, RobotData*> g2o::DataQueue::Buffer

Definition at line 43 of file data_queue.h.

Member Function Documentation

◆ add()

void g2o::DataQueue::add ( RobotData rd)

Definition at line 62 of file data_queue.cpp.

62{ _buffer[rd->timestamp()] = rd; }

References _buffer, and g2o::RobotData::timestamp().

Referenced by g2o::Gm2dlIO::readRobotLaser().

◆ after()

RobotData * g2o::DataQueue::after ( double  timestamp) const

Definition at line 54 of file data_queue.cpp.

54 {
55 if (_buffer.size() == 0 || _buffer.rbegin()->first < timestamp)
56 return nullptr;
57 Buffer::const_iterator ub = _buffer.upper_bound(timestamp);
58 if (ub == _buffer.end()) return nullptr;
59 return ub->second;
60}

References _buffer.

◆ before()

RobotData * g2o::DataQueue::before ( double  timestamp) const

Definition at line 46 of file data_queue.cpp.

46 {
47 if (_buffer.size() == 0 || _buffer.begin()->first >= timestamp)
48 return nullptr;
49 Buffer::const_iterator lb = _buffer.upper_bound(timestamp);
50 --lb; // now it's the lower bound
51 return lb->second;
52}

References _buffer.

◆ buffer()

const Buffer & g2o::DataQueue::buffer ( ) const
inline

Definition at line 53 of file data_queue.h.

53{ return _buffer; }

Referenced by main().

◆ findClosestData()

RobotData * g2o::DataQueue::findClosestData ( double  timestamp) const

Definition at line 33 of file data_queue.cpp.

33 {
34 if (_buffer.rbegin()->first < timestamp) return _buffer.rbegin()->second;
35 if (_buffer.begin()->first > timestamp) return _buffer.begin()->second;
36
37 Buffer::const_iterator ub = _buffer.upper_bound(timestamp);
38 Buffer::const_iterator lb = ub;
39 --lb;
40 if (fabs(lb->first - timestamp) < fabs(ub->first - timestamp))
41 return lb->second;
42 else
43 return ub->second;
44}

References _buffer.

Referenced by g2o::addOdometryCalibLinksDifferential(), and main().

Member Data Documentation

◆ _buffer

Buffer g2o::DataQueue::_buffer
protected

Definition at line 56 of file data_queue.h.

Referenced by add(), after(), before(), and findClosestData().


The documentation for this class was generated from the following files: