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  // these are hard constrains
73 
74  // these are soft constrains
77 
79 
80  // remember, if this message type has a header
81  bool hasHeader_;
82 
83  // frequency to publish statistics
85 
86  // publisher for statistics data
88 
89  struct StatData {
90  // last time, we published /statistics data
92  // arrival times of all messages within the current window
93  std::list<ros::Time> arrival_time_list;
94  // age of all messages within the current window (if available)
95  std::list<ros::Duration> age_list;
96  // number of dropped messages
97  uint64_t dropped_msgs;
98  // latest sequence number observered (if available)
99  uint64_t last_seq;
100  // latest total traffic volume observed
101  uint64_t stat_bytes_last;
102  };
103 
104  // storage for statistics data
105  std::map<std::string, struct StatData> map_;
106 };
107 
108 }
109 
110 #endif
std::list< ros::Time > arrival_time_list
Definition: statistics.h:93
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROS initialization function.
Definition: init.cpp:470
std::map< std::string, struct StatData > map_
Definition: statistics.h:105
Manages an advertisement on a specific topic.
Definition: publisher.h:47
ros::Publisher pub_
Definition: statistics.h:87
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:95


roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim
autogenerated on Sun Feb 3 2019 03:29:54