single_sync.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef _SINGLE_SYNC_HEADER_
  2. #define _SINGLE_SYNC_HEADER_
  3. #include "ros/ros.h"
  4. #include <boost/circular_buffer.hpp>
  5. template<typename T1, typename T2, typename T3>
  6. class SingleSynchronizer
  7. {
  8. public:
  9. SingleSynchronizer(const std::string sub1_topic, const std::string sub2_topic, const std::string pub1_topic, const std::string pub2_topic, const std::string req_topic, const std::string ns);
  10. void run();
  11. private:
  12. bool buf_flag_;
  13. /* user var */
  14. boost::circular_buffer<T1> type1_ringbuf_;
  15. boost::circular_buffer<T2> type2_ringbuf_;
  16. ros::Publisher type1_pub_;
  17. ros::Publisher type2_pub_;
  18. ros::Publisher sync_time_diff_pub_;
  19. bool is_req_;
  20. T1* p_type1_buf_;
  21. T2* p_type2_buf_;
  22. ros::Subscriber type1_sub_;
  23. ros::Subscriber type2_sub_;
  24. ros::Subscriber req_sub_;
  25. std::string req_topic_;
  26. void publish_msg(T1* p_type1_buf_, T2* p_type2_buf_);
  27. bool publish();
  28. void type1_callback(const typename T1::ConstPtr& type1_msg);
  29. void type2_callback(const typename T2::ConstPtr& type2_msg);
  30. void req_callback(const typename T3::ConstPtr& req_msg);
  31. };
  32. #include "impl/single_sync_impl.hpp"
  33. #endif