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


sick_scan_xd
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Fri Oct 25 2024 02:47:12