Template Class ApproximateSync
Defined in File approximate_sync.hpp
Class Documentation
-
template<typename ...MsgTypes>
class ApproximateSync Public Types
-
using Callback = std::function<void(const std::vector<std::shared_ptr<const MsgTypes>>&...)>
The type of callback to expect from this sync. A typical callback function signature would be
void foo(const std::vector<std::shared_ptr<const MsgType>> &vec1, const std::vector<std::shared_ptr<const MsgType>> &vec2)
Public Functions
-
inline ApproximateSync(const std::vector<std::vector<std::string>> &topics, Callback cb, size_t queue_size)
Creates an exact sync like the one in ROS1, but with flexible number of topics per type.
- Parameters:
topics – vector of vector of topics, corresponding to message type. The first vector has all topics for type 1, second for type 2 etc.
cb – callback to invoke when sync is obtained. The callback signature looks different. For example for two message types, MsgType1 and MsgType2
void callback( const std::vector<MsgType1::ConstPtr> &m1, const std::vector<MsgType2::ConstPtr> &m2);
queue_size – depth of sync queue. A
queue_size
of 0 means unlimited queue.
-
inline size_t getNumberDropped() const
Query the number of messages dropped because they were not synced.
- Returns:
total number of dropped messages since last call to clearNumberDropped()
-
inline void clearNumberDropped()
Clears number of dropped messages to zero. The number of dropped messages can be queried with getNumberDropped().
-
inline const std::vector<std::vector<std::string>> &getTopics() const
Get topics with which this sync was created.
- Returns:
topics with which this sync was created.
-
inline size_t getQueueSize() const
Query the sync queue size.
- Returns:
size of sync queue
-
template<typename MsgPtrT>
inline void process(const std::string &topic, const MsgPtrT &msg) Call this method to feed data into the sync. Once a sync is obtained (all topics have messages for a given time), the sync will invoke the callback function.
- Parameters:
topic – topic of the message to be processed. Must be one of the topics provided when the sync was created.
msg – shared pointer to message to be processed. Message type must match positionally to topic used when the sync was created.
-
using Callback = std::function<void(const std::vector<std::shared_ptr<const MsgTypes>>&...)>