Template Class Cache
Defined in File cache.h
Inheritance Relationships
Base Type
public message_filters::SimpleFilter< M >
(Template Class SimpleFilter)
Class Documentation
-
template<class M>
class Cache : public message_filters::SimpleFilter<M> Stores a time history of messages.
Given a stream of messages, the most recent N messages are cached in a ring buffer, from which time intervals of the cache can then be retrieved by the client.
Cache immediately passes messages through to its output connections.
CONNECTIONS
Cache’s input and output connections are both of the same signature as rclcpp subscription callbacks, ie.
void callback(const std::shared_ptr<M const>&);
Public Functions
-
inline Cache(unsigned int cache_size = 1)
Initializes a Message Cache without specifying a parent filter. This implies that in order to populate the cache, the user then has to call add themselves, or connectInput() is called later
-
inline ~Cache()
-
inline void setCacheSize(unsigned int cache_size)
Set the size of the cache.
- Parameters:
cache_size – The new size the cache should be. Must be > 0
-
inline void add(const MConstPtr &msg)
Add a message to the cache, and pop off any elements that are too old. This method is registered with a data provider when connectTo is called.
-
inline void add(const EventType &evt)
Add a message to the cache, and pop off any elements that are too old. This method is registered with a data provider when connectTo is called.
-
inline std::vector<MConstPtr> getInterval(const rclcpp::Time &start, const rclcpp::Time &end) const
Receive a vector of messages that occur between a start and end time (inclusive).
This call is non-blocking, and only aggregates messages it has already received. It will not wait for messages have not yet been received, but occur in the interval.
- Parameters:
start – The start of the requested interval
end – The end of the requested interval
-
inline std::vector<MConstPtr> getSurroundingInterval(const rclcpp::Time &start, const rclcpp::Time &end) const
Retrieve the smallest interval of messages that surrounds an interval from start to end.
If the messages in the cache do not surround (start,end), then this will return the interval that gets closest to surrounding (start,end)
-
inline MConstPtr getElemBeforeTime(const rclcpp::Time &time) const
Grab the newest element that occurs right before the specified time.
- Parameters:
time – Time that must occur right after the returned elem
- Returns:
shared_ptr to the newest elem that occurs before ‘time’. NULL if doesn’t exist
-
inline MConstPtr getElemAfterTime(const rclcpp::Time &time) const
Grab the oldest element that occurs right after the specified time.
- Parameters:
time – Time that must occur right before the returned elem
- Returns:
shared_ptr to the oldest elem that occurs after ‘time’. NULL if doesn’t exist
-
inline rclcpp::Time getLatestTime() const
Returns the timestamp associated with the newest packet cache.
-
inline rclcpp::Time getOldestTime() const
Returns the timestamp associated with the oldest packet cache.
-
inline Cache(unsigned int cache_size = 1)