event_detector 1.0.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
event_detector::BufferManager::DataBuffers< T > Class Template Reference

Template class designed to hold all buffers for a specific data type. More...

#include <BufferManager.hpp>

Public Member Functions

 DataBuffers ()
 Creates a new DataBuffers instance.
 
void setBufferManager (BufferManager *manager)
 Assigns the managing BufferManager.
 
void update (const std::vector< ClientConnection > &clients)
 Creates buffers and mutexes for topics mentioned in clients. If a buffer and mutex already exists for a topic, the old buffer and mutex will be retained and no new buffer and mutex will be created. Existing mutexes and buffers for topics that are not mentioned in clients will be deleted.
 
void insert (const typename std::shared_ptr< const T > &sample, const rclcpp::Time &stamp, const std::string &client_id, const std::string &topic, const bool clear_if_time_is_running_backwards=true)
 Inserts a new ROS message into the buffer.
 
std::vector< std::string > getClients ()
 Gets the clients IDs that have buffered data.
 
std::vector< std::string > getFrames (const std::string &client_id)
 Gets the frame IDs for a specific client that has buffered data.
 
std::vector< Stamped< T > > get (const std::string &client_id="", const std::string &frame_id="", const std::string &topic="")
 Fetches all buffer samples.
 
std::vector< Stamped< T > > get (const int k, const std::string &client_id="", const std::string &frame_id="", const std::string &topic="")
 Fetches most recent k buffer samples.
 
std::vector< Stamped< T > > get (const rclcpp::Time &start_time, const rclcpp::Time &end_time, const std::string &client_id="", const std::string &frame_id="", const std::string &topic="")
 Fetches all buffer samples within specified timeframe.
 
std::vector< Stamped< T > > get (const int k, const rclcpp::Time &start_time, const rclcpp::Time &end_time, const std::string &client_id="", const std::string &frame_id="", const std::string &topic="")
 Fetches most recent k buffer samples within specified timeframe.
 
string_map< std::vector< Stamped< T > > > getWithTopic (const int k, const rclcpp::Time &start_time, const rclcpp::Time &end_time, const std::string &client_id="", const std::string &frame_id="", const std::string &topic="")
 Same as corresponding get, but returns samples grouped by topic.
 
std::string getInfo () const
 Returns a string representation of the buffers that are currently present.
 
void clearBuffer (const std::string &client_id, const std::string &topic)
 Clears buffer for a specific client and topic.
 
bool timeIsRunningBackwards (const std::string &client_id, const std::string &topic, const rclcpp::Time &stamp)
 Checks whether time is running backwards for a specific client and topic.
 

Protected Attributes

BufferManagermanager_ = nullptr
 managing BufferManager
 
string_map_2d< Buffer< std::shared_ptr< const T > > > buffer_by_client_topic_
 container for data buffers, stored by client ID and topic
 
string_map_2d< std::string > frame_by_client_topic_
 container to store frame ID by client ID and topic
 
string_map_2d< rclcpp::Time > last_stamp_by_client_topic_
 container to store the last time stamp for each client and topic
 
string_map_2d< std::shared_ptr< std::shared_mutex > > mutex_by_client_topic_
 container to store mutexes for locking buffer access
 
std::shared_mutex reconfigure_mutex_
 

Detailed Description

template<typename T>
class event_detector::BufferManager::DataBuffers< T >

Template class designed to hold all buffers for a specific data type.

An instance of this class manages the buffers for multiple clients / frames for a specific data type. It provides multiple generic getter functions.

Template Parameters
TROS data type to buffer

Definition at line 66 of file BufferManager.hpp.

Member Function Documentation

◆ clearBuffer()

template<typename T >
void event_detector::BufferManager::DataBuffers< T >::clearBuffer ( const std::string &  client_id,
const std::string &  topic 
)

Clears buffer for a specific client and topic.

Parameters
client_idclient ID
topictopic

◆ get() [1/4]

template<typename T >
std::vector< Stamped< T > > event_detector::BufferManager::DataBuffers< T >::get ( const int  k,
const rclcpp::Time &  start_time,
const rclcpp::Time &  end_time,
const std::string &  client_id = "",
const std::string &  frame_id = "",
const std::string &  topic = "" 
)

Fetches most recent k buffer samples within specified timeframe.

If end_time is 0, time filter is not used. If k is negative, no limit on the number of samples is imposed.

If no client or frame ID is given, data from all clients/frames is returned.

The returned data samples are stamped and sorted in ascending order.

Parameters
khow many recent samples to return
start_timestarting time filter
end_timeending time filter
client_idclient ID (optional)
frame_idframe ID (optional)
topictopic (optional)
Returns
std::vector<Stamped<T>> data samples

◆ get() [2/4]

template<typename T >
std::vector< Stamped< T > > event_detector::BufferManager::DataBuffers< T >::get ( const int  k,
const std::string &  client_id = "",
const std::string &  frame_id = "",
const std::string &  topic = "" 
)

Fetches most recent k buffer samples.

If k is negative, no limit on the number of samples is imposed.

If no client or frame ID is given, data from all clients/frames is returned.

The returned data samples are stamped and sorted in ascending order.

Parameters
khow many recent samples to return
client_idclient ID (optional)
frame_idframe ID (optional)
topictopic (optional)
Returns
std::vector<Stamped<T>> data samples

◆ get() [3/4]

template<typename T >
std::vector< Stamped< T > > event_detector::BufferManager::DataBuffers< T >::get ( const rclcpp::Time &  start_time,
const rclcpp::Time &  end_time,
const std::string &  client_id = "",
const std::string &  frame_id = "",
const std::string &  topic = "" 
)

Fetches all buffer samples within specified timeframe.

If end_time is 0, time filter is not used.

If no client or frame ID is given, data from all clients/frames is returned.

The returned data samples are stamped and sorted in ascending order.

Parameters
start_timestarting time filter
end_timeending time filter
client_idclient ID (optional)
frame_idframe ID (optional)
topictopic (optional)
Returns
std::vector<Stamped<T>> data samples

◆ get() [4/4]

template<typename T >
std::vector< Stamped< T > > event_detector::BufferManager::DataBuffers< T >::get ( const std::string &  client_id = "",
const std::string &  frame_id = "",
const std::string &  topic = "" 
)

Fetches all buffer samples.

If no client or frame ID is given, data from all clients/frames is returned.

The returned data samples are stamped and sorted in ascending order.

Parameters
client_idclient ID (optional)
frame_idframe ID (optional)
topictopic (optional)
Returns
std::vector<Stamped<T>> data samples

◆ getClients()

template<typename T >
std::vector< std::string > event_detector::BufferManager::DataBuffers< T >::getClients ( )

Gets the clients IDs that have buffered data.

Returns
std::vector<std::string> client IDs

◆ getFrames()

template<typename T >
std::vector< std::string > event_detector::BufferManager::DataBuffers< T >::getFrames ( const std::string &  client_id)

Gets the frame IDs for a specific client that has buffered data.

Parameters
client_idclient ID
Returns
std::vector<std::string> frame IDs

◆ getInfo()

template<typename T >
std::string event_detector::BufferManager::DataBuffers< T >::getInfo ( ) const

Returns a string representation of the buffers that are currently present.

Returns
std::string string representation of the buffers

◆ getWithTopic()

template<typename T >
string_map< std::vector< Stamped< T > > > event_detector::BufferManager::DataBuffers< T >::getWithTopic ( const int  k,
const rclcpp::Time &  start_time,
const rclcpp::Time &  end_time,
const std::string &  client_id = "",
const std::string &  frame_id = "",
const std::string &  topic = "" 
)

Same as corresponding get, but returns samples grouped by topic.

Parameters
start_timestarting time filter
end_timeending time filter
client_idclient ID (optional)
frame_idframe ID (optional)
topictopic (optional)
Returns
string_map<std::vector<Stamped<T>>> data samples by topic

◆ insert()

template<typename T >
void event_detector::BufferManager::DataBuffers< T >::insert ( const typename std::shared_ptr< const T > &  sample,
const rclcpp::Time &  stamp,
const std::string &  client_id,
const std::string &  topic,
const bool  clear_if_time_is_running_backwards = true 
)

Inserts a new ROS message into the buffer.

May be used as a ROS subscription callback. Buffer has to be initialized before first insertion. Supports ROS messages with or without header.

Parameters
samplenew data message
stampROS time stamp associated with the message
client_idclient ID
topicROS topic
clear_if_time_is_running_backwardswhether to clear the buffer if time is running backwards

◆ setBufferManager()

template<typename T >
void event_detector::BufferManager::DataBuffers< T >::setBufferManager ( BufferManager manager)

Assigns the managing BufferManager.

Parameters
managerBufferManager

◆ timeIsRunningBackwards()

template<typename T >
bool event_detector::BufferManager::DataBuffers< T >::timeIsRunningBackwards ( const std::string &  client_id,
const std::string &  topic,
const rclcpp::Time &  stamp 
)

Checks whether time is running backwards for a specific client and topic.

Parameters
client_idclient ID
topictopic
stampstamp to compare with the last known time stamp
Returns
bool whether time is running backwards

◆ update()

template<typename T >
void event_detector::BufferManager::DataBuffers< T >::update ( const std::vector< ClientConnection > &  clients)

Creates buffers and mutexes for topics mentioned in clients. If a buffer and mutex already exists for a topic, the old buffer and mutex will be retained and no new buffer and mutex will be created. Existing mutexes and buffers for topics that are not mentioned in clients will be deleted.

Parameters
clientsclient connections for which to set up buffers

Member Data Documentation

◆ buffer_by_client_topic_

template<typename T >
string_map_2d<Buffer<std::shared_ptr<const T> > > event_detector::BufferManager::DataBuffers< T >::buffer_by_client_topic_
protected

container for data buffers, stored by client ID and topic

Definition at line 256 of file BufferManager.hpp.

◆ frame_by_client_topic_

template<typename T >
string_map_2d<std::string> event_detector::BufferManager::DataBuffers< T >::frame_by_client_topic_
protected

container to store frame ID by client ID and topic

Definition at line 261 of file BufferManager.hpp.

◆ last_stamp_by_client_topic_

template<typename T >
string_map_2d<rclcpp::Time> event_detector::BufferManager::DataBuffers< T >::last_stamp_by_client_topic_
protected

container to store the last time stamp for each client and topic

Definition at line 266 of file BufferManager.hpp.

◆ manager_

template<typename T >
BufferManager* event_detector::BufferManager::DataBuffers< T >::manager_ = nullptr
protected

managing BufferManager

Definition at line 251 of file BufferManager.hpp.

◆ mutex_by_client_topic_

template<typename T >
string_map_2d<std::shared_ptr<std::shared_mutex> > event_detector::BufferManager::DataBuffers< T >::mutex_by_client_topic_
protected

container to store mutexes for locking buffer access

Definition at line 271 of file BufferManager.hpp.

◆ reconfigure_mutex_

template<typename T >
std::shared_mutex event_detector::BufferManager::DataBuffers< T >::reconfigure_mutex_
mutableprotected

mutex for reconfiguration

Definition at line 276 of file BufferManager.hpp.


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