Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
message_filters::Cache< M > Class Template Reference

Stores a time history of messages. More...

#include <cache.h>

Inheritance diagram for message_filters::Cache< M >:
Inheritance graph
[legend]

Public Types

typedef ros::MessageEvent< M const > EventType
 
typedef boost::shared_ptr< M const > MConstPtr
 
- Public Types inherited from message_filters::SimpleFilter< M >
typedef boost::function< void(const MConstPtr &)> Callback
 
typedef boost::function< void(const EventType &)> EventCallback
 
typedef ros::MessageEvent< M const > EventType
 
typedef boost::shared_ptr< M const > MConstPtr
 

Public Member Functions

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. More...
 
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. More...
 
template<class F >
 Cache (F &f, unsigned int cache_size=1)
 
 Cache (unsigned int cache_size=1)
 
template<class F >
void connectInput (F &f)
 
MConstPtr getElemAfterTime (const ros::Time &time) const
 Grab the oldest element that occurs right after the specified time. More...
 
MConstPtr getElemBeforeTime (const ros::Time &time) const
 Grab the newest element that occurs right before the specified time. More...
 
std::vector< MConstPtrgetInterval (const ros::Time &start, const ros::Time &end) const
 Receive a vector of messages that occur between a start and end time (inclusive). More...
 
ros::Time getLatestTime () const
 Returns the timestamp associated with the newest packet cache. More...
 
ros::Time getOldestTime () const
 Returns the timestamp associated with the oldest packet cache. More...
 
std::vector< MConstPtrgetSurroundingInterval (const ros::Time &start, const ros::Time &end) const
 Retrieve the smallest interval of messages that surrounds an interval from start to end. More...
 
void setCacheSize (unsigned int cache_size)
 
 ~Cache ()
 
- Public Member Functions inherited from message_filters::SimpleFilter< M >
const std::string & getName ()
 Get the name of this filter. For debugging use. More...
 
template<typename P >
Connection registerCallback (const boost::function< void(P)> &callback)
 Register a callback to be called when this filter has passed. More...
 
template<typename C >
Connection registerCallback (const C &callback)
 Register a callback to be called when this filter has passed. More...
 
template<typename P >
Connection registerCallback (void(*callback)(P))
 Register a callback to be called when this filter has passed. More...
 
template<typename T , typename P >
Connection registerCallback (void(T::*callback)(P), T *t)
 Register a callback to be called when this filter has passed. More...
 
void setName (const std::string &name)
 Set the name of this filter. For debugging use. More...
 

Private Member Functions

void callback (const EventType &evt)
 

Private Attributes

std::deque< EventTypecache_
 Cache for the messages. More...
 
boost::mutex cache_lock_
 Lock for cache_. More...
 
unsigned int cache_size_
 Maximum number of elements allowed in the cache. More...
 
Connection incoming_connection_
 

Additional Inherited Members

- Protected Member Functions inherited from message_filters::SimpleFilter< M >
void signalMessage (const MConstPtr &msg)
 Call all registered callbacks, passing them the specified message. More...
 
void signalMessage (const ros::MessageEvent< M const > &event)
 Call all registered callbacks, passing them the specified message. More...
 

Detailed Description

template<class M>
class message_filters::Cache< 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 roscpp subscription callbacks, ie.

void callback(const boost::shared_ptr<M const>&);

Definition at line 98 of file cache.h.

Member Typedef Documentation

◆ EventType

template<class M >
typedef ros::MessageEvent<M const> message_filters::Cache< M >::EventType

Definition at line 134 of file cache.h.

◆ MConstPtr

template<class M >
typedef boost::shared_ptr<M const> message_filters::Cache< M >::MConstPtr

Definition at line 133 of file cache.h.

Constructor & Destructor Documentation

◆ Cache() [1/2]

template<class M >
template<class F >
message_filters::Cache< M >::Cache ( F &  f,
unsigned int  cache_size = 1 
)
inline

Definition at line 137 of file cache.h.

◆ Cache() [2/2]

template<class M >
message_filters::Cache< M >::Cache ( unsigned int  cache_size = 1)
inline

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

Definition at line 148 of file cache.h.

◆ ~Cache()

template<class M >
message_filters::Cache< M >::~Cache ( )
inline

Definition at line 159 of file cache.h.

Member Function Documentation

◆ add() [1/2]

template<class M >
void message_filters::Cache< M >::add ( const EventType evt)
inline

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.

Definition at line 192 of file cache.h.

◆ add() [2/2]

template<class M >
void message_filters::Cache< M >::add ( const MConstPtr msg)
inline

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.

Definition at line 183 of file cache.h.

◆ callback()

template<class M >
void message_filters::Cache< M >::callback ( const EventType evt)
inlineprivate

Definition at line 392 of file cache.h.

◆ connectInput()

template<class M >
template<class F >
void message_filters::Cache< M >::connectInput ( F &  f)
inline

Definition at line 154 of file cache.h.

◆ getElemAfterTime()

template<class M >
MConstPtr message_filters::Cache< M >::getElemAfterTime ( const ros::Time time) const
inline

Grab the oldest element that occurs right after the specified time.

Parameters
timeTime that must occur right before the returned elem
Returns
shared_ptr to the oldest elem that occurs after 'time'. NULL if doesn't exist

Definition at line 331 of file cache.h.

◆ getElemBeforeTime()

template<class M >
MConstPtr message_filters::Cache< M >::getElemBeforeTime ( const ros::Time time) const
inline

Grab the newest element that occurs right before the specified time.

Parameters
timeTime that must occur right after the returned elem
Returns
shared_ptr to the newest elem that occurs before 'time'. NULL if doesn't exist

Definition at line 303 of file cache.h.

◆ getInterval()

template<class M >
std::vector<MConstPtr> message_filters::Cache< M >::getInterval ( const ros::Time start,
const ros::Time end 
) const
inline

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
startThe start of the requested interval
endThe end of the requested interval

Definition at line 230 of file cache.h.

◆ getLatestTime()

template<class M >
ros::Time message_filters::Cache< M >::getLatestTime ( ) const
inline

Returns the timestamp associated with the newest packet cache.

Definition at line 359 of file cache.h.

◆ getOldestTime()

template<class M >
ros::Time message_filters::Cache< M >::getOldestTime ( ) const
inline

Returns the timestamp associated with the oldest packet cache.

Definition at line 376 of file cache.h.

◆ getSurroundingInterval()

template<class M >
std::vector<MConstPtr> message_filters::Cache< M >::getSurroundingInterval ( const ros::Time start,
const ros::Time end 
) const
inline

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)

Definition at line 269 of file cache.h.

◆ setCacheSize()

template<class M >
void message_filters::Cache< M >::setCacheSize ( unsigned int  cache_size)
inline

Set the size of the cache.

Parameters
cache_sizeThe new size the cache should be. Must be > 0

Definition at line 168 of file cache.h.

Member Data Documentation

◆ cache_

template<class M >
std::deque<EventType> message_filters::Cache< M >::cache_
private

Cache for the messages.

Definition at line 398 of file cache.h.

◆ cache_lock_

template<class M >
boost::mutex message_filters::Cache< M >::cache_lock_
mutableprivate

Lock for cache_.

Definition at line 397 of file cache.h.

◆ cache_size_

template<class M >
unsigned int message_filters::Cache< M >::cache_size_
private

Maximum number of elements allowed in the cache.

Definition at line 399 of file cache.h.

◆ incoming_connection_

template<class M >
Connection message_filters::Cache< M >::incoming_connection_
private

Definition at line 401 of file cache.h.


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


message_filters
Author(s): Josh Faust, Vijay Pradeep, Dirk Thomas , Jacob Perron
autogenerated on Thu Nov 23 2023 04:01:54