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);
67 
68 private:
69 
70  // Range of window length, in seconds
73 
74  // Range of acceptable messages in window.
75  // Window size will be adjusted if number of observed is
76  // outside this range.
79 
81 
82  // remember, if this message type has a header
83  bool hasHeader_;
84 
85  // frequency to publish statistics
87 
88  // publisher for statistics data
90 
91  struct StatData {
92  // last time, we published /statistics data
94  // arrival times of all messages within the current window
95  std::list<ros::Time> arrival_time_list;
96  // age of all messages within the current window (if available)
97  std::list<ros::Duration> age_list;
98  // number of dropped messages
99  uint64_t dropped_msgs;
100  // latest sequence number observed (if available)
101  uint64_t last_seq;
102  // latest total traffic volume observed
103  uint64_t stat_bytes_last;
104  };
105 
106  // storage for statistics data
107  std::map<std::string, struct StatData> map_;
108 };
109 
110 }
111 
112 #endif
std::list< ros::Time > arrival_time_list
Definition: statistics.h:95
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROS initialization function.
Definition: init.cpp:486
std::map< std::string, struct StatData > map_
Definition: statistics.h:107
Manages an advertisement on a specific topic.
Definition: publisher.h:47
ros::Publisher pub_
Definition: statistics.h:89
This class logs statistics data about a ROS connection and publishs them periodically on a common top...
Definition: statistics.h:49
std::list< ros::Duration > age_list
Definition: statistics.h:97


roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim, Dirk Thomas
autogenerated on Mon Feb 28 2022 23:33:27