1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-02-06 22:20:09 +00:00
This commit is contained in:
Carles Fernandez 2015-05-29 19:16:33 +02:00
commit 115366d3f1
6 changed files with 79 additions and 346 deletions

View File

@ -272,7 +272,9 @@ private:
inline std::string leftJustify(const std::string & s, inline std::string leftJustify(const std::string & s,
const std::string::size_type length, const std::string::size_type length,
const char pad = ' ') const char pad = ' ')
{ std::string t(s); return leftJustify(t, length, pad); } {
std::string t(s); return leftJustify(t, length, pad);
}
/* /*
@ -294,8 +296,9 @@ private:
inline std::string rightJustify(const std::string & s, inline std::string rightJustify(const std::string & s,
const std::string::size_type length, const std::string::size_type length,
const char pad = ' ') const char pad = ' ')
{ std::string t(s); return rightJustify(t, length, pad); } {
std::string t(s); return rightJustify(t, length, pad);
}
/* /*
@ -315,8 +318,6 @@ private:
const bool checkSwitch = true); const bool checkSwitch = true);
/* /*
* Convert scientific notation to FORTRAN notation. * Convert scientific notation to FORTRAN notation.
* As an example, the string "1.5636E5" becomes " .15636D6". * As an example, the string "1.5636E5" becomes " .15636D6".
@ -338,9 +339,6 @@ private:
const bool checkSwitch = true); const bool checkSwitch = true);
/* /*
* Convert double precision floating point to a string * Convert double precision floating point to a string
* containing the number in FORTRAN notation. * containing the number in FORTRAN notation.
@ -365,7 +363,9 @@ private:
* @return double representation of string. * @return double representation of string.
*/ */
inline double asDouble(const std::string & s) inline double asDouble(const std::string & s)
{ return strtod(s.c_str(), 0); } {
return strtod(s.c_str(), 0);
}
inline int toInt(std::string bitString, int sLength); inline int toInt(std::string bitString, int sLength);
@ -376,7 +376,9 @@ private:
* @return long integer representation of string. * @return long integer representation of string.
*/ */
inline long asInt(const std::string & s) inline long asInt(const std::string & s)
{ return strtol(s.c_str(), 0, 10); } {
return strtol(s.c_str(), 0, 10);
}
/* /*
@ -398,14 +400,15 @@ private:
inline std::string asString(const long double x, inline std::string asString(const long double x,
const std::string::size_type precision = 21); const std::string::size_type precision = 21);
/* /*
* Convert any old object to a string. * Convert any old object to a string.
* The class must have stream operators defined. * The class must have stream operators defined.
* @param x object to turn into a string. * @param x object to turn into a string.
* @return string representation of \a x. * @return string representation of \a x.
*/ */
template <class X> template <class X> inline std::string asString(const X x);
inline std::string asString(const X x);
inline std::string asFixWidthString(const int x, const int width, char fill_digit); inline std::string asFixWidthString(const int x, const int width, char fill_digit);
}; };
@ -417,7 +420,6 @@ inline std::string& Rinex_Printer::leftJustify(std::string& s,
const std::string::size_type length, const std::string::size_type length,
const char pad) const char pad)
{ {
if(length < s.length()) if(length < s.length())
{ {
s = s.substr(0, length); s = s.substr(0, length);
@ -449,14 +451,11 @@ inline std::string& Rinex_Printer::rightJustify(std::string& s,
inline std::string Rinex_Printer::doub2for(const double & d, inline std::string Rinex_Printer::doub2for(const double & d,
const std::string::size_type length, const std::string::size_type length,
const std::string::size_type expLen, const std::string::size_type expLen,
const bool checkSwitch) const bool checkSwitch)
{ {
short exponentLength = expLen; short exponentLength = expLen;
/* Validate the assumptions regarding the input arguments */ /* Validate the assumptions regarding the input arguments */
@ -467,7 +466,6 @@ inline std::string Rinex_Printer::doub2for(const double& d,
sci2for(toReturn, 0, length, exponentLength, checkSwitch); sci2for(toReturn, 0, length, exponentLength, checkSwitch);
return toReturn; return toReturn;
} }
@ -501,6 +499,7 @@ inline std::string Rinex_Printer::doub2sci(const double& d,
return toReturn; return toReturn;
} }
inline std::string & Rinex_Printer::sci2for(std::string & aStr, inline std::string & Rinex_Printer::sci2for(std::string & aStr,
const std::string::size_type startPos, const std::string::size_type startPos,
const std::string::size_type length, const std::string::size_type length,
@ -518,7 +517,7 @@ inline std::string& Rinex_Printer::sci2for(std::string& aStr,
// Check for decimal place within specified boundaries // Check for decimal place within specified boundaries
if ((idx == 0) || (idx >= (startPos + length - expLen - 1))) if ((idx == 0) || (idx >= (startPos + length - expLen - 1)))
{ {
//StringException e("sci2for: no decimal point in string"); // Error: no decimal point in string
} }
// Here, account for the possibility that there are // Here, account for the possibility that there are
@ -530,8 +529,8 @@ inline std::string& Rinex_Printer::sci2for(std::string& aStr,
{ {
redoexp = true; redoexp = true;
// Swap digit and decimal. // Swap digit and decimal.
aStr[idx] = aStr[idx - 1]; aStr[static_cast<unsigned int>(idx)] = aStr[static_cast<unsigned int>(idx - 1)];
aStr[idx - 1] = '.'; aStr[static_cast<unsigned int>(idx - 1)] = '.';
// Only add one to the exponent if the number is non-zero // Only add one to the exponent if the number is non-zero
if (asDouble(aStr.substr(startPos, length)) != 0.0) if (asDouble(aStr.substr(startPos, length)) != 0.0)
expAdd = 1; expAdd = 1;
@ -543,8 +542,7 @@ inline std::string& Rinex_Printer::sci2for(std::string& aStr,
idx = aStr.find('E', startPos); idx = aStr.find('E', startPos);
if (idx == std::string::npos) if (idx == std::string::npos)
{ {
//StringException e("sci2for:no 'e' or 'E' in string"); // Error: no 'e' or 'E' in string";
//GPSTK_THROW(e);
} }
} }
@ -598,8 +596,6 @@ inline std::string asString(const long double x, const std::string::size_type pr
} }
inline std::string Rinex_Printer::asString(const double x, const std::string::size_type precision) inline std::string Rinex_Printer::asString(const double x, const std::string::size_type precision)
{ {
std::ostringstream ss; std::ostringstream ss;
@ -612,12 +608,14 @@ inline std::string Rinex_Printer::asFixWidthString(const int x, const int width,
{ {
std::ostringstream ss; std::ostringstream ss;
ss << std::setfill(fill_digit) << std::setw(width) << x; ss << std::setfill(fill_digit) << std::setw(width) << x;
//std::cout << "asFixWidthString(): x=" << x << " width=" << width << " fill_digit=" << fill_digit << " ss=" << ss.str() << std::endl;
return ss.str().substr(ss.str().size() - width); return ss.str().substr(ss.str().size() - width);
} }
inline long asInt(const std::string & s) inline long asInt(const std::string & s)
{ return strtol(s.c_str(), 0, 10); } {
return strtol(s.c_str(), 0, 10);
}
inline int Rinex_Printer::toInt(std::string bitString, int sLength) inline int Rinex_Printer::toInt(std::string bitString, int sLength)
@ -633,8 +631,7 @@ inline int Rinex_Printer::toInt(std::string bitString, int sLength)
} }
template<class X> template<class X> inline std::string Rinex_Printer::asString(const X x)
inline std::string Rinex_Printer::asString(const X x)
{ {
std::ostringstream ss; std::ostringstream ss;
ss << x; ss << x;

View File

@ -116,6 +116,11 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::galileo_e5a_noncoherentIQ_acquisit
d_fft_code_Q_A = static_cast<gr_complex*>(volk_malloc(d_fft_size * sizeof(gr_complex), volk_get_alignment())); d_fft_code_Q_A = static_cast<gr_complex*>(volk_malloc(d_fft_size * sizeof(gr_complex), volk_get_alignment()));
d_magnitudeQA = static_cast<float*>(volk_malloc(d_fft_size * sizeof(float), volk_get_alignment())); d_magnitudeQA = static_cast<float*>(volk_malloc(d_fft_size * sizeof(float), volk_get_alignment()));
} }
else
{
d_fft_code_Q_A = 0;
d_magnitudeQA = 0;
}
// IF COHERENT INTEGRATION TIME > 1 // IF COHERENT INTEGRATION TIME > 1
if (d_sampled_ms > 1) if (d_sampled_ms > 1)
{ {
@ -126,6 +131,11 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::galileo_e5a_noncoherentIQ_acquisit
d_fft_code_Q_B = static_cast<gr_complex*>(volk_malloc(d_fft_size * sizeof(gr_complex), volk_get_alignment())); d_fft_code_Q_B = static_cast<gr_complex*>(volk_malloc(d_fft_size * sizeof(gr_complex), volk_get_alignment()));
d_magnitudeQB = static_cast<float*>(volk_malloc(d_fft_size * sizeof(float), volk_get_alignment())); d_magnitudeQB = static_cast<float*>(volk_malloc(d_fft_size * sizeof(float), volk_get_alignment()));
} }
else
{
d_fft_code_Q_B = 0;
d_magnitudeQB = 0;
}
} }
// Direct FFT // Direct FFT
@ -147,6 +157,7 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::galileo_e5a_noncoherentIQ_acquisit
d_doppler_freq = 0; d_doppler_freq = 0;
d_test_statistics = 0; d_test_statistics = 0;
d_channel_internal_queue = 0; d_channel_internal_queue = 0;
d_CAF_vector = 0;
d_CAF_vector_I = 0; d_CAF_vector_I = 0;
d_CAF_vector_Q = 0; d_CAF_vector_Q = 0;
d_channel = 0; d_channel = 0;

View File

@ -17,7 +17,6 @@
# #
set(TRACKING_LIB_SOURCES set(TRACKING_LIB_SOURCES
cordic.cc
correlator.cc correlator.cc
lock_detectors.cc lock_detectors.cc
tcp_communication.cc tcp_communication.cc

View File

@ -1,194 +0,0 @@
/*!
* \file cordic.cc
* \brief Implementation of the CORDIC (COordinate Rotation DIgital Computer) algorithm.
* This implementation is NOT OPTIMIZED, only for demonstration purposes
* \author Carles Fernandez-Prades, 2012. cfernandez(at)cttc.es
*
* This is a modified implementation of the one found at
* http://www.dspguru.com/dsp/faqs/cordic
*
* -------------------------------------------------------------------------
*
* 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/>.
*
* -------------------------------------------------------------------------
*/
#include <stdlib.h>
//#include <math.h>
#include <cmath>
#include "cordic.h"
const double HALF_PI = 3.1415926535898 / 2;
const int INVALID_K = -1;
Cordic::Cordic(int max_L)
{
double K, dummy;
int L;
//mp_cordic_table = (CORDIC_TABLE *) calloc(max_L + 1, sizeof(CORDIC_TABLE));
mp_cordic_table = (CORDIC_TABLE *) malloc((max_L + 1) * sizeof(CORDIC_TABLE));
if (!mp_cordic_table)
{
/* failed to calloc table */
}
K = 1.0;
for (L = 0; L <= max_L; L++)
{
mp_cordic_table[L].K = K;
mp_cordic_table[L].phase_rads = (double) atan(K);
K *= 0.5;
}
m_max_L = max_L;
/* get m_mag_scale by getting the cordic magnitude with m_mag_scale = 1.0 */
m_mag_scale = 1.0;
Cordic::cordic_get_mag_phase(1.0, 0.0, m_mag_scale, dummy);
m_mag_scale = 1.0 / m_mag_scale;
}
Cordic::~Cordic ()
{
free(mp_cordic_table);
m_max_L = INVALID_K;
}
void Cordic::cordic_get_mag_phase(double I, double Q, double &p_mag, double &p_phase_rads)
{
int L;
double tmp_I, K, phase_rads, acc_phase_rads;
if (I < 0)
{
/* rotate by an initial +/- 90 degrees */
tmp_I = I;
if (Q > 0.0)
{
I = Q; /* subtract 90 degrees */
Q = -tmp_I;
acc_phase_rads = -HALF_PI;
}
else
{
I = -Q; /* add 90 degrees */
Q = tmp_I;
acc_phase_rads = HALF_PI;
}
}
else
{
acc_phase_rads = 0.0;
}
/* rotate using "1 + jK" factors */
for (L = 0; L <= m_max_L; L++)
{
K = mp_cordic_table[L].K;
phase_rads = mp_cordic_table[L].phase_rads;
tmp_I = I;
if (Q >= 0.0)
{
/* phase is positive: do negative rotation */
I += Q * K;
Q -= tmp_I * K;
acc_phase_rads -= phase_rads;
}
else
{
/* phase is negative: do positive rotation */
I -= Q * K;
Q += tmp_I * K;
acc_phase_rads += phase_rads;
}
}
p_phase_rads = -acc_phase_rads;
p_mag = I * m_mag_scale;
}
void Cordic::cordic_get_cos_sin(double desired_phase_rads, double &p_cos, double &p_sin)
{
double I, Q, tmp_I;
double acc_phase_rads, phase_rads, K;
int L;
/* start with +90, -90, or 0 degrees */
if (desired_phase_rads > HALF_PI)
{
I = 0.0;
Q = 1.0;
acc_phase_rads = HALF_PI;
}
else if (desired_phase_rads < -HALF_PI)
{
I = 0.0;
Q = -1.0;
acc_phase_rads = -HALF_PI;
}
else
{
I = 1.0;
Q = 0.0;
acc_phase_rads = 0.0;
}
/* rotate using "1 + jK" factors */
for (L = 0; L <= m_max_L; L++)
{
K = mp_cordic_table[L].K;
phase_rads = mp_cordic_table[L].phase_rads;
tmp_I = I;
if (desired_phase_rads - acc_phase_rads < 0.0)
{
/* do negative rotation */
I += Q * K;
Q -= tmp_I * K;
acc_phase_rads -= phase_rads;
}
else
{
/* do positive rotation */
I -= Q * K;
Q += tmp_I * K;
acc_phase_rads += phase_rads;
}
}
p_cos = I * m_mag_scale;
p_sin = Q * m_mag_scale;
}

View File

@ -1,80 +0,0 @@
/*!
* \file cordic.h
* \brief Interface of the CORDIC (COordinate Rotation DIgital Computer) algorithm.
* \author Carles Fernandez-Prades, 2012. cfernandez(at)cttc.es
*
*
* -------------------------------------------------------------------------
*
* 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_CORDIC_H_
#define GNSS_SDR_CORDIC_H_
typedef struct tagCORDIC_TABLE {
double K;
double phase_rads;
} CORDIC_TABLE;
/*!
* \brief Implementation of the CORDIC (COordinate Rotation DIgital Computer) algorithm.
* This implementation is NOT OPTIMIZED, only for demonstration purposes
*/
class Cordic
{
public:
/*!
* \brief construct the CORDIC table which will be of size "largest_k + 1".
*/
Cordic(int largest_k);
/*!
* \brief Frees the CORDIC table's memory
*/
~Cordic();
/*!
* \brief Calculates the magnitude and phase of "I + jQ". p_phase_rads is in radians
*/
void cordic_get_mag_phase(double I, double Q, double &p_mag, double &p_phase_rads);
/* calculate the magnitude and phase of "I + jQ". phase is in radians */
/*!
* \brief Calculates the cosine and sine of the desired phase in radians
*/
void cordic_get_cos_sin(double desired_phase_rads, double &p_cos, double &p_sin);
private:
CORDIC_TABLE *mp_cordic_table;
int m_max_L;
double m_mag_scale;
};
#endif

View File

@ -723,7 +723,7 @@ int Sbas_Telemetry_Data::decode_sbstype9(const sbsmsg_t *msg, nav_t *nav)
seph.af1 = getbits(msg->msg, 218, 8)*P2_39/2.0; seph.af1 = getbits(msg->msg, 218, 8)*P2_39/2.0;
i = msg->prn-MINPRNSBS; i = msg->prn-MINPRNSBS;
if (!nav->seph || std::abs(nav->seph[i].t0 - seph.t0) < 1E-3) if (std::abs(nav->seph[i].t0 - seph.t0) < 1E-3)
{ /* not change */ { /* not change */
VLOG(FLOW) << "<<T>> no change in ephemeris -> won't parse"; VLOG(FLOW) << "<<T>> no change in ephemeris -> won't parse";
return 0; return 0;