Loading...
Searching...
No Matches
SignalStats.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16*/
17#ifndef IGNITION_MATH_SIGNALSTATS_HH_
18#define IGNITION_MATH_SIGNALSTATS_HH_
19
20#include <map>
21#include <memory>
22#include <string>
24#include <ignition/math/config.hh>
25
26namespace ignition
27{
28 namespace math
29 {
30 inline namespace IGNITION_MATH_VERSION_NAMESPACE
31 {
33 class SignalStatisticPrivate;
34
37 class IGNITION_MATH_VISIBLE SignalStatistic
38 {
40 public: SignalStatistic();
41
43 public: virtual ~SignalStatistic();
44
47 public: SignalStatistic(const SignalStatistic &_ss);
48
51 public: virtual double Value() const = 0;
52
55 public: virtual std::string ShortName() const = 0;
56
59 public: virtual size_t Count() const;
60
63 public: virtual void InsertData(const double _data) = 0;
64
66 public: virtual void Reset();
67
68#ifdef _WIN32
69// Disable warning C4251 which is triggered by
70// std::unique_ptr
71#pragma warning(push)
72#pragma warning(disable: 4251)
73#endif
75 protected: std::unique_ptr<SignalStatisticPrivate> dataPtr;
76#ifdef _WIN32
77#pragma warning(pop)
78#endif
79 };
80
81
84 class IGNITION_MATH_VISIBLE SignalMaximum : public SignalStatistic
85 {
86 // Documentation inherited.
87 public: virtual double Value() const;
88
91 public: virtual std::string ShortName() const;
92
93 // Documentation inherited.
94 public: virtual void InsertData(const double _data);
95 };
96
97
100 class IGNITION_MATH_VISIBLE SignalMean : public SignalStatistic
101 {
102 // Documentation inherited.
103 public: virtual double Value() const;
104
107 public: virtual std::string ShortName() const;
108
109 // Documentation inherited.
110 public: virtual void InsertData(const double _data);
111 };
112
113
116 class IGNITION_MATH_VISIBLE SignalMinimum : public SignalStatistic
117 {
118 // Documentation inherited.
119 public: virtual double Value() const;
120
123 public: virtual std::string ShortName() const;
124
125 // Documentation inherited.
126 public: virtual void InsertData(const double _data);
127 };
128
129
133 class IGNITION_MATH_VISIBLE SignalRootMeanSquare : public SignalStatistic
134 {
135 // Documentation inherited.
136 public: virtual double Value() const;
137
140 public: virtual std::string ShortName() const;
141
142 // Documentation inherited.
143 public: virtual void InsertData(const double _data);
144 };
145
146
152 class IGNITION_MATH_VISIBLE SignalMaxAbsoluteValue : public SignalStatistic
153 {
154 // Documentation inherited.
155 public: virtual double Value() const;
156
159 public: virtual std::string ShortName() const;
160
161 // Documentation inherited.
162 public: virtual void InsertData(const double _data);
163 };
164
165
169 class IGNITION_MATH_VISIBLE SignalVariance : public SignalStatistic
170 {
171 // Documentation inherited.
172 public: virtual double Value() const;
173
176 public: virtual std::string ShortName() const;
177
178 // Documentation inherited.
179 public: virtual void InsertData(const double _data);
180 };
181
182
184 class SignalStatsPrivate;
185
188 class IGNITION_MATH_VISIBLE SignalStats
189 {
191 public: SignalStats();
192
194 public: ~SignalStats();
195
198 public: SignalStats(const SignalStats &_ss);
199
205 public: size_t Count() const;
206
211 public: std::map<std::string, double> Map() const;
212
215 public: void InsertData(const double _data);
216
226 public: bool InsertStatistic(const std::string &_name);
227
235 public: bool InsertStatistics(const std::string &_names);
236
238 public: void Reset();
239
243 public: SignalStats &operator=(const SignalStats &_s);
244
245#ifdef _WIN32
246// Disable warning C4251 which is triggered by
247// std::unique_ptr
248#pragma warning(push)
249#pragma warning(disable: 4251)
250#endif
252 private: std::unique_ptr<SignalStatsPrivate> dataPtr;
253#ifdef _WIN32
254#pragma warning(pop)
255#endif
256 };
257 }
259 }
260}
261#endif
262
ignition/math/SignalStats.hh
Definition SignalStats.hh:153
virtual std::string ShortName() const
Get a short version of the name of this statistical measure.
virtual void InsertData(const double _data)
Add a new sample to the statistical measure.
virtual double Value() const
Get the current value of the statistical measure.
Computing the maximum value of a discretely sampled signal.
Definition SignalStats.hh:85
virtual double Value() const
Get the current value of the statistical measure.
virtual void InsertData(const double _data)
Add a new sample to the statistical measure.
virtual std::string ShortName() const
Get a short version of the name of this statistical measure.
Computing the mean value of a discretely sampled signal.
Definition SignalStats.hh:101
virtual double Value() const
Get the current value of the statistical measure.
virtual std::string ShortName() const
Get a short version of the name of this statistical measure.
virtual void InsertData(const double _data)
Add a new sample to the statistical measure.
Computing the minimum value of a discretely sampled signal.
Definition SignalStats.hh:117
virtual double Value() const
Get the current value of the statistical measure.
virtual void InsertData(const double _data)
Add a new sample to the statistical measure.
virtual std::string ShortName() const
Get a short version of the name of this statistical measure.
Computing the square root of the mean squared value of a discretely sampled signal.
Definition SignalStats.hh:134
virtual void InsertData(const double _data)
Add a new sample to the statistical measure.
virtual std::string ShortName() const
Get a short version of the name of this statistical measure.
virtual double Value() const
Get the current value of the statistical measure.
std::unique_ptr< SignalStatisticPrivate > dataPtr
Pointer to private data.
Definition SignalStats.hh:75
SignalStatistic(const SignalStatistic &_ss)
Copy constructor.
virtual void InsertData(const double _data)=0
Add a new sample to the statistical measure.
virtual std::string ShortName() const =0
Get a short version of the name of this statistical measure.
virtual size_t Count() const
Get number of data points in measurement.
virtual double Value() const =0
Get the current value of the statistical measure.
std::map< std::string, double > Map() const
Get the current values of each statistical measure, stored in a map using the short name as the key.
bool InsertStatistics(const std::string &_names)
Add multiple statistics.
void InsertData(const double _data)
Add a new sample to the statistical measures.
bool InsertStatistic(const std::string &_name)
Add a new type of statistic.
SignalStats(const SignalStats &_ss)
Copy constructor.
SignalStats & operator=(const SignalStats &_s)
Assignment operator.
size_t Count() const
Get number of data points in first statistic.
Computing the incremental variance of a discretely sampled signal.
Definition SignalStats.hh:170
virtual void InsertData(const double _data)
Add a new sample to the statistical measure.
virtual std::string ShortName() const
Get a short version of the name of this statistical measure.
virtual double Value() const
Get the current value of the statistical measure.
Math classes and function useful in robot applications.
Definition Angle.hh:42
Definition Angle.hh:40