mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-31 15:23:04 +00:00 
			
		
		
		
	Simplify code
This commit is contained in:
		| @@ -33,10 +33,10 @@ | ||||
| #include "galileo_e1_signal_processing.h" | ||||
| #include "Galileo_E1.h" | ||||
| #include "gnss_signal_processing.h" | ||||
| #include <volk_gnsssdr/volk_gnsssdr.h> | ||||
| #include <array> | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
|  | ||||
| void galileo_e1_code_gen_int(gsl::span<int> _dest, const std::array<char, 3>& _Signal, int32_t _prn) | ||||
| @@ -111,8 +111,8 @@ void galileo_e1_code_gen_sinboc11_float(gsl::span<float> _dest, const std::array | ||||
| { | ||||
|     std::string _galileo_signal = _Signal.data(); | ||||
|     const auto _codeLength = static_cast<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS); | ||||
|     std::array<int32_t, 4092> primary_code_E1_chips{};                                               // _codeLength not accepted by Clang | ||||
|     galileo_e1_code_gen_int(gsl::span<int32_t>(primary_code_E1_chips.data(), 4092), _Signal, _prn);  //generate Galileo E1 code, 1 sample per chip | ||||
|     std::array<int32_t, 4092> 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<float>(primary_code_E1_chips[i]); | ||||
| @@ -163,35 +163,31 @@ void galileo_e1_code_gen_float_sampled(gsl::span<float> _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<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS); | ||||
|     auto* primary_code_E1_chips = static_cast<int32_t*>(volk_gnsssdr_malloc(static_cast<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS) * sizeof(int32_t), volk_gnsssdr_get_alignment())); | ||||
|  | ||||
|     _samplesPerCode = static_cast<uint32_t>(static_cast<double>(_fs) / (static_cast<double>(_codeFreqBasis) / static_cast<double>(_codeLength))); | ||||
|     std::vector<int32_t> primary_code_E1_chips(static_cast<int32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS)); | ||||
|     _samplesPerCode = static_cast<uint32_t>(static_cast<double>(_fs) / (static_cast<double>(_codeFreqBasis) / GALILEO_E1_B_CODE_LENGTH_CHIPS)); | ||||
|     const int32_t _samplesPerChip = (_cboc == true) ? 12 : 2; | ||||
|  | ||||
|     const uint32_t delay = ((static_cast<int32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS) - _chip_shift) % static_cast<int32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * _samplesPerCode / GALILEO_E1_B_CODE_LENGTH_CHIPS; | ||||
|  | ||||
|     galileo_e1_code_gen_int(gsl::span<int32_t>(primary_code_E1_chips, static_cast<uint32_t>(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<float> _signal_E1{new float[_codeLength]}; | ||||
|     gsl::span<float> _signal_E1_span(_signal_E1, _codeLength); | ||||
|  | ||||
|     if (_cboc == true) | ||||
|         { | ||||
|             galileo_e1_gen_float(_signal_E1_span, gsl::span<int>(primary_code_E1_chips, static_cast<uint32_t>(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<int32_t*>(volk_gnsssdr_malloc(_codeLength * sizeof(int32_t), volk_gnsssdr_get_alignment())); | ||||
|             gsl::span<int32_t> _signal_E1_int_span(_signal_E1_int, _codeLength); | ||||
|             galileo_e1_sinboc_11_gen_int(_signal_E1_int_span, gsl::span<int>(primary_code_E1_chips, static_cast<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS)));  // generate sinboc(1,1) 2 samples per chip | ||||
|             std::vector<int32_t> _signal_E1_int(static_cast<int32_t>(_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<float>(_signal_E1_int_span[ii]); | ||||
|                     _signal_E1_span[ii] = static_cast<float>(_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<float> _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<std::complex<float>> _dest, c | ||||
|     std::string _galileo_signal = _Signal.data(); | ||||
|     const int32_t _codeFreqBasis = GALILEO_E1_CODE_CHIP_RATE_HZ;  // Hz | ||||
|     auto _samplesPerCode = static_cast<uint32_t>(static_cast<double>(_fs) / | ||||
|                                                  (static_cast<double>(_codeFreqBasis) / static_cast<double>(GALILEO_E1_B_CODE_LENGTH_CHIPS))); | ||||
|                                                  (static_cast<double>(_codeFreqBasis) / GALILEO_E1_B_CODE_LENGTH_CHIPS)); | ||||
|  | ||||
|     if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2 && _secondary_flag) | ||||
|         { | ||||
|             _samplesPerCode *= static_cast<int32_t>(GALILEO_E1_C_SECONDARY_CODE_LENGTH); | ||||
|         } | ||||
|  | ||||
|     auto* real_code = static_cast<float*>(volk_gnsssdr_malloc(_samplesPerCode * sizeof(float), volk_gnsssdr_get_alignment())); | ||||
|     gsl::span<float> 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<float> 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<float>(real_code_span[ii], 0.0F); | ||||
|             _dest[ii] = std::complex<float>(real_code[ii], 0.0F); | ||||
|         } | ||||
|     volk_gnsssdr_free(real_code); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -119,7 +119,7 @@ void glonass_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest | ||||
|     _ts = 1.0 / static_cast<float>(_fs);             // Sampling period in sec | ||||
|     _tc = 1.0 / static_cast<float>(_codeFreqBasis);  // C/A chip period in sec | ||||
|  | ||||
|     glonass_l1_ca_code_gen_complex(gsl::span<std::complex<float>>(_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++) | ||||
|         { | ||||
| @@ -130,7 +130,6 @@ void glonass_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _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; | ||||
|  | ||||
|   | ||||
| @@ -119,7 +119,7 @@ void glonass_l2_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest | ||||
|     _ts = 1.0 / static_cast<float>(_fs);             // Sampling period in sec | ||||
|     _tc = 1.0 / static_cast<float>(_codeFreqBasis);  // C/A chip period in sec | ||||
|  | ||||
|     glonass_l2_ca_code_gen_complex(gsl::span<std::complex<float>>(_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++) | ||||
|         { | ||||
| @@ -130,7 +130,6 @@ void glonass_l2_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _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; | ||||
|  | ||||
|   | ||||
| @@ -168,9 +168,8 @@ void resampler(const gsl::span<float> _from, gsl::span<float> _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; | ||||
|  | ||||
| @@ -192,9 +191,8 @@ void resampler(gsl::span<const std::complex<float>> _from, gsl::span<std::comple | ||||
|     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; | ||||
|  | ||||
|   | ||||
| @@ -32,6 +32,7 @@ | ||||
|  | ||||
| #include "gps_l2c_signal.h" | ||||
| #include "GPS_L2C.h" | ||||
| #include <array> | ||||
| #include <cmath> | ||||
| #include <memory> | ||||
|  | ||||
| @@ -56,32 +57,30 @@ void gps_l2c_m_code(gsl::span<int32_t> _dest, uint32_t _prn) | ||||
|  | ||||
| void gps_l2c_m_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _prn) | ||||
| { | ||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]}; | ||||
|     gsl::span<int32_t> _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS); | ||||
|     std::array<int32_t, GPS_L2_M_CODE_LENGTH_CHIPS> _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<float>(1.0 - 2.0 * _code_span[i], 0.0); | ||||
|             _dest[i] = std::complex<float>(1.0 - 2.0 * _code[i], 0.0); | ||||
|         } | ||||
| } | ||||
|  | ||||
|  | ||||
| void gps_l2c_m_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | ||||
| { | ||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]}; | ||||
|     gsl::span<int32_t> _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS); | ||||
|     std::array<int32_t, GPS_L2_M_CODE_LENGTH_CHIPS> _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<float>(_code_span[i]); | ||||
|             _dest[i] = 1.0 - 2.0 * static_cast<float>(_code[i]); | ||||
|         } | ||||
| } | ||||
|  | ||||
| @@ -91,11 +90,10 @@ void gps_l2c_m_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | ||||
|  */ | ||||
| void gps_l2c_m_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs) | ||||
| { | ||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]}; | ||||
|     gsl::span<int32_t> _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS); | ||||
|     std::array<int32_t, GPS_L2_M_CODE_LENGTH_CHIPS> _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<std::complex<float>> _dest, ui | ||||
|             if (i == _samplesPerCode - 1) | ||||
|                 { | ||||
|                     //--- Correct the last index (due to number rounding issues) ----------- | ||||
|                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeLength - 1], 0); | ||||
|                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeLength - 1], 0); | ||||
|                 } | ||||
|             else | ||||
|                 { | ||||
|                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeValueIndex], 0);  //repeat the chip -> upsample | ||||
|                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeValueIndex], 0);  //repeat the chip -> upsample | ||||
|                 } | ||||
|         } | ||||
| } | ||||
|   | ||||
| @@ -32,9 +32,9 @@ | ||||
|  | ||||
| #include "gps_l5_signal.h" | ||||
| #include "GPS_L5.h" | ||||
| #include <array> | ||||
| #include <deque> | ||||
|  | ||||
|  | ||||
| std::deque<bool> l5i_xa_shift(std::deque<bool> xa)  // GPS-IS-705E Figure 3-4 pp. 15 | ||||
| { | ||||
|     if (xa == std::deque<bool>{true, true, true, true, true, true, true, true, true, true, true, false, true}) | ||||
| @@ -173,32 +173,30 @@ void make_l5q(gsl::span<int32_t> _dest, int32_t prn) | ||||
|  | ||||
| void gps_l5i_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _prn) | ||||
| { | ||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]}; | ||||
|     gsl::span<int32_t> _code_span(_code, GPS_L5I_CODE_LENGTH_CHIPS); | ||||
|     std::array<int32_t, GPS_L5I_CODE_LENGTH_CHIPS> _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<float>(1.0 - 2.0 * _code_span[i], 0.0); | ||||
|             _dest[i] = std::complex<float>(1.0 - 2.0 * static_cast<float>(_code[i]), 0.0); | ||||
|         } | ||||
| } | ||||
|  | ||||
|  | ||||
| void gps_l5i_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | ||||
| { | ||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]}; | ||||
|     gsl::span<int32_t> _code_span(_code, GPS_L5I_CODE_LENGTH_CHIPS); | ||||
|     std::array<int32_t, GPS_L5I_CODE_LENGTH_CHIPS> _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<float>(_code_span[i]); | ||||
|             _dest[i] = 1.0 - 2.0 * static_cast<float>(_code[i]); | ||||
|         } | ||||
| } | ||||
|  | ||||
| @@ -208,11 +206,10 @@ void gps_l5i_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | ||||
|  */ | ||||
| void gps_l5i_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs) | ||||
| { | ||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]}; | ||||
|     gsl::span<int32_t> _code_span(_code, GPS_L5I_CODE_LENGTH_CHIPS); | ||||
|     std::array<int32_t, GPS_L5I_CODE_LENGTH_CHIPS> _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<std::complex<float>> _dest, uint | ||||
|             if (i == _samplesPerCode - 1) | ||||
|                 { | ||||
|                     //--- Correct the last index (due to number rounding issues) ----------- | ||||
|                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeLength - 1], 0.0); | ||||
|                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeLength - 1], 0.0); | ||||
|                 } | ||||
|             else | ||||
|                 { | ||||
|                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeValueIndex], 0.0);  // repeat the chip -> upsample | ||||
|                     _dest[i] = std::complex<float>(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<std::complex<float>> _dest, uint | ||||
|  | ||||
| void gps_l5q_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _prn) | ||||
| { | ||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]}; | ||||
|     gsl::span<int32_t> _code_span(_code, GPS_L5Q_CODE_LENGTH_CHIPS); | ||||
|     std::array<int32_t, GPS_L5Q_CODE_LENGTH_CHIPS> _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<float>(1.0 - 2.0 * _code_span[i], 0.0); | ||||
|             _dest[i] = std::complex<float>(1.0 - 2.0 * static_cast<float>(_code[i]), 0.0); | ||||
|         } | ||||
| } | ||||
|  | ||||
|  | ||||
| void gps_l5q_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | ||||
| { | ||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]}; | ||||
|     gsl::span<int32_t> _code_span(_code, GPS_L5Q_CODE_LENGTH_CHIPS); | ||||
|     std::array<int32_t, GPS_L5Q_CODE_LENGTH_CHIPS> _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<float>(_code_span[i]); | ||||
|             _dest[i] = 1.0 - 2.0 * static_cast<float>(_code[i]); | ||||
|         } | ||||
| } | ||||
|  | ||||
| @@ -285,11 +280,10 @@ void gps_l5q_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | ||||
|  */ | ||||
| void gps_l5q_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs) | ||||
| { | ||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]}; | ||||
|     gsl::span<int32_t> _code_span(_code, GPS_L5Q_CODE_LENGTH_CHIPS); | ||||
|     std::array<int32_t, GPS_L5Q_CODE_LENGTH_CHIPS> _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<std::complex<float>> _dest, uint | ||||
|             if (i == _samplesPerCode - 1) | ||||
|                 { | ||||
|                     //--- Correct the last index (due to number rounding issues) ----------- | ||||
|                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeLength - 1], 0); | ||||
|                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeLength - 1], 0); | ||||
|                 } | ||||
|             else | ||||
|                 { | ||||
|                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeValueIndex], 0);  // repeat the chip -> upsample | ||||
|                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeValueIndex], 0);  // repeat the chip -> upsample | ||||
|                 } | ||||
|         } | ||||
| } | ||||
|   | ||||
| @@ -172,23 +172,22 @@ void gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Carles Fernandez
					Carles Fernandez