Class EndpointStatistics

Class Documentation

class EndpointStatistics

Rolling window statistics for a single topic endpoint (Publisher, Subscription). Default statistic is “Period”, that is the time between samples. But this also provides another set of APIs for “Age”, which is only relevant for subscriptions and is one measure of latency.

Public Functions

EndpointStatistics(EndpointType stat_type, const char *topic_name, const rmw_node_t *node, size_t window_size)
virtual ~EndpointStatistics() = default
void onMessage(MonoTime ts)
bool checkNewData()

Checks and clears new data flag.

Returns:

Whether any new messages have been added since last call

rosgraph_monitor_msgs::msg::TopicStatistic periodMsg()
void onAge(std::chrono::nanoseconds age)
bool checkNewAgeData()

Checks and clears new data flag.

Returns:

Whether any new messages have been added since last call

rosgraph_monitor_msgs::msg::TopicStatistic ageMsg()

Public Members

const rmw_node_t *const node_

Protected Attributes

std::atomic<bool> new_age_data_ = false
std::atomic<bool> new_data_ = false
EndpointType type_
std::string topic_name_
std::string node_name_
RollingMeanAccumulator<std::chrono::nanoseconds> period_acc_
RollingMeanAccumulator<std::chrono::nanoseconds> age_acc_
std::optional<MonoTime> last_ts_