g2o
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

 DataQueue ()
 
 ~DataQueue ()
 
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 40 of file data_queue.h.

Member Typedef Documentation

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

Definition at line 43 of file data_queue.h.

Constructor & Destructor Documentation

g2o::DataQueue::DataQueue ( )

Definition at line 33 of file data_queue.cpp.

34  {
35  }
g2o::DataQueue::~DataQueue ( )

Definition at line 37 of file data_queue.cpp.

38  {
39  }

Member Function Documentation

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

Definition at line 76 of file data_queue.cpp.

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

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

77  {
78  _buffer[rd->timestamp()] = rd;
79  }
Buffer _buffer
Definition: data_queue.h:59
RobotData * g2o::DataQueue::after ( double  timestamp) const

Definition at line 66 of file data_queue.cpp.

References _buffer.

67  {
68  if (_buffer.size() == 0 || _buffer.rbegin()->first < timestamp)
69  return 0;
70  Buffer::const_iterator ub = _buffer.upper_bound(timestamp);
71  if (ub == _buffer.end())
72  return 0;
73  return ub->second;
74  }
Buffer _buffer
Definition: data_queue.h:59
RobotData * g2o::DataQueue::before ( double  timestamp) const

Definition at line 57 of file data_queue.cpp.

References _buffer.

58  {
59  if (_buffer.size() == 0 || _buffer.begin()->first > timestamp)
60  return 0;
61  Buffer::const_iterator lb = _buffer.upper_bound(timestamp);
62  --lb; // now it's the lower bound
63  return lb->second;
64  }
Buffer _buffer
Definition: data_queue.h:59
const Buffer& g2o::DataQueue::buffer ( ) const
inline

Definition at line 56 of file data_queue.h.

Referenced by main().

56 {return _buffer;}
Buffer _buffer
Definition: data_queue.h:59
RobotData * g2o::DataQueue::findClosestData ( double  timestamp) const

Definition at line 41 of file data_queue.cpp.

References _buffer.

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

42  {
43  if (_buffer.rbegin()->first < timestamp)
44  return _buffer.rbegin()->second;
45  if (_buffer.begin()->first > timestamp)
46  return _buffer.begin()->second;
47 
48  Buffer::const_iterator ub = _buffer.upper_bound(timestamp);
49  Buffer::const_iterator lb = ub;
50  --lb;
51  if (fabs(lb->first - timestamp) < fabs(ub->first - timestamp))
52  return lb->second;
53  else
54  return ub->second;
55  }
Buffer _buffer
Definition: data_queue.h:59

Member Data Documentation

Buffer g2o::DataQueue::_buffer
protected

Definition at line 59 of file data_queue.h.

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


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