ROS 2 rclcpp + rcl - humble  humble
ROS 2 C++ Client Library with ROS Client Library
Public Member Functions | Protected Member Functions | List of all members
rclcpp::topic_statistics::SubscriptionTopicStatistics< CallbackMessageT > Class Template Reference

#include <rclcpp/topic_statistics/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 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

Definition at line 55 of file subscription_topic_statistics.hpp.

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

Definition at line 80 of file subscription_topic_statistics.hpp.

Member Function Documentation

◆ 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

Definition at line 165 of file subscription_topic_statistics.hpp.

◆ 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

Definition at line 107 of file subscription_topic_statistics.hpp.

References rclcpp::Time::nanoseconds().

Here is the call graph for this function:

◆ 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.

Definition at line 130 of file subscription_topic_statistics.hpp.

References rclcpp::Publisher< MessageT, AllocatorT >::publish().

Here is the call graph for this function:

◆ 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

Definition at line 121 of file subscription_topic_statistics.hpp.


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