Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
include
ros
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
>
36
#include "
ros/subscription_callback_helper.h
"
37
#include <map>
38
39
namespace
ros
40
{
41
49
class
ROSCPP_DECL
StatisticsLogger
50
{
51
public
:
52
56
StatisticsLogger
();
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
71
int
max_window
;
72
int
min_window
;
73
74
// these are soft constrains
75
int
max_elements
;
76
int
min_elements
;
77
78
bool
enable_statistics
;
79
80
// remember, if this message type has a header
81
bool
hasHeader_
;
82
83
// frequency to publish statistics
84
double
pub_frequency_
;
85
86
// publisher for statistics data
87
ros::Publisher
pub_
;
88
89
struct
StatData
{
90
// last time, we published /statistics data
91
ros::Time
last_publish
;
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
ros::StatisticsLogger::StatData::last_seq
uint64_t last_seq
Definition:
statistics.h:99
ros::StatisticsLogger::min_elements
int min_elements
Definition:
statistics.h:76
ros::StatisticsLogger::pub_frequency_
double pub_frequency_
Definition:
statistics.h:84
ros::StatisticsLogger::StatData::arrival_time_list
std::list< ros::Time > arrival_time_list
Definition:
statistics.h:93
ros::StatisticsLogger::min_window
int min_window
Definition:
statistics.h:72
time.h
ros::Time
ros::StatisticsLogger::StatData
Definition:
statistics.h:89
ros::StatisticsLogger::StatData::last_publish
ros::Time last_publish
Definition:
statistics.h:91
ros::StatisticsLogger::hasHeader_
bool hasHeader_
Definition:
statistics.h:81
ros::init
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROS initialization function.
Definition:
init.cpp:470
forwards.h
subscription_callback_helper.h
ros::StatisticsLogger::max_window
int max_window
Definition:
statistics.h:71
poll_set.h
boost::shared_ptr< SubscriptionCallbackHelper >
ros::StatisticsLogger::map_
std::map< std::string, struct StatData > map_
Definition:
statistics.h:105
ros::SerializedMessage
ros::StatisticsLogger::enable_statistics
bool enable_statistics
Definition:
statistics.h:78
ros::StatisticsLogger::max_elements
int max_elements
Definition:
statistics.h:75
ros
ros::Publisher
Manages an advertisement on a specific topic.
Definition:
publisher.h:47
ros::StatisticsLogger::pub_
ros::Publisher pub_
Definition:
statistics.h:87
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::age_list
std::list< ros::Duration > age_list
Definition:
statistics.h:95
publisher.h
ros::StatisticsLogger::StatData::stat_bytes_last
uint64_t stat_bytes_last
Definition:
statistics.h:101
ros::StatisticsLogger::StatData::dropped_msgs
uint64_t dropped_msgs
Definition:
statistics.h:97
roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim, Dirk Thomas
autogenerated on Mon Nov 2 2020 03:52:26