statistics.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013-2014, Dariush Forouher
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice,
7  * this list of conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution.
11  * * Neither the names of Willow Garage, Inc. nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef ROSCPP_STATISTICS_H
29 #define ROSCPP_STATISTICS_H
30 
31 #include "forwards.h"
32 #include "poll_set.h"
33 #include "common.h"
34 #include "publisher.h"
35 #include <ros/time.h>
37 #include <map>
38 
39 namespace ros
40 {
41 
49 class ROSCPP_DECL StatisticsLogger
50 {
51 public:
52 
57 
61  void init(const SubscriptionCallbackHelperPtr& helper);
62 
66  void callback(const boost::shared_ptr<M_string>& connection_header, const std::string& topic, const std::string& callerid, const SerializedMessage& m, const uint64_t& bytes_sent, const ros::Time& received_time, bool dropped, int connection_id);
67 
68 private:
69 
70  // Range of window length, in seconds
74 
75  // Range of acceptable messages in window.
76  // Window size will be adjusted if number of observed is
77  // outside this range.
80 
82 
83  // remember, if this message type has a header
84  bool hasHeader_;
85 
86  // frequency to publish statistics
88 
89  // publisher for statistics data
91 
92  struct StatData {
93  // last time, we published /statistics data
95  // arrival times of all messages within the current window
96  std::list<ros::Time> arrival_time_list;
97  // age of all messages within the current window (if available)
98  std::list<ros::Duration> age_list;
99  // number of dropped messages
100  uint64_t dropped_msgs;
101  // latest sequence number observed (if available)
102  uint64_t last_seq;
103  // latest total traffic volume observed
104  uint64_t stat_bytes_last;
105  };
106 
107  // storage for statistics data
108  std::map<std::string, struct StatData> map_;
109 };
110 
111 }
112 
113 #endif
ros::StatisticsLogger::min_window
int min_window
Definition: statistics.h:72
ros::SerializedMessage
ros::init
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROS initialization function.
Definition: init.cpp:500
boost::shared_ptr< SubscriptionCallbackHelper >
forwards.h
ros::StatisticsLogger::StatData::last_seq
uint64_t last_seq
Definition: statistics.h:102
ros
ros::StatisticsLogger::pub_frequency_
double pub_frequency_
Definition: statistics.h:87
time.h
ros::StatisticsLogger::StatData::age_list
std::list< ros::Duration > age_list
Definition: statistics.h:98
ros::StatisticsLogger::previous_connection_id
int previous_connection_id
Definition: statistics.h:73
subscription_callback_helper.h
ros::StatisticsLogger::hasHeader_
bool hasHeader_
Definition: statistics.h:84
poll_set.h
ros::StatisticsLogger::max_window
int max_window
Definition: statistics.h:71
ros::StatisticsLogger::pub_
ros::Publisher pub_
Definition: statistics.h:90
ros::StatisticsLogger::map_
std::map< std::string, struct StatData > map_
Definition: statistics.h:108
ros::StatisticsLogger::StatData::last_publish
ros::Time last_publish
Definition: statistics.h:94
publisher.h
ros::StatisticsLogger::StatData::stat_bytes_last
uint64_t stat_bytes_last
Definition: statistics.h:104
ros::Publisher
Manages an advertisement on a specific topic.
Definition: publisher.h:51
ros::StatisticsLogger::enable_statistics
bool enable_statistics
Definition: statistics.h:81
ros::StatisticsLogger::max_elements
int max_elements
Definition: statistics.h:78
ros::Time
ros::StatisticsLogger
This class logs statistics data about a ROS connection and publishs them periodically on a common top...
Definition: statistics.h:49
ros::StatisticsLogger::StatData
Definition: statistics.h:92
ros::StatisticsLogger::StatData::arrival_time_list
std::list< ros::Time > arrival_time_list
Definition: statistics.h:96
ros::StatisticsLogger::StatData::dropped_msgs
uint64_t dropped_msgs
Definition: statistics.h:100
ros::StatisticsLogger::min_elements
int min_elements
Definition: statistics.h:79


roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim, Dirk Thomas , Jacob Perron
autogenerated on Sat Sep 14 2024 02:59:35