1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-06-25 22:43:14 +00:00
gnss-sdr/src/algorithms/tracking/libs/tracking_loop_filter.h
Cillian O'Driscoll 26b18c19ee Added a generic tracking_loop_filter class
This implements a generic loop filter. Based on the analog PLL filters
from Kaplan and Hegarty, with a bilinear (Tustin's) transform from
s-plane to z-plane ( 1/s -> T/2 ( 1 + z^-1 )/( 1 - z^-1 ) )

Also added tests. Note the "truth" outputs
were derived from an Octave implementation of the loop filter and
Octave's builtin filter function
2015-11-26 15:12:26 +00:00

99 lines
3.0 KiB
C++

/*!
* \file tracking_loop_filter.h
* \brief Generic 1st to 3rd order loop filter implementation
* \author Cillian O'Driscoll, 2015. cillian.odriscoll(at)gmail.com
*
* Class implementing a generic 1st, 2nd or 3rd order loop filter. Based
* on the bilinear transform of the standard Weiner filter.
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is part of GNSS-SDR.
*
* GNSS-SDR is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GNSS-SDR is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_TRACKING_LOOP_FILTER_H_
#define GNSS_SDR_TRACKING_LOOP_FILTER_H_
#include <vector>
/*!
* \brief This class implements a generic 1st, 2nd or 3rd order loop filter
*
*/
class Tracking_loop_filter
{
private:
// Store the last inputs and outputs:
std::vector< float > d_inputs;
std::vector< float > d_outputs;
// Store the filter coefficients:
std::vector< float > d_input_coefficients;
std::vector< float > d_output_coefficients;
// The loop order:
int d_loop_order;
// The current index in the i/o arrays:
int d_current_index;
// Should the last integrator be included?
bool d_include_last_integrator;
// The noise bandwidth (in Hz)
// Note this is an approximation only valid when the product of this
// number and the update interval (T) is small.
float d_noise_bandwidth;
// Loop update interval
float d_update_interval;
// Compute the filter coefficients:
void update_coefficients(void);
public:
float get_noise_bandwidth(void) const;
float get_update_interval(void) const;
bool get_include_last_integrator(void) const;
int get_order(void) const;
void set_noise_bandwidth( float noise_bandwidth );
void set_update_interval( float update_interval );
void set_include_last_integrator( bool include_last_integrator );
void set_order( int loop_order );
void initialize(float initial_output = 0.0);
float apply(float current_input );
Tracking_loop_filter(float update_interval, float noise_bandwidth,
int loop_order = 2,
bool include_last_integrator = false );
Tracking_loop_filter();
~Tracking_loop_filter();
};
#endif