Gazebo Math

API Reference

6.15.1
gz/math/RollingMean.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 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_ROLLINGMEAN_HH_
18 #define GZ_MATH_ROLLINGMEAN_HH_
19 
20 #include <memory>
21 #include <gz/math/Export.hh>
22 #include <gz/math/config.hh>
23 
24 namespace ignition
25 {
26  namespace math
27  {
28  // Inline bracket to help doxygen filtering.
29  inline namespace IGNITION_MATH_VERSION_NAMESPACE {
30  //
31  // Forward declarations.
32  class RollingMeanPrivate;
33 
38  class IGNITION_MATH_VISIBLE RollingMean
39  {
43  public: explicit RollingMean(size_t _windowSize = 10);
44 
46  public: ~RollingMean();
47 
52  public: double Mean() const;
53 
56  public: size_t Count() const;
57 
60  public: void Push(double _value);
61 
63  public: void Clear();
64 
68  public: void SetWindowSize(size_t _windowSize);
69 
72  public: size_t WindowSize() const;
73 
74 #ifdef _WIN32
75 // Disable warning C4251 which is triggered by
76 // std::unique_ptr
77 #pragma warning(push)
78 #pragma warning(disable: 4251)
79 #endif
80  private: std::unique_ptr<RollingMeanPrivate> dataPtr;
82 #ifdef _WIN32
83 #pragma warning(pop)
84 #endif
85  };
86  }
87  }
88 }
89 
90 #endif
double Mean() const
Get the mean value.
Definition: gz/math/AdditivelySeparableScalarField3.hh:27
void Push(double _value)
Insert a new value.
void Clear()
Remove all the pushed values.
RollingMean(size_t _windowSize=10)
Constructor.
size_t WindowSize() const
Get the window size.
A class that computes the mean over a series of data points. The window size determines the maximum n...
Definition: gz/math/RollingMean.hh:38
void SetWindowSize(size_t _windowSize)
Set the new window size. This will also clear the data. Nothing happens if the _windowSize is zero.
size_t Count() const
Get the number of data points.