GNSS-SDR  0.0.13
An Open Source GNSS Software Defined Receiver
exponential_smoother.h
Go to the documentation of this file.
1 /*!
2  * \file exponential_smoother.h
3  * \brief Class that implements an exponential smoother
4  * \authors Carles Fernandez, 2019 cfernandez@cttc.es
5  *
6  * Class that implements a first-order exponential smoother.
7  *
8  * -----------------------------------------------------------------------------
9  *
10  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
11  *
12  * GNSS-SDR is a software defined Global Navigation
13  * Satellite Systems receiver
14  *
15  * This file is part of GNSS-SDR.
16  *
17  * SPDX-License-Identifier: GPL-3.0-or-later
18  *
19  * -----------------------------------------------------------------------------
20  */
21 
22 
23 #ifndef GNSS_SDR_EXPONENTIAL_SMOOTHER_H
24 #define GNSS_SDR_EXPONENTIAL_SMOOTHER_H
25 
26 #include <vector>
27 
28 /*! \brief
29  * Class that implements a first-order exponential smoother.
30  *
31  * smoothed_value[k] = alpha * raw + (1-alpha) * smoothed_value[k-1]
32  *
33  * The length of the initialization can be controlled with
34  * set_samples_for_initialization(int num_samples)
35  */
37 {
38 public:
39  Exponential_Smoother(); //!< Constructor
40  ~Exponential_Smoother() = default; //!< Destructor
41 
42  Exponential_Smoother(Exponential_Smoother&&) = default; //!< Move operator
43  Exponential_Smoother& operator=(Exponential_Smoother&& /*other*/) = default; //!< Move assignment operator
44 
45  void set_alpha(float alpha); //!< 0 < alpha < 1. The higher, the most responsive, but more variance. Default value: 0.001
46  void set_samples_for_initialization(int num_samples); //!< Number of samples averaged for initialization. Default value: 200
47  void reset();
48  void set_min_value(float value);
49  void set_offset(float offset);
50  float smooth(float raw);
51  double smooth(double raw);
52 
53 private:
54  std::vector<float> init_buffer_;
55  float alpha_; // takes value 0.0001 if not set
56  float one_minus_alpha_;
57  float old_value_;
58  float min_value_;
59  float offset_;
60  int samples_for_initialization_;
61  int init_counter_;
62  bool initializing_;
63 };
64 
65 #endif // GNSS_SDR_EXPONENTIAL_SMOOTHER_H
Class that implements a first-order exponential smoother.
Exponential_Smoother & operator=(Exponential_Smoother &&)=default
Move assignment operator.
void set_samples_for_initialization(int num_samples)
Number of samples averaged for initialization. Default value: 200.
Exponential_Smoother()
Constructor.
~Exponential_Smoother()=default
Destructor.
void set_alpha(float alpha)
0 < alpha < 1. The higher, the most responsive, but more variance. Default value: 0...