2019-04-25 06:50:21 +00:00
|
|
|
/*!
|
|
|
|
* \file exponential_smoother.h
|
|
|
|
* \brief Class that implements an exponential smoother
|
|
|
|
* \authors Carles Fernandez, 2019 cfernandez@cttc.es
|
|
|
|
*
|
|
|
|
* Class that implements a first-order exponential smoother.
|
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2019-04-25 06:50:21 +00:00
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
2019-04-25 06:50:21 +00:00
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2019-04-25 06:50:21 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2019-04-25 06:50:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2020-02-08 09:10:46 +00:00
|
|
|
#ifndef GNSS_SDR_EXPONENTIAL_SMOOTHER_H
|
|
|
|
#define GNSS_SDR_EXPONENTIAL_SMOOTHER_H
|
2019-04-25 06:50:21 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2020-11-01 12:37:19 +00:00
|
|
|
/** \addtogroup Tracking
|
|
|
|
* \{ */
|
|
|
|
/** \addtogroup Tracking_libs
|
|
|
|
* \{ */
|
|
|
|
|
|
|
|
|
2019-04-25 06:50:21 +00:00
|
|
|
/*! \brief
|
|
|
|
* Class that implements a first-order exponential smoother.
|
|
|
|
*
|
|
|
|
* smoothed_value[k] = alpha * raw + (1-alpha) * smoothed_value[k-1]
|
|
|
|
*
|
|
|
|
* The length of the initialization can be controlled with
|
|
|
|
* set_samples_for_initialization(int num_samples)
|
|
|
|
*/
|
|
|
|
class Exponential_Smoother
|
|
|
|
{
|
|
|
|
public:
|
2020-06-23 07:47:58 +00:00
|
|
|
Exponential_Smoother(); //!< Constructor
|
|
|
|
~Exponential_Smoother() = default; //!< Destructor
|
|
|
|
|
|
|
|
Exponential_Smoother(Exponential_Smoother&&) = default; //!< Move operator
|
|
|
|
Exponential_Smoother& operator=(Exponential_Smoother&& /*other*/) = default; //!< Move assignment operator
|
|
|
|
|
2019-07-06 10:34:27 +00:00
|
|
|
void set_alpha(float alpha); //!< 0 < alpha < 1. The higher, the most responsive, but more variance. Default value: 0.001
|
|
|
|
void set_samples_for_initialization(int num_samples); //!< Number of samples averaged for initialization. Default value: 200
|
2019-04-25 06:50:21 +00:00
|
|
|
void reset();
|
|
|
|
void set_min_value(float value);
|
|
|
|
void set_offset(float offset);
|
|
|
|
float smooth(float raw);
|
|
|
|
double smooth(double raw);
|
2020-06-23 07:47:58 +00:00
|
|
|
|
2019-04-25 06:50:21 +00:00
|
|
|
private:
|
2020-06-23 07:47:58 +00:00
|
|
|
std::vector<float> init_buffer_;
|
2021-10-11 13:13:12 +00:00
|
|
|
float alpha_{0.001};
|
|
|
|
float one_minus_alpha_{0.999};
|
|
|
|
float old_value_{0.0};
|
|
|
|
float min_value_{25.0};
|
|
|
|
float offset_{12.0};
|
|
|
|
int samples_for_initialization_{200};
|
|
|
|
int init_counter_{0};
|
|
|
|
bool initializing_{true};
|
2019-04-25 06:50:21 +00:00
|
|
|
};
|
|
|
|
|
2020-11-01 12:37:19 +00:00
|
|
|
|
|
|
|
/** \} */
|
|
|
|
/** \} */
|
2020-02-08 09:10:46 +00:00
|
|
|
#endif // GNSS_SDR_EXPONENTIAL_SMOOTHER_H
|