GNSS-SDR  0.0.19
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  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
11  * This file is part of GNSS-SDR.
12  *
13  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
14  * SPDX-License-Identifier: GPL-3.0-or-later
15  *
16  * -----------------------------------------------------------------------------
17  */
18 
19 
20 #ifndef GNSS_SDR_EXPONENTIAL_SMOOTHER_H
21 #define GNSS_SDR_EXPONENTIAL_SMOOTHER_H
22 
23 #include <vector>
24 
25 /** \addtogroup Tracking
26  * \{ */
27 /** \addtogroup Tracking_libs
28  * \{ */
29 
30 
31 /*! \brief
32  * Class that implements a first-order exponential smoother.
33  *
34  * smoothed_value[k] = alpha * raw + (1-alpha) * smoothed_value[k-1]
35  *
36  * The length of the initialization can be controlled with
37  * set_samples_for_initialization(int num_samples)
38  */
40 {
41 public:
42  Exponential_Smoother(); //!< Constructor
43  ~Exponential_Smoother() = default; //!< Destructor
44 
45  Exponential_Smoother(Exponential_Smoother&&) = default; //!< Move operator
46  Exponential_Smoother& operator=(Exponential_Smoother&& /*other*/) = default; //!< Move assignment operator
47 
48  void set_alpha(float alpha); //!< 0 < alpha < 1. The higher, the most responsive, but more variance. Default value: 0.001
49  void set_samples_for_initialization(int num_samples); //!< Number of samples averaged for initialization. Default value: 200
50  void reset();
51  void set_min_value(float value);
52  void set_offset(float offset);
53  float smooth(float raw);
54  double smooth(double raw);
55 
56 private:
57  std::vector<float> init_buffer_;
58  float alpha_{0.001};
59  float one_minus_alpha_{0.999};
60  float old_value_{0.0};
61  float min_value_{25.0};
62  float offset_{12.0};
63  int samples_for_initialization_{200};
64  int init_counter_{0};
65  bool initializing_{true};
66 };
67 
68 
69 /** \} */
70 /** \} */
71 #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...