mars_lib  0.1.0.3dc76ee85e09
Modular and Robust Sensor-Fusion
Public Member Functions | Private Attributes | List of all members
mars::Buffer Class Reference

BufferClass that holds mars::BufferEntryType elements and provides access methods. More...

#include </home/runner/work/mars_lib/mars_lib/source/mars/include/mars/buffer.h>

+ Collaboration diagram for mars::Buffer:

Public Member Functions

 Buffer ()
 Buffer default constructor max buffer size is set to 400 by default. More...
 
 Buffer (const int &size)
 Buffer constructor. More...
 
void set_max_buffer_size (const int &size)
 set_max_buffer_size More...
 
void set_keep_last_sensor_handle (const bool &value)
 set_keep_last_sensor_handle More...
 
int get_max_buffer_size () const
 get_max_buffer_size More...
 
void ResetBufferData ()
 Removes all entrys from the buffer. More...
 
bool IsEmpty () const
 IsEmpty. More...
 
int get_length () const
 get_length More...
 
void PrintBufferEntries () const
 PrintBufferEntries prints all buffer entries in a formatted way. More...
 
bool get_latest_entry (BufferEntryType *entry) const
 get_latest_entry Returns the last buffer entry More...
 
bool get_latest_state (BufferEntryType *entry) const
 get_latest_state returns the most recent state entry More...
 
bool get_oldest_state (BufferEntryType *entry) const
 get_oldest_state Gets the oldest entry with metadata in the state group More...
 
bool get_oldest_core_state (BufferEntryType *entry) const
 get_oldest_core_state Gets the oldest entry with metadata_ core_state More...
 
bool get_latest_init_state (BufferEntryType *entry) const
 Gets the latest entry with init_state as metadata. More...
 
bool get_latest_sensor_handle_state (const std::shared_ptr< SensorAbsClass > &sensor_handle, BufferEntryType *entry) const
 get_latest_sensor_handle_state More...
 
bool get_latest_sensor_handle_state (const std::shared_ptr< SensorAbsClass > &sensor_handle, BufferEntryType *entry, int *index) const
 get_latest_sensor_handle_state More...
 
bool get_oldest_sensor_handle_state (const std::shared_ptr< SensorAbsClass > &sensor_handle, BufferEntryType *entry) const
 get_oldest_sensor_handle_state More...
 
bool get_latest_sensor_handle_measurement (const std::shared_ptr< SensorAbsClass > &sensor_handle, BufferEntryType *entry) const
 get_latest_sensor_handle_measurement More...
 
bool get_sensor_handle_measurements (const std::shared_ptr< SensorAbsClass > &sensor_handle, std::vector< const BufferEntryType * > *entries) const
 get_sensor_handle_measurements More...
 
bool get_closest_state (const Time &timestamp, BufferEntryType *entry) const
 get_closest_state More...
 
bool get_closest_state (const Time &timestamp, BufferEntryType *entry, int *index) const
 
bool get_entry_at_idx (const int &index, BufferEntryType *entry) const
 get_entry_at_idx More...
 
bool RemoveSensorFromBuffer (const std::shared_ptr< SensorAbsClass > &sensor_handle)
 RemoveSensorFromBuffer Removes all entrys that are associated with the given sensor handle. More...
 
int AddEntrySorted (const BufferEntryType &new_entry, const bool &after=true)
 AddEntrySorted Adds a new entry to the buffer and ensures the buffer is sorted. More...
 
int FindClosestTimestamp (const Time &timestamp) const
 FindClosestTimestamp Returns the index of the entry which is the closest to the specified 'timestamp' when searching from newest to oldest entry. More...
 
bool ClearStatesStartingAtIdx (const int &idx)
 Deletes all states after, and including the given index This also deletes all auto generated states. More...
 
bool IsSorted () const
 Checks if all buffer entrys are correctly sorted by time. More...
 
bool OverwriteDataAtIndex (const BufferEntryType &new_entry, const int &index)
 InsertDataAtIndex Adds 'entry' at buffer position 'index'. More...
 
bool get_intermediate_entry_pair (const std::shared_ptr< SensorAbsClass > &sensor_handle, BufferEntryType *imu_state, BufferEntryType *sensor_state) const
 get_latest_interm_entrie Get last state pair of imu prop and sensor update More...
 
bool CheckForLastSensorHandleWithState (const std::shared_ptr< SensorAbsClass > &sensor_handle) const
 CheckForLastSensorHandleWithState Checks if the given sensor handle only exists once in the buffer and if it has a state. More...
 
int RemoveOverflowEntrys ()
 RemoveOverflowEntrys Removes the oldest entries if max buffer size is reached. More...
 

Private Attributes

std::deque< BufferEntryTypedata_
 deque container that holds the buffer entries More...
 
int max_buffer_size_ { 2000 }
 defines the max size at wich the oldest entry is removed More...
 
bool keep_last_sensor_handle_ { true }
 If true, the last entry of a sensor state entry will be keept in the buffer. More...
 
bool verbose_ { false }
 Increased cmd output. More...
 

Detailed Description

BufferClass that holds mars::BufferEntryType elements and provides access methods.

Author
Christian Brommer chris.nosp@m.tian.nosp@m..brom.nosp@m.mer@.nosp@m.ieee..nosp@m.org
Attention
Erasing elements that are not located at the end or beginning of the buffer will invalidate the deque iterator

Constructor & Destructor Documentation

◆ Buffer() [1/2]

mars::Buffer::Buffer ( )

Buffer default constructor max buffer size is set to 400 by default.

◆ Buffer() [2/2]

mars::Buffer::Buffer ( const int &  size)

Buffer constructor.

Parameters
sizemax buffer size

Member Function Documentation

◆ set_max_buffer_size()

void mars::Buffer::set_max_buffer_size ( const int &  size)

set_max_buffer_size

Parameters
sizemax number of entrys after which the oldest entry is deleted

◆ set_keep_last_sensor_handle()

void mars::Buffer::set_keep_last_sensor_handle ( const bool &  value)

set_keep_last_sensor_handle

Parameters
valueenables or disables the mechanism to keep the last sensor handle

◆ get_max_buffer_size()

int mars::Buffer::get_max_buffer_size ( ) const

get_max_buffer_size

Returns
current setting for the highest buffer size

◆ ResetBufferData()

void mars::Buffer::ResetBufferData ( )

Removes all entrys from the buffer.

◆ IsEmpty()

bool mars::Buffer::IsEmpty ( ) const

IsEmpty.

Returns
True if the buffer is empty, false otherwise

◆ get_length()

int mars::Buffer::get_length ( ) const
inline

get_length

Returns
current number of elements stored in the buffer
83  {
84  return static_cast<int>(data_.size());
85  }
std::deque< BufferEntryType > data_
deque container that holds the buffer entries
Definition: buffer.h:270

◆ PrintBufferEntries()

void mars::Buffer::PrintBufferEntries ( ) const

PrintBufferEntries prints all buffer entries in a formatted way.

◆ get_latest_entry()

bool mars::Buffer::get_latest_entry ( BufferEntryType entry) const

get_latest_entry Returns the last buffer entry

Parameters
entryOutput parameter for the latest entry
Returns
True if the operation was performed, false otherwise

◆ get_latest_state()

bool mars::Buffer::get_latest_state ( BufferEntryType entry) const

get_latest_state returns the most recent state entry

Parameters
entryOutput parameter for the latest state entry
Returns
True if the operation was performed, false otherwise

◆ get_oldest_state()

bool mars::Buffer::get_oldest_state ( BufferEntryType entry) const

get_oldest_state Gets the oldest entry with metadata in the state group

Parameters
entryOutput variable for the oldest state entry
Returns
true if the operation was successfully, false otherwise

◆ get_oldest_core_state()

bool mars::Buffer::get_oldest_core_state ( BufferEntryType entry) const

get_oldest_core_state Gets the oldest entry with metadata_ core_state

Parameters
entryOutput variable for the oldest core state entry
Returns
true if the operation was successfully, false otherwise

◆ get_latest_init_state()

bool mars::Buffer::get_latest_init_state ( BufferEntryType entry) const

Gets the latest entry with init_state as metadata.

Parameters
entryOutput parameter for the latest init_state entry
Returns
true if the operation was performed, false otherwise

◆ get_latest_sensor_handle_state() [1/2]

bool mars::Buffer::get_latest_sensor_handle_state ( const std::shared_ptr< SensorAbsClass > &  sensor_handle,
BufferEntryType entry 
) const

get_latest_sensor_handle_state

Parameters
sensor_handleSeach parameter for the latest assosiated state entry
entryOutput parameter for the latest sensor handle state entry
Returns
true if the operation was performed, false otherwise

◆ get_latest_sensor_handle_state() [2/2]

bool mars::Buffer::get_latest_sensor_handle_state ( const std::shared_ptr< SensorAbsClass > &  sensor_handle,
BufferEntryType entry,
int *  index 
) const

get_latest_sensor_handle_state

Parameters
sensor_handleSeach parameter for the latest assosiated state entry
entryOutput parameter for the latest sensor handle state entry
indexReturns the current index of this entry
Returns
true if the operation was performed, false otherwise

◆ get_oldest_sensor_handle_state()

bool mars::Buffer::get_oldest_sensor_handle_state ( const std::shared_ptr< SensorAbsClass > &  sensor_handle,
BufferEntryType entry 
) const

get_oldest_sensor_handle_state

Parameters
sensor_handleseach parameter for the oldest assosiated state entry
entryoutput parameter for the oldest sensor handle state entry
Returns
true if the operation was successfully, false otherwise

◆ get_latest_sensor_handle_measurement()

bool mars::Buffer::get_latest_sensor_handle_measurement ( const std::shared_ptr< SensorAbsClass > &  sensor_handle,
BufferEntryType entry 
) const

get_latest_sensor_handle_measurement

Parameters
sensor_handleseach parameter for the latest associated measurement entry
entryoutput parameter for the latest sensor handle measurement entry
Returns
true if the operation was performed, false otherwise

◆ get_sensor_handle_measurements()

bool mars::Buffer::get_sensor_handle_measurements ( const std::shared_ptr< SensorAbsClass > &  sensor_handle,
std::vector< const BufferEntryType * > *  entries 
) const

get_sensor_handle_measurements

Parameters
sensor_handleseach parameter for the all associated measurement entries
entriesoutput parameter for the sensor handle measurement entries
Returns
true if the operation was performed and values are returned, false otherwise
Author
Martin Scheiber marti.nosp@m.n.sc.nosp@m.heibe.nosp@m.r@ie.nosp@m.ee.or.nosp@m.g

◆ get_closest_state() [1/2]

bool mars::Buffer::get_closest_state ( const Time timestamp,
BufferEntryType entry 
) const

get_closest_state

Parameters
timestamp
entry
Returns
true if the operation was performed, false otherwise
Note
The newer entry is returned if the time distance between two entrys is equal

◆ get_closest_state() [2/2]

bool mars::Buffer::get_closest_state ( const Time timestamp,
BufferEntryType entry,
int *  index 
) const

◆ get_entry_at_idx()

bool mars::Buffer::get_entry_at_idx ( const int &  index,
BufferEntryType entry 
) const

get_entry_at_idx

Parameters
index
entry
Returns

◆ RemoveSensorFromBuffer()

bool mars::Buffer::RemoveSensorFromBuffer ( const std::shared_ptr< SensorAbsClass > &  sensor_handle)

RemoveSensorFromBuffer Removes all entrys that are associated with the given sensor handle.

Parameters
sensor_handleSensor handle to be removed
Returns
true if the operation was performed, false otherwise
+ Here is the caller graph for this function:

◆ AddEntrySorted()

int mars::Buffer::AddEntrySorted ( const BufferEntryType new_entry,
const bool &  after = true 
)

AddEntrySorted Adds a new entry to the buffer and ensures the buffer is sorted.

Parameters
new_entrynew buffer entry to be added
Returns
Index of the added entry. The index is -1 if the entry was removed because the max_buffer_size was reached.

The method finds the closest timestamp based on the shortest 'time' distance between the new and existing buffer elements. It then determines if the entry needs to be added before or after the closest entry.

◆ FindClosestTimestamp()

int mars::Buffer::FindClosestTimestamp ( const Time timestamp) const

FindClosestTimestamp Returns the index of the entry which is the closest to the specified 'timestamp' when searching from newest to oldest entry.

Parameters
timestampfor the surch routine
Returns
index of the closest entry

◆ ClearStatesStartingAtIdx()

bool mars::Buffer::ClearStatesStartingAtIdx ( const int &  idx)

Deletes all states after, and including the given index This also deletes all auto generated states.

Parameters
idxStart index after which all states are deleted
Returns
true if function was performed correct, false otherwise

◆ IsSorted()

bool mars::Buffer::IsSorted ( ) const

Checks if all buffer entrys are correctly sorted by time.

Returns
true if sorted, false otherwise

◆ OverwriteDataAtIndex()

bool mars::Buffer::OverwriteDataAtIndex ( const BufferEntryType new_entry,
const int &  index 
)

InsertDataAtIndex Adds 'entry' at buffer position 'index'.

Parameters
new_entryEntry buffer entry to be added
indexposition at which the entry is added

◆ get_intermediate_entry_pair()

bool mars::Buffer::get_intermediate_entry_pair ( const std::shared_ptr< SensorAbsClass > &  sensor_handle,
BufferEntryType imu_state,
BufferEntryType sensor_state 
) const

get_latest_interm_entrie Get last state pair of imu prop and sensor update

This function provides a state pair for an intermediate propagated state and a corresponding sensor update for the same point in time. The intermediate state reflects the propagation of the latest real IMU measurement to the current point in time at which the sensor update will be performed. This is mostelikely an auto generated state, added via the 'InsertIntermediateData' function.

Returns
True if successfull, false of no pair was found

◆ CheckForLastSensorHandleWithState()

bool mars::Buffer::CheckForLastSensorHandleWithState ( const std::shared_ptr< SensorAbsClass > &  sensor_handle) const

CheckForLastSensorHandleWithState Checks if the given sensor handle only exists once in the buffer and if it has a state.

Parameters
sensor_handle
Returns
true if current sensor handle is the last in the buffer, false otherwise

◆ RemoveOverflowEntrys()

int mars::Buffer::RemoveOverflowEntrys ( )

RemoveOverflowEntrys Removes the oldest entries if max buffer size is reached.

Member Data Documentation

◆ data_

std::deque<BufferEntryType> mars::Buffer::data_
private

deque container that holds the buffer entries

◆ max_buffer_size_

int mars::Buffer::max_buffer_size_ { 2000 }
private

defines the max size at wich the oldest entry is removed

◆ keep_last_sensor_handle_

bool mars::Buffer::keep_last_sensor_handle_ { true }
private

If true, the last entry of a sensor state entry will be keept in the buffer.

Note
This only keeps sensor states, not measurements or core states

◆ verbose_

bool mars::Buffer::verbose_ { false }
private

Increased cmd output.


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