gnss-sdr/src/algorithms/tracking/libs/exponential_smoother.h

72 lines
2.2 KiB
C
Raw Permalink Normal View History

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
*
* 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.
*
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
* 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
*/
#ifndef GNSS_SDR_EXPONENTIAL_SMOOTHER_H
#define GNSS_SDR_EXPONENTIAL_SMOOTHER_H
2019-04-25 06:50:21 +00:00
#include <vector>
/** \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:
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);
2019-04-25 06:50:21 +00:00
private:
std::vector<float> init_buffer_;
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
};
/** \} */
/** \} */
#endif // GNSS_SDR_EXPONENTIAL_SMOOTHER_H