From 5d4dbf3ce766a4618edc1296aaa899ae7733edc2 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 21 Jul 2020 14:31:45 +0200 Subject: [PATCH] Minor, misc. fixes --- .../libs/galileo_e1_signal_processing.cc | 17 +++++++------ src/algorithms/libs/gnss_signal_processing.cc | 24 +++++-------------- .../gps_l1_ca_telemetry_decoder_gs.cc | 6 ++--- 3 files changed, 17 insertions(+), 30 deletions(-) diff --git a/src/algorithms/libs/galileo_e1_signal_processing.cc b/src/algorithms/libs/galileo_e1_signal_processing.cc index 3f9dd91ff..e7a3edc83 100644 --- a/src/algorithms/libs/galileo_e1_signal_processing.cc +++ b/src/algorithms/libs/galileo_e1_signal_processing.cc @@ -23,6 +23,7 @@ #include "Galileo_E1.h" #include "gnss_signal_processing.h" #include +#include // for size_t #include #include #include @@ -112,22 +113,20 @@ void galileo_e1_code_gen_sinboc11_float(own::span _dest, const std::array void galileo_e1_gen_float(own::span _dest, own::span _prn, const std::array& _Signal) { - constexpr uint32_t _codeLength = 12 * GALILEO_E1_B_CODE_LENGTH_CHIPS; + const auto _codeLength = _dest.size(); const float alpha = std::sqrt(10.0F / 11.0F); const float beta = std::sqrt(1.0F / 11.0F); const std::string _galileo_signal = _Signal.data(); - std::array sinboc_11{}; - std::array sinboc_61{}; - own::span sinboc_11_(sinboc_11.data(), _codeLength); - own::span sinboc_61_(sinboc_61.data(), _codeLength); + std::vector sinboc_11(_codeLength); + std::vector sinboc_61(_codeLength); - galileo_e1_sinboc_11_gen_int(sinboc_11_, _prn); // generate sinboc(1,1) 12 samples per chip - galileo_e1_sinboc_61_gen_int(sinboc_61_, _prn); // generate sinboc(6,1) 12 samples per chip + galileo_e1_sinboc_11_gen_int(sinboc_11, _prn); // generate sinboc(1,1) 12 samples per chip + galileo_e1_sinboc_61_gen_int(sinboc_61, _prn); // generate sinboc(6,1) 12 samples per chip if (_galileo_signal.rfind("1B") != std::string::npos && _galileo_signal.length() >= 2) { - for (uint32_t i = 0; i < _codeLength; i++) + for (size_t i = 0; i < _codeLength; i++) { _dest[i] = alpha * static_cast(sinboc_11[i]) + beta * static_cast(sinboc_61[i]); @@ -135,7 +134,7 @@ void galileo_e1_gen_float(own::span _dest, own::span _prn, const std } else if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2) { - for (uint32_t i = 0; i < _codeLength; i++) + for (size_t i = 0; i < _codeLength; i++) { _dest[i] = alpha * static_cast(sinboc_11[i]) - beta * static_cast(sinboc_61[i]); diff --git a/src/algorithms/libs/gnss_signal_processing.cc b/src/algorithms/libs/gnss_signal_processing.cc index 048a1f227..fc609b81f 100644 --- a/src/algorithms/libs/gnss_signal_processing.cc +++ b/src/algorithms/libs/gnss_signal_processing.cc @@ -154,20 +154,14 @@ void resampler(const own::span _from, own::span _dest, float _fs_i { uint32_t _codeValueIndex; float aux; - // --- Find time constants ------------------------------------------------- - const float _t_in = 1.0F / _fs_in; // Incoming sampling period in sec - const float _t_out = 1.0F / _fs_out; // Out sampling period in sec + const float _t_out = 1.0F / _fs_out; // Output sampling period for (size_t i = 0; i < _dest.size() - 1; i++) { - // === Digitizing ================================================== - // --- compute index array to read sampled values ------------------ - aux = (_t_out * (static_cast(i) + 1.0F)) / _t_in; + aux = (_t_out * (static_cast(i) + 1.0F)) * _fs_in; _codeValueIndex = AUX_CEIL2(aux) - 1; - - // if repeat the chip -> upsample by nearest neighborhood interpolation _dest[i] = _from[_codeValueIndex]; } - // --- Correct the last index (due to number rounding issues) ----------- + // Correct the last index (due to number rounding issues) _dest[_dest.size() - 1] = _from[_from.size() - 1]; } @@ -177,19 +171,13 @@ void resampler(own::span> _from, own::span(i) + 1.0F)) / _t_in; + aux = (_t_out * (static_cast(i) + 1.0F)) * _fs_in; _codeValueIndex = AUX_CEIL2(aux) - 1; - - // if repeat the chip -> upsample by nearest neighborhood interpolation _dest[i] = _from[_codeValueIndex]; } - // --- Correct the last index (due to number rounding issues) ----------- + // Correct the last index (due to number rounding issues) _dest[_dest.size() - 1] = _from[_from.size() - 1]; } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc index c9e726c48..ee2dd2191 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc @@ -274,19 +274,19 @@ bool gps_l1_ca_telemetry_decoder_gs::decode_subframe() if (d_nav.satellite_validation() == true) { // get ephemeris object for this SV (mandatory) - std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); + const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } break; case 4: // Possible IONOSPHERE and UTC model update (page 18) if (d_nav.get_flag_iono_valid() == true) { - std::shared_ptr tmp_obj = std::make_shared(d_nav.get_iono()); + const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_iono()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } if (d_nav.get_flag_utc_model_valid() == true) { - std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); + const std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } break;