event_detector 1.0.0
|
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 | |
BufferManager * | manager_ = 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_ |
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.
T | ROS data type to buffer |
Definition at line 66 of file BufferManager.hpp.
void event_detector::BufferManager::DataBuffers< T >::clearBuffer | ( | const std::string & | client_id, |
const std::string & | topic | ||
) |
Clears buffer for a specific client and topic.
client_id | client ID |
topic | topic |
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.
k | how many recent samples to return |
start_time | starting time filter |
end_time | ending time filter |
client_id | client ID (optional) |
frame_id | frame ID (optional) |
topic | topic (optional) |
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.
k | how many recent samples to return |
client_id | client ID (optional) |
frame_id | frame ID (optional) |
topic | topic (optional) |
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.
start_time | starting time filter |
end_time | ending time filter |
client_id | client ID (optional) |
frame_id | frame ID (optional) |
topic | topic (optional) |
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.
client_id | client ID (optional) |
frame_id | frame ID (optional) |
topic | topic (optional) |
std::vector< std::string > event_detector::BufferManager::DataBuffers< T >::getClients | ( | ) |
Gets the clients IDs that have buffered data.
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.
client_id | client ID |
std::string event_detector::BufferManager::DataBuffers< T >::getInfo | ( | ) | const |
Returns a string representation of the buffers that are currently present.
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.
start_time | starting time filter |
end_time | ending time filter |
client_id | client ID (optional) |
frame_id | frame ID (optional) |
topic | topic (optional) |
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.
sample | new data message |
stamp | ROS time stamp associated with the message |
client_id | client ID |
topic | ROS topic |
clear_if_time_is_running_backwards | whether to clear the buffer if time is running backwards |
void event_detector::BufferManager::DataBuffers< T >::setBufferManager | ( | BufferManager * | manager | ) |
Assigns the managing BufferManager.
manager | BufferManager |
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.
client_id | client ID |
topic | topic |
stamp | stamp to compare with the last known time stamp |
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.
clients | client connections for which to set up buffers |
|
protected |
container for data buffers, stored by client ID and topic
Definition at line 256 of file BufferManager.hpp.
|
protected |
container to store frame ID by client ID and topic
Definition at line 261 of file BufferManager.hpp.
|
protected |
container to store the last time stamp for each client and topic
Definition at line 266 of file BufferManager.hpp.
|
protected |
managing BufferManager
Definition at line 251 of file BufferManager.hpp.
|
protected |
container to store mutexes for locking buffer access
Definition at line 271 of file BufferManager.hpp.
|
mutableprotected |
mutex for reconfiguration
Definition at line 276 of file BufferManager.hpp.