Class SubscriptionTopicStatistics

Class Documentation

class SubscriptionTopicStatistics

Class used to collect, measure, and publish topic statistics data. Current statistics supported for subscribers are received message age and received message period.

Public Functions

inline SubscriptionTopicStatistics(const std::string &node_name, rclcpp::Publisher<statistics_msgs::msg::MetricsMessage>::SharedPtr publisher)

Construct a SubscriptionTopicStatistics object.

This object wraps utilities, defined in libstatistics_collector, to collect, measure, and publish topic statistics data. This throws an invalid_argument if the input publisher is null.

Parameters:
  • node_name – the name of the node, which created this instance, in order to denote topic source

  • publisher – instance constructed by the node in order to publish statistics data. This class owns the publisher.

Throws:

std::invalid_argument – if publisher pointer is nullptr

inline virtual ~SubscriptionTopicStatistics()
inline virtual void handle_message(const rmw_message_info_t &message_info, const rclcpp::Time now_nanoseconds) const

Handle a message received by the subscription to collect statistics.

This method acquires a lock to prevent race conditions to collectors list.

Parameters:
  • message_info – the message info corresponding to the received message

  • now_nanoseconds – current time in nanoseconds

inline void set_publisher_timer(rclcpp::TimerBase::SharedPtr publisher_timer)

Set the timer used to publish statistics messages.

Parameters:

publisher_timer – the timer to fire the publisher, created by the node

inline virtual void publish_message_and_reset_measurements()

Publish a populated MetricsStatisticsMessage.

This method acquires a lock to prevent race conditions to collectors list.

Protected Functions

inline std::vector<StatisticData> get_current_collector_data() const

Return a vector of all the currently collected data.

This method acquires a lock to prevent race conditions to collectors list.

Returns:

a vector of all the collected data