Gazebo Math

API Reference

6.15.1
gz/math/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 GZ_MATH_SIGNALSTATS_HH_
18 #define GZ_MATH_SIGNALSTATS_HH_
19 
20 #include <map>
21 #include <memory>
22 #include <string>
23 #include <gz/math/Helpers.hh>
24 #include <gz/math/config.hh>
25 
26 namespace ignition
27 {
28  namespace math
29  {
30  // Inline bracket to help doxygen filtering.
31  inline namespace IGNITION_MATH_VERSION_NAMESPACE {
32  //
34  class SignalStatisticPrivate;
35 
38  class IGNITION_MATH_VISIBLE SignalStatistic
39  {
41  public: SignalStatistic();
42 
44  public: virtual ~SignalStatistic();
45 
48  public: SignalStatistic(const SignalStatistic &_ss);
49 
52  public: virtual double Value() const = 0;
53 
56  public: virtual std::string ShortName() const = 0;
57 
60  public: virtual size_t Count() const;
61 
64  public: virtual void InsertData(const double _data) = 0;
65 
67  public: virtual void Reset();
68 
69 #ifdef _WIN32
70 // Disable warning C4251 which is triggered by
71 // std::unique_ptr
72 #pragma warning(push)
73 #pragma warning(disable: 4251)
74 #endif
75  protected: std::unique_ptr<SignalStatisticPrivate> dataPtr;
77 #ifdef _WIN32
78 #pragma warning(pop)
79 #endif
80  };
81 
84  class IGNITION_MATH_VISIBLE SignalMaximum : public SignalStatistic
85  {
86  // Documentation inherited.
87  public: virtual double Value() const override;
88 
91  public: virtual std::string ShortName() const override;
92 
93  // Documentation inherited.
94  public: virtual void InsertData(const double _data) override;
95  };
96 
99  class IGNITION_MATH_VISIBLE SignalMean : public SignalStatistic
100  {
101  // Documentation inherited.
102  public: virtual double Value() const override;
103 
106  public: virtual std::string ShortName() const override;
107 
108  // Documentation inherited.
109  public: virtual void InsertData(const double _data) override;
110  };
111 
114  class IGNITION_MATH_VISIBLE SignalMinimum : public SignalStatistic
115  {
116  // Documentation inherited.
117  public: virtual double Value() const override;
118 
121  public: virtual std::string ShortName() const override;
122 
123  // Documentation inherited.
124  public: virtual void InsertData(const double _data) override;
125  };
126 
130  class IGNITION_MATH_VISIBLE SignalRootMeanSquare : public SignalStatistic
131  {
132  // Documentation inherited.
133  public: virtual double Value() const override;
134 
137  public: virtual std::string ShortName() const override;
138 
139  // Documentation inherited.
140  public: virtual void InsertData(const double _data) override;
141  };
142 
148  class IGNITION_MATH_VISIBLE SignalMaxAbsoluteValue : public SignalStatistic
149  {
150  // Documentation inherited.
151  public: virtual double Value() const override;
152 
155  public: virtual std::string ShortName() const override;
156 
157  // Documentation inherited.
158  public: virtual void InsertData(const double _data) override;
159  };
160 
164  class IGNITION_MATH_VISIBLE SignalVariance : public SignalStatistic
165  {
166  // Documentation inherited.
167  public: virtual double Value() const override;
168 
171  public: virtual std::string ShortName() const override;
172 
173  // Documentation inherited.
174  public: virtual void InsertData(const double _data) override;
175  };
176 
178  class SignalStatsPrivate;
179 
182  class IGNITION_MATH_VISIBLE SignalStats
183  {
185  public: SignalStats();
186 
188  public: ~SignalStats();
189 
192  public: SignalStats(const SignalStats &_ss);
193 
199  public: size_t Count() const;
200 
205  public: std::map<std::string, double> Map() const;
206 
209  public: void InsertData(const double _data);
210 
220  public: bool InsertStatistic(const std::string &_name);
221 
229  public: bool InsertStatistics(const std::string &_names);
230 
232  public: void Reset();
233 
237  public: SignalStats &operator=(const SignalStats &_s);
238 
239 #ifdef _WIN32
240 // Disable warning C4251 which is triggered by
241 // std::unique_ptr
242 #pragma warning(push)
243 #pragma warning(disable: 4251)
244 #endif
245  private: std::unique_ptr<SignalStatsPrivate> dataPtr;
247 #ifdef _WIN32
248 #pragma warning(pop)
249 #endif
250  };
251  }
252  }
253 }
254 #endif
255 
virtual double Value() const override
Get the current value of the statistical measure.
void Reset()
Forget all previous data.
Definition: gz/math/AdditivelySeparableScalarField3.hh:27
STL class.
Computing the mean value of a discretely sampled signal.
Definition: gz/math/SignalStats.hh:99
Computing the square root of the mean squared value of a discretely sampled signal.
Definition: gz/math/SignalStats.hh:130
virtual double Value() const =0
Get the current value of the statistical measure.
void InsertData(const double _data)
Add a new sample to the statistical measures.
Computing the maximum of the absolute value of a discretely sampled signal. Also known as the maximum...
Definition: gz/math/SignalStats.hh:148
virtual void Reset()
Forget all previous data.
virtual ~SignalStatistic()
Destructor.
virtual void InsertData(const double _data) override
Add a new sample to the statistical measure.
virtual std::string ShortName() const override
Get a short version of the name of this statistical measure.
SignalStats & operator=(const SignalStats &_s)
Assignment operator.
bool InsertStatistic(const std::string &_name)
Add a new type of statistic.
virtual std::string ShortName() const override
Get a short version of the name of this statistical measure.
virtual std::string ShortName() const override
Get a short version of the name of this 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.
virtual std::string ShortName() const override
Get a short version of the name of this statistical measure.
virtual std::string ShortName() const override
Get a short version of the name of this statistical measure.
Collection of statistics for a scalar signal.
Definition: gz/math/SignalStats.hh:182
virtual std::string ShortName() const override
Get a short version of the name of this statistical measure.
virtual std::string ShortName() const =0
Get a short version of the name of this statistical measure.
STL class.
Statistical properties of a discrete time scalar signal.
Definition: gz/math/SignalStats.hh:38
Computing the incremental variance of a discretely sampled signal.
Definition: gz/math/SignalStats.hh:164
virtual void InsertData(const double _data) override
Add a new sample to the statistical measure.
size_t Count() const
Get number of data points in first statistic. Technically you can have different numbers of data poin...
virtual void InsertData(const double _data) override
Add a new sample to the statistical measure.
virtual void InsertData(const double _data) override
Add a new sample to the statistical measure.
virtual void InsertData(const double _data)=0
Add a new sample to the statistical measure.
virtual double Value() const override
Get the current value of the statistical measure.
virtual double Value() const override
Get the current value of the statistical measure.
virtual double Value() const override
Get the current value of the statistical measure.
virtual double Value() const override
Get the current value of the statistical measure.
Computing the minimum value of a discretely sampled signal.
Definition: gz/math/SignalStats.hh:114
virtual void InsertData(const double _data) override
Add a new sample to the statistical measure.
std::unique_ptr< SignalStatisticPrivate > dataPtr
Pointer to private data.
Definition: gz/math/SignalStats.hh:76
virtual void InsertData(const double _data) override
Add a new sample to the statistical measure.
bool InsertStatistics(const std::string &_names)
Add multiple statistics.
virtual size_t Count() const
Get number of data points in measurement.
virtual double Value() const override
Get the current value of the statistical measure.
Computing the maximum value of a discretely sampled signal.
Definition: gz/math/SignalStats.hh:84