Overte C++ Documentation
ExponentialSmoothingFilter.h
1 //
2 // Created by Anthony Thibault 2017/12/17
3 // Copyright 2017 High Fidelity, Inc.
4 //
5 // Distributed under the Apache License, Version 2.0.
6 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 //
8 
9 #ifndef hifi_Controllers_Filters_Exponential_Smoothing_h
10 #define hifi_Controllers_Filters_Exponential_Smoothing_h
11 
12 #include "../Filter.h"
13 
14 namespace controller {
15 
16  class ExponentialSmoothingFilter : public Filter {
17  REGISTER_FILTER_CLASS(ExponentialSmoothingFilter);
18 
19  public:
20  ExponentialSmoothingFilter() {}
21  ExponentialSmoothingFilter(float rotationConstant, float translationConstant) :
22  _translationConstant(translationConstant), _rotationConstant(rotationConstant) {}
23 
24  AxisValue apply(AxisValue value) const override { return value; }
25  Pose apply(Pose value) const override;
26  bool parseParameters(const QJsonValue& parameters) override;
27 
28  private:
29 
30  // Constant between 0 and 1.
31  // 1 indicates no smoothing at all, poses are passed through unaltered.
32  // Values near 1 are less smooth with lower latency.
33  // Values near 0 are more smooth with higher latency.
34  float _translationConstant { 0.375f };
35  float _rotationConstant { 0.375f };
36 
37  mutable Pose _prevSensorValue { Pose() }; // sensor space
38  };
39 
40 }
41 
42 #endif