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
// Range of window length, in seconds
71
int
max_window
;
72
int
min_window
;
73
74
// Range of acceptable messages in window.
75
// Window size will be adjusted if number of observed is
76
// outside this range.
77
int
max_elements
;
78
int
min_elements
;
79
80
bool
enable_statistics
;
81
82
// remember, if this message type has a header
83
bool
hasHeader_
;
84
85
// frequency to publish statistics
86
double
pub_frequency_
;
87
88
// publisher for statistics data
89
ros::Publisher
pub_
;
90
91
struct
StatData
{
92
// last time, we published /statistics data
93
ros::Time
last_publish
;
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
ros::StatisticsLogger::StatData::last_seq
uint64_t last_seq
Definition:
statistics.h:101
ros::StatisticsLogger::min_elements
int min_elements
Definition:
statistics.h:78
ros::StatisticsLogger::pub_frequency_
double pub_frequency_
Definition:
statistics.h:86
ros::StatisticsLogger::StatData::arrival_time_list
std::list< ros::Time > arrival_time_list
Definition:
statistics.h:95
ros::StatisticsLogger::min_window
int min_window
Definition:
statistics.h:72
time.h
ros::Time
ros::StatisticsLogger::StatData
Definition:
statistics.h:91
ros::StatisticsLogger::StatData::last_publish
ros::Time last_publish
Definition:
statistics.h:93
ros::StatisticsLogger::hasHeader_
bool hasHeader_
Definition:
statistics.h:83
ros::init
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROS initialization function.
Definition:
init.cpp:486
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:107
ros::SerializedMessage
ros::StatisticsLogger::enable_statistics
bool enable_statistics
Definition:
statistics.h:80
ros::StatisticsLogger::max_elements
int max_elements
Definition:
statistics.h:77
ros
ros::Publisher
Manages an advertisement on a specific topic.
Definition:
publisher.h:47
ros::StatisticsLogger::pub_
ros::Publisher pub_
Definition:
statistics.h:89
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:97
publisher.h
ros::StatisticsLogger::StatData::stat_bytes_last
uint64_t stat_bytes_last
Definition:
statistics.h:103
ros::StatisticsLogger::StatData::dropped_msgs
uint64_t dropped_msgs
Definition:
statistics.h:99
roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim, Dirk Thomas
autogenerated on Mon Feb 28 2022 23:33:27