rclcpp  master
C++ ROS Client Library API
Public Member Functions | Protected Member Functions | List of all members
rclcpp::topic_statistics::SubscriptionTopicStatistics< CallbackMessageT > Class Template Reference

#include <subscription_topic_statistics.hpp>

Public Member Functions

 SubscriptionTopicStatistics (const std::string &node_name, rclcpp::Publisher< statistics_msgs::msg::MetricsMessage >::SharedPtr publisher)
 Construct a SubscriptionTopicStatistics object. More...
 
virtual ~SubscriptionTopicStatistics ()
 
virtual void handle_message (const CallbackMessageT &received_message, const rclcpp::Time now_nanoseconds) const
 Handle a message received by the subscription to collect statistics. More...
 
void set_publisher_timer (rclcpp::TimerBase::SharedPtr publisher_timer)
 Set the timer used to publish statistics messages. More...
 
virtual void publish_message_and_reset_measurements ()
 Publish a populated MetricsStatisticsMessage. More...
 

Protected Member Functions

std::vector< StatisticData > get_current_collector_data () const
 Return a vector of all the currently collected data. More...
 

Detailed Description

template<typename CallbackMessageT>
class rclcpp::topic_statistics::SubscriptionTopicStatistics< CallbackMessageT >

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

Template Parameters
CallbackMessageTthe subscribed message type

Constructor & Destructor Documentation

◆ SubscriptionTopicStatistics()

template<typename CallbackMessageT >
rclcpp::topic_statistics::SubscriptionTopicStatistics< CallbackMessageT >::SubscriptionTopicStatistics ( const std::string node_name,
rclcpp::Publisher< statistics_msgs::msg::MetricsMessage >::SharedPtr  publisher 
)
inline

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_namethe name of the node, which created this instance, in order to denote topic source
publisherinstance constructed by the node in order to publish statistics data. This class owns the publisher.
Exceptions
std::invalid_argumentif publisher pointer is nullptr

◆ ~SubscriptionTopicStatistics()

template<typename CallbackMessageT >
virtual rclcpp::topic_statistics::SubscriptionTopicStatistics< CallbackMessageT >::~SubscriptionTopicStatistics ( )
inlinevirtual

Member Function Documentation

◆ handle_message()

template<typename CallbackMessageT >
virtual void rclcpp::topic_statistics::SubscriptionTopicStatistics< CallbackMessageT >::handle_message ( const CallbackMessageT &  received_message,
const rclcpp::Time  now_nanoseconds 
) const
inlinevirtual

Handle a message received by the subscription to collect statistics.

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

Parameters
received_messagethe message received by the subscription
now_nanosecondscurrent time in nanoseconds

◆ set_publisher_timer()

template<typename CallbackMessageT >
void rclcpp::topic_statistics::SubscriptionTopicStatistics< CallbackMessageT >::set_publisher_timer ( rclcpp::TimerBase::SharedPtr  publisher_timer)
inline

Set the timer used to publish statistics messages.

Parameters
publisher_timerthe timer to fire the publisher, created by the node

◆ publish_message_and_reset_measurements()

template<typename CallbackMessageT >
virtual void rclcpp::topic_statistics::SubscriptionTopicStatistics< CallbackMessageT >::publish_message_and_reset_measurements ( )
inlinevirtual

Publish a populated MetricsStatisticsMessage.

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

◆ get_current_collector_data()

template<typename CallbackMessageT >
std::vector<StatisticData> rclcpp::topic_statistics::SubscriptionTopicStatistics< CallbackMessageT >::get_current_collector_data ( ) const
inlineprotected

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

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