ROS 2 rclcpp + rcl - rolling  rolling-a919a6e5
ROS 2 C++ Client Library with ROS Client Library
Public Member Functions | Protected Member Functions | List of all members
rclcpp::topic_statistics::SubscriptionTopicStatistics Class 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 rmw_message_info_t &message_info, 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

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

Definition at line 52 of file subscription_topic_statistics.hpp.

Constructor & Destructor Documentation

◆ SubscriptionTopicStatistics()

rclcpp::topic_statistics::SubscriptionTopicStatistics::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 71 of file subscription_topic_statistics.hpp.

Member Function Documentation

◆ get_current_collector_data()

std::vector<StatisticData> rclcpp::topic_statistics::SubscriptionTopicStatistics::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 156 of file subscription_topic_statistics.hpp.

◆ handle_message()

virtual void rclcpp::topic_statistics::SubscriptionTopicStatistics::handle_message ( const rmw_message_info_t &  message_info,
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
message_infothe message info corresponding to the received message
now_nanosecondscurrent time in nanoseconds

Definition at line 98 of file subscription_topic_statistics.hpp.

References rclcpp::Time::nanoseconds().

Here is the call graph for this function:

◆ publish_message_and_reset_measurements()

virtual void rclcpp::topic_statistics::SubscriptionTopicStatistics::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 121 of file subscription_topic_statistics.hpp.

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

Here is the call graph for this function:

◆ set_publisher_timer()

void rclcpp::topic_statistics::SubscriptionTopicStatistics::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 112 of file subscription_topic_statistics.hpp.


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