GNSS-SDR 0.0.21
An Open Source GNSS Software Defined Receiver
Loading...
Searching...
No Matches
tracking_discriminators.h
Go to the documentation of this file.
1/*!
2 * \file tracking_discriminators.h
3 * \brief Interface of a library with a set of code tracking and carrier
4 * tracking discriminators.
5 * \authors <ul>
6 * <li> Javier Arribas, 2011. jarribas(at)cttc.es
7 * <li> Luis Esteve, 2012. luis(at)epsilon-formacion.com
8 * </ul>
9 *
10 * Library with a set of code tracking and carrier tracking discriminators
11 * that is used by the tracking algorithms.
12 *
13 * -----------------------------------------------------------------------------
14 *
15 * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
16 * This file is part of GNSS-SDR.
17 *
18 * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
19 * SPDX-License-Identifier: GPL-3.0-or-later
20 *
21 * -----------------------------------------------------------------------------
22 */
23
24#ifndef GNSS_SDR_TRACKING_DISCRIMINATORS_H
25#define GNSS_SDR_TRACKING_DISCRIMINATORS_H
26
27#include <gnuradio/gr_complex.h>
28#include <cmath>
29
30/** \addtogroup Tracking
31 * \{ */
32/** \addtogroup Tracking_libs
33 * \{ */
34
35
36/*! brief FLL four quadrant arctan discriminator
37 *
38 * FLL four quadrant arctan discriminator:
39 * \f{equation}
40 * \frac{\phi_2-\phi_1}{t_2-t1}=\frac{ATAN2(cross,dot)}{t_1-t_2},
41 * \f}
42 * where \f$cross=I_{PS1}Q_{PS2}-I_{PS2}Q_{PS1}\f$ and \f$dot=I_{PS1}I_{PS2}+Q_{PS1}Q_{PS2}\f$,
43 * \f$I_{PS1},Q_{PS1}\f$ are the inphase and quadrature prompt correlator outputs respectively at sample time \f$t_1\f$, and
44 * \f$I_{PS2},Q_{PS2}\f$ are the inphase and quadrature prompt correlator outputs respectively at sample time \f$t_2\f$. The output is in [radians/second].
45 */
46double fll_four_quadrant_atan(gr_complex prompt_s1, gr_complex prompt_s2, double t1, double t2);
47
48
49/*
50 * FLL differential arctan discriminator:
51 * \f{equation}
52 * e_{atan}(k)=\frac{1}{t_1-t_2}\text{phase_unwrap}(\tan^-1(\frac{Q(k)}{I(k)})-\tan^-1(\frac{Q(k-1)}{I(k-1)}))
53 * \f}
54 * The output is in [radians/second].
55 */
56double fll_diff_atan(gr_complex prompt_s1, gr_complex prompt_s2, double t1, double t2);
57
58
59/*! \brief Phase unwrapping function, input is [rad]
60 */
61double phase_unwrap(double phase_rad);
62
63
64/*! \brief PLL four quadrant arctan discriminator
65 *
66 * PLL four quadrant arctan discriminator:
67 * \f{equation}
68 * \phi=ATAN2(Q_{PS},I_{PS}),
69 * \f}
70 * where \f$I_{PS1},Q_{PS1}\f$ are the inphase and quadrature prompt correlator outputs respectively. The output is in [radians].
71 */
72double pll_four_quadrant_atan(gr_complex prompt_s1);
73
74
75/*! \brief PLL Costas loop two quadrant arctan discriminator
76 *
77 * PLL Costas loop two quadrant arctan discriminator:
78 * \f{equation}
79 * \phi=ATAN\left(\frac{Q_{PS}}{I_{PS}}\right),
80 * \f}
81 * where \f$I_{PS1},Q_{PS1}\f$ are the inphase and quadrature prompt correlator outputs respectively. The output is in [radians].
82 */
83double pll_cloop_two_quadrant_atan(gr_complex prompt_s1);
84
85
86/*! \brief DLL Noncoherent Early minus Late envelope normalized discriminator
87 *
88 * DLL Noncoherent Early minus Late envelope normalized discriminator:
89 * \f{equation}
90 * error = \frac{y_{intercept} - \text{slope} * \epsilon}{\text{slope}} \frac{E-L}{E+L},
91 * \f}
92 * where \f$E=\sqrt{I_{ES}^2+Q_{ES}^2}\f$ is the Early correlator output absolute value and
93 * \f$L=\sqrt{I_{LS}^2+Q_{LS}^2}\f$ is the Late correlator output absolute value. The output is in [chips].
94 */
95double dll_nc_e_minus_l_normalized(gr_complex early_s1, gr_complex late_s1, float spc = 0.5, float slope = 1.0, float y_intercept = 1.0);
96
97
98/*! \brief DLL Noncoherent Very Early Minus Late Power (VEMLP) normalized discriminator
99 *
100 * DLL Noncoherent Very Early Minus Late Power (VEMLP) normalized discriminator, using the outputs
101 * of four correlators, Very Early (VE), Early (E), Late (L) and Very Late (VL):
102 * \f{equation}
103 * error=\frac{E-L}{E+L},
104 * \f}
105 * where \f$E=\sqrt{I_{VE}^2+Q_{VE}^2+I_{E}^2+Q_{E}^2}\f$ and
106 * \f$L=\sqrt{I_{VL}^2+Q_{VL}^2+I_{L}^2+Q_{L}^2}\f$ . The output is in [chips].
107 */
108double dll_nc_vemlp_normalized(gr_complex very_early_s1, gr_complex early_s1, gr_complex late_s1, gr_complex very_late_s1);
109
110
111template <typename Fun>
112double CalculateSlope(Fun &&f, double x)
113{
114 static constexpr double dx = 1e-6;
115
116 return (f(x + dx / 2.0) - f(x - dx / 2.0)) / dx;
117}
118
119template <typename Fun>
120double CalculateSlopeAbs(Fun &&f, double x)
121{
122 static constexpr double dx = 1e-6;
123
124 return (std::abs(f(x + dx / 2.0)) - std::abs(f(x - dx / 2.0))) / dx;
125}
126
127template <typename Fun>
128double GetYIntercept(Fun &&f, double x)
129{
130 double slope = CalculateSlope(f, x);
131 double y1 = f(x);
132
133 return y1 - slope * x;
134}
135
136template <typename Fun>
137double GetYInterceptAbs(Fun &&f, double x)
138{
139 double slope = CalculateSlopeAbs(f, x);
140 double y1 = std::abs(f(x));
141 return y1 - slope * x;
142}
143
144// SinBocCorrelationFunction and CosBocCorrelationFunction from
145// Sousa, F. and Nunes, F., "New Expressions for the Autocorrelation
146// Function of BOC GNSS Signals", NAVIGATION - Journal of the Institute
147// of Navigation, March 2013.
148//
149template <int M = 1, int N = M>
150double SinBocCorrelationFunction(double offset_in_chips)
151{
152 static constexpr int TWO_P = 2 * M / N;
153
154 double abs_tau = std::abs(offset_in_chips);
155
156 if (abs_tau > 1.0)
157 {
158 return 0.0;
159 }
160
161 int k = static_cast<int>(std::ceil(TWO_P * abs_tau));
162
163 double sgn = ((k & 0x01) == 0 ? 1.0 : -1.0); // (-1)^k
164
165 return sgn * (2.0 * (k * k - k * TWO_P - k) / TWO_P + 1.0 +
166 (2 * TWO_P - 2 * k + 1) * abs_tau);
167}
168
169
170template <int M = 1, int N = M>
171double CosBocCorrelationFunction(double offset_in_chips)
172{
173 static constexpr int TWO_P = 2 * M / N;
174
175 double abs_tau = std::abs(offset_in_chips);
176
177 if (abs_tau > 1.0)
178 {
179 return 0.0;
180 }
181
182 int k = static_cast<int>(std::floor(2.0 * TWO_P * abs_tau));
183
184 if ((k & 0x01) == 0) // k is even
185 {
186 double sgn = ((k >> 1) & 0x01 ? -1.0 : 1.0); // (-1)^(k/2)
187
188 return sgn * ((2 * k * TWO_P + 2 * TWO_P - k * k) / (2.0 * TWO_P) + (-2 * TWO_P + k - 1) * abs_tau);
189 }
190 else
191 {
192 double sgn = (((k + 1) >> 1) & 0x01 ? -1.0 : 1.0); // (-1)^((k+1)/2)
193
194 return sgn * ((k * k + 2 * k - 2 * k * TWO_P + 1) / (2.0 * TWO_P) + (2 * TWO_P - k - 2) * abs_tau);
195 }
196}
197
198
199/** \} */
200/** \} */
201#endif // GNSS_SDR_TRACKING_DISCRIMINATORS_H
double pll_four_quadrant_atan(gr_complex prompt_s1)
PLL four quadrant arctan discriminator.
double dll_nc_e_minus_l_normalized(gr_complex early_s1, gr_complex late_s1, float spc=0.5, float slope=1.0, float y_intercept=1.0)
DLL Noncoherent Early minus Late envelope normalized discriminator.
double phase_unwrap(double phase_rad)
Phase unwrapping function, input is [rad].
double fll_four_quadrant_atan(gr_complex prompt_s1, gr_complex prompt_s2, double t1, double t2)
double dll_nc_vemlp_normalized(gr_complex very_early_s1, gr_complex early_s1, gr_complex late_s1, gr_complex very_late_s1)
DLL Noncoherent Very Early Minus Late Power (VEMLP) normalized discriminator.
double pll_cloop_two_quadrant_atan(gr_complex prompt_s1)
PLL Costas loop two quadrant arctan discriminator.