diff --git a/CMakeLists.txt b/CMakeLists.txt index d3c95eea4..1872be76f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -397,7 +397,7 @@ set(GNSSSDR_PROTOBUF_MIN_VERSION "3.0.0") ################################################################################ set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.2") set(GNSSSDR_GLOG_LOCAL_VERSION "0.4.0") -set(GNSSSDR_ARMADILLO_LOCAL_VERSION "9.500.x") +set(GNSSSDR_ARMADILLO_LOCAL_VERSION "9.600.x") set(GNSSSDR_GTEST_LOCAL_VERSION "1.8.1") set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master") set(GNSSSDR_GPSTK_LOCAL_VERSION "2.10.6") diff --git a/README.md b/README.md index 7240ccbca..fcbcd7223 100644 --- a/README.md +++ b/README.md @@ -220,9 +220,9 @@ $ sudo apt-get install libblas-dev liblapack-dev # For Debian/Ubuntu/Linux $ sudo yum install lapack-devel blas-devel # For Fedora/CentOS/RHEL $ sudo zypper install lapack-devel blas-devel # For OpenSUSE $ sudo pacman -S blas lapack # For Arch Linux -$ wget http://sourceforge.net/projects/arma/files/armadillo-9.400.4.tar.xz -$ tar xvfz armadillo-9.400.4.tar.xz -$ cd armadillo-9.400.4 +$ wget http://sourceforge.net/projects/arma/files/armadillo-9.600.4.tar.xz +$ tar xvfz armadillo-9.600.4.tar.xz +$ cd armadillo-9.600.4 $ cmake . $ make $ sudo make install diff --git a/src/algorithms/libs/beidou_b1i_signal_processing.cc b/src/algorithms/libs/beidou_b1i_signal_processing.cc index 504d7ee0d..3a4d310bf 100644 --- a/src/algorithms/libs/beidou_b1i_signal_processing.cc +++ b/src/algorithms/libs/beidou_b1i_signal_processing.cc @@ -71,7 +71,7 @@ void beidou_b1i_code_gen_int(gsl::span _dest, int32_t _prn, uint32_t _c for (lcv = 0; lcv < _code_length; lcv++) { G1[lcv] = G1_register[0]; - G2[lcv] = G2_register[-(phase1[prn_idx] - 11)] ^ G2_register[-(phase2[prn_idx] - 11)]; + G2[lcv] = G2_register[-(phase1[prn_idx] - 11)] xor G2_register[-(phase2[prn_idx] - 11)]; feedback1 = G1_register[0] xor G1_register[1] xor G1_register[2] xor G1_register[3] xor G1_register[4] xor G1_register[10]; feedback2 = G2_register[0] xor G2_register[2] xor G2_register[3] xor G2_register[6] xor G2_register[7] xor G2_register[8] xor G2_register[9] xor G2_register[10]; @@ -94,7 +94,7 @@ void beidou_b1i_code_gen_int(gsl::span _dest, int32_t _prn, uint32_t _c // Generate PRN from G1 and G2 Registers for (lcv = 0; lcv < _code_length; lcv++) { - aux = G1[(lcv + _chip_shift) % _code_length] ^ G2[delay]; + aux = G1[(lcv + _chip_shift) % _code_length] xor G2[delay]; if (aux == true) { _dest[lcv] = 1; diff --git a/src/algorithms/libs/beidou_b3i_signal_processing.cc b/src/algorithms/libs/beidou_b3i_signal_processing.cc index e47771d6f..a08cdd7b4 100644 --- a/src/algorithms/libs/beidou_b3i_signal_processing.cc +++ b/src/algorithms/libs/beidou_b3i_signal_processing.cc @@ -42,9 +42,9 @@ void beidou_b3i_code_gen_int(gsl::span _dest, signed int _prn, unsigned int const unsigned int _code_length = 10230; std::bitset<_code_length> G1{}; std::bitset<_code_length> G2{}; - auto G1_register = std::move(std::bitset<13>{}.set()); // All true - auto G2_register = std::move(std::bitset<13>{}.set()); // All true - auto G1_register_reset = std::move(std::bitset<13>{}.set()); + auto G1_register = std::bitset<13>{}.set(); // All true + auto G2_register = std::bitset<13>{}.set(); // All true + auto G1_register_reset = std::bitset<13>{}.set(); G1_register_reset.reset(0); G1_register_reset.reset(1); // {false, false, true, true, true, true, true, true, true, true, true, true, true}; @@ -148,7 +148,7 @@ void beidou_b3i_code_gen_int(gsl::span _dest, signed int _prn, unsigned int // Reset G1 register if sequence found if (G1_register == G1_register_reset) { - G1_register = std::move(std::bitset<13>{}.set()); // All true + G1_register = std::bitset<13>{}.set(); // All true } } diff --git a/src/algorithms/libs/galileo_e1_signal_processing.cc b/src/algorithms/libs/galileo_e1_signal_processing.cc index 63c2ca743..59f0cfb1c 100644 --- a/src/algorithms/libs/galileo_e1_signal_processing.cc +++ b/src/algorithms/libs/galileo_e1_signal_processing.cc @@ -33,10 +33,10 @@ #include "galileo_e1_signal_processing.h" #include "Galileo_E1.h" #include "gnss_signal_processing.h" -#include #include #include #include +#include void galileo_e1_code_gen_int(gsl::span _dest, const std::array& _Signal, int32_t _prn) @@ -111,8 +111,8 @@ void galileo_e1_code_gen_sinboc11_float(gsl::span _dest, const std::array { std::string _galileo_signal = _Signal.data(); const auto _codeLength = static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS); - std::array primary_code_E1_chips{}; // _codeLength not accepted by Clang - galileo_e1_code_gen_int(gsl::span(primary_code_E1_chips.data(), 4092), _Signal, _prn); //generate Galileo E1 code, 1 sample per chip + std::array primary_code_E1_chips{}; + galileo_e1_code_gen_int(primary_code_E1_chips, _Signal, _prn); // generate Galileo E1 code, 1 sample per chip for (uint32_t i = 0; i < _codeLength; i++) { _dest[2 * i] = static_cast(primary_code_E1_chips[i]); @@ -163,35 +163,31 @@ void galileo_e1_code_gen_float_sampled(gsl::span _dest, const std::array< std::string _galileo_signal = _Signal.data(); uint32_t _samplesPerCode; const int32_t _codeFreqBasis = GALILEO_E1_CODE_CHIP_RATE_HZ; // Hz - auto _codeLength = static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS); - auto* primary_code_E1_chips = static_cast(volk_gnsssdr_malloc(static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * sizeof(int32_t), volk_gnsssdr_get_alignment())); - - _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(_codeFreqBasis) / static_cast(_codeLength))); + std::vector primary_code_E1_chips(static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)); + _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(_codeFreqBasis) / GALILEO_E1_B_CODE_LENGTH_CHIPS)); const int32_t _samplesPerChip = (_cboc == true) ? 12 : 2; const uint32_t delay = ((static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) - _chip_shift) % static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * _samplesPerCode / GALILEO_E1_B_CODE_LENGTH_CHIPS; - galileo_e1_code_gen_int(gsl::span(primary_code_E1_chips, static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)), _Signal, _prn); // generate Galileo E1 code, 1 sample per chip + galileo_e1_code_gen_int(primary_code_E1_chips, _Signal, _prn); // generate Galileo E1 code, 1 sample per chip - _codeLength = _samplesPerChip * GALILEO_E1_B_CODE_LENGTH_CHIPS; + const uint32_t _codeLength = _samplesPerChip * GALILEO_E1_B_CODE_LENGTH_CHIPS; std::unique_ptr _signal_E1{new float[_codeLength]}; gsl::span _signal_E1_span(_signal_E1, _codeLength); if (_cboc == true) { - galileo_e1_gen_float(_signal_E1_span, gsl::span(primary_code_E1_chips, static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)), _Signal); // generate cboc 12 samples per chip + galileo_e1_gen_float(_signal_E1_span, primary_code_E1_chips, _Signal); // generate cboc 12 samples per chip } else { - auto* _signal_E1_int = static_cast(volk_gnsssdr_malloc(_codeLength * sizeof(int32_t), volk_gnsssdr_get_alignment())); - gsl::span _signal_E1_int_span(_signal_E1_int, _codeLength); - galileo_e1_sinboc_11_gen_int(_signal_E1_int_span, gsl::span(primary_code_E1_chips, static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS))); // generate sinboc(1,1) 2 samples per chip + std::vector _signal_E1_int(static_cast(_codeLength)); + galileo_e1_sinboc_11_gen_int(_signal_E1_int, primary_code_E1_chips); // generate sinboc(1,1) 2 samples per chip for (uint32_t ii = 0; ii < _codeLength; ++ii) { - _signal_E1_span[ii] = static_cast(_signal_E1_int_span[ii]); + _signal_E1_span[ii] = static_cast(_signal_E1_int[ii]); } - volk_gnsssdr_free(_signal_E1_int); } if (_fs != _samplesPerChip * _codeFreqBasis) @@ -233,8 +229,6 @@ void galileo_e1_code_gen_float_sampled(gsl::span _dest, const std::array< { _dest[(i + delay) % _samplesPerCode] = _signal_E1_span_aux2[i]; } - - volk_gnsssdr_free(primary_code_E1_chips); } @@ -245,22 +239,20 @@ void galileo_e1_code_gen_complex_sampled(gsl::span> _dest, c std::string _galileo_signal = _Signal.data(); const int32_t _codeFreqBasis = GALILEO_E1_CODE_CHIP_RATE_HZ; // Hz auto _samplesPerCode = static_cast(static_cast(_fs) / - (static_cast(_codeFreqBasis) / static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS))); + (static_cast(_codeFreqBasis) / GALILEO_E1_B_CODE_LENGTH_CHIPS)); if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2 && _secondary_flag) { _samplesPerCode *= static_cast(GALILEO_E1_C_SECONDARY_CODE_LENGTH); } - auto* real_code = static_cast(volk_gnsssdr_malloc(_samplesPerCode * sizeof(float), volk_gnsssdr_get_alignment())); - gsl::span real_code_span(real_code, _samplesPerCode); - galileo_e1_code_gen_float_sampled(real_code_span, _Signal, _cboc, _prn, _fs, _chip_shift, _secondary_flag); + std::vector real_code(_samplesPerCode); + galileo_e1_code_gen_float_sampled(real_code, _Signal, _cboc, _prn, _fs, _chip_shift, _secondary_flag); for (uint32_t ii = 0; ii < _samplesPerCode; ++ii) { - _dest[ii] = std::complex(real_code_span[ii], 0.0F); + _dest[ii] = std::complex(real_code[ii], 0.0F); } - volk_gnsssdr_free(real_code); } diff --git a/src/algorithms/libs/glonass_l1_signal_processing.cc b/src/algorithms/libs/glonass_l1_signal_processing.cc index da1cc34ce..ee07164bf 100644 --- a/src/algorithms/libs/glonass_l1_signal_processing.cc +++ b/src/algorithms/libs/glonass_l1_signal_processing.cc @@ -32,30 +32,26 @@ #include "glonass_l1_signal_processing.h" #include +#include auto auxCeil = [](float x) { return static_cast(static_cast((x) + 1)); }; void glonass_l1_ca_code_gen_complex(gsl::span> _dest, /* int32_t _prn,*/ uint32_t _chip_shift) { const uint32_t _code_length = 511; - std::array G1{}; - std::array G1_register{}; + std::bitset<_code_length> G1{}; + auto G1_register = std::bitset<9>{}.set(); // All true bool feedback1; bool aux; uint32_t delay; uint32_t lcv, lcv2; - for (lcv = 0; lcv < 9; lcv++) - { - G1_register[lcv] = true; - } - /* Generate G1 Register */ for (lcv = 0; lcv < _code_length; lcv++) { G1[lcv] = G1_register[2]; - feedback1 = G1_register[4] ^ G1_register[0]; + feedback1 = G1_register[4] xor G1_register[0]; for (lcv2 = 0; lcv2 < 8; lcv2++) { @@ -123,7 +119,7 @@ void glonass_l1_ca_code_gen_complex_sampled(gsl::span> _dest _ts = 1.0 / static_cast(_fs); // Sampling period in sec _tc = 1.0 / static_cast(_codeFreqBasis); // C/A chip period in sec - glonass_l1_ca_code_gen_complex(gsl::span>(_code.data(), 511), _chip_shift); // generate C/A code 1 sample per chip + glonass_l1_ca_code_gen_complex(_code, _chip_shift); // generate C/A code 1 sample per chip for (int32_t i = 0; i < _samplesPerCode; i++) { @@ -134,7 +130,6 @@ void glonass_l1_ca_code_gen_complex_sampled(gsl::span> _dest // number of samples per millisecond (because one C/A code period is one // millisecond). - // _codeValueIndex = ceil((_ts * ((float)i + 1)) / _tc) - 1; aux = (_ts * (i + 1)) / _tc; _codeValueIndex = auxCeil(aux) - 1; @@ -148,7 +143,7 @@ void glonass_l1_ca_code_gen_complex_sampled(gsl::span> _dest } else { - _dest[i] = _code[_codeValueIndex]; //repeat the chip -> upsample + _dest[i] = _code[_codeValueIndex]; // repeat the chip -> upsample } } } diff --git a/src/algorithms/libs/glonass_l2_signal_processing.cc b/src/algorithms/libs/glonass_l2_signal_processing.cc index d92b785c9..f2223fa94 100644 --- a/src/algorithms/libs/glonass_l2_signal_processing.cc +++ b/src/algorithms/libs/glonass_l2_signal_processing.cc @@ -32,30 +32,26 @@ #include "glonass_l2_signal_processing.h" #include +#include auto auxCeil = [](float x) { return static_cast(static_cast((x) + 1)); }; void glonass_l2_ca_code_gen_complex(gsl::span> _dest, /* int32_t _prn,*/ uint32_t _chip_shift) { const uint32_t _code_length = 511; - std::array G1{}; - std::array G1_register{}; + std::bitset<_code_length> G1{}; + auto G1_register = std::bitset<9>{}.set(); // All true bool feedback1; bool aux; uint32_t delay; uint32_t lcv, lcv2; - for (lcv = 0; lcv < 9; lcv++) - { - G1_register[lcv] = true; - } - /* Generate G1 Register */ for (lcv = 0; lcv < _code_length; lcv++) { G1[lcv] = G1_register[2]; - feedback1 = G1_register[4] ^ G1_register[0]; + feedback1 = G1_register[4] xor G1_register[0]; for (lcv2 = 0; lcv2 < 8; lcv2++) { @@ -123,7 +119,7 @@ void glonass_l2_ca_code_gen_complex_sampled(gsl::span> _dest _ts = 1.0 / static_cast(_fs); // Sampling period in sec _tc = 1.0 / static_cast(_codeFreqBasis); // C/A chip period in sec - glonass_l2_ca_code_gen_complex(gsl::span>(_code.data(), 511), _chip_shift); // generate C/A code 1 sample per chip + glonass_l2_ca_code_gen_complex(_code, _chip_shift); // generate C/A code 1 sample per chip for (int32_t i = 0; i < _samplesPerCode; i++) { @@ -134,7 +130,6 @@ void glonass_l2_ca_code_gen_complex_sampled(gsl::span> _dest // number of samples per millisecond (because one C/A code period is one // millisecond). - // _codeValueIndex = ceil((_ts * ((float)i + 1)) / _tc) - 1; aux = (_ts * (i + 1)) / _tc; _codeValueIndex = auxCeil(aux) - 1; @@ -148,7 +143,7 @@ void glonass_l2_ca_code_gen_complex_sampled(gsl::span> _dest } else { - _dest[i] = _code[_codeValueIndex]; //repeat the chip -> upsample + _dest[i] = _code[_codeValueIndex]; // repeat the chip -> upsample } } } diff --git a/src/algorithms/libs/gnss_signal_processing.cc b/src/algorithms/libs/gnss_signal_processing.cc index 71e61e159..63a244d8b 100644 --- a/src/algorithms/libs/gnss_signal_processing.cc +++ b/src/algorithms/libs/gnss_signal_processing.cc @@ -168,13 +168,12 @@ void resampler(const gsl::span _from, gsl::span _dest, float _fs_i const float _t_out = 1 / _fs_out; // Out sampling period in sec for (uint32_t i = 0; i < _dest.size() - 1; i++) { - //=== Digitizing ======================================================= - //--- compute index array to read sampled values ------------------------- - //_codeValueIndex = ceil((_t_out * ((float)i + 1)) / _t_in) - 1; + //=== Digitizing =================================================== + //--- compute index array to read sampled values ------------------- aux = (_t_out * (i + 1)) / _t_in; _codeValueIndex = auxCeil2(aux) - 1; - //if repeat the chip -> upsample by nearest neighborhood interpolation + // if repeat the chip -> upsample by nearest neighborhood interpolation _dest[i] = _from[_codeValueIndex]; } //--- Correct the last index (due to number rounding issues) ----------- @@ -192,13 +191,12 @@ void resampler(gsl::span> _from, gsl::span upsample by nearest neighborhood interpolation + // if repeat the chip -> upsample by nearest neighborhood interpolation _dest[i] = _from[_codeValueIndex]; } //--- Correct the last index (due to number rounding issues) ----------- diff --git a/src/algorithms/libs/gps_l2c_signal.cc b/src/algorithms/libs/gps_l2c_signal.cc index 364c5ee66..73d9e5b7a 100644 --- a/src/algorithms/libs/gps_l2c_signal.cc +++ b/src/algorithms/libs/gps_l2c_signal.cc @@ -32,13 +32,14 @@ #include "gps_l2c_signal.h" #include "GPS_L2C.h" +#include #include #include uint32_t gps_l2c_m_shift(uint32_t x) { - return static_cast((x >> 1U) ^ ((x & 1U) * 0445112474U)); + return static_cast((x >> 1U) xor ((x & 1U) * 0445112474U)); } @@ -56,32 +57,30 @@ void gps_l2c_m_code(gsl::span _dest, uint32_t _prn) void gps_l2c_m_code_gen_complex(gsl::span> _dest, uint32_t _prn) { - std::unique_ptr _code{new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]}; - gsl::span _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS); + std::array _code{}; if (_prn > 0 and _prn < 51) { - gps_l2c_m_code(_code_span, _prn); + gps_l2c_m_code(_code, _prn); } for (int32_t i = 0; i < GPS_L2_M_CODE_LENGTH_CHIPS; i++) { - _dest[i] = std::complex(1.0 - 2.0 * _code_span[i], 0.0); + _dest[i] = std::complex(1.0 - 2.0 * _code[i], 0.0); } } void gps_l2c_m_code_gen_float(gsl::span _dest, uint32_t _prn) { - std::unique_ptr _code{new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]}; - gsl::span _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS); + std::array _code{}; if (_prn > 0 and _prn < 51) { - gps_l2c_m_code(_code_span, _prn); + gps_l2c_m_code(_code, _prn); } for (int32_t i = 0; i < GPS_L2_M_CODE_LENGTH_CHIPS; i++) { - _dest[i] = 1.0 - 2.0 * static_cast(_code_span[i]); + _dest[i] = 1.0 - 2.0 * static_cast(_code[i]); } } @@ -91,11 +90,10 @@ void gps_l2c_m_code_gen_float(gsl::span _dest, uint32_t _prn) */ void gps_l2c_m_code_gen_complex_sampled(gsl::span> _dest, uint32_t _prn, int32_t _fs) { - std::unique_ptr _code{new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]}; - gsl::span _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS); + std::array _code{}; if (_prn > 0 and _prn < 51) { - gps_l2c_m_code(_code_span, _prn); + gps_l2c_m_code(_code, _prn); } int32_t _samplesPerCode, _codeValueIndex; @@ -121,11 +119,11 @@ void gps_l2c_m_code_gen_complex_sampled(gsl::span> _dest, ui if (i == _samplesPerCode - 1) { //--- Correct the last index (due to number rounding issues) ----------- - _dest[i] = std::complex(1.0 - 2.0 * _code_span[_codeLength - 1], 0); + _dest[i] = std::complex(1.0 - 2.0 * _code[_codeLength - 1], 0); } else { - _dest[i] = std::complex(1.0 - 2.0 * _code_span[_codeValueIndex], 0); //repeat the chip -> upsample + _dest[i] = std::complex(1.0 - 2.0 * _code[_codeValueIndex], 0); //repeat the chip -> upsample } } } diff --git a/src/algorithms/libs/gps_l5_signal.cc b/src/algorithms/libs/gps_l5_signal.cc index 8fa132b63..8c301ee6e 100644 --- a/src/algorithms/libs/gps_l5_signal.cc +++ b/src/algorithms/libs/gps_l5_signal.cc @@ -32,9 +32,9 @@ #include "gps_l5_signal.h" #include "GPS_L5.h" +#include #include - std::deque l5i_xa_shift(std::deque xa) // GPS-IS-705E Figure 3-4 pp. 15 { if (xa == std::deque{true, true, true, true, true, true, true, true, true, true, true, false, true}) @@ -173,32 +173,30 @@ void make_l5q(gsl::span _dest, int32_t prn) void gps_l5i_code_gen_complex(gsl::span> _dest, uint32_t _prn) { - std::unique_ptr _code{new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]}; - gsl::span _code_span(_code, GPS_L5I_CODE_LENGTH_CHIPS); + std::array _code{}; if (_prn > 0 and _prn < 51) { - make_l5i(_code_span, _prn - 1); + make_l5i(_code, _prn - 1); } for (int32_t i = 0; i < GPS_L5I_CODE_LENGTH_CHIPS; i++) { - _dest[i] = std::complex(1.0 - 2.0 * _code_span[i], 0.0); + _dest[i] = std::complex(1.0 - 2.0 * static_cast(_code[i]), 0.0); } } void gps_l5i_code_gen_float(gsl::span _dest, uint32_t _prn) { - std::unique_ptr _code{new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]}; - gsl::span _code_span(_code, GPS_L5I_CODE_LENGTH_CHIPS); + std::array _code{}; if (_prn > 0 and _prn < 51) { - make_l5i(_code_span, _prn - 1); + make_l5i(_code, _prn - 1); } for (int32_t i = 0; i < GPS_L5I_CODE_LENGTH_CHIPS; i++) { - _dest[i] = 1.0 - 2.0 * static_cast(_code_span[i]); + _dest[i] = 1.0 - 2.0 * static_cast(_code[i]); } } @@ -208,11 +206,10 @@ void gps_l5i_code_gen_float(gsl::span _dest, uint32_t _prn) */ void gps_l5i_code_gen_complex_sampled(gsl::span> _dest, uint32_t _prn, int32_t _fs) { - std::unique_ptr _code{new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]}; - gsl::span _code_span(_code, GPS_L5I_CODE_LENGTH_CHIPS); + std::array _code{}; if (_prn > 0 and _prn < 51) { - make_l5i(_code_span, _prn - 1); + make_l5i(_code, _prn - 1); } int32_t _samplesPerCode, _codeValueIndex; @@ -238,11 +235,11 @@ void gps_l5i_code_gen_complex_sampled(gsl::span> _dest, uint if (i == _samplesPerCode - 1) { //--- Correct the last index (due to number rounding issues) ----------- - _dest[i] = std::complex(1.0 - 2.0 * _code_span[_codeLength - 1], 0.0); + _dest[i] = std::complex(1.0 - 2.0 * _code[_codeLength - 1], 0.0); } else { - _dest[i] = std::complex(1.0 - 2.0 * _code_span[_codeValueIndex], 0.0); // repeat the chip -> upsample + _dest[i] = std::complex(1.0 - 2.0 * _code[_codeValueIndex], 0.0); // repeat the chip -> upsample } } } @@ -250,32 +247,30 @@ void gps_l5i_code_gen_complex_sampled(gsl::span> _dest, uint void gps_l5q_code_gen_complex(gsl::span> _dest, uint32_t _prn) { - std::unique_ptr _code{new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]}; - gsl::span _code_span(_code, GPS_L5Q_CODE_LENGTH_CHIPS); + std::array _code{}; if (_prn > 0 and _prn < 51) { - make_l5q(_code_span, _prn - 1); + make_l5q(_code, _prn - 1); } for (int32_t i = 0; i < GPS_L5Q_CODE_LENGTH_CHIPS; i++) { - _dest[i] = std::complex(1.0 - 2.0 * _code_span[i], 0.0); + _dest[i] = std::complex(1.0 - 2.0 * static_cast(_code[i]), 0.0); } } void gps_l5q_code_gen_float(gsl::span _dest, uint32_t _prn) { - std::unique_ptr _code{new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]}; - gsl::span _code_span(_code, GPS_L5Q_CODE_LENGTH_CHIPS); + std::array _code{}; if (_prn > 0 and _prn < 51) { - make_l5q(_code_span, _prn - 1); + make_l5q(_code, _prn - 1); } for (int32_t i = 0; i < GPS_L5Q_CODE_LENGTH_CHIPS; i++) { - _dest[i] = 1.0 - 2.0 * static_cast(_code_span[i]); + _dest[i] = 1.0 - 2.0 * static_cast(_code[i]); } } @@ -285,11 +280,10 @@ void gps_l5q_code_gen_float(gsl::span _dest, uint32_t _prn) */ void gps_l5q_code_gen_complex_sampled(gsl::span> _dest, uint32_t _prn, int32_t _fs) { - std::unique_ptr _code{new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]}; - gsl::span _code_span(_code, GPS_L5Q_CODE_LENGTH_CHIPS); + std::array _code{}; if (_prn > 0 and _prn < 51) { - make_l5q(_code_span, _prn - 1); + make_l5q(_code, _prn - 1); } int32_t _samplesPerCode, _codeValueIndex; @@ -316,11 +310,11 @@ void gps_l5q_code_gen_complex_sampled(gsl::span> _dest, uint if (i == _samplesPerCode - 1) { //--- Correct the last index (due to number rounding issues) ----------- - _dest[i] = std::complex(1.0 - 2.0 * _code_span[_codeLength - 1], 0); + _dest[i] = std::complex(1.0 - 2.0 * _code[_codeLength - 1], 0); } else { - _dest[i] = std::complex(1.0 - 2.0 * _code_span[_codeValueIndex], 0); // repeat the chip -> upsample + _dest[i] = std::complex(1.0 - 2.0 * _code[_codeValueIndex], 0); // repeat the chip -> upsample } } } diff --git a/src/algorithms/libs/gps_sdr_signal_processing.cc b/src/algorithms/libs/gps_sdr_signal_processing.cc index 1a4483200..66ebf8036 100644 --- a/src/algorithms/libs/gps_sdr_signal_processing.cc +++ b/src/algorithms/libs/gps_sdr_signal_processing.cc @@ -83,7 +83,7 @@ void gps_l1_ca_code_gen_int(gsl::span _dest, int32_t _prn, uint32_t _ch G1[lcv] = G1_register[0]; G2[lcv] = G2_register[0]; - feedback1 = G1_register[7] ^ G1_register[0]; + feedback1 = G1_register[7] xor G1_register[0]; feedback2 = G2_register[8] xor G2_register[7] xor G2_register[4] xor G2_register[2] xor G2_register[1] xor G2_register[0]; for (lcv2 = 0; lcv2 < 9; lcv2++) @@ -104,7 +104,7 @@ void gps_l1_ca_code_gen_int(gsl::span _dest, int32_t _prn, uint32_t _ch // Generate PRN from G1 and G2 Registers for (lcv = 0; lcv < _code_length; lcv++) { - aux = G1[(lcv + _chip_shift) % _code_length] ^ G2[delay]; + aux = G1[(lcv + _chip_shift) % _code_length] xor G2[delay]; if (aux == true) { _dest[lcv] = 1; @@ -172,28 +172,27 @@ void gps_l1_ca_code_gen_complex_sampled(gsl::span> _dest, ui for (int32_t i = 0; i < _samplesPerCode; i++) { - //=== Digitizing ======================================================= + //=== Digitizing =================================================== - //--- Make index array to read C/A code values ------------------------- + //--- Make index array to read C/A code values --------------------- // The length of the index array depends on the sampling frequency - // number of samples per millisecond (because one C/A code period is one // millisecond). - // _codeValueIndex = ceil((_ts * ((float)i + 1)) / _tc) - 1; aux = (_ts * (i + 1)) / _tc; _codeValueIndex = auxCeil(aux) - 1; - //--- Make the digitized version of the C/A code ----------------------- + //--- Make the digitized version of the C/A code ------------------- // The "upsampled" code is made by selecting values form the CA code // chip array (caCode) for the time instances of each sample. if (i == _samplesPerCode - 1) { - //--- Correct the last index (due to number rounding issues) ----------- + //--- Correct the last index (due to number rounding issues) _dest[i] = _code[_codeLength - 1]; } else { - _dest[i] = _code[_codeValueIndex]; //repeat the chip -> upsample + _dest[i] = _code[_codeValueIndex]; // repeat the chip -> upsample } } } diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc index 73e09e9ec..8c9c87779 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc @@ -293,7 +293,7 @@ protected: num_thresholds = pfa_vector.size(); - int aux2 = ((generated_signal_duration_s * 1000 - (FLAGS_acq_test_coherent_time_ms * FLAGS_acq_test_max_dwells)) / (FLAGS_acq_test_coherent_time_ms * FLAGS_acq_test_max_dwells)); + int aux2 = ((generated_signal_duration_s * 900 - (FLAGS_acq_test_coherent_time_ms * FLAGS_acq_test_max_dwells)) / (FLAGS_acq_test_coherent_time_ms * FLAGS_acq_test_max_dwells)); if ((FLAGS_acq_test_num_meas > 0) and (FLAGS_acq_test_num_meas < aux2)) { num_of_measurements = static_cast(FLAGS_acq_test_num_meas);