Class SubscriptionManager

Class Documentation

class SubscriptionManager

Public Functions

inline SubscriptionManager()
template<typename MessageT>
inline void add_subscription(const std::string &topic_name, size_t expected_number_of_messages, const rclcpp::QoS &qos = rclcpp::QoS{rmw_qos_profile_default.depth})
template<typename MessageT>
inline std::vector<std::shared_ptr<MessageT>> get_received_messages(const std::string &topic_name)
template<typename Timeout>
inline bool spin_and_wait_for_matched(const std::vector<rclcpp::PublisherBase*> &publishers, Timeout timeout, size_t n_subscribers_to_match = 1)

Wait until publishers will be connected to the subscribers or timeout occur.

Template Parameters:

Timeout – Data type for timeout duration from std::chrono:: namespace

Parameters:
  • publishers – List of raw pointers to the publishers

  • timeout – Maximum time duration during which discovery should happen.

  • n_subscribers_to_match – Number of subscribers each publisher should have for match.

Returns:

true if publishers have specified number of subscribers, otherwise false.

inline bool spin_and_wait_for_matched(const std::vector<std::string> &topic_names, std::chrono::duration<double> timeout = std::chrono::seconds(10), size_t n_publishers_to_match = 1)

Wait until publishers will be connected to the subscriptions or timeout occur.

Parameters:
  • topic_names – List of topic names

  • timeout – Maximum time duration during which discovery should happen.

  • n_publishers_to_match – Number of publishers each subscription should have for match.

Returns:

true if subscriptions have specified number of publishers, otherwise false.

inline std::future<void> spin_subscriptions(std::chrono::duration<double> timeout = std::chrono::seconds(10))
inline void spin_subscriptions_sync()