From d42d6b2ed4e4f4975f9172f32b4ce2b8468fc76e Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Mon, 9 Apr 2018 16:16:50 +0200 Subject: [PATCH 01/44] Change std::vector> by gnss_circular_deque --- src/algorithms/libs/gnss_circular_deque.h | 213 ++++++++++++++++++ .../observables/adapters/CMakeLists.txt | 1 + .../gnuradio_blocks/CMakeLists.txt | 6 +- .../gnuradio_blocks/hybrid_observables_cc.cc | 122 +++++++--- .../gnuradio_blocks/hybrid_observables_cc.h | 11 +- 5 files changed, 312 insertions(+), 41 deletions(-) create mode 100644 src/algorithms/libs/gnss_circular_deque.h diff --git a/src/algorithms/libs/gnss_circular_deque.h b/src/algorithms/libs/gnss_circular_deque.h new file mode 100644 index 000000000..f453be3d2 --- /dev/null +++ b/src/algorithms/libs/gnss_circular_deque.h @@ -0,0 +1,213 @@ +/*! + * \file gnss_circular_deque.h + * \brief This class implements a circular deque for Gnss_Synchro + * + * \author Luis Esteve, 2018. antonio.ramos(at)cttc.es + * + * Detailed description of the file here if needed. + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (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 . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_CIRCULAR_DEQUE_H_ +#define GNSS_SDR_CIRCULAR_DEQUE_H_ + +template +class Gnss_circular_deque +{ +public: + Gnss_circular_deque(); + Gnss_circular_deque(const unsigned int max_size, const unsigned int nchann); + ~Gnss_circular_deque(); + unsigned int size(const unsigned int ch); + T& at(const unsigned int ch, const unsigned int pos); + T& front(const unsigned int ch); + T& back(const unsigned int ch); + void push_back(const unsigned int ch, const T& new_data); + T pop_front(const unsigned int ch); + void clear(const unsigned int ch); + T* get_vector(const unsigned int ch); + +private: + T** d_history; + T d_return_void; // Void object for avoid compiler errors + unsigned int* d_index_pop; + unsigned int* d_index_push; + unsigned int* d_size; + unsigned int d_max_size; + unsigned int d_nchannels; +}; + + +template +Gnss_circular_deque::Gnss_circular_deque() +{ + d_max_size = 0; + d_nchannels = 0; + d_size = nullptr; + d_index_pop = nullptr; + d_index_push = nullptr; + d_history = nullptr; +} + +template +Gnss_circular_deque::Gnss_circular_deque(const unsigned int max_size, const unsigned int nchann) +{ + d_max_size = max_size; + d_nchannels = nchann; + if (d_max_size > 0 and d_nchannels > 0) + { + d_size = new unsigned int[d_nchannels]; + d_index_pop = new unsigned int[d_nchannels]; + d_index_push = new unsigned int[d_nchannels]; + d_history = new T*[d_nchannels]; + for (unsigned int i = 0; i < d_nchannels; i++) + { + d_size[i] = 0; + d_index_pop[i] = 0; + d_index_push[i] = 0; + d_history[i] = new T[d_max_size]; + } + } +} + +template +Gnss_circular_deque::~Gnss_circular_deque() +{ + if (d_max_size > 0 and d_nchannels > 0) + { + delete[] d_size; + delete[] d_index_pop; + delete[] d_index_push; + for (unsigned int i = 0; i < d_nchannels; i++) + { + delete[] d_history[i]; + } + delete[] d_history; + } +} + +template +unsigned int Gnss_circular_deque::size(const unsigned int ch) +{ + return d_size[ch]; +} + +template +T& Gnss_circular_deque::back(const unsigned int ch) +{ + if (d_size[ch] > 0) + { + unsigned int index = 0; + if (d_index_push[ch] > 0) + { + index = d_index_push[ch] - 1; + } + else + { + index = d_max_size; + } + return d_history[ch][index]; + } + else + { + return d_return_void; + } +} + +template +T& Gnss_circular_deque::front(const unsigned int ch) +{ + if (d_size[ch] > 0) + { + return d_history[ch][d_index_pop[ch]]; + } + else + { + return d_return_void; + } +} + +template +T& Gnss_circular_deque::at(const unsigned int ch, const unsigned int pos) +{ + if (d_size[ch] > 0 and pos < d_size[ch]) + { + unsigned int index = (d_index_pop[ch] + pos) % d_max_size; + return d_history[ch][index]; + } + else + { + return d_return_void; + } +} + +template +void Gnss_circular_deque::clear(const unsigned int ch) +{ + d_size[ch] = 0; + d_index_pop[ch] = 0; + d_index_push[ch] = 0; +} + +template +T Gnss_circular_deque::pop_front(const unsigned int ch) +{ + T result; + if (d_size[ch] > 0) + { + d_size[ch]--; + result = d_history[ch][d_index_pop[ch]]; + d_index_pop[ch]++; + d_index_pop[ch] %= d_max_size; + } + return result; +} + +template +void Gnss_circular_deque::push_back(const unsigned int ch, const T& new_data) +{ + d_history[ch][d_index_push[ch]] = new_data; + d_index_push[ch]++; + d_index_push[ch] %= d_max_size; + if (d_size[ch] < d_max_size) + { + d_size[ch]++; + } + else + { + d_index_pop[ch]++; + d_index_pop[ch] %= d_max_size; + } +} + +template +T* Gnss_circular_deque::get_vector(const unsigned int ch) +{ + return d_history[ch]; +} + + +#endif /* GNSS_SDR_CIRCULAR_DEQUE_H_ */ diff --git a/src/algorithms/observables/adapters/CMakeLists.txt b/src/algorithms/observables/adapters/CMakeLists.txt index 5129e4157..882b22d83 100644 --- a/src/algorithms/observables/adapters/CMakeLists.txt +++ b/src/algorithms/observables/adapters/CMakeLists.txt @@ -26,6 +26,7 @@ include_directories( ${CMAKE_SOURCE_DIR}/src/core/interfaces ${CMAKE_SOURCE_DIR}/src/core/receiver ${CMAKE_SOURCE_DIR}/src/algorithms/observables/gnuradio_blocks + ${CMAKE_SOURCE_DIR}/src/algorithms/libs ${CMAKE_SOURCE_DIR}/src/algorithms/PVT/libs ${GLOG_INCLUDE_DIRS} ${GFlags_INCLUDE_DIRS} diff --git a/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt b/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt index 98b8213d8..e3db8ebcf 100644 --- a/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt @@ -39,8 +39,8 @@ list(SORT OBS_GR_BLOCKS_HEADERS) add_library(obs_gr_blocks ${OBS_GR_BLOCKS_SOURCES} ${OBS_GR_BLOCKS_HEADERS}) source_group(Headers FILES ${OBS_GR_BLOCKS_HEADERS}) if(MATIO_FOUND) - add_dependencies(obs_gr_blocks glog-${glog_RELEASE} armadillo-${armadillo_RELEASE}) + add_dependencies(obs_gr_blocks gnss_sp_libs glog-${glog_RELEASE} armadillo-${armadillo_RELEASE}) else(MATIO_FOUND) - add_dependencies(obs_gr_blocks glog-${glog_RELEASE} armadillo-${armadillo_RELEASE} matio-${GNSSSDR_MATIO_LOCAL_VERSION}) + add_dependencies(obs_gr_blocks gnss_sp_libs glog-${glog_RELEASE} armadillo-${armadillo_RELEASE} matio-${GNSSSDR_MATIO_LOCAL_VERSION}) endif(MATIO_FOUND) -target_link_libraries(obs_gr_blocks ${GNURADIO_RUNTIME_LIBRARIES} ${ARMADILLO_LIBRARIES} ${MATIO_LIBRARIES}) +target_link_libraries(obs_gr_blocks gnss_sp_libs ${GNURADIO_RUNTIME_LIBRARIES} ${ARMADILLO_LIBRARIES} ${MATIO_LIBRARIES}) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index 6e95da824..4b03988aa 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -66,11 +66,7 @@ hybrid_observables_cc::hybrid_observables_cc(unsigned int nchannels_in, max_delta = 0.15; // 150 ms valid_channels.resize(d_nchannels, false); d_num_valid_channels = 0; - - for (unsigned int i = 0; i < d_nchannels; i++) - { - d_gnss_synchro_history.push_back(std::deque()); - } + d_gnss_synchro_history = Gnss_circular_deque(200, d_nchannels); // ############# ENABLE DATA FILE LOG ################# if (d_dump) @@ -302,15 +298,37 @@ int hybrid_observables_cc::save_matfile() } -bool hybrid_observables_cc::interpolate_data(Gnss_Synchro &out, std::deque &data, const double &ti) +bool hybrid_observables_cc::interpolate_data(Gnss_Synchro &out, const unsigned int &ch, const double &ti) { - if ((ti < data.front().RX_time) or (ti > data.back().RX_time)) + if ((ti < d_gnss_synchro_history.front(ch).RX_time) or (ti > d_gnss_synchro_history.back(ch).RX_time)) { return false; } - std::deque::iterator it; + std::pair ind = find_interp_elements(ch, ti); - arma::vec t = arma::vec(data.size()); + double m = 0.0; + double c = 0.0; + + // CARRIER PHASE INTERPOLATION + + m = (d_gnss_synchro_history.at(ch, ind.first).Carrier_phase_rads - d_gnss_synchro_history.at(ch, ind.second).Carrier_phase_rads) / (d_gnss_synchro_history.at(ch, ind.first).RX_time - d_gnss_synchro_history.at(ch, ind.second).RX_time); + c = d_gnss_synchro_history.at(ch, ind.first).Carrier_phase_rads - m * d_gnss_synchro_history.at(ch, ind.first).RX_time; + out.Carrier_phase_rads = m * ti + c; + + // CARRIER DOPPLER INTERPOLATION + m = (d_gnss_synchro_history.at(ch, ind.first).Carrier_Doppler_hz - d_gnss_synchro_history.at(ch, ind.second).Carrier_Doppler_hz) / (d_gnss_synchro_history.at(ch, ind.first).RX_time - d_gnss_synchro_history.at(ch, ind.second).RX_time); + c = d_gnss_synchro_history.at(ch, ind.first).Carrier_Doppler_hz - m * d_gnss_synchro_history.at(ch, ind.first).RX_time; + out.Carrier_Doppler_hz = m * ti + c; + + // TOW INTERPOLATION + m = (d_gnss_synchro_history.at(ch, ind.first).TOW_at_current_symbol_s - d_gnss_synchro_history.at(ch, ind.second).TOW_at_current_symbol_s) / (d_gnss_synchro_history.at(ch, ind.first).RX_time - d_gnss_synchro_history.at(ch, ind.second).RX_time); + c = d_gnss_synchro_history.at(ch, ind.first).TOW_at_current_symbol_s - m * d_gnss_synchro_history.at(ch, ind.first).RX_time; + out.TOW_at_current_symbol_s = m * ti + c; + + return true; + + /* + arma::vec t = arma::vec(d_gnss_synchro_history.size(ch)); arma::vec dop = t; arma::vec cph = t; arma::vec tow = t; @@ -336,6 +354,7 @@ bool hybrid_observables_cc::interpolate_data(Gnss_Synchro &out, std::deque hybrid_observables_cc::find_interp_elements(const unsigned int &ch, const double &ti) +{ + unsigned int closest = 0; + double dif = std::numeric_limits::max(); + double dt = 0.0; + for (unsigned int i = 0; i < d_gnss_synchro_history.size(ch); i++) + { + dt = std::fabs(ti - d_gnss_synchro_history.at(ch, i).RX_time); + if (dt < dif) + { + dif = dt; + closest = i; + } + } + unsigned int index1; + unsigned int index2; + if (closest == 0) + { + index1 = 0; + index2 = 1; + } + else if (closest == (d_gnss_synchro_history.size(ch) - 1)) + { + index1 = d_gnss_synchro_history.size(ch) - 2; + index2 = d_gnss_synchro_history.size(ch) - 1; + } + else + { + if (d_gnss_synchro_history.at(ch, closest).RX_time < ti) + { + index1 = closest; + index2 = closest + 1; + } + else + { + index1 = closest - 1; + index2 = closest; + } + } + return std::pair(index1, index2); +} + void hybrid_observables_cc::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required) @@ -363,13 +424,13 @@ void hybrid_observables_cc::forecast(int noutput_items __attribute__((unused)), } -void hybrid_observables_cc::clean_history(std::deque &data) +void hybrid_observables_cc::clean_history(Gnss_circular_deque &data, unsigned int pos) { - while (data.size() > 0) + while (data.size(pos) > 0) { - if ((T_rx_s - data.front().RX_time) > max_delta) + if ((T_rx_s - data.front(pos).RX_time) > max_delta) { - data.pop_front(); + data.pop_front(pos); } else { @@ -454,11 +515,9 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) } ////////////////////////////////////////////////////////////////////////// - std::vector>::iterator it; if (total_input_items > 0) { - i = 0; - for (it = d_gnss_synchro_history.begin(); it != d_gnss_synchro_history.end(); it++) + for (unsigned int i = 0; i < d_nchannels; i++) { if (ninput_items[i] > 0) { @@ -467,26 +526,25 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) { if (in[i][aux].Flag_valid_word) { - it->push_back(in[i][aux]); - it->back().RX_time = compute_T_rx_s(in[i][aux]); + d_gnss_synchro_history.push_back(i, in[i][aux]); + d_gnss_synchro_history.back(i).RX_time = compute_T_rx_s(in[i][aux]); // Check if the last Gnss_Synchro comes from the same satellite as the previous ones - if (it->size() > 1) + if (d_gnss_synchro_history.size(i) > 1) { - if (it->front().PRN != it->back().PRN) + if (d_gnss_synchro_history.front(i).PRN != d_gnss_synchro_history.back(i).PRN) { - it->clear(); + d_gnss_synchro_history.clear(i); } } } } consume(i, ninput_items[i]); } - i++; } } for (i = 0; i < d_nchannels; i++) { - if (d_gnss_synchro_history.at(i).size() > 2) + if (d_gnss_synchro_history.size(i) > 2) { valid_channels[i] = true; } @@ -506,8 +564,8 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) { if (valid_channels[i]) { - clean_history(d_gnss_synchro_history.at(i)); - if (d_gnss_synchro_history.at(i).size() < 2) + clean_history(d_gnss_synchro_history, i); + if (d_gnss_synchro_history.size(i) < 2) { valid_channels[i] = false; } @@ -523,13 +581,12 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) } std::vector epoch_data; - i = 0; - for (it = d_gnss_synchro_history.begin(); it != d_gnss_synchro_history.end(); it++) + for (unsigned int i = 0; i < d_nchannels; i++) { if (valid_channels[i]) { - Gnss_Synchro interpolated_gnss_synchro = it->back(); - if (interpolate_data(interpolated_gnss_synchro, *it, T_rx_s_out)) + Gnss_Synchro interpolated_gnss_synchro = d_gnss_synchro_history.back(i); + if (interpolate_data(interpolated_gnss_synchro, i, T_rx_s_out)) { epoch_data.push_back(interpolated_gnss_synchro); } @@ -538,7 +595,6 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) valid_channels[i] = false; } } - i++; } d_num_valid_channels = valid_channels.count(); if (d_num_valid_channels == 0) @@ -546,14 +602,14 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) return 0; } correct_TOW_and_compute_prange(epoch_data); - std::vector::iterator it2 = epoch_data.begin(); + std::vector::iterator it = epoch_data.begin(); for (i = 0; i < d_nchannels; i++) { if (valid_channels[i]) { - out[i][0] = (*it2); + out[i][0] = (*it); out[i][0].Flag_valid_pseudorange = true; - it2++; + it++; } else { diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h index aedba43ab..298a9a0bb 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h @@ -35,12 +35,12 @@ #define GNSS_SDR_HYBRID_OBSERVABLES_CC_H #include "gnss_synchro.h" +#include "gnss_circular_deque.h" #include #include #include #include -#include -#include +#include class hybrid_observables_cc; @@ -65,14 +65,15 @@ private: friend hybrid_observables_cc_sptr hybrid_make_observables_cc(unsigned int nchannels_in, unsigned int nchannels_out, bool dump, std::string dump_filename); hybrid_observables_cc(unsigned int nchannels_in, unsigned int nchannels_out, bool dump, std::string dump_filename); - void clean_history(std::deque& data); + void clean_history(Gnss_circular_deque& data, unsigned int pos); double compute_T_rx_s(const Gnss_Synchro& a); - bool interpolate_data(Gnss_Synchro& out, std::deque& data, const double& ti); + bool interpolate_data(Gnss_Synchro& out, const unsigned int& ch, const double& ti); + std::pair find_interp_elements(const unsigned int& ch, const double& ti); void correct_TOW_and_compute_prange(std::vector& data); int save_matfile(); //Tracking observable history - std::vector> d_gnss_synchro_history; + Gnss_circular_deque d_gnss_synchro_history; boost::dynamic_bitset<> valid_channels; double T_rx_s; double T_rx_step_s; From f022d49709930ff9913f1cee95f1b4d5efabff07 Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Mon, 9 Apr 2018 16:45:05 +0200 Subject: [PATCH 02/44] Revert "Modify observables history" --- src/algorithms/libs/gnss_circular_deque.h | 213 ------------------ .../observables/adapters/CMakeLists.txt | 1 - .../gnuradio_blocks/CMakeLists.txt | 6 +- .../gnuradio_blocks/hybrid_observables_cc.cc | 122 +++------- .../gnuradio_blocks/hybrid_observables_cc.h | 11 +- 5 files changed, 41 insertions(+), 312 deletions(-) delete mode 100644 src/algorithms/libs/gnss_circular_deque.h diff --git a/src/algorithms/libs/gnss_circular_deque.h b/src/algorithms/libs/gnss_circular_deque.h deleted file mode 100644 index f453be3d2..000000000 --- a/src/algorithms/libs/gnss_circular_deque.h +++ /dev/null @@ -1,213 +0,0 @@ -/*! - * \file gnss_circular_deque.h - * \brief This class implements a circular deque for Gnss_Synchro - * - * \author Luis Esteve, 2018. antonio.ramos(at)cttc.es - * - * Detailed description of the file here if needed. - * - * ------------------------------------------------------------------------- - * - * Copyright (C) 2010-2018 (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 . - * - * ------------------------------------------------------------------------- - */ - -#ifndef GNSS_SDR_CIRCULAR_DEQUE_H_ -#define GNSS_SDR_CIRCULAR_DEQUE_H_ - -template -class Gnss_circular_deque -{ -public: - Gnss_circular_deque(); - Gnss_circular_deque(const unsigned int max_size, const unsigned int nchann); - ~Gnss_circular_deque(); - unsigned int size(const unsigned int ch); - T& at(const unsigned int ch, const unsigned int pos); - T& front(const unsigned int ch); - T& back(const unsigned int ch); - void push_back(const unsigned int ch, const T& new_data); - T pop_front(const unsigned int ch); - void clear(const unsigned int ch); - T* get_vector(const unsigned int ch); - -private: - T** d_history; - T d_return_void; // Void object for avoid compiler errors - unsigned int* d_index_pop; - unsigned int* d_index_push; - unsigned int* d_size; - unsigned int d_max_size; - unsigned int d_nchannels; -}; - - -template -Gnss_circular_deque::Gnss_circular_deque() -{ - d_max_size = 0; - d_nchannels = 0; - d_size = nullptr; - d_index_pop = nullptr; - d_index_push = nullptr; - d_history = nullptr; -} - -template -Gnss_circular_deque::Gnss_circular_deque(const unsigned int max_size, const unsigned int nchann) -{ - d_max_size = max_size; - d_nchannels = nchann; - if (d_max_size > 0 and d_nchannels > 0) - { - d_size = new unsigned int[d_nchannels]; - d_index_pop = new unsigned int[d_nchannels]; - d_index_push = new unsigned int[d_nchannels]; - d_history = new T*[d_nchannels]; - for (unsigned int i = 0; i < d_nchannels; i++) - { - d_size[i] = 0; - d_index_pop[i] = 0; - d_index_push[i] = 0; - d_history[i] = new T[d_max_size]; - } - } -} - -template -Gnss_circular_deque::~Gnss_circular_deque() -{ - if (d_max_size > 0 and d_nchannels > 0) - { - delete[] d_size; - delete[] d_index_pop; - delete[] d_index_push; - for (unsigned int i = 0; i < d_nchannels; i++) - { - delete[] d_history[i]; - } - delete[] d_history; - } -} - -template -unsigned int Gnss_circular_deque::size(const unsigned int ch) -{ - return d_size[ch]; -} - -template -T& Gnss_circular_deque::back(const unsigned int ch) -{ - if (d_size[ch] > 0) - { - unsigned int index = 0; - if (d_index_push[ch] > 0) - { - index = d_index_push[ch] - 1; - } - else - { - index = d_max_size; - } - return d_history[ch][index]; - } - else - { - return d_return_void; - } -} - -template -T& Gnss_circular_deque::front(const unsigned int ch) -{ - if (d_size[ch] > 0) - { - return d_history[ch][d_index_pop[ch]]; - } - else - { - return d_return_void; - } -} - -template -T& Gnss_circular_deque::at(const unsigned int ch, const unsigned int pos) -{ - if (d_size[ch] > 0 and pos < d_size[ch]) - { - unsigned int index = (d_index_pop[ch] + pos) % d_max_size; - return d_history[ch][index]; - } - else - { - return d_return_void; - } -} - -template -void Gnss_circular_deque::clear(const unsigned int ch) -{ - d_size[ch] = 0; - d_index_pop[ch] = 0; - d_index_push[ch] = 0; -} - -template -T Gnss_circular_deque::pop_front(const unsigned int ch) -{ - T result; - if (d_size[ch] > 0) - { - d_size[ch]--; - result = d_history[ch][d_index_pop[ch]]; - d_index_pop[ch]++; - d_index_pop[ch] %= d_max_size; - } - return result; -} - -template -void Gnss_circular_deque::push_back(const unsigned int ch, const T& new_data) -{ - d_history[ch][d_index_push[ch]] = new_data; - d_index_push[ch]++; - d_index_push[ch] %= d_max_size; - if (d_size[ch] < d_max_size) - { - d_size[ch]++; - } - else - { - d_index_pop[ch]++; - d_index_pop[ch] %= d_max_size; - } -} - -template -T* Gnss_circular_deque::get_vector(const unsigned int ch) -{ - return d_history[ch]; -} - - -#endif /* GNSS_SDR_CIRCULAR_DEQUE_H_ */ diff --git a/src/algorithms/observables/adapters/CMakeLists.txt b/src/algorithms/observables/adapters/CMakeLists.txt index 882b22d83..5129e4157 100644 --- a/src/algorithms/observables/adapters/CMakeLists.txt +++ b/src/algorithms/observables/adapters/CMakeLists.txt @@ -26,7 +26,6 @@ include_directories( ${CMAKE_SOURCE_DIR}/src/core/interfaces ${CMAKE_SOURCE_DIR}/src/core/receiver ${CMAKE_SOURCE_DIR}/src/algorithms/observables/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/libs ${CMAKE_SOURCE_DIR}/src/algorithms/PVT/libs ${GLOG_INCLUDE_DIRS} ${GFlags_INCLUDE_DIRS} diff --git a/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt b/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt index e3db8ebcf..98b8213d8 100644 --- a/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt @@ -39,8 +39,8 @@ list(SORT OBS_GR_BLOCKS_HEADERS) add_library(obs_gr_blocks ${OBS_GR_BLOCKS_SOURCES} ${OBS_GR_BLOCKS_HEADERS}) source_group(Headers FILES ${OBS_GR_BLOCKS_HEADERS}) if(MATIO_FOUND) - add_dependencies(obs_gr_blocks gnss_sp_libs glog-${glog_RELEASE} armadillo-${armadillo_RELEASE}) + add_dependencies(obs_gr_blocks glog-${glog_RELEASE} armadillo-${armadillo_RELEASE}) else(MATIO_FOUND) - add_dependencies(obs_gr_blocks gnss_sp_libs glog-${glog_RELEASE} armadillo-${armadillo_RELEASE} matio-${GNSSSDR_MATIO_LOCAL_VERSION}) + add_dependencies(obs_gr_blocks glog-${glog_RELEASE} armadillo-${armadillo_RELEASE} matio-${GNSSSDR_MATIO_LOCAL_VERSION}) endif(MATIO_FOUND) -target_link_libraries(obs_gr_blocks gnss_sp_libs ${GNURADIO_RUNTIME_LIBRARIES} ${ARMADILLO_LIBRARIES} ${MATIO_LIBRARIES}) +target_link_libraries(obs_gr_blocks ${GNURADIO_RUNTIME_LIBRARIES} ${ARMADILLO_LIBRARIES} ${MATIO_LIBRARIES}) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index 4b03988aa..6e95da824 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -66,7 +66,11 @@ hybrid_observables_cc::hybrid_observables_cc(unsigned int nchannels_in, max_delta = 0.15; // 150 ms valid_channels.resize(d_nchannels, false); d_num_valid_channels = 0; - d_gnss_synchro_history = Gnss_circular_deque(200, d_nchannels); + + for (unsigned int i = 0; i < d_nchannels; i++) + { + d_gnss_synchro_history.push_back(std::deque()); + } // ############# ENABLE DATA FILE LOG ################# if (d_dump) @@ -298,37 +302,15 @@ int hybrid_observables_cc::save_matfile() } -bool hybrid_observables_cc::interpolate_data(Gnss_Synchro &out, const unsigned int &ch, const double &ti) +bool hybrid_observables_cc::interpolate_data(Gnss_Synchro &out, std::deque &data, const double &ti) { - if ((ti < d_gnss_synchro_history.front(ch).RX_time) or (ti > d_gnss_synchro_history.back(ch).RX_time)) + if ((ti < data.front().RX_time) or (ti > data.back().RX_time)) { return false; } - std::pair ind = find_interp_elements(ch, ti); + std::deque::iterator it; - double m = 0.0; - double c = 0.0; - - // CARRIER PHASE INTERPOLATION - - m = (d_gnss_synchro_history.at(ch, ind.first).Carrier_phase_rads - d_gnss_synchro_history.at(ch, ind.second).Carrier_phase_rads) / (d_gnss_synchro_history.at(ch, ind.first).RX_time - d_gnss_synchro_history.at(ch, ind.second).RX_time); - c = d_gnss_synchro_history.at(ch, ind.first).Carrier_phase_rads - m * d_gnss_synchro_history.at(ch, ind.first).RX_time; - out.Carrier_phase_rads = m * ti + c; - - // CARRIER DOPPLER INTERPOLATION - m = (d_gnss_synchro_history.at(ch, ind.first).Carrier_Doppler_hz - d_gnss_synchro_history.at(ch, ind.second).Carrier_Doppler_hz) / (d_gnss_synchro_history.at(ch, ind.first).RX_time - d_gnss_synchro_history.at(ch, ind.second).RX_time); - c = d_gnss_synchro_history.at(ch, ind.first).Carrier_Doppler_hz - m * d_gnss_synchro_history.at(ch, ind.first).RX_time; - out.Carrier_Doppler_hz = m * ti + c; - - // TOW INTERPOLATION - m = (d_gnss_synchro_history.at(ch, ind.first).TOW_at_current_symbol_s - d_gnss_synchro_history.at(ch, ind.second).TOW_at_current_symbol_s) / (d_gnss_synchro_history.at(ch, ind.first).RX_time - d_gnss_synchro_history.at(ch, ind.second).RX_time); - c = d_gnss_synchro_history.at(ch, ind.first).TOW_at_current_symbol_s - m * d_gnss_synchro_history.at(ch, ind.first).RX_time; - out.TOW_at_current_symbol_s = m * ti + c; - - return true; - - /* - arma::vec t = arma::vec(d_gnss_synchro_history.size(ch)); + arma::vec t = arma::vec(data.size()); arma::vec dop = t; arma::vec cph = t; arma::vec tow = t; @@ -354,7 +336,6 @@ bool hybrid_observables_cc::interpolate_data(Gnss_Synchro &out, const unsigned i out.TOW_at_current_symbol_s = result(0); return result.is_finite(); - */ } @@ -370,48 +351,6 @@ double hybrid_observables_cc::compute_T_rx_s(const Gnss_Synchro &a) } } -std::pair hybrid_observables_cc::find_interp_elements(const unsigned int &ch, const double &ti) -{ - unsigned int closest = 0; - double dif = std::numeric_limits::max(); - double dt = 0.0; - for (unsigned int i = 0; i < d_gnss_synchro_history.size(ch); i++) - { - dt = std::fabs(ti - d_gnss_synchro_history.at(ch, i).RX_time); - if (dt < dif) - { - dif = dt; - closest = i; - } - } - unsigned int index1; - unsigned int index2; - if (closest == 0) - { - index1 = 0; - index2 = 1; - } - else if (closest == (d_gnss_synchro_history.size(ch) - 1)) - { - index1 = d_gnss_synchro_history.size(ch) - 2; - index2 = d_gnss_synchro_history.size(ch) - 1; - } - else - { - if (d_gnss_synchro_history.at(ch, closest).RX_time < ti) - { - index1 = closest; - index2 = closest + 1; - } - else - { - index1 = closest - 1; - index2 = closest; - } - } - return std::pair(index1, index2); -} - void hybrid_observables_cc::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required) @@ -424,13 +363,13 @@ void hybrid_observables_cc::forecast(int noutput_items __attribute__((unused)), } -void hybrid_observables_cc::clean_history(Gnss_circular_deque &data, unsigned int pos) +void hybrid_observables_cc::clean_history(std::deque &data) { - while (data.size(pos) > 0) + while (data.size() > 0) { - if ((T_rx_s - data.front(pos).RX_time) > max_delta) + if ((T_rx_s - data.front().RX_time) > max_delta) { - data.pop_front(pos); + data.pop_front(); } else { @@ -515,9 +454,11 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) } ////////////////////////////////////////////////////////////////////////// + std::vector>::iterator it; if (total_input_items > 0) { - for (unsigned int i = 0; i < d_nchannels; i++) + i = 0; + for (it = d_gnss_synchro_history.begin(); it != d_gnss_synchro_history.end(); it++) { if (ninput_items[i] > 0) { @@ -526,25 +467,26 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) { if (in[i][aux].Flag_valid_word) { - d_gnss_synchro_history.push_back(i, in[i][aux]); - d_gnss_synchro_history.back(i).RX_time = compute_T_rx_s(in[i][aux]); + it->push_back(in[i][aux]); + it->back().RX_time = compute_T_rx_s(in[i][aux]); // Check if the last Gnss_Synchro comes from the same satellite as the previous ones - if (d_gnss_synchro_history.size(i) > 1) + if (it->size() > 1) { - if (d_gnss_synchro_history.front(i).PRN != d_gnss_synchro_history.back(i).PRN) + if (it->front().PRN != it->back().PRN) { - d_gnss_synchro_history.clear(i); + it->clear(); } } } } consume(i, ninput_items[i]); } + i++; } } for (i = 0; i < d_nchannels; i++) { - if (d_gnss_synchro_history.size(i) > 2) + if (d_gnss_synchro_history.at(i).size() > 2) { valid_channels[i] = true; } @@ -564,8 +506,8 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) { if (valid_channels[i]) { - clean_history(d_gnss_synchro_history, i); - if (d_gnss_synchro_history.size(i) < 2) + clean_history(d_gnss_synchro_history.at(i)); + if (d_gnss_synchro_history.at(i).size() < 2) { valid_channels[i] = false; } @@ -581,12 +523,13 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) } std::vector epoch_data; - for (unsigned int i = 0; i < d_nchannels; i++) + i = 0; + for (it = d_gnss_synchro_history.begin(); it != d_gnss_synchro_history.end(); it++) { if (valid_channels[i]) { - Gnss_Synchro interpolated_gnss_synchro = d_gnss_synchro_history.back(i); - if (interpolate_data(interpolated_gnss_synchro, i, T_rx_s_out)) + Gnss_Synchro interpolated_gnss_synchro = it->back(); + if (interpolate_data(interpolated_gnss_synchro, *it, T_rx_s_out)) { epoch_data.push_back(interpolated_gnss_synchro); } @@ -595,6 +538,7 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) valid_channels[i] = false; } } + i++; } d_num_valid_channels = valid_channels.count(); if (d_num_valid_channels == 0) @@ -602,14 +546,14 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) return 0; } correct_TOW_and_compute_prange(epoch_data); - std::vector::iterator it = epoch_data.begin(); + std::vector::iterator it2 = epoch_data.begin(); for (i = 0; i < d_nchannels; i++) { if (valid_channels[i]) { - out[i][0] = (*it); + out[i][0] = (*it2); out[i][0].Flag_valid_pseudorange = true; - it++; + it2++; } else { diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h index 298a9a0bb..aedba43ab 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h @@ -35,12 +35,12 @@ #define GNSS_SDR_HYBRID_OBSERVABLES_CC_H #include "gnss_synchro.h" -#include "gnss_circular_deque.h" #include #include #include #include -#include +#include +#include class hybrid_observables_cc; @@ -65,15 +65,14 @@ private: friend hybrid_observables_cc_sptr hybrid_make_observables_cc(unsigned int nchannels_in, unsigned int nchannels_out, bool dump, std::string dump_filename); hybrid_observables_cc(unsigned int nchannels_in, unsigned int nchannels_out, bool dump, std::string dump_filename); - void clean_history(Gnss_circular_deque& data, unsigned int pos); + void clean_history(std::deque& data); double compute_T_rx_s(const Gnss_Synchro& a); - bool interpolate_data(Gnss_Synchro& out, const unsigned int& ch, const double& ti); - std::pair find_interp_elements(const unsigned int& ch, const double& ti); + bool interpolate_data(Gnss_Synchro& out, std::deque& data, const double& ti); void correct_TOW_and_compute_prange(std::vector& data); int save_matfile(); //Tracking observable history - Gnss_circular_deque d_gnss_synchro_history; + std::vector> d_gnss_synchro_history; boost::dynamic_bitset<> valid_channels; double T_rx_s; double T_rx_step_s; From 15e867ec274f9b0c54119aab95c245d92d6a26ff Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Mon, 9 Apr 2018 18:02:07 +0200 Subject: [PATCH 03/44] Fix segmentation fault --- .../gnuradio_blocks/hybrid_observables_cc.cc | 60 ++++++++++--------- .../gnuradio_blocks/hybrid_observables_cc.h | 4 +- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index 4b03988aa..3ee00cbaf 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -66,7 +66,7 @@ hybrid_observables_cc::hybrid_observables_cc(unsigned int nchannels_in, max_delta = 0.15; // 150 ms valid_channels.resize(d_nchannels, false); d_num_valid_channels = 0; - d_gnss_synchro_history = Gnss_circular_deque(200, d_nchannels); + d_gnss_synchro_history = new Gnss_circular_deque(200, d_nchannels); // ############# ENABLE DATA FILE LOG ################# if (d_dump) @@ -86,11 +86,13 @@ hybrid_observables_cc::hybrid_observables_cc(unsigned int nchannels_in, } } } + std::cout << "SALIDA CONST HO. ()" << std::endl; } hybrid_observables_cc::~hybrid_observables_cc() { + delete d_gnss_synchro_history; if (d_dump_file.is_open()) { try @@ -300,7 +302,7 @@ int hybrid_observables_cc::save_matfile() bool hybrid_observables_cc::interpolate_data(Gnss_Synchro &out, const unsigned int &ch, const double &ti) { - if ((ti < d_gnss_synchro_history.front(ch).RX_time) or (ti > d_gnss_synchro_history.back(ch).RX_time)) + if ((ti < d_gnss_synchro_history->front(ch).RX_time) or (ti > d_gnss_synchro_history->back(ch).RX_time)) { return false; } @@ -311,18 +313,18 @@ bool hybrid_observables_cc::interpolate_data(Gnss_Synchro &out, const unsigned i // CARRIER PHASE INTERPOLATION - m = (d_gnss_synchro_history.at(ch, ind.first).Carrier_phase_rads - d_gnss_synchro_history.at(ch, ind.second).Carrier_phase_rads) / (d_gnss_synchro_history.at(ch, ind.first).RX_time - d_gnss_synchro_history.at(ch, ind.second).RX_time); - c = d_gnss_synchro_history.at(ch, ind.first).Carrier_phase_rads - m * d_gnss_synchro_history.at(ch, ind.first).RX_time; + m = (d_gnss_synchro_history->at(ch, ind.first).Carrier_phase_rads - d_gnss_synchro_history->at(ch, ind.second).Carrier_phase_rads) / (d_gnss_synchro_history->at(ch, ind.first).RX_time - d_gnss_synchro_history->at(ch, ind.second).RX_time); + c = d_gnss_synchro_history->at(ch, ind.first).Carrier_phase_rads - m * d_gnss_synchro_history->at(ch, ind.first).RX_time; out.Carrier_phase_rads = m * ti + c; // CARRIER DOPPLER INTERPOLATION - m = (d_gnss_synchro_history.at(ch, ind.first).Carrier_Doppler_hz - d_gnss_synchro_history.at(ch, ind.second).Carrier_Doppler_hz) / (d_gnss_synchro_history.at(ch, ind.first).RX_time - d_gnss_synchro_history.at(ch, ind.second).RX_time); - c = d_gnss_synchro_history.at(ch, ind.first).Carrier_Doppler_hz - m * d_gnss_synchro_history.at(ch, ind.first).RX_time; + m = (d_gnss_synchro_history->at(ch, ind.first).Carrier_Doppler_hz - d_gnss_synchro_history->at(ch, ind.second).Carrier_Doppler_hz) / (d_gnss_synchro_history->at(ch, ind.first).RX_time - d_gnss_synchro_history->at(ch, ind.second).RX_time); + c = d_gnss_synchro_history->at(ch, ind.first).Carrier_Doppler_hz - m * d_gnss_synchro_history->at(ch, ind.first).RX_time; out.Carrier_Doppler_hz = m * ti + c; // TOW INTERPOLATION - m = (d_gnss_synchro_history.at(ch, ind.first).TOW_at_current_symbol_s - d_gnss_synchro_history.at(ch, ind.second).TOW_at_current_symbol_s) / (d_gnss_synchro_history.at(ch, ind.first).RX_time - d_gnss_synchro_history.at(ch, ind.second).RX_time); - c = d_gnss_synchro_history.at(ch, ind.first).TOW_at_current_symbol_s - m * d_gnss_synchro_history.at(ch, ind.first).RX_time; + m = (d_gnss_synchro_history->at(ch, ind.first).TOW_at_current_symbol_s - d_gnss_synchro_history->at(ch, ind.second).TOW_at_current_symbol_s) / (d_gnss_synchro_history->at(ch, ind.first).RX_time - d_gnss_synchro_history->at(ch, ind.second).RX_time); + c = d_gnss_synchro_history->at(ch, ind.first).TOW_at_current_symbol_s - m * d_gnss_synchro_history->at(ch, ind.first).RX_time; out.TOW_at_current_symbol_s = m * ti + c; return true; @@ -375,9 +377,9 @@ std::pair hybrid_observables_cc::find_interp_element unsigned int closest = 0; double dif = std::numeric_limits::max(); double dt = 0.0; - for (unsigned int i = 0; i < d_gnss_synchro_history.size(ch); i++) + for (unsigned int i = 0; i < d_gnss_synchro_history->size(ch); i++) { - dt = std::fabs(ti - d_gnss_synchro_history.at(ch, i).RX_time); + dt = std::fabs(ti - d_gnss_synchro_history->at(ch, i).RX_time); if (dt < dif) { dif = dt; @@ -391,14 +393,14 @@ std::pair hybrid_observables_cc::find_interp_element index1 = 0; index2 = 1; } - else if (closest == (d_gnss_synchro_history.size(ch) - 1)) + else if (closest == (d_gnss_synchro_history->size(ch) - 1)) { - index1 = d_gnss_synchro_history.size(ch) - 2; - index2 = d_gnss_synchro_history.size(ch) - 1; + index1 = d_gnss_synchro_history->size(ch) - 2; + index2 = d_gnss_synchro_history->size(ch) - 1; } else { - if (d_gnss_synchro_history.at(ch, closest).RX_time < ti) + if (d_gnss_synchro_history->at(ch, closest).RX_time < ti) { index1 = closest; index2 = closest + 1; @@ -424,13 +426,13 @@ void hybrid_observables_cc::forecast(int noutput_items __attribute__((unused)), } -void hybrid_observables_cc::clean_history(Gnss_circular_deque &data, unsigned int pos) +void hybrid_observables_cc::clean_history(unsigned int pos) { - while (data.size(pos) > 0) + while (d_gnss_synchro_history->size(pos) > 0) { - if ((T_rx_s - data.front(pos).RX_time) > max_delta) + if ((T_rx_s - d_gnss_synchro_history->front(pos).RX_time) > max_delta) { - data.pop_front(pos); + d_gnss_synchro_history->pop_front(pos); } else { @@ -517,7 +519,7 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) if (total_input_items > 0) { - for (unsigned int i = 0; i < d_nchannels; i++) + for (i = 0; i < d_nchannels; i++) { if (ninput_items[i] > 0) { @@ -526,14 +528,14 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) { if (in[i][aux].Flag_valid_word) { - d_gnss_synchro_history.push_back(i, in[i][aux]); - d_gnss_synchro_history.back(i).RX_time = compute_T_rx_s(in[i][aux]); + d_gnss_synchro_history->push_back(i, in[i][aux]); + d_gnss_synchro_history->back(i).RX_time = compute_T_rx_s(in[i][aux]); // Check if the last Gnss_Synchro comes from the same satellite as the previous ones - if (d_gnss_synchro_history.size(i) > 1) + if (d_gnss_synchro_history->size(i) > 1) { - if (d_gnss_synchro_history.front(i).PRN != d_gnss_synchro_history.back(i).PRN) + if (d_gnss_synchro_history->front(i).PRN != d_gnss_synchro_history->back(i).PRN) { - d_gnss_synchro_history.clear(i); + d_gnss_synchro_history->clear(i); } } } @@ -544,7 +546,7 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) } for (i = 0; i < d_nchannels; i++) { - if (d_gnss_synchro_history.size(i) > 2) + if (d_gnss_synchro_history->size(i) > 2) { valid_channels[i] = true; } @@ -564,8 +566,8 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) { if (valid_channels[i]) { - clean_history(d_gnss_synchro_history, i); - if (d_gnss_synchro_history.size(i) < 2) + clean_history(i); + if (d_gnss_synchro_history->size(i) < 2) { valid_channels[i] = false; } @@ -581,11 +583,11 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) } std::vector epoch_data; - for (unsigned int i = 0; i < d_nchannels; i++) + for (i = 0; i < d_nchannels; i++) { if (valid_channels[i]) { - Gnss_Synchro interpolated_gnss_synchro = d_gnss_synchro_history.back(i); + Gnss_Synchro interpolated_gnss_synchro = d_gnss_synchro_history->back(i); if (interpolate_data(interpolated_gnss_synchro, i, T_rx_s_out)) { epoch_data.push_back(interpolated_gnss_synchro); diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h index 298a9a0bb..c5557963b 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h @@ -65,7 +65,7 @@ private: friend hybrid_observables_cc_sptr hybrid_make_observables_cc(unsigned int nchannels_in, unsigned int nchannels_out, bool dump, std::string dump_filename); hybrid_observables_cc(unsigned int nchannels_in, unsigned int nchannels_out, bool dump, std::string dump_filename); - void clean_history(Gnss_circular_deque& data, unsigned int pos); + void clean_history(unsigned int pos); double compute_T_rx_s(const Gnss_Synchro& a); bool interpolate_data(Gnss_Synchro& out, const unsigned int& ch, const double& ti); std::pair find_interp_elements(const unsigned int& ch, const double& ti); @@ -73,7 +73,7 @@ private: int save_matfile(); //Tracking observable history - Gnss_circular_deque d_gnss_synchro_history; + Gnss_circular_deque* d_gnss_synchro_history; boost::dynamic_bitset<> valid_channels; double T_rx_s; double T_rx_step_s; From 2a62d868ab60d1600d3ab8cad9a500b51cb9400d Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Mon, 9 Apr 2018 18:18:06 +0200 Subject: [PATCH 04/44] Clean code --- .../observables/gnuradio_blocks/hybrid_observables_cc.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index 3ee00cbaf..6a87b156c 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -86,7 +86,6 @@ hybrid_observables_cc::hybrid_observables_cc(unsigned int nchannels_in, } } } - std::cout << "SALIDA CONST HO. ()" << std::endl; } From f350174fd8e7450793e4fd87b679b0c26ba0a0ab Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Tue, 10 Apr 2018 15:37:07 +0200 Subject: [PATCH 05/44] Fix bugs --- src/algorithms/libs/gnss_circular_deque.h | 53 ++++++++++++++----- .../gnuradio_blocks/hybrid_observables_cc.cc | 17 ++---- 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/src/algorithms/libs/gnss_circular_deque.h b/src/algorithms/libs/gnss_circular_deque.h index f453be3d2..12a8e64c0 100644 --- a/src/algorithms/libs/gnss_circular_deque.h +++ b/src/algorithms/libs/gnss_circular_deque.h @@ -33,6 +33,7 @@ #ifndef GNSS_SDR_CIRCULAR_DEQUE_H_ #define GNSS_SDR_CIRCULAR_DEQUE_H_ +#include template class Gnss_circular_deque @@ -89,6 +90,10 @@ Gnss_circular_deque::Gnss_circular_deque(const unsigned int max_size, const u d_index_pop[i] = 0; d_index_push[i] = 0; d_history[i] = new T[d_max_size]; + for (unsigned int ii = 0; ii < d_max_size; ii++) + { + d_history[i][ii] = d_return_void; + } } } } @@ -127,12 +132,14 @@ T& Gnss_circular_deque::back(const unsigned int ch) } else { - index = d_max_size; + index = d_max_size - 1; } return d_history[ch][index]; } else { + std::exception ex; + throw ex; return d_return_void; } } @@ -146,6 +153,8 @@ T& Gnss_circular_deque::front(const unsigned int ch) } else { + std::exception ex; + throw ex; return d_return_void; } } @@ -155,11 +164,13 @@ T& Gnss_circular_deque::at(const unsigned int ch, const unsigned int pos) { if (d_size[ch] > 0 and pos < d_size[ch]) { - unsigned int index = (d_index_pop[ch] + pos) % d_max_size; + unsigned int index = ((d_index_pop[ch] + pos) % d_max_size); return d_history[ch][index]; } else { + std::exception ex; + throw ex; return d_return_void; } } @@ -175,31 +186,45 @@ void Gnss_circular_deque::clear(const unsigned int ch) template T Gnss_circular_deque::pop_front(const unsigned int ch) { - T result; if (d_size[ch] > 0) { d_size[ch]--; - result = d_history[ch][d_index_pop[ch]]; - d_index_pop[ch]++; - d_index_pop[ch] %= d_max_size; + T result = d_history[ch][d_index_pop[ch]]; + if (d_size[ch] > 0) + { + d_index_pop[ch]++; + d_index_pop[ch] %= d_max_size; + } + else + { + clear(ch); + } + return result; + } + else + { + std::exception ex; + throw ex; + return d_return_void; } - return result; } template void Gnss_circular_deque::push_back(const unsigned int ch, const T& new_data) { + bool increment_pop = true; + if (d_size[ch] < d_max_size) + { + increment_pop = false; + d_size[ch]++; + } + d_history[ch][d_index_push[ch]] = new_data; d_index_push[ch]++; d_index_push[ch] %= d_max_size; - if (d_size[ch] < d_max_size) + if (increment_pop) { - d_size[ch]++; - } - else - { - d_index_pop[ch]++; - d_index_pop[ch] %= d_max_size; + d_index_pop[ch] = d_index_push[ch]; } } diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index 6a87b156c..603b28c8e 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -307,6 +307,7 @@ bool hybrid_observables_cc::interpolate_data(Gnss_Synchro &out, const unsigned i } std::pair ind = find_interp_elements(ch, ti); + //Linear interpolation parameters: y(t) = m * t + c double m = 0.0; double c = 0.0; @@ -378,8 +379,8 @@ std::pair hybrid_observables_cc::find_interp_element double dt = 0.0; for (unsigned int i = 0; i < d_gnss_synchro_history->size(ch); i++) { - dt = std::fabs(ti - d_gnss_synchro_history->at(ch, i).RX_time); - if (dt < dif) + dt = ti - d_gnss_synchro_history->at(ch, i).RX_time; + if (dt < dif and dt > 0.0) { dif = dt; closest = i; @@ -399,16 +400,8 @@ std::pair hybrid_observables_cc::find_interp_element } else { - if (d_gnss_synchro_history->at(ch, closest).RX_time < ti) - { - index1 = closest; - index2 = closest + 1; - } - else - { - index1 = closest - 1; - index2 = closest; - } + index1 = closest; + index2 = closest + 1; } return std::pair(index1, index2); } From 01d41e2f0763bcc3a3ce7ff9de2b623c419332d7 Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Tue, 10 Apr 2018 16:05:22 +0200 Subject: [PATCH 06/44] Use boost circular buffers --- src/algorithms/libs/gnss_circular_deque.h | 185 ++++-------------- .../gnuradio_blocks/hybrid_observables_cc.cc | 20 +- 2 files changed, 48 insertions(+), 157 deletions(-) diff --git a/src/algorithms/libs/gnss_circular_deque.h b/src/algorithms/libs/gnss_circular_deque.h index 12a8e64c0..e1b73c87d 100644 --- a/src/algorithms/libs/gnss_circular_deque.h +++ b/src/algorithms/libs/gnss_circular_deque.h @@ -33,206 +33,103 @@ #ifndef GNSS_SDR_CIRCULAR_DEQUE_H_ #define GNSS_SDR_CIRCULAR_DEQUE_H_ -#include +#include +#include template class Gnss_circular_deque { public: - Gnss_circular_deque(); - Gnss_circular_deque(const unsigned int max_size, const unsigned int nchann); - ~Gnss_circular_deque(); - unsigned int size(const unsigned int ch); - T& at(const unsigned int ch, const unsigned int pos); - T& front(const unsigned int ch); - T& back(const unsigned int ch); - void push_back(const unsigned int ch, const T& new_data); - T pop_front(const unsigned int ch); - void clear(const unsigned int ch); - T* get_vector(const unsigned int ch); + Gnss_circular_deque(); // Default constructor + Gnss_circular_deque(const unsigned int max_size, const unsigned int nchann); // nchann = number of channels; max_size = channel capacity + unsigned int size(const unsigned int ch); // Returns the number of available elements in a channel + T& at(const unsigned int ch, const unsigned int pos); // Returns a reference to an element + T& front(const unsigned int ch); // Returns a reference to the first element in the deque + T& back(const unsigned int ch); // Returns a reference to the last element in the deque + void push_back(const unsigned int ch, const T& new_data); // Inserts an element at the end of the deque + void pop_front(const unsigned int ch); // Removes the first element of the deque + void clear(const unsigned int ch); // Removes all the elements of the deque (Sets size to 0). Capacity is not modified + void reset(const unsigned int max_size, const unsigned int nchann); // Removes all the elements in all the channels. Re-sets the number of channels and their capacity + void reset(); // Removes all the channels (Sets nchann to 0) private: - T** d_history; - T d_return_void; // Void object for avoid compiler errors - unsigned int* d_index_pop; - unsigned int* d_index_push; - unsigned int* d_size; - unsigned int d_max_size; - unsigned int d_nchannels; + std::vector> d_data; }; template Gnss_circular_deque::Gnss_circular_deque() { - d_max_size = 0; - d_nchannels = 0; - d_size = nullptr; - d_index_pop = nullptr; - d_index_push = nullptr; - d_history = nullptr; + reset(); } template Gnss_circular_deque::Gnss_circular_deque(const unsigned int max_size, const unsigned int nchann) { - d_max_size = max_size; - d_nchannels = nchann; - if (d_max_size > 0 and d_nchannels > 0) - { - d_size = new unsigned int[d_nchannels]; - d_index_pop = new unsigned int[d_nchannels]; - d_index_push = new unsigned int[d_nchannels]; - d_history = new T*[d_nchannels]; - for (unsigned int i = 0; i < d_nchannels; i++) - { - d_size[i] = 0; - d_index_pop[i] = 0; - d_index_push[i] = 0; - d_history[i] = new T[d_max_size]; - for (unsigned int ii = 0; ii < d_max_size; ii++) - { - d_history[i][ii] = d_return_void; - } - } - } -} - -template -Gnss_circular_deque::~Gnss_circular_deque() -{ - if (d_max_size > 0 and d_nchannels > 0) - { - delete[] d_size; - delete[] d_index_pop; - delete[] d_index_push; - for (unsigned int i = 0; i < d_nchannels; i++) - { - delete[] d_history[i]; - } - delete[] d_history; - } + reset(max_size, nchann); } template unsigned int Gnss_circular_deque::size(const unsigned int ch) { - return d_size[ch]; + return d_data.at(ch).size(); } template T& Gnss_circular_deque::back(const unsigned int ch) { - if (d_size[ch] > 0) - { - unsigned int index = 0; - if (d_index_push[ch] > 0) - { - index = d_index_push[ch] - 1; - } - else - { - index = d_max_size - 1; - } - return d_history[ch][index]; - } - else - { - std::exception ex; - throw ex; - return d_return_void; - } + return d_data.at(ch).back(); } + template T& Gnss_circular_deque::front(const unsigned int ch) { - if (d_size[ch] > 0) - { - return d_history[ch][d_index_pop[ch]]; - } - else - { - std::exception ex; - throw ex; - return d_return_void; - } + return d_data.at(ch).front(); } + template T& Gnss_circular_deque::at(const unsigned int ch, const unsigned int pos) { - if (d_size[ch] > 0 and pos < d_size[ch]) - { - unsigned int index = ((d_index_pop[ch] + pos) % d_max_size); - return d_history[ch][index]; - } - else - { - std::exception ex; - throw ex; - return d_return_void; - } + return d_data.at(ch).at(pos); } template void Gnss_circular_deque::clear(const unsigned int ch) { - d_size[ch] = 0; - d_index_pop[ch] = 0; - d_index_push[ch] = 0; + d_data.at(ch).clear(); } template -T Gnss_circular_deque::pop_front(const unsigned int ch) +void Gnss_circular_deque::reset(const unsigned int max_size, const unsigned int nchann) { - if (d_size[ch] > 0) + d_data.clear(); + if (max_size > 0 and nchann > 0) { - d_size[ch]--; - T result = d_history[ch][d_index_pop[ch]]; - if (d_size[ch] > 0) + for (unsigned int i = 0; i < nchann; i++) { - d_index_pop[ch]++; - d_index_pop[ch] %= d_max_size; + d_data.push_back(boost::circular_buffer(max_size)); } - else - { - clear(ch); - } - return result; - } - else - { - std::exception ex; - throw ex; - return d_return_void; } } +template +void Gnss_circular_deque::reset() +{ + d_data.clear(); +} + +template +void Gnss_circular_deque::pop_front(const unsigned int ch) +{ + d_data.at(ch).pop_front(); +} + template void Gnss_circular_deque::push_back(const unsigned int ch, const T& new_data) { - bool increment_pop = true; - if (d_size[ch] < d_max_size) - { - increment_pop = false; - d_size[ch]++; - } - - d_history[ch][d_index_push[ch]] = new_data; - d_index_push[ch]++; - d_index_push[ch] %= d_max_size; - if (increment_pop) - { - d_index_pop[ch] = d_index_push[ch]; - } + d_data.at(ch).push_back(new_data); } -template -T* Gnss_circular_deque::get_vector(const unsigned int ch) -{ - return d_history[ch]; -} - - #endif /* GNSS_SDR_CIRCULAR_DEQUE_H_ */ diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index 603b28c8e..0566e86f9 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -66,7 +66,7 @@ hybrid_observables_cc::hybrid_observables_cc(unsigned int nchannels_in, max_delta = 0.15; // 150 ms valid_channels.resize(d_nchannels, false); d_num_valid_channels = 0; - d_gnss_synchro_history = new Gnss_circular_deque(200, d_nchannels); + d_gnss_synchro_history = new Gnss_circular_deque(1000, d_nchannels); // ############# ENABLE DATA FILE LOG ################# if (d_dump) @@ -307,25 +307,19 @@ bool hybrid_observables_cc::interpolate_data(Gnss_Synchro &out, const unsigned i } std::pair ind = find_interp_elements(ch, ti); - //Linear interpolation parameters: y(t) = m * t + c - double m = 0.0; - double c = 0.0; + //Linear interpolation: y(t) = y(t1) + (y(t2) - y(t1)) * (t - t1) / (t2 - t1) // CARRIER PHASE INTERPOLATION - m = (d_gnss_synchro_history->at(ch, ind.first).Carrier_phase_rads - d_gnss_synchro_history->at(ch, ind.second).Carrier_phase_rads) / (d_gnss_synchro_history->at(ch, ind.first).RX_time - d_gnss_synchro_history->at(ch, ind.second).RX_time); - c = d_gnss_synchro_history->at(ch, ind.first).Carrier_phase_rads - m * d_gnss_synchro_history->at(ch, ind.first).RX_time; - out.Carrier_phase_rads = m * ti + c; + out.Carrier_phase_rads = d_gnss_synchro_history->at(ch, ind.first).Carrier_phase_rads + (d_gnss_synchro_history->at(ch, ind.second).Carrier_phase_rads - d_gnss_synchro_history->at(ch, ind.first).Carrier_phase_rads) * (ti - d_gnss_synchro_history->at(ch, ind.first).RX_time) / (d_gnss_synchro_history->at(ch, ind.second).RX_time - d_gnss_synchro_history->at(ch, ind.first).RX_time); // CARRIER DOPPLER INTERPOLATION - m = (d_gnss_synchro_history->at(ch, ind.first).Carrier_Doppler_hz - d_gnss_synchro_history->at(ch, ind.second).Carrier_Doppler_hz) / (d_gnss_synchro_history->at(ch, ind.first).RX_time - d_gnss_synchro_history->at(ch, ind.second).RX_time); - c = d_gnss_synchro_history->at(ch, ind.first).Carrier_Doppler_hz - m * d_gnss_synchro_history->at(ch, ind.first).RX_time; - out.Carrier_Doppler_hz = m * ti + c; + + out.Carrier_Doppler_hz = d_gnss_synchro_history->at(ch, ind.first).Carrier_Doppler_hz + (d_gnss_synchro_history->at(ch, ind.second).Carrier_Doppler_hz - d_gnss_synchro_history->at(ch, ind.first).Carrier_Doppler_hz) * (ti - d_gnss_synchro_history->at(ch, ind.first).RX_time) / (d_gnss_synchro_history->at(ch, ind.second).RX_time - d_gnss_synchro_history->at(ch, ind.first).RX_time); // TOW INTERPOLATION - m = (d_gnss_synchro_history->at(ch, ind.first).TOW_at_current_symbol_s - d_gnss_synchro_history->at(ch, ind.second).TOW_at_current_symbol_s) / (d_gnss_synchro_history->at(ch, ind.first).RX_time - d_gnss_synchro_history->at(ch, ind.second).RX_time); - c = d_gnss_synchro_history->at(ch, ind.first).TOW_at_current_symbol_s - m * d_gnss_synchro_history->at(ch, ind.first).RX_time; - out.TOW_at_current_symbol_s = m * ti + c; + + out.TOW_at_current_symbol_s = d_gnss_synchro_history->at(ch, ind.first).TOW_at_current_symbol_s + (d_gnss_synchro_history->at(ch, ind.second).TOW_at_current_symbol_s - d_gnss_synchro_history->at(ch, ind.first).TOW_at_current_symbol_s) * (ti - d_gnss_synchro_history->at(ch, ind.first).RX_time) / (d_gnss_synchro_history->at(ch, ind.second).RX_time - d_gnss_synchro_history->at(ch, ind.first).RX_time); return true; From bdd1a0e97706ebbd70eff2facc539005a6adde20 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 11 Apr 2018 01:22:11 +0200 Subject: [PATCH 07/44] Add more friendy messages Move general_work to the bottom, so it is easier to find --- .../gnuradio_blocks/dll_pll_veml_tracking.cc | 22 +- .../gnuradio_blocks/dll_pll_veml_tracking.h | 2 + .../galileo_e1_tcp_connector_tracking_cc.cc | 80 +-- ...glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc | 68 +-- ...glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc | 68 +-- .../glonass_l1_ca_dll_pll_tracking_cc.cc | 66 +-- ...glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc | 68 +-- ...glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc | 68 +-- .../glonass_l2_ca_dll_pll_tracking_cc.cc | 66 +-- .../gps_l1_ca_dll_pll_c_aid_tracking_cc.cc | 68 +-- ...ps_l1_ca_dll_pll_c_aid_tracking_fpga_sc.cc | 509 +++++++++--------- .../gps_l1_ca_dll_pll_c_aid_tracking_sc.cc | 66 +-- .../gps_l1_ca_dll_pll_tracking_gpu_cc.cc | 66 +-- .../gps_l1_ca_tcp_connector_tracking_cc.cc | 80 +-- 14 files changed, 652 insertions(+), 645 deletions(-) diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc index 4ae6f8195..272825bd3 100755 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc @@ -362,6 +362,14 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl d_code_phase_samples = 0.0; d_last_prompt = gr_complex(0.0, 0.0); d_state = 0; // initial state: standby + + signal_pretty_name["1C"] = "L1 C/A"; + signal_pretty_name["1B"] = "E1"; + signal_pretty_name["1G"] = "L1 C/A"; + signal_pretty_name["2S"] = "L2C"; + signal_pretty_name["2G"] = "L2 C/A"; + signal_pretty_name["5X"] = "E5a"; + signal_pretty_name["L5"] = "L5"; } @@ -504,7 +512,7 @@ void dll_pll_veml_tracking::start_tracking() d_code_loop_filter.set_pdi(static_cast(d_code_period)); // DEBUG OUTPUT - std::cout << "Tracking of " << systemName << " " << signal_type << " signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; + std::cout << "Tracking of " << systemName << " " << signal_pretty_name[signal_type] << " signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; // enable tracking pull-in @@ -1256,8 +1264,8 @@ int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused) next_state = acquire_secondary(); if (next_state) { - std::cout << "Secondary code locked for CH " << d_channel - << " : Satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; + std::cout << systemName << " " << signal_pretty_name[signal_type] << " secondary code locked in channel " << d_channel + << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; } d_Prompt_buffer_deque.pop_front(); @@ -1318,12 +1326,12 @@ int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused) d_carrier_loop_filter.set_pdi(new_correlation_time); d_code_loop_filter.set_pdi(new_correlation_time); d_state = 3; // next state is the extended correlator integrator - LOG(INFO) << "Enabled " << trk_parameters.extend_correlation_symbols << " [symbols] extended correlator for CH " + LOG(INFO) << "Enabled " << trk_parameters.extend_correlation_symbols * static_cast(d_code_period * 1000.0) << " ms extended correlator in channel " << d_channel - << " : Satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN); - std::cout << "Enabled " << trk_parameters.extend_correlation_symbols << " [symbols] extended correlator for CH " + << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN); + std::cout << "Enabled " << trk_parameters.extend_correlation_symbols * static_cast(d_code_period * 1000.0) << " ms extended correlator in channel " << d_channel - << " : Satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; + << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; // Set narrow taps delay values [chips] d_code_loop_filter.set_DLL_BW(trk_parameters.dll_bw_narrow_hz); d_carrier_loop_filter.set_PLL_BW(trk_parameters.pll_bw_narrow_hz); diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h index e9e41ccbc..89f71a99a 100755 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h @@ -38,6 +38,7 @@ #include #include #include +#include typedef struct { @@ -118,6 +119,7 @@ private: std::string systemName; std::string signal_type; std::string *d_secondary_code_string; + std::map signal_pretty_name; //tracking state machine int d_state; diff --git a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc index a7c0062a2..49777f199 100644 --- a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc @@ -224,7 +224,7 @@ void Galileo_E1_Tcp_Connector_Tracking_cc::start_tracking() // DEBUG OUTPUT std::cout << "Tracking of Galileo E1 signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; - LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; + LOG(INFO) << "Tracking of Galileo E1 signal for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; // enable tracking d_pull_in = true; @@ -263,6 +263,45 @@ Galileo_E1_Tcp_Connector_Tracking_cc::~Galileo_E1_Tcp_Connector_Tracking_cc() } +void Galileo_E1_Tcp_Connector_Tracking_cc::set_channel(unsigned int channel) +{ + d_channel = channel; + LOG(INFO) << "Tracking Channel set to " << d_channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); + } + } + } + + //! Listen for connections on a TCP port + if (d_listen_connection == true) + { + d_port = d_port_ch0 + d_channel; + d_listen_connection = d_tcp_com.listen_tcp_connection(d_port, d_port_ch0); + } +} + + +void Galileo_E1_Tcp_Connector_Tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) +{ + d_acquisition_gnss_synchro = p_gnss_synchro; +} + + int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -514,42 +553,3 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri return 0; } } - - -void Galileo_E1_Tcp_Connector_Tracking_cc::set_channel(unsigned int channel) -{ - d_channel = channel; - LOG(INFO) << "Tracking Channel set to " << d_channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); - } - } - } - - //! Listen for connections on a TCP port - if (d_listen_connection == true) - { - d_port = d_port_ch0 + d_channel; - d_listen_connection = d_tcp_com.listen_tcp_connection(d_port, d_port_ch0); - } -} - - -void Galileo_E1_Tcp_Connector_Tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) -{ - d_acquisition_gnss_synchro = p_gnss_synchro; -} diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc index df57be51e..9e93616bb 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc @@ -295,8 +295,8 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_cc::start_tracking() sys = sys_.substr(0, 1); // DEBUG OUTPUT - std::cout << "Tracking start on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; - LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; + std::cout << "Tracking of GLONASS L1 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; + LOG(INFO) << "Tracking of GLONASS L1 C/A signal for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; // enable tracking d_pull_in = true; @@ -558,6 +558,38 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile() } +void glonass_l1_ca_dll_pll_c_aid_tracking_cc::set_channel(unsigned int channel) +{ + d_channel = channel; + LOG(INFO) << "Tracking Channel set to " << d_channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl; + } + catch (const std::ifstream::failure *e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; + } + } + } +} + + +void glonass_l1_ca_dll_pll_c_aid_tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) +{ + d_acquisition_gnss_synchro = p_gnss_synchro; +} + + int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -895,35 +927,3 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at return 1; //output tracking result ALWAYS even in the case of d_enable_tracking==false } - - -void glonass_l1_ca_dll_pll_c_aid_tracking_cc::set_channel(unsigned int channel) -{ - d_channel = channel; - LOG(INFO) << "Tracking Channel set to " << d_channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl; - } - catch (const std::ifstream::failure *e) - { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; - } - } - } -} - - -void glonass_l1_ca_dll_pll_c_aid_tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) -{ - d_acquisition_gnss_synchro = p_gnss_synchro; -} diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc index 313756921..ebfc2516a 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc @@ -292,8 +292,8 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_sc::start_tracking() sys = sys_.substr(0, 1); // DEBUG OUTPUT - std::cout << "Tracking start on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; - LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; + std::cout << "Tracking of GLONASS L1 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; + LOG(INFO) << "Tracking of GLONASS L1 C/A signal for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; // enable tracking d_pull_in = true; @@ -551,6 +551,38 @@ glonass_l1_ca_dll_pll_c_aid_tracking_sc::~glonass_l1_ca_dll_pll_c_aid_tracking_s } +void glonass_l1_ca_dll_pll_c_aid_tracking_sc::set_channel(unsigned int channel) +{ + d_channel = channel; + LOG(INFO) << "Tracking Channel set to " << d_channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl; + } + catch (const std::ifstream::failure *e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; + } + } + } +} + + +void glonass_l1_ca_dll_pll_c_aid_tracking_sc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) +{ + d_acquisition_gnss_synchro = p_gnss_synchro; +} + + int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -886,35 +918,3 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at return 1; //output tracking result ALWAYS even in the case of d_enable_tracking==false } - - -void glonass_l1_ca_dll_pll_c_aid_tracking_sc::set_channel(unsigned int channel) -{ - d_channel = channel; - LOG(INFO) << "Tracking Channel set to " << d_channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl; - } - catch (const std::ifstream::failure *e) - { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; - } - } - } -} - - -void glonass_l1_ca_dll_pll_c_aid_tracking_sc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) -{ - d_acquisition_gnss_synchro = p_gnss_synchro; -} diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc index d35b6159c..278b320e3 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc @@ -253,7 +253,7 @@ void Glonass_L1_Ca_Dll_Pll_Tracking_cc::start_tracking() // DEBUG OUTPUT std::cout << "Tracking of GLONASS L1 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; - LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; + LOG(INFO) << "Tracking of GLONASS L1 C/A signal for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; // enable tracking d_pull_in = true; @@ -512,6 +512,38 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::save_matfile() } +void Glonass_L1_Ca_Dll_Pll_Tracking_cc::set_channel(unsigned int channel) +{ + d_channel = channel; + LOG(INFO) << "Tracking Channel set to " << d_channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); + } + } + } +} + + +void Glonass_L1_Ca_Dll_Pll_Tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) +{ + d_acquisition_gnss_synchro = p_gnss_synchro; +} + + int Glonass_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -738,35 +770,3 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut d_sample_counter += d_current_prn_length_samples; // count for the processed samples return 1; // output tracking result ALWAYS even in the case of d_enable_tracking==false } - - -void Glonass_L1_Ca_Dll_Pll_Tracking_cc::set_channel(unsigned int channel) -{ - d_channel = channel; - LOG(INFO) << "Tracking Channel set to " << d_channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); - } - } - } -} - - -void Glonass_L1_Ca_Dll_Pll_Tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) -{ - d_acquisition_gnss_synchro = p_gnss_synchro; -} diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc index 53f8f704b..1b269f709 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc @@ -292,8 +292,8 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_cc::start_tracking() sys = sys_.substr(0, 1); // DEBUG OUTPUT - std::cout << "Tracking start on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; - LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; + std::cout << "Tracking of GLONASS L2 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; + LOG(INFO) << "Tracking of GLONASS L2 C/A signal for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; // enable tracking d_pull_in = true; @@ -555,6 +555,38 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::save_matfile() } +void glonass_l2_ca_dll_pll_c_aid_tracking_cc::set_channel(unsigned int channel) +{ + d_channel = channel; + LOG(INFO) << "Tracking Channel set to " << d_channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl; + } + catch (const std::ifstream::failure *e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; + } + } + } +} + + +void glonass_l2_ca_dll_pll_c_aid_tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) +{ + d_acquisition_gnss_synchro = p_gnss_synchro; +} + + int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -892,35 +924,3 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at return 1; //output tracking result ALWAYS even in the case of d_enable_tracking==false } - - -void glonass_l2_ca_dll_pll_c_aid_tracking_cc::set_channel(unsigned int channel) -{ - d_channel = channel; - LOG(INFO) << "Tracking Channel set to " << d_channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl; - } - catch (const std::ifstream::failure *e) - { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; - } - } - } -} - - -void glonass_l2_ca_dll_pll_c_aid_tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) -{ - d_acquisition_gnss_synchro = p_gnss_synchro; -} diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc index decc5d5ca..80c7e6a80 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc @@ -290,8 +290,8 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_sc::start_tracking() sys = sys_.substr(0, 1); // DEBUG OUTPUT - std::cout << "Tracking start on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; - LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; + std::cout << "Tracking of GLONASS L2 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; + LOG(INFO) << "Tracking of GLONASS L2 C/A signal for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; // enable tracking d_pull_in = true; @@ -549,6 +549,38 @@ glonass_l2_ca_dll_pll_c_aid_tracking_sc::~glonass_l2_ca_dll_pll_c_aid_tracking_s } +void glonass_l2_ca_dll_pll_c_aid_tracking_sc::set_channel(unsigned int channel) +{ + d_channel = channel; + LOG(INFO) << "Tracking Channel set to " << d_channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl; + } + catch (const std::ifstream::failure *e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; + } + } + } +} + + +void glonass_l2_ca_dll_pll_c_aid_tracking_sc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) +{ + d_acquisition_gnss_synchro = p_gnss_synchro; +} + + int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -884,35 +916,3 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at return 1; //output tracking result ALWAYS even in the case of d_enable_tracking==false } - - -void glonass_l2_ca_dll_pll_c_aid_tracking_sc::set_channel(unsigned int channel) -{ - d_channel = channel; - LOG(INFO) << "Tracking Channel set to " << d_channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl; - } - catch (const std::ifstream::failure *e) - { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; - } - } - } -} - - -void glonass_l2_ca_dll_pll_c_aid_tracking_sc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) -{ - d_acquisition_gnss_synchro = p_gnss_synchro; -} diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc index f6428bc5c..77c7776ed 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc @@ -253,7 +253,7 @@ void Glonass_L2_Ca_Dll_Pll_Tracking_cc::start_tracking() // DEBUG OUTPUT std::cout << "Tracking of GLONASS L2 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; - LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; + LOG(INFO) << "Tracking of GLONASS L2 C/A signal for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; // enable tracking d_pull_in = true; @@ -512,6 +512,38 @@ int Glonass_L2_Ca_Dll_Pll_Tracking_cc::save_matfile() } +void Glonass_L2_Ca_Dll_Pll_Tracking_cc::set_channel(unsigned int channel) +{ + d_channel = channel; + LOG(INFO) << "Tracking Channel set to " << d_channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); + } + } + } +} + + +void Glonass_L2_Ca_Dll_Pll_Tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) +{ + d_acquisition_gnss_synchro = p_gnss_synchro; +} + + int Glonass_L2_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -738,35 +770,3 @@ int Glonass_L2_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut d_sample_counter += d_current_prn_length_samples; // count for the processed samples return 1; // output tracking result ALWAYS even in the case of d_enable_tracking==false } - - -void Glonass_L2_Ca_Dll_Pll_Tracking_cc::set_channel(unsigned int channel) -{ - d_channel = channel; - LOG(INFO) << "Tracking Channel set to " << d_channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); - } - } - } -} - - -void Glonass_L2_Ca_Dll_Pll_Tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) -{ - d_acquisition_gnss_synchro = p_gnss_synchro; -} diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc index c242a10b8..461334537 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc @@ -276,7 +276,7 @@ void gps_l1_ca_dll_pll_c_aid_tracking_cc::start_tracking() // DEBUG OUTPUT std::cout << "Tracking of GPS L1 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; - LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; + LOG(INFO) << "Tracking of GPS L1 C/A signal for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; // enable tracking d_pull_in = true; @@ -538,6 +538,38 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile() } +void gps_l1_ca_dll_pll_c_aid_tracking_cc::set_channel(unsigned int channel) +{ + d_channel = channel; + LOG(INFO) << "Tracking Channel set to " << d_channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure *e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; + } + } + } +} + + +void gps_l1_ca_dll_pll_c_aid_tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) +{ + d_acquisition_gnss_synchro = p_gnss_synchro; +} + + int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -842,7 +874,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib // PLL commands tmp_float = 1.0 / (d_carr_phase_error_secs_Ti * CURRENT_INTEGRATION_TIME_S); d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - tmp_float = 1.0 / (d_code_error_filt_chips_Ti * CURRENT_INTEGRATION_TIME_S);; + tmp_float = 1.0 / (d_code_error_filt_chips_Ti * CURRENT_INTEGRATION_TIME_S); d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // DLL commands tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; @@ -881,35 +913,3 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib return 0; } } - - -void gps_l1_ca_dll_pll_c_aid_tracking_cc::set_channel(unsigned int channel) -{ - d_channel = channel; - LOG(INFO) << "Tracking Channel set to " << d_channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); - } - catch (const std::ifstream::failure *e) - { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; - } - } - } -} - - -void gps_l1_ca_dll_pll_c_aid_tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) -{ - d_acquisition_gnss_synchro = p_gnss_synchro; -} diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc.cc index 1d1561a21..8112feaf3 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc.cc @@ -268,12 +268,8 @@ void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::start_tracking() sys = sys_.substr(0, 1); // DEBUG OUTPUT - std::cout << "Tracking start on channel " << d_channel << " for satellite " - << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) - << std::endl; - LOG(INFO) << "Starting tracking of satellite " - << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) - << " on channel " << d_channel; + std::cout << "Tracking of GPS L1 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; + LOG(INFO) << "Tracking of GPS L1 C/A signal for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; // enable tracking d_pull_in = true; @@ -333,6 +329,257 @@ gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::~gps_l1_ca_dll_pll_c_aid_tracking_fpga } +void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::set_channel(unsigned int channel) +{ + d_channel = channel; + multicorrelator_fpga_8sc->set_channel(d_channel); + LOG(INFO) << "Tracking Channel set to " << d_channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Tracking dump enabled on channel " + << d_channel << " Log file: " + << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure *e) + { + LOG(WARNING) << "channel " << d_channel + << " Exception opening trk dump file " + << e->what(); + } + } + } +} + + +int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::save_matfile() +{ + // READ DUMP FILE + std::ifstream::pos_type size; + int number_of_double_vars = 11; + int number_of_float_vars = 5; + int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars + + sizeof(float) * number_of_float_vars + sizeof(unsigned int); + std::ifstream dump_file; + dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + try + { + dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate); + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem opening dump file:" << e.what() << std::endl; + return 1; + } + // count number of epochs and rewind + long int num_epoch = 0; + if (dump_file.is_open()) + { + size = dump_file.tellg(); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + dump_file.seekg(0, std::ios::beg); + } + else + { + return 1; + } + float *abs_E = new float[num_epoch]; + float *abs_P = new float[num_epoch]; + float *abs_L = new float[num_epoch]; + float *Prompt_I = new float[num_epoch]; + float *Prompt_Q = new float[num_epoch]; + unsigned long int *PRN_start_sample_count = new unsigned long int[num_epoch]; + double *acc_carrier_phase_rad = new double[num_epoch]; + double *carrier_doppler_hz = new double[num_epoch]; + double *code_freq_chips = new double[num_epoch]; + double *carr_error_hz = new double[num_epoch]; + double *carr_error_filt_hz = new double[num_epoch]; + double *code_error_chips = new double[num_epoch]; + double *code_error_filt_chips = new double[num_epoch]; + double *CN0_SNV_dB_Hz = new double[num_epoch]; + double *carrier_lock_test = new double[num_epoch]; + double *aux1 = new double[num_epoch]; + double *aux2 = new double[num_epoch]; + unsigned int *PRN = new unsigned int[num_epoch]; + + try + { + if (dump_file.is_open()) + { + for (long int i = 0; i < num_epoch; i++) + { + dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carr_error_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carr_error_filt_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_error_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_error_filt_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&CN0_SNV_dB_Hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&aux1[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + } + } + dump_file.close(); + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem reading dump file:" << e.what() << std::endl; + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 1; + } + + // WRITE MAT FILE + mat_t *matfp; + matvar_t *matvar; + std::string filename = d_dump_filename; + filename.erase(filename.length() - 4, 4); + filename.append(".mat"); + matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); + if (reinterpret_cast(matfp) != NULL) + { + size_t dims[2] = {1, static_cast(num_epoch)}; + matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, acc_carrier_phase_rad, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_doppler_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_freq_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_freq_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_filt_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_filt_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, CN0_SNV_dB_Hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_lock_test", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_lock_test, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux1", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux1, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + } + Mat_Close(matfp); + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 0; +} + + +void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::set_gnss_synchro( + Gnss_Synchro *p_gnss_synchro) +{ + d_acquisition_gnss_synchro = p_gnss_synchro; +} + + +void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::reset(void) +{ + multicorrelator_fpga_8sc->unlock_channel(); +} + + int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::general_work( int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), @@ -703,253 +950,3 @@ int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::general_work( return 0; } } - - -void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::set_channel(unsigned int channel) -{ - d_channel = channel; - multicorrelator_fpga_8sc->set_channel(d_channel); - LOG(INFO) << "Tracking Channel set to " << d_channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Tracking dump enabled on channel " - << d_channel << " Log file: " - << d_dump_filename.c_str(); - } - catch (const std::ifstream::failure *e) - { - LOG(WARNING) << "channel " << d_channel - << " Exception opening trk dump file " - << e->what(); - } - } - } -} - - -int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::save_matfile() -{ - // READ DUMP FILE - std::ifstream::pos_type size; - int number_of_double_vars = 11; - int number_of_float_vars = 5; - int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars + - sizeof(float) * number_of_float_vars + sizeof(unsigned int); - std::ifstream dump_file; - dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - try - { - dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate); - } - catch (const std::ifstream::failure &e) - { - std::cerr << "Problem opening dump file:" << e.what() << std::endl; - return 1; - } - // count number of epochs and rewind - long int num_epoch = 0; - if (dump_file.is_open()) - { - size = dump_file.tellg(); - num_epoch = static_cast(size) / static_cast(epoch_size_bytes); - dump_file.seekg(0, std::ios::beg); - } - else - { - return 1; - } - float *abs_E = new float[num_epoch]; - float *abs_P = new float[num_epoch]; - float *abs_L = new float[num_epoch]; - float *Prompt_I = new float[num_epoch]; - float *Prompt_Q = new float[num_epoch]; - unsigned long int *PRN_start_sample_count = new unsigned long int[num_epoch]; - double *acc_carrier_phase_rad = new double[num_epoch]; - double *carrier_doppler_hz = new double[num_epoch]; - double *code_freq_chips = new double[num_epoch]; - double *carr_error_hz = new double[num_epoch]; - double *carr_error_filt_hz = new double[num_epoch]; - double *code_error_chips = new double[num_epoch]; - double *code_error_filt_chips = new double[num_epoch]; - double *CN0_SNV_dB_Hz = new double[num_epoch]; - double *carrier_lock_test = new double[num_epoch]; - double *aux1 = new double[num_epoch]; - double *aux2 = new double[num_epoch]; - unsigned int *PRN = new unsigned int[num_epoch]; - - try - { - if (dump_file.is_open()) - { - for (long int i = 0; i < num_epoch; i++) - { - dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); - dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&carr_error_hz[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&carr_error_filt_hz[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&code_error_chips[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&code_error_filt_chips[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&CN0_SNV_dB_Hz[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&aux1[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); - } - } - dump_file.close(); - } - catch (const std::ifstream::failure &e) - { - std::cerr << "Problem reading dump file:" << e.what() << std::endl; - delete[] abs_E; - delete[] abs_P; - delete[] abs_L; - delete[] Prompt_I; - delete[] Prompt_Q; - delete[] PRN_start_sample_count; - delete[] acc_carrier_phase_rad; - delete[] carrier_doppler_hz; - delete[] code_freq_chips; - delete[] carr_error_hz; - delete[] carr_error_filt_hz; - delete[] code_error_chips; - delete[] code_error_filt_chips; - delete[] CN0_SNV_dB_Hz; - delete[] carrier_lock_test; - delete[] aux1; - delete[] aux2; - delete[] PRN; - return 1; - } - - // WRITE MAT FILE - mat_t *matfp; - matvar_t *matvar; - std::string filename = d_dump_filename; - filename.erase(filename.length() - 4, 4); - filename.append(".mat"); - matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); - if (reinterpret_cast(matfp) != NULL) - { - size_t dims[2] = {1, static_cast(num_epoch)}; - matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, acc_carrier_phase_rad, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_doppler_hz, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("code_freq_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_freq_chips, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("carr_error_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_hz, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_filt_hz, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("code_error_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_chips, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_filt_chips, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, CN0_SNV_dB_Hz, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("carrier_lock_test", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_lock_test, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("aux1", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux1, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - } - Mat_Close(matfp); - delete[] abs_E; - delete[] abs_P; - delete[] abs_L; - delete[] Prompt_I; - delete[] Prompt_Q; - delete[] PRN_start_sample_count; - delete[] acc_carrier_phase_rad; - delete[] carrier_doppler_hz; - delete[] code_freq_chips; - delete[] carr_error_hz; - delete[] carr_error_filt_hz; - delete[] code_error_chips; - delete[] code_error_filt_chips; - delete[] CN0_SNV_dB_Hz; - delete[] carrier_lock_test; - delete[] aux1; - delete[] aux2; - delete[] PRN; - return 0; -} - -void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::set_gnss_synchro( - Gnss_Synchro *p_gnss_synchro) -{ - d_acquisition_gnss_synchro = p_gnss_synchro; -} - - -void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::reset(void) -{ - multicorrelator_fpga_8sc->unlock_channel(); -} diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc index 9a4332f06..9e6e136c9 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc @@ -277,7 +277,7 @@ void gps_l1_ca_dll_pll_c_aid_tracking_sc::start_tracking() // DEBUG OUTPUT std::cout << "Tracking of GPS L1 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; - LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; + LOG(INFO) << "Tracking of GPS L1 C/A signal for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; // enable tracking d_pull_in = true; @@ -541,6 +541,38 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile() } +void gps_l1_ca_dll_pll_c_aid_tracking_sc::set_channel(unsigned int channel) +{ + d_channel = channel; + LOG(INFO) << "Tracking Channel set to " << d_channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure *e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what(); + } + } + } +} + + +void gps_l1_ca_dll_pll_c_aid_tracking_sc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) +{ + d_acquisition_gnss_synchro = p_gnss_synchro; +} + + int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -883,35 +915,3 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attrib return 0; } } - - -void gps_l1_ca_dll_pll_c_aid_tracking_sc::set_channel(unsigned int channel) -{ - d_channel = channel; - LOG(INFO) << "Tracking Channel set to " << d_channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); - } - catch (const std::ifstream::failure *e) - { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what(); - } - } - } -} - - -void gps_l1_ca_dll_pll_c_aid_tracking_sc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) -{ - d_acquisition_gnss_synchro = p_gnss_synchro; -} diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc index 759128d0b..914f08e5a 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc @@ -245,7 +245,7 @@ void Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::start_tracking() // DEBUG OUTPUT std::cout << "Tracking of GPS L1 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; - LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; + LOG(INFO) << "Tracking of GPS L1 C/A signal for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; // enable tracking d_pull_in = true; @@ -287,6 +287,38 @@ Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::~Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc() } +void Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::set_channel(unsigned int channel) +{ + d_channel = channel; + LOG(INFO) << "Tracking Channel set to " << d_channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure *e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what(); + } + } + } +} + + +void Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) +{ + d_acquisition_gnss_synchro = p_gnss_synchro; +} + + int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -539,35 +571,3 @@ int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribut return 0; } } - - -void Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::set_channel(unsigned int channel) -{ - d_channel = channel; - LOG(INFO) << "Tracking Channel set to " << d_channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); - } - catch (const std::ifstream::failure *e) - { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what(); - } - } - } -} - - -void Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) -{ - d_acquisition_gnss_synchro = p_gnss_synchro; -} diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc index cd4c86652..ed85d234b 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc @@ -252,7 +252,7 @@ void Gps_L1_Ca_Tcp_Connector_Tracking_cc::start_tracking() // DEBUG OUTPUT std::cout << "Tracking of GPS L1 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; - LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; + LOG(INFO) << "Tracking of GPS L1 C/A signal for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; // enable tracking d_pull_in = true; @@ -293,6 +293,45 @@ Gps_L1_Ca_Tcp_Connector_Tracking_cc::~Gps_L1_Ca_Tcp_Connector_Tracking_cc() } +void Gps_L1_Ca_Tcp_Connector_Tracking_cc::set_channel(unsigned int channel) +{ + d_channel = channel; + LOG(INFO) << "Tracking Channel set to " << d_channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); + } + } + } + + //! Listen for connections on a TCP port + if (d_listen_connection == true) + { + d_port = d_port_ch0 + d_channel; + d_listen_connection = d_tcp_com.listen_tcp_connection(d_port, d_port_ch0); + } +} + + +void Gps_L1_Ca_Tcp_Connector_Tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) +{ + d_acquisition_gnss_synchro = p_gnss_synchro; +} + + int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -553,42 +592,3 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib return 0; } } - - -void Gps_L1_Ca_Tcp_Connector_Tracking_cc::set_channel(unsigned int channel) -{ - d_channel = channel; - LOG(INFO) << "Tracking Channel set to " << d_channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); - } - } - } - - //! Listen for connections on a TCP port - if (d_listen_connection == true) - { - d_port = d_port_ch0 + d_channel; - d_listen_connection = d_tcp_com.listen_tcp_connection(d_port, d_port_ch0); - } -} - - -void Gps_L1_Ca_Tcp_Connector_Tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) -{ - d_acquisition_gnss_synchro = p_gnss_synchro; -} From 2e15b16660df0d83e10b88215afe91411243afc1 Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Wed, 11 Apr 2018 11:26:24 +0200 Subject: [PATCH 08/44] Change std::deque to boost::circular_buffer The circular buffer (fixed memory) increases the performance of the receiver --- .../gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc | 7 ++----- .../gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc index 580bc8bdc..09f4e2621 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc @@ -105,6 +105,8 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc( flag_PLL_180_deg_phase_locked = false; d_preamble_time_samples = 0; d_TOW_at_current_symbol_ms = 0; + d_symbol_history.resize(GPS_CA_PREAMBLE_LENGTH_SYMBOLS + 1); // Change fixed buffer size + d_symbol_history.clear(); // Clear all the elements in the buffer } @@ -395,11 +397,6 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ } } - // remove used symbols from history - if (d_symbol_history.size() > required_symbols) - { - d_symbol_history.pop_front(); - } //3. Make the output (copy the object contents to the GNURadio reserved memory) *out[0] = current_symbol; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h index 8904f7e85..22a9526a2 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h @@ -36,9 +36,9 @@ #include "gnss_satellite.h" #include "gnss_synchro.h" #include -#include #include #include +#include class gps_l1_ca_telemetry_decoder_cc; @@ -79,7 +79,7 @@ private: bool d_flag_frame_sync; // symbols - std::deque d_symbol_history; + boost::circular_buffer d_symbol_history; double d_symbol_accumulator; short int d_symbol_accumulator_counter; From 385055e884374f8cd75c47b75c5d3fcce45d9757 Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Wed, 11 Apr 2018 12:49:22 +0200 Subject: [PATCH 09/44] Increase buffer size --- .../gnuradio_blocks/hybrid_observables_cc.cc | 36 +++---------------- .../gnuradio_blocks/hybrid_observables_cc.h | 1 + 2 files changed, 5 insertions(+), 32 deletions(-) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index 0566e86f9..1b4d3ab62 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -63,10 +63,11 @@ hybrid_observables_cc::hybrid_observables_cc(unsigned int nchannels_in, d_dump_filename = dump_filename; T_rx_s = 0.0; T_rx_step_s = 0.001; // 1 ms - max_delta = 0.15; // 150 ms + max_delta = 2.5; // 2.5 s + d_latency = 0.08; // 80 ms valid_channels.resize(d_nchannels, false); d_num_valid_channels = 0; - d_gnss_synchro_history = new Gnss_circular_deque(1000, d_nchannels); + d_gnss_synchro_history = new Gnss_circular_deque(static_cast(max_delta * 1000.0), d_nchannels); // ############# ENABLE DATA FILE LOG ################# if (d_dump) @@ -322,35 +323,6 @@ bool hybrid_observables_cc::interpolate_data(Gnss_Synchro &out, const unsigned i out.TOW_at_current_symbol_s = d_gnss_synchro_history->at(ch, ind.first).TOW_at_current_symbol_s + (d_gnss_synchro_history->at(ch, ind.second).TOW_at_current_symbol_s - d_gnss_synchro_history->at(ch, ind.first).TOW_at_current_symbol_s) * (ti - d_gnss_synchro_history->at(ch, ind.first).RX_time) / (d_gnss_synchro_history->at(ch, ind.second).RX_time - d_gnss_synchro_history->at(ch, ind.first).RX_time); return true; - - /* - arma::vec t = arma::vec(d_gnss_synchro_history.size(ch)); - arma::vec dop = t; - arma::vec cph = t; - arma::vec tow = t; - arma::vec tiv = arma::vec(1); - arma::vec result; - tiv(0) = ti; - - unsigned int aux = 0; - for (it = data.begin(); it != data.end(); it++) - { - t(aux) = it->RX_time; - dop(aux) = it->Carrier_Doppler_hz; - cph(aux) = it->Carrier_phase_rads; - tow(aux) = it->TOW_at_current_symbol_s; - - aux++; - } - arma::interp1(t, dop, tiv, result); - out.Carrier_Doppler_hz = result(0); - arma::interp1(t, cph, tiv, result); - out.Carrier_phase_rads = result(0); - arma::interp1(t, tow, tiv, result); - out.TOW_at_current_symbol_s = result(0); - - return result.is_finite(); - */ } @@ -562,7 +534,7 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) // Check if there is any valid channel after computing the time distance between the Gnss_Synchro data and the receiver time d_num_valid_channels = valid_channels.count(); - double T_rx_s_out = T_rx_s - (max_delta / 2.0); + double T_rx_s_out = T_rx_s - d_latency; if ((d_num_valid_channels == 0) or (T_rx_s_out < 0.0)) { return 0; diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h index c5557963b..64f929857 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h @@ -78,6 +78,7 @@ private: double T_rx_s; double T_rx_step_s; double max_delta; + double d_latency; bool d_dump; unsigned int d_nchannels; unsigned int d_num_valid_channels; From 2eea1a66aaec477bd5cade49ff9afef66c1b0041 Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Wed, 11 Apr 2018 12:56:15 +0200 Subject: [PATCH 10/44] Solve conflicts --- .../observables/gnuradio_blocks/hybrid_observables_cc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index 1b4d3ab62..a7142d635 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -63,7 +63,7 @@ hybrid_observables_cc::hybrid_observables_cc(unsigned int nchannels_in, d_dump_filename = dump_filename; T_rx_s = 0.0; T_rx_step_s = 0.001; // 1 ms - max_delta = 2.5; // 2.5 s + max_delta = 3.0; // 3 s d_latency = 0.08; // 80 ms valid_channels.resize(d_nchannels, false); d_num_valid_channels = 0; From b606e1d71fb797df1c0d7c875d77c4e15fdb1b13 Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Wed, 11 Apr 2018 13:35:01 +0200 Subject: [PATCH 11/44] Solve more conflicts --- .../observables/adapters/CMakeLists.txt | 1 + .../gnuradio_blocks/CMakeLists.txt | 6 +- .../gnuradio_blocks/hybrid_observables_cc.cc | 126 ++++++++++-------- .../gnuradio_blocks/hybrid_observables_cc.h | 11 +- 4 files changed, 80 insertions(+), 64 deletions(-) diff --git a/src/algorithms/observables/adapters/CMakeLists.txt b/src/algorithms/observables/adapters/CMakeLists.txt index 5129e4157..882b22d83 100644 --- a/src/algorithms/observables/adapters/CMakeLists.txt +++ b/src/algorithms/observables/adapters/CMakeLists.txt @@ -26,6 +26,7 @@ include_directories( ${CMAKE_SOURCE_DIR}/src/core/interfaces ${CMAKE_SOURCE_DIR}/src/core/receiver ${CMAKE_SOURCE_DIR}/src/algorithms/observables/gnuradio_blocks + ${CMAKE_SOURCE_DIR}/src/algorithms/libs ${CMAKE_SOURCE_DIR}/src/algorithms/PVT/libs ${GLOG_INCLUDE_DIRS} ${GFlags_INCLUDE_DIRS} diff --git a/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt b/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt index 98b8213d8..e3db8ebcf 100644 --- a/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt @@ -39,8 +39,8 @@ list(SORT OBS_GR_BLOCKS_HEADERS) add_library(obs_gr_blocks ${OBS_GR_BLOCKS_SOURCES} ${OBS_GR_BLOCKS_HEADERS}) source_group(Headers FILES ${OBS_GR_BLOCKS_HEADERS}) if(MATIO_FOUND) - add_dependencies(obs_gr_blocks glog-${glog_RELEASE} armadillo-${armadillo_RELEASE}) + add_dependencies(obs_gr_blocks gnss_sp_libs glog-${glog_RELEASE} armadillo-${armadillo_RELEASE}) else(MATIO_FOUND) - add_dependencies(obs_gr_blocks glog-${glog_RELEASE} armadillo-${armadillo_RELEASE} matio-${GNSSSDR_MATIO_LOCAL_VERSION}) + add_dependencies(obs_gr_blocks gnss_sp_libs glog-${glog_RELEASE} armadillo-${armadillo_RELEASE} matio-${GNSSSDR_MATIO_LOCAL_VERSION}) endif(MATIO_FOUND) -target_link_libraries(obs_gr_blocks ${GNURADIO_RUNTIME_LIBRARIES} ${ARMADILLO_LIBRARIES} ${MATIO_LIBRARIES}) +target_link_libraries(obs_gr_blocks gnss_sp_libs ${GNURADIO_RUNTIME_LIBRARIES} ${ARMADILLO_LIBRARIES} ${MATIO_LIBRARIES}) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index a60318772..4b6ccfb1d 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -63,15 +63,11 @@ hybrid_observables_cc::hybrid_observables_cc(unsigned int nchannels_in, d_dump_filename = dump_filename; T_rx_s = 0.0; T_rx_step_s = 0.001; // 1 ms - max_delta = 3.0; // 3 s + max_delta = 3.5; // 3.5 s d_latency = 0.08; // 80 ms valid_channels.resize(d_nchannels, false); d_num_valid_channels = 0; - - for (unsigned int i = 0; i < d_nchannels; i++) - { - d_gnss_synchro_history.push_back(std::deque()); - } + d_gnss_synchro_history = new Gnss_circular_deque(static_cast(max_delta * 1000.0), d_nchannels); // ############# ENABLE DATA FILE LOG ################# if (d_dump) @@ -304,40 +300,29 @@ int hybrid_observables_cc::save_matfile() } -bool hybrid_observables_cc::interpolate_data(Gnss_Synchro &out, std::deque &data, const double &ti) +bool hybrid_observables_cc::interpolate_data(Gnss_Synchro &out, const unsigned int &ch, const double &ti) { - if ((ti < data.front().RX_time) or (ti > data.back().RX_time)) + if ((ti < d_gnss_synchro_history->front(ch).RX_time) or (ti > d_gnss_synchro_history->back(ch).RX_time)) { return false; } - std::deque::iterator it; + std::pair ind = find_interp_elements(ch, ti); - arma::vec t = arma::vec(data.size()); - arma::vec dop = t; - arma::vec cph = t; - arma::vec tow = t; - arma::vec tiv = arma::vec(1); - arma::vec result; - tiv(0) = ti; + //Linear interpolation: y(t) = y(t1) + (y(t2) - y(t1)) * (t - t1) / (t2 - t1) - unsigned int aux = 0; - for (it = data.begin(); it != data.end(); it++) - { - t(aux) = it->RX_time; - dop(aux) = it->Carrier_Doppler_hz; - cph(aux) = it->Carrier_phase_rads; - tow(aux) = it->TOW_at_current_symbol_s; + // CARRIER PHASE INTERPOLATION - aux++; - } - arma::interp1(t, dop, tiv, result); - out.Carrier_Doppler_hz = result(0); - arma::interp1(t, cph, tiv, result); - out.Carrier_phase_rads = result(0); - arma::interp1(t, tow, tiv, result); - out.TOW_at_current_symbol_s = result(0); + out.Carrier_phase_rads = d_gnss_synchro_history->at(ch, ind.first).Carrier_phase_rads + (d_gnss_synchro_history->at(ch, ind.second).Carrier_phase_rads - d_gnss_synchro_history->at(ch, ind.first).Carrier_phase_rads) * (ti - d_gnss_synchro_history->at(ch, ind.first).RX_time) / (d_gnss_synchro_history->at(ch, ind.second).RX_time - d_gnss_synchro_history->at(ch, ind.first).RX_time); - return result.is_finite(); + // CARRIER DOPPLER INTERPOLATION + + out.Carrier_Doppler_hz = d_gnss_synchro_history->at(ch, ind.first).Carrier_Doppler_hz + (d_gnss_synchro_history->at(ch, ind.second).Carrier_Doppler_hz - d_gnss_synchro_history->at(ch, ind.first).Carrier_Doppler_hz) * (ti - d_gnss_synchro_history->at(ch, ind.first).RX_time) / (d_gnss_synchro_history->at(ch, ind.second).RX_time - d_gnss_synchro_history->at(ch, ind.first).RX_time); + + // TOW INTERPOLATION + + out.TOW_at_current_symbol_s = d_gnss_synchro_history->at(ch, ind.first).TOW_at_current_symbol_s + (d_gnss_synchro_history->at(ch, ind.second).TOW_at_current_symbol_s - d_gnss_synchro_history->at(ch, ind.first).TOW_at_current_symbol_s) * (ti - d_gnss_synchro_history->at(ch, ind.first).RX_time) / (d_gnss_synchro_history->at(ch, ind.second).RX_time - d_gnss_synchro_history->at(ch, ind.first).RX_time); + + return true; } @@ -353,6 +338,40 @@ double hybrid_observables_cc::compute_T_rx_s(const Gnss_Synchro &a) } } +std::pair hybrid_observables_cc::find_interp_elements(const unsigned int &ch, const double &ti) +{ + unsigned int closest = 0; + double dif = std::numeric_limits::max(); + double dt = 0.0; + for (unsigned int i = 0; i < d_gnss_synchro_history->size(ch); i++) + { + dt = ti - d_gnss_synchro_history->at(ch, i).RX_time; + if (dt < dif and dt > 0.0) + { + dif = dt; + closest = i; + } + } + unsigned int index1; + unsigned int index2; + if (closest == 0) + { + index1 = 0; + index2 = 1; + } + else if (closest == (d_gnss_synchro_history->size(ch) - 1)) + { + index1 = d_gnss_synchro_history->size(ch) - 2; + index2 = d_gnss_synchro_history->size(ch) - 1; + } + else + { + index1 = closest; + index2 = closest + 1; + } + return std::pair(index1, index2); +} + void hybrid_observables_cc::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required) @@ -365,13 +384,13 @@ void hybrid_observables_cc::forecast(int noutput_items __attribute__((unused)), } -void hybrid_observables_cc::clean_history(std::deque &data) +void hybrid_observables_cc::clean_history(unsigned int pos) { - while (data.size() > 0) + while (d_gnss_synchro_history->size(pos) > 0) { - if ((T_rx_s - data.front().RX_time) > max_delta) + if ((T_rx_s - d_gnss_synchro_history->front(pos).RX_time) > max_delta) { - data.pop_front(); + d_gnss_synchro_history->pop_front(pos); } else { @@ -456,11 +475,9 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) } ////////////////////////////////////////////////////////////////////////// - std::vector>::iterator it; if (total_input_items > 0) { - i = 0; - for (it = d_gnss_synchro_history.begin(); it != d_gnss_synchro_history.end(); it++) + for (i = 0; i < d_nchannels; i++) { if (ninput_items[i] > 0) { @@ -469,26 +486,25 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) { if (in[i][aux].Flag_valid_word) { - it->push_back(in[i][aux]); - it->back().RX_time = compute_T_rx_s(in[i][aux]); + d_gnss_synchro_history->push_back(i, in[i][aux]); + d_gnss_synchro_history->back(i).RX_time = compute_T_rx_s(in[i][aux]); // Check if the last Gnss_Synchro comes from the same satellite as the previous ones - if (it->size() > 1) + if (d_gnss_synchro_history->size(i) > 1) { - if (it->front().PRN != it->back().PRN) + if (d_gnss_synchro_history->front(i).PRN != d_gnss_synchro_history->back(i).PRN) { - it->clear(); + d_gnss_synchro_history->clear(i); } } } } consume(i, ninput_items[i]); } - i++; } } for (i = 0; i < d_nchannels; i++) { - if (d_gnss_synchro_history.at(i).size() > 2) + if (d_gnss_synchro_history->size(i) > 2) { valid_channels[i] = true; } @@ -508,8 +524,8 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) { if (valid_channels[i]) { - clean_history(d_gnss_synchro_history.at(i)); - if (d_gnss_synchro_history.at(i).size() < 2) + clean_history(i); + if (d_gnss_synchro_history->size(i) < 2) { valid_channels[i] = false; } @@ -525,13 +541,12 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) } std::vector epoch_data; - i = 0; - for (it = d_gnss_synchro_history.begin(); it != d_gnss_synchro_history.end(); it++) + for (i = 0; i < d_nchannels; i++) { if (valid_channels[i]) { - Gnss_Synchro interpolated_gnss_synchro = it->back(); - if (interpolate_data(interpolated_gnss_synchro, *it, T_rx_s_out)) + Gnss_Synchro interpolated_gnss_synchro = d_gnss_synchro_history->back(i); + if (interpolate_data(interpolated_gnss_synchro, i, T_rx_s_out)) { epoch_data.push_back(interpolated_gnss_synchro); } @@ -540,7 +555,6 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) valid_channels[i] = false; } } - i++; } d_num_valid_channels = valid_channels.count(); if (d_num_valid_channels == 0) @@ -548,14 +562,14 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) return 0; } correct_TOW_and_compute_prange(epoch_data); - std::vector::iterator it2 = epoch_data.begin(); + std::vector::iterator it = epoch_data.begin(); for (i = 0; i < d_nchannels; i++) { if (valid_channels[i]) { - out[i][0] = (*it2); + out[i][0] = (*it); out[i][0].Flag_valid_pseudorange = true; - it2++; + it++; } else { diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h index 8d48fc3fa..64f929857 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h @@ -35,12 +35,12 @@ #define GNSS_SDR_HYBRID_OBSERVABLES_CC_H #include "gnss_synchro.h" +#include "gnss_circular_deque.h" #include #include #include #include -#include -#include +#include class hybrid_observables_cc; @@ -65,14 +65,15 @@ private: friend hybrid_observables_cc_sptr hybrid_make_observables_cc(unsigned int nchannels_in, unsigned int nchannels_out, bool dump, std::string dump_filename); hybrid_observables_cc(unsigned int nchannels_in, unsigned int nchannels_out, bool dump, std::string dump_filename); - void clean_history(std::deque& data); + void clean_history(unsigned int pos); double compute_T_rx_s(const Gnss_Synchro& a); - bool interpolate_data(Gnss_Synchro& out, std::deque& data, const double& ti); + bool interpolate_data(Gnss_Synchro& out, const unsigned int& ch, const double& ti); + std::pair find_interp_elements(const unsigned int& ch, const double& ti); void correct_TOW_and_compute_prange(std::vector& data); int save_matfile(); //Tracking observable history - std::vector> d_gnss_synchro_history; + Gnss_circular_deque* d_gnss_synchro_history; boost::dynamic_bitset<> valid_channels; double T_rx_s; double T_rx_step_s; From 6c55c3a93f257e88f4e0300b009d3919e9fd7339 Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Wed, 11 Apr 2018 17:41:27 +0200 Subject: [PATCH 12/44] Improve performance --- .../gnuradio_blocks/hybrid_observables_cc.cc | 49 +++++++++---------- .../gnuradio_blocks/hybrid_observables_cc.h | 2 +- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index 4b6ccfb1d..0dbda3661 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -67,7 +67,7 @@ hybrid_observables_cc::hybrid_observables_cc(unsigned int nchannels_in, d_latency = 0.08; // 80 ms valid_channels.resize(d_nchannels, false); d_num_valid_channels = 0; - d_gnss_synchro_history = new Gnss_circular_deque(static_cast(max_delta * 1000.0), d_nchannels); + d_gnss_synchro_history = new Gnss_circular_deque(static_cast(max_delta * 1000.0 * 2.0), d_nchannels); // ############# ENABLE DATA FILE LOG ################# if (d_dump) @@ -306,21 +306,18 @@ bool hybrid_observables_cc::interpolate_data(Gnss_Synchro &out, const unsigned i { return false; } - std::pair ind = find_interp_elements(ch, ti); + find_interp_elements(ch, ti); //Linear interpolation: y(t) = y(t1) + (y(t2) - y(t1)) * (t - t1) / (t2 - t1) // CARRIER PHASE INTERPOLATION - - out.Carrier_phase_rads = d_gnss_synchro_history->at(ch, ind.first).Carrier_phase_rads + (d_gnss_synchro_history->at(ch, ind.second).Carrier_phase_rads - d_gnss_synchro_history->at(ch, ind.first).Carrier_phase_rads) * (ti - d_gnss_synchro_history->at(ch, ind.first).RX_time) / (d_gnss_synchro_history->at(ch, ind.second).RX_time - d_gnss_synchro_history->at(ch, ind.first).RX_time); + out.Carrier_phase_rads = d_gnss_synchro_history->at(ch, 0).Carrier_phase_rads + (d_gnss_synchro_history->at(ch, 1).Carrier_phase_rads - d_gnss_synchro_history->at(ch, 0).Carrier_phase_rads) * (ti - d_gnss_synchro_history->at(ch, 0).RX_time) / (d_gnss_synchro_history->at(ch, 1).RX_time - d_gnss_synchro_history->at(ch, 0).RX_time); // CARRIER DOPPLER INTERPOLATION - - out.Carrier_Doppler_hz = d_gnss_synchro_history->at(ch, ind.first).Carrier_Doppler_hz + (d_gnss_synchro_history->at(ch, ind.second).Carrier_Doppler_hz - d_gnss_synchro_history->at(ch, ind.first).Carrier_Doppler_hz) * (ti - d_gnss_synchro_history->at(ch, ind.first).RX_time) / (d_gnss_synchro_history->at(ch, ind.second).RX_time - d_gnss_synchro_history->at(ch, ind.first).RX_time); + out.Carrier_Doppler_hz = d_gnss_synchro_history->at(ch, 0).Carrier_Doppler_hz + (d_gnss_synchro_history->at(ch, 1).Carrier_Doppler_hz - d_gnss_synchro_history->at(ch, 0).Carrier_Doppler_hz) * (ti - d_gnss_synchro_history->at(ch, 0).RX_time) / (d_gnss_synchro_history->at(ch, 1).RX_time - d_gnss_synchro_history->at(ch, 0).RX_time); // TOW INTERPOLATION - - out.TOW_at_current_symbol_s = d_gnss_synchro_history->at(ch, ind.first).TOW_at_current_symbol_s + (d_gnss_synchro_history->at(ch, ind.second).TOW_at_current_symbol_s - d_gnss_synchro_history->at(ch, ind.first).TOW_at_current_symbol_s) * (ti - d_gnss_synchro_history->at(ch, ind.first).RX_time) / (d_gnss_synchro_history->at(ch, ind.second).RX_time - d_gnss_synchro_history->at(ch, ind.first).RX_time); + out.TOW_at_current_symbol_s = d_gnss_synchro_history->at(ch, 0).TOW_at_current_symbol_s + (d_gnss_synchro_history->at(ch, 1).TOW_at_current_symbol_s - d_gnss_synchro_history->at(ch, 0).TOW_at_current_symbol_s) * (ti - d_gnss_synchro_history->at(ch, 0).RX_time) / (d_gnss_synchro_history->at(ch, 1).RX_time - d_gnss_synchro_history->at(ch, 0).RX_time); return true; } @@ -338,38 +335,40 @@ double hybrid_observables_cc::compute_T_rx_s(const Gnss_Synchro &a) } } -std::pair hybrid_observables_cc::find_interp_elements(const unsigned int &ch, const double &ti) +void hybrid_observables_cc::find_interp_elements(const unsigned int &ch, const double &ti) { unsigned int closest = 0; double dif = std::numeric_limits::max(); double dt = 0.0; for (unsigned int i = 0; i < d_gnss_synchro_history->size(ch); i++) { - dt = ti - d_gnss_synchro_history->at(ch, i).RX_time; - if (dt < dif and dt > 0.0) + dt = std::fabs(ti - d_gnss_synchro_history->at(ch, i).RX_time); + if (dt < dif) { - dif = dt; closest = i; + dif = dt; + } + else + { + break; } } - unsigned int index1; - unsigned int index2; - if (closest == 0) + if (ti > d_gnss_synchro_history->at(ch, closest).RX_time) { - index1 = 0; - index2 = 1; - } - else if (closest == (d_gnss_synchro_history->size(ch) - 1)) - { - index1 = d_gnss_synchro_history->size(ch) - 2; - index2 = d_gnss_synchro_history->size(ch) - 1; + while (closest > 0) + { + d_gnss_synchro_history->pop_front(ch); + closest--; + } } else { - index1 = closest; - index2 = closest + 1; + while (closest > 1) + { + d_gnss_synchro_history->pop_front(ch); + closest--; + } } - return std::pair(index1, index2); } diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h index 64f929857..5772464e2 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h @@ -68,7 +68,7 @@ private: void clean_history(unsigned int pos); double compute_T_rx_s(const Gnss_Synchro& a); bool interpolate_data(Gnss_Synchro& out, const unsigned int& ch, const double& ti); - std::pair find_interp_elements(const unsigned int& ch, const double& ti); + void find_interp_elements(const unsigned int& ch, const double& ti); void correct_TOW_and_compute_prange(std::vector& data); int save_matfile(); From 6de28277edf9ef487905cde13a409aadde16ccaa Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Thu, 12 Apr 2018 10:57:12 +0200 Subject: [PATCH 13/44] Fine tune buffer parameters --- .../observables/gnuradio_blocks/hybrid_observables_cc.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index 0dbda3661..274dc0732 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -63,11 +63,11 @@ hybrid_observables_cc::hybrid_observables_cc(unsigned int nchannels_in, d_dump_filename = dump_filename; T_rx_s = 0.0; T_rx_step_s = 0.001; // 1 ms - max_delta = 3.5; // 3.5 s - d_latency = 0.08; // 80 ms + max_delta = 1.5; // 1.5 s + d_latency = 0.175; // 175 ms valid_channels.resize(d_nchannels, false); d_num_valid_channels = 0; - d_gnss_synchro_history = new Gnss_circular_deque(static_cast(max_delta * 1000.0 * 2.0), d_nchannels); + d_gnss_synchro_history = new Gnss_circular_deque(static_cast(max_delta * 1000.0), d_nchannels); // ############# ENABLE DATA FILE LOG ################# if (d_dump) From f92dd4dc839c7fec9b1d4da5781e505f10a1e170 Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Thu, 12 Apr 2018 11:03:52 +0200 Subject: [PATCH 14/44] New correlation procedure --- .../gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc | 11 +++++++++-- .../gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc index 09f4e2621..fd42488d0 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc @@ -107,6 +107,8 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc( d_TOW_at_current_symbol_ms = 0; d_symbol_history.resize(GPS_CA_PREAMBLE_LENGTH_SYMBOLS + 1); // Change fixed buffer size d_symbol_history.clear(); // Clear all the elements in the buffer + d_make_correlation = true; + d_symbol_counter_corr = 0; } @@ -170,7 +172,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ unsigned int required_symbols = GPS_CA_PREAMBLE_LENGTH_SYMBOLS; d_flag_preamble = false; - if (d_symbol_history.size() > required_symbols) + if (d_symbol_history.size() > required_symbols and d_make_correlation) { //******* preamble correlation ******** for (unsigned int i = 0; i < GPS_CA_PREAMBLE_LENGTH_SYMBOLS; i++) @@ -186,7 +188,12 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ corr_value += d_preambles_symbols[i] * d_symbol_history.at(i).correlation_length_ms; } } - if (corr_value >= GPS_CA_PREAMBLE_LENGTH_SYMBOLS) break; + if (corr_value >= GPS_CA_PREAMBLE_LENGTH_SYMBOLS) + { + d_symbol_counter_corr = 0; + d_make_correlation = false; + break; + } } } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h index 22a9526a2..8e3600e3a 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h @@ -84,6 +84,10 @@ private: double d_symbol_accumulator; short int d_symbol_accumulator_counter; + // symbol counting + bool d_make_correlation; + unsigned int d_symbol_counter_corr; + //bits and frame unsigned short int d_frame_bit_index; unsigned int d_GPS_frame_4bytes; From ad220dd279943408f417cb23c109881634813563 Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Thu, 12 Apr 2018 17:01:07 +0200 Subject: [PATCH 15/44] Minor changes --- .../gps_l1_ca_telemetry_decoder_cc.cc | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc index fd42488d0..0c79165c2 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc @@ -172,7 +172,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ unsigned int required_symbols = GPS_CA_PREAMBLE_LENGTH_SYMBOLS; d_flag_preamble = false; - if (d_symbol_history.size() > required_symbols and d_make_correlation) + if ((d_symbol_history.size() > required_symbols) and (d_make_correlation or !d_flag_frame_sync)) { //******* preamble correlation ******** for (unsigned int i = 0; i < GPS_CA_PREAMBLE_LENGTH_SYMBOLS; i++) @@ -181,24 +181,22 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ { if (d_symbol_history.at(i).Prompt_I < 0) // symbols clipping { - corr_value -= d_preambles_symbols[i] * d_symbol_history.at(i).correlation_length_ms; + corr_value -= d_preambles_symbols[i]; } else { - corr_value += d_preambles_symbols[i] * d_symbol_history.at(i).correlation_length_ms; + corr_value += d_preambles_symbols[i]; } } - if (corr_value >= GPS_CA_PREAMBLE_LENGTH_SYMBOLS) - { - d_symbol_counter_corr = 0; - d_make_correlation = false; - break; - } + } + if (std::abs(corr_value) >= GPS_CA_PREAMBLE_LENGTH_SYMBOLS) + { + d_symbol_counter_corr++; } } //******* frame sync ****************** - if (abs(corr_value) == GPS_CA_PREAMBLE_LENGTH_SYMBOLS) + if (std::abs(corr_value) == GPS_CA_PREAMBLE_LENGTH_SYMBOLS) { //TODO: Rewrite with state machine if (d_stat == 0) @@ -215,12 +213,14 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ } else if (d_stat == 1) //check 6 seconds of preamble separation { - preamble_diff_ms = round(((static_cast(d_symbol_history.at(0).Tracking_sample_counter) - d_preamble_time_samples) / static_cast(d_symbol_history.at(0).fs)) * 1000.0); - if (abs(preamble_diff_ms - GPS_SUBFRAME_MS) < 1) + preamble_diff_ms = std::round(((static_cast(d_symbol_history.at(0).Tracking_sample_counter) - d_preamble_time_samples) / static_cast(d_symbol_history.at(0).fs)) * 1000.0); + if (std::abs(preamble_diff_ms - GPS_SUBFRAME_MS) < 1) { DLOG(INFO) << "Preamble confirmation for SAT " << this->d_satellite; d_GPS_FSM.Event_gps_word_preamble(); d_flag_preamble = true; + d_make_correlation = false; + d_symbol_counter_corr = 0; d_preamble_time_samples = d_symbol_history.at(0).Tracking_sample_counter; // record the PRN start sample index associated to the preamble if (!d_flag_frame_sync) { @@ -245,6 +245,11 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ } else { + d_symbol_counter_corr++; + if (d_symbol_counter_corr > (GPS_SUBFRAME_MS - GPS_CA_TELEMETRY_SYMBOLS_PER_BIT)) + { + d_make_correlation = true; + } if (d_stat == 1) { preamble_diff_ms = round(((static_cast(d_symbol_history.at(0).Tracking_sample_counter) - static_cast(d_preamble_time_samples)) / static_cast(d_symbol_history.at(0).fs)) * 1000.0); @@ -254,6 +259,8 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ d_stat = 0; //lost of frame sync d_flag_frame_sync = false; flag_TOW_set = false; + d_make_correlation = true; + d_symbol_counter_corr = 0; } } } From fcdf123e0ecb6a2d24328f05a8dac5bbe979e14f Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Thu, 12 Apr 2018 17:14:57 +0200 Subject: [PATCH 16/44] Correct name --- src/algorithms/libs/gnss_circular_deque.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/libs/gnss_circular_deque.h b/src/algorithms/libs/gnss_circular_deque.h index e1b73c87d..d9694e722 100644 --- a/src/algorithms/libs/gnss_circular_deque.h +++ b/src/algorithms/libs/gnss_circular_deque.h @@ -2,7 +2,7 @@ * \file gnss_circular_deque.h * \brief This class implements a circular deque for Gnss_Synchro * - * \author Luis Esteve, 2018. antonio.ramos(at)cttc.es + * \author Antonio Ramos, 2018. antonio.ramosdet(at)gmail.com * * Detailed description of the file here if needed. * From 52cc6ab04dacc6aa8fa5c706541d4abd0e9bcb13 Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Thu, 12 Apr 2018 18:01:12 +0200 Subject: [PATCH 17/44] Remove telemetry -> tracking msg port --- src/algorithms/channel/adapters/channel.cc | 4 ---- .../gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc | 2 -- .../gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc | 2 -- .../gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc | 5 ----- .../gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc | 5 ----- .../gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc | 5 ----- .../gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc | 2 -- .../gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc | 2 -- .../gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc | 2 -- .../tracking/gnuradio_blocks/dll_pll_veml_tracking.cc | 1 - .../gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc | 2 -- .../gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc | 2 -- .../gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc | 2 -- .../gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc | 2 -- 14 files changed, 38 deletions(-) diff --git a/src/algorithms/channel/adapters/channel.cc b/src/algorithms/channel/adapters/channel.cc index 5a6284888..f7cec1949 100644 --- a/src/algorithms/channel/adapters/channel.cc +++ b/src/algorithms/channel/adapters/channel.cc @@ -108,8 +108,6 @@ Channel::Channel(ConfigurationInterface* configuration, unsigned int channel, // Destructor Channel::~Channel() {} - - void Channel::connect(gr::top_block_sptr top_block) { if (connected_) @@ -137,8 +135,6 @@ void Channel::connect(gr::top_block_sptr top_block) DLOG(INFO) << "tracking -> telemetry_decoder"; // Message ports - top_block->msg_connect(nav_->get_left_block(), pmt::mp("preamble_timestamp_s"), trk_->get_right_block(), pmt::mp("preamble_timestamp_s")); - DLOG(INFO) << "MSG FEEDBACK CHANNEL telemetry_decoder -> tracking"; top_block->msg_connect(acq_->get_right_block(), pmt::mp("events"), channel_msg_rx, pmt::mp("events")); top_block->msg_connect(trk_->get_right_block(), pmt::mp("events"), channel_msg_rx, pmt::mp("events")); diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc index a774577a5..286ca0c68 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc @@ -106,8 +106,6 @@ galileo_e1b_telemetry_decoder_cc::galileo_e1b_telemetry_decoder_cc( bool dump) : gr::block("galileo_e1b_telemetry_decoder_cc", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { - // Telemetry Bit transition synchronization port out - this->message_port_register_out(pmt::mp("preamble_timestamp_s")); // Ephemeris data port out this->message_port_register_out(pmt::mp("telemetry")); // initialize internal vars diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc index 640cbf009..8e032956e 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc @@ -183,8 +183,6 @@ galileo_e5a_telemetry_decoder_cc::galileo_e5a_telemetry_decoder_cc( gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { - // Telemetry Bit transition synchronization port out - this->message_port_register_out(pmt::mp("preamble_timestamp_s")); // Ephemeris data port out this->message_port_register_out(pmt::mp("telemetry")); // initialize internal vars diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc index 0bd2fae54..ca6dc8681 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc @@ -54,8 +54,6 @@ glonass_l1_ca_telemetry_decoder_cc::glonass_l1_ca_telemetry_decoder_cc( bool dump) : gr::block("glonass_l1_ca_telemetry_decoder_cc", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { - // Telemetry Bit transition synchronization port out - this->message_port_register_out(pmt::mp("preamble_timestamp_s")); // Ephemeris data port out this->message_port_register_out(pmt::mp("telemetry")); // initialize internal vars @@ -285,9 +283,6 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu LOG(INFO) << "Starting string decoder for GLONASS L1 C/A SAT " << this->d_satellite; d_preamble_index = d_sample_counter; //record the preamble sample stamp d_stat = 2; - // send asynchronous message to tracking to inform of frame sync and extend correlation time - pmt::pmt_t value = pmt::from_double(static_cast(d_preamble_time_samples) / static_cast(d_symbol_history.at(0).fs) - 0.001); - this->message_port_pub(pmt::mp("preamble_timestamp_s"), value); } else { diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc index 2b168a89c..e2a362974 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc @@ -53,8 +53,6 @@ glonass_l2_ca_telemetry_decoder_cc::glonass_l2_ca_telemetry_decoder_cc( bool dump) : gr::block("glonass_l2_ca_telemetry_decoder_cc", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { - // Telemetry Bit transition synchronization port out - this->message_port_register_out(pmt::mp("preamble_timestamp_s")); // Ephemeris data port out this->message_port_register_out(pmt::mp("telemetry")); // initialize internal vars @@ -284,9 +282,6 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu LOG(INFO) << "Starting string decoder for GLONASS L2 C/A SAT " << this->d_satellite; d_preamble_index = d_sample_counter; //record the preamble sample stamp d_stat = 2; - // send asynchronous message to tracking to inform of frame sync and extend correlation time - pmt::pmt_t value = pmt::from_double(static_cast(d_preamble_time_samples) / static_cast(d_symbol_history.at(0).fs) - 0.001); - this->message_port_pub(pmt::mp("preamble_timestamp_s"), value); } else { diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc index 0c79165c2..955d180d7 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc @@ -54,8 +54,6 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc( bool dump) : gr::block("gps_navigation_cc", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { - // Telemetry Bit transition synchronization port out - this->message_port_register_out(pmt::mp("preamble_timestamp_s")); // Ephemeris data port out this->message_port_register_out(pmt::mp("telemetry")); // initialize internal vars @@ -224,9 +222,6 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ d_preamble_time_samples = d_symbol_history.at(0).Tracking_sample_counter; // record the PRN start sample index associated to the preamble if (!d_flag_frame_sync) { - // send asynchronous message to tracking to inform of frame sync and extend correlation time - pmt::pmt_t value = pmt::from_double(static_cast(d_preamble_time_samples) / static_cast(d_symbol_history.at(0).fs) - 0.001); - this->message_port_pub(pmt::mp("preamble_timestamp_s"), value); d_flag_frame_sync = true; if (corr_value < 0) { diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc index 0325041d3..dee30987e 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc @@ -55,8 +55,6 @@ gps_l2c_telemetry_decoder_cc::gps_l2c_telemetry_decoder_cc( gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { - // Telemetry Bit transition synchronization port out - this->message_port_register_out(pmt::mp("preamble_timestamp_s")); // Ephemeris data port out this->message_port_register_out(pmt::mp("telemetry")); // initialize internal vars diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc index af9666c03..1cfd20162 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc @@ -56,8 +56,6 @@ gps_l5_telemetry_decoder_cc::gps_l5_telemetry_decoder_cc( gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { - // Telemetry Bit transition synchronization port out - this->message_port_register_out(pmt::mp("preamble_timestamp_s")); // Ephemeris data port out this->message_port_register_out(pmt::mp("telemetry")); // initialize internal vars diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc index 672dbb101..194db3c11 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc @@ -59,8 +59,6 @@ sbas_l1_telemetry_decoder_cc::sbas_l1_telemetry_decoder_cc( gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { - // Telemetry Bit transition synchronization port out - this->message_port_register_out(pmt::mp("preamble_timestamp_s")); // Ephemeris data port out this->message_port_register_out(pmt::mp("telemetry")); // initialize internal vars diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc index 4ae6f8195..cd7986d2a 100755 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc @@ -82,7 +82,6 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl { trk_parameters = conf_; // Telemetry bit synchronization message port input - this->message_port_register_in(pmt::mp("preamble_timestamp_s")); this->message_port_register_out(pmt::mp("events")); this->set_relative_rate(1.0 / static_cast(trk_parameters.vector_length)); diff --git a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc index a7c0062a2..563a5ea22 100644 --- a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc @@ -99,8 +99,6 @@ Galileo_E1_Tcp_Connector_Tracking_cc::Galileo_E1_Tcp_Connector_Tracking_cc( size_t port_ch0) : gr::block("Galileo_E1_Tcp_Connector_Tracking_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { - // Telemetry bit synchronization message port input - this->message_port_register_in(pmt::mp("preamble_timestamp_s")); this->message_port_register_out(pmt::mp("events")); this->set_relative_rate(1.0 / vector_length); // initialize internal vars diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc index d35b6159c..15f58228c 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc @@ -94,8 +94,6 @@ Glonass_L1_Ca_Dll_Pll_Tracking_cc::Glonass_L1_Ca_Dll_Pll_Tracking_cc( float early_late_space_chips) : gr::block("Glonass_L1_Ca_Dll_Pll_Tracking_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { - // Telemetry bit synchronization message port input - this->message_port_register_in(pmt::mp("preamble_timestamp_s")); this->message_port_register_out(pmt::mp("events")); // initialize internal vars diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc index f6428bc5c..f6b62fade 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc @@ -94,8 +94,6 @@ Glonass_L2_Ca_Dll_Pll_Tracking_cc::Glonass_L2_Ca_Dll_Pll_Tracking_cc( float early_late_space_chips) : gr::block("Glonass_L2_Ca_Dll_Pll_Tracking_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { - // Telemetry bit synchronization message port input - this->message_port_register_in(pmt::mp("preamble_timestamp_s")); this->message_port_register_out(pmt::mp("events")); // initialize internal vars diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc index cd4c86652..62b93ecd1 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc @@ -91,8 +91,6 @@ Gps_L1_Ca_Tcp_Connector_Tracking_cc::Gps_L1_Ca_Tcp_Connector_Tracking_cc( size_t port_ch0) : gr::block("Gps_L1_Ca_Tcp_Connector_Tracking_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { - // Telemetry bit synchronization message port input - this->message_port_register_in(pmt::mp("preamble_timestamp_s")); this->message_port_register_out(pmt::mp("events")); // initialize internal vars d_dump = dump; From 51d19fd298d11db4542ba975fd68423e149ef2a5 Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Thu, 12 Apr 2018 18:36:52 +0200 Subject: [PATCH 18/44] Change hybrid observables forecast --- .../gnuradio_blocks/hybrid_observables_cc.cc | 238 +++++++++--------- 1 file changed, 123 insertions(+), 115 deletions(-) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index 274dc0732..593e01b6b 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -372,14 +372,13 @@ void hybrid_observables_cc::find_interp_elements(const unsigned int &ch, const d } -void hybrid_observables_cc::forecast(int noutput_items __attribute__((unused)), - gr_vector_int &ninput_items_required) +void hybrid_observables_cc::forecast(int noutput_items, gr_vector_int &ninput_items_required) { for (unsigned int i = 0; i < d_nchannels; i++) { ninput_items_required[i] = 0; } - ninput_items_required[d_nchannels] = 1; + ninput_items_required[d_nchannels] = noutput_items; } @@ -459,152 +458,161 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) Gnss_Synchro **out = reinterpret_cast(&output_items[0]); unsigned int i; + unsigned int returned_elements = 0; int total_input_items = 0; for (i = 0; i < d_nchannels; i++) { total_input_items += ninput_items[i]; } - consume(d_nchannels, 1); - T_rx_s += T_rx_step_s; - - ////////////////////////////////////////////////////////////////////////// - if ((total_input_items == 0) and (d_num_valid_channels == 0)) + for (int epoch = 0; epoch < ninput_items[d_nchannels]; epoch++) { - return 0; - } - ////////////////////////////////////////////////////////////////////////// + T_rx_s += T_rx_step_s; - if (total_input_items > 0) - { - for (i = 0; i < d_nchannels; i++) + ////////////////////////////////////////////////////////////////////////// + if ((total_input_items == 0) and (d_num_valid_channels == 0)) { - if (ninput_items[i] > 0) + consume(d_nchannels, epoch + 1); + return returned_elements; + } + ////////////////////////////////////////////////////////////////////////// + + if (total_input_items > 0 and epoch == 0) + { + for (i = 0; i < d_nchannels; i++) { - // Add the new Gnss_Synchros to their corresponding deque - for (int aux = 0; aux < ninput_items[i]; aux++) + if (ninput_items[i] > 0) { - if (in[i][aux].Flag_valid_word) + // Add the new Gnss_Synchros to their corresponding deque + for (int aux = 0; aux < ninput_items[i]; aux++) { - d_gnss_synchro_history->push_back(i, in[i][aux]); - d_gnss_synchro_history->back(i).RX_time = compute_T_rx_s(in[i][aux]); - // Check if the last Gnss_Synchro comes from the same satellite as the previous ones - if (d_gnss_synchro_history->size(i) > 1) + if (in[i][aux].Flag_valid_word) { - if (d_gnss_synchro_history->front(i).PRN != d_gnss_synchro_history->back(i).PRN) + d_gnss_synchro_history->push_back(i, in[i][aux]); + d_gnss_synchro_history->back(i).RX_time = compute_T_rx_s(in[i][aux]); + // Check if the last Gnss_Synchro comes from the same satellite as the previous ones + if (d_gnss_synchro_history->size(i) > 1) { - d_gnss_synchro_history->clear(i); + if (d_gnss_synchro_history->front(i).PRN != d_gnss_synchro_history->back(i).PRN) + { + d_gnss_synchro_history->clear(i); + } } } } + consume(i, ninput_items[i]); } - consume(i, ninput_items[i]); } } - } - for (i = 0; i < d_nchannels; i++) - { - if (d_gnss_synchro_history->size(i) > 2) + for (i = 0; i < d_nchannels; i++) { - valid_channels[i] = true; - } - else - { - valid_channels[i] = false; - } - } - d_num_valid_channels = valid_channels.count(); - // Check if there is any valid channel after reading the new incoming Gnss_Synchro data - if (d_num_valid_channels == 0) - { - return 0; - } - - for (i = 0; i < d_nchannels; i++) //Discard observables with T_rx higher than the threshold - { - if (valid_channels[i]) - { - clean_history(i); - if (d_gnss_synchro_history->size(i) < 2) + if (d_gnss_synchro_history->size(i) > 2) { - valid_channels[i] = false; - } - } - } - - // Check if there is any valid channel after computing the time distance between the Gnss_Synchro data and the receiver time - d_num_valid_channels = valid_channels.count(); - double T_rx_s_out = T_rx_s - d_latency; - if ((d_num_valid_channels == 0) or (T_rx_s_out < 0.0)) - { - return 0; - } - - std::vector epoch_data; - for (i = 0; i < d_nchannels; i++) - { - if (valid_channels[i]) - { - Gnss_Synchro interpolated_gnss_synchro = d_gnss_synchro_history->back(i); - if (interpolate_data(interpolated_gnss_synchro, i, T_rx_s_out)) - { - epoch_data.push_back(interpolated_gnss_synchro); + valid_channels[i] = true; } else { valid_channels[i] = false; } } - } - d_num_valid_channels = valid_channels.count(); - if (d_num_valid_channels == 0) - { - return 0; - } - correct_TOW_and_compute_prange(epoch_data); - std::vector::iterator it = epoch_data.begin(); - for (i = 0; i < d_nchannels; i++) - { - if (valid_channels[i]) + d_num_valid_channels = valid_channels.count(); + // Check if there is any valid channel after reading the new incoming Gnss_Synchro data + if (d_num_valid_channels == 0) { - out[i][0] = (*it); - out[i][0].Flag_valid_pseudorange = true; - it++; + consume(d_nchannels, epoch + 1); + return returned_elements; } - else + + for (i = 0; i < d_nchannels; i++) //Discard observables with T_rx higher than the threshold { - out[i][0] = Gnss_Synchro(); - out[i][0].Flag_valid_pseudorange = false; - } - } - if (d_dump) - { - // MULTIPLEXED FILE RECORDING - Record results to file - try - { - double tmp_double; - for (i = 0; i < d_nchannels; i++) + if (valid_channels[i]) { - tmp_double = out[i][0].RX_time; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = out[i][0].TOW_at_current_symbol_s; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = out[i][0].Carrier_Doppler_hz; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = out[i][0].Carrier_phase_rads / GPS_TWO_PI; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = out[i][0].Pseudorange_m; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = static_cast(out[i][0].PRN); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = static_cast(out[i][0].Flag_valid_pseudorange); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + clean_history(i); + if (d_gnss_synchro_history->size(i) < 2) + { + valid_channels[i] = false; + } } } - catch (const std::ifstream::failure &e) + + // Check if there is any valid channel after computing the time distance between the Gnss_Synchro data and the receiver time + d_num_valid_channels = valid_channels.count(); + double T_rx_s_out = T_rx_s - d_latency; + if ((d_num_valid_channels == 0) or (T_rx_s_out < 0.0)) { - LOG(WARNING) << "Exception writing observables dump file " << e.what(); - d_dump = false; + consume(d_nchannels, epoch + 1); + return returned_elements; } + + std::vector epoch_data; + for (i = 0; i < d_nchannels; i++) + { + if (valid_channels[i]) + { + Gnss_Synchro interpolated_gnss_synchro = d_gnss_synchro_history->back(i); + if (interpolate_data(interpolated_gnss_synchro, i, T_rx_s_out)) + { + epoch_data.push_back(interpolated_gnss_synchro); + } + else + { + valid_channels[i] = false; + } + } + } + d_num_valid_channels = valid_channels.count(); + if (d_num_valid_channels == 0) + { + consume(d_nchannels, epoch + 1); + return returned_elements; + } + correct_TOW_and_compute_prange(epoch_data); + std::vector::iterator it = epoch_data.begin(); + for (i = 0; i < d_nchannels; i++) + { + if (valid_channels[i]) + { + out[i][0] = (*it); + out[i][0].Flag_valid_pseudorange = true; + it++; + } + else + { + out[i][0] = Gnss_Synchro(); + out[i][0].Flag_valid_pseudorange = false; + } + } + if (d_dump) + { + // MULTIPLEXED FILE RECORDING - Record results to file + try + { + double tmp_double; + for (i = 0; i < d_nchannels; i++) + { + tmp_double = out[i][0].RX_time; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_double = out[i][0].TOW_at_current_symbol_s; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_double = out[i][0].Carrier_Doppler_hz; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_double = out[i][0].Carrier_phase_rads / GPS_TWO_PI; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_double = out[i][0].Pseudorange_m; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_double = static_cast(out[i][0].PRN); + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_double = static_cast(out[i][0].Flag_valid_pseudorange); + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + } + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "Exception writing observables dump file " << e.what(); + d_dump = false; + } + } + returned_elements++; } - return 1; + consume(d_nchannels, ninput_items[d_nchannels]); + return returned_elements; } From 525d8877319f5bfba84da757ff861a59aae8850c Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Thu, 12 Apr 2018 18:51:43 +0200 Subject: [PATCH 19/44] Fix bug --- .../gnuradio_blocks/hybrid_observables_cc.cc | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index 593e01b6b..0fdd85c31 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -571,14 +571,14 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) { if (valid_channels[i]) { - out[i][0] = (*it); - out[i][0].Flag_valid_pseudorange = true; + out[i][epoch] = (*it); + out[i][epoch].Flag_valid_pseudorange = true; it++; } else { - out[i][0] = Gnss_Synchro(); - out[i][0].Flag_valid_pseudorange = false; + out[i][epoch] = Gnss_Synchro(); + out[i][epoch].Flag_valid_pseudorange = false; } } if (d_dump) @@ -589,19 +589,19 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) double tmp_double; for (i = 0; i < d_nchannels; i++) { - tmp_double = out[i][0].RX_time; + tmp_double = out[i][epoch].RX_time; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = out[i][0].TOW_at_current_symbol_s; + tmp_double = out[i][epoch].TOW_at_current_symbol_s; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = out[i][0].Carrier_Doppler_hz; + tmp_double = out[i][epoch].Carrier_Doppler_hz; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = out[i][0].Carrier_phase_rads / GPS_TWO_PI; + tmp_double = out[i][epoch].Carrier_phase_rads / GPS_TWO_PI; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = out[i][0].Pseudorange_m; + tmp_double = out[i][epoch].Pseudorange_m; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = static_cast(out[i][0].PRN); + tmp_double = static_cast(out[i][epoch].PRN); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = static_cast(out[i][0].Flag_valid_pseudorange); + tmp_double = static_cast(out[i][epoch].Flag_valid_pseudorange); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); } } From 6dfacb1676a1dd66e060a55b6285782907dfbd5d Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 12 Apr 2018 20:44:15 +0200 Subject: [PATCH 20/44] Fix building for clang-900.0.39.2 (OSX 10.12), tnx to michaelld --- .../volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt index d4ea0c46f..f9634c801 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -62,6 +62,7 @@ endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # Enable C++17 support in GCC >= 8.0.0 # Enable C++14 support in 8.0.0 > GCC >= 6.1.1 # Fallback to C++11 when using GCC < 6.1.1 + if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1") set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11") @@ -75,8 +76,8 @@ if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -Wall -Wextra") #Add warning flags: For "-Wall" see http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html endif(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) -# Enable C++17 support in Clang >= 6.0.0 or AppleClang >= 900 -# Enable C++14 support in 6.0.0 > Clang >= 3.5.0 or 900 > AppleClang >= 600 +# Enable C++17 support in Clang >= 6.0.0 +# Enable C++14 support in 6.0.0 > Clang >= 3.5.0 or AppleClang >= 600 # Fallback to C++11 if older version if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") if(CMAKE_SYSTEM_NAME MATCHES "Darwin") @@ -84,11 +85,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") if(CLANG_VERSION VERSION_LESS "600") set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11") else(CLANG_VERSION VERSION_LESS "600") - if(CLANG_VERSION VERSION_LESS "900") - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14") - else(CLANG_VERSION VERSION_LESS "900") - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++17") - endif(CLANG_VERSION VERSION_LESS "900") + set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14") endif(CLANG_VERSION VERSION_LESS "600") else(CMAKE_SYSTEM_NAME MATCHES "Darwin") if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0") From 1094e870bc7c6dadb136a115c5a8c89311e6f5ae Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 12 Apr 2018 20:45:13 +0200 Subject: [PATCH 21/44] Accessing maps is not so cheap, so doing in the constructor --- .../gnuradio_blocks/dll_pll_veml_tracking.cc | 20 ++++++++++--------- .../gnuradio_blocks/dll_pll_veml_tracking.h | 3 ++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc index d10af3177..087e48199 100755 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc @@ -362,13 +362,15 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl d_last_prompt = gr_complex(0.0, 0.0); d_state = 0; // initial state: standby - signal_pretty_name["1C"] = "L1 C/A"; - signal_pretty_name["1B"] = "E1"; - signal_pretty_name["1G"] = "L1 C/A"; - signal_pretty_name["2S"] = "L2C"; - signal_pretty_name["2G"] = "L2 C/A"; - signal_pretty_name["5X"] = "E5a"; - signal_pretty_name["L5"] = "L5"; + map_signal_pretty_name["1C"] = "L1 C/A"; + map_signal_pretty_name["1B"] = "E1"; + map_signal_pretty_name["1G"] = "L1 C/A"; + map_signal_pretty_name["2S"] = "L2C"; + map_signal_pretty_name["2G"] = "L2 C/A"; + map_signal_pretty_name["5X"] = "E5a"; + map_signal_pretty_name["L5"] = "L5"; + + signal_pretty_name = map_signal_pretty_name[signal_type]; } @@ -511,7 +513,7 @@ void dll_pll_veml_tracking::start_tracking() d_code_loop_filter.set_pdi(static_cast(d_code_period)); // DEBUG OUTPUT - std::cout << "Tracking of " << systemName << " " << signal_pretty_name[signal_type] << " signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; + std::cout << "Tracking of " << systemName << " " << signal_pretty_name << " signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; // enable tracking pull-in @@ -1263,7 +1265,7 @@ int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused) next_state = acquire_secondary(); if (next_state) { - std::cout << systemName << " " << signal_pretty_name[signal_type] << " secondary code locked in channel " << d_channel + std::cout << systemName << " " << signal_pretty_name << " secondary code locked in channel " << d_channel << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; } diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h index 89f71a99a..0b8392d2d 100755 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h @@ -119,7 +119,8 @@ private: std::string systemName; std::string signal_type; std::string *d_secondary_code_string; - std::map signal_pretty_name; + std::map map_signal_pretty_name; + std::string signal_pretty_name; //tracking state machine int d_state; From 31e634635ce96a0ba863e91943069d8a79f01823 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 13 Apr 2018 11:07:58 +0200 Subject: [PATCH 22/44] Move general_work to the bottom of the file --- .../gnuradio_blocks/pcps_acquisition.cc | 156 ++++++++-------- .../galileo_e1b_telemetry_decoder_cc.cc | 70 ++++---- .../galileo_e5a_telemetry_decoder_cc.cc | 70 ++++---- .../glonass_l1_ca_telemetry_decoder_cc.cc | 70 ++++---- .../glonass_l2_ca_telemetry_decoder_cc.cc | 70 ++++---- .../gps_l1_ca_telemetry_decoder_cc.cc | 76 ++++---- .../gps_l2c_telemetry_decoder_cc.cc | 70 ++++---- .../gps_l5_telemetry_decoder_cc.cc | 74 ++++---- .../sbas_l1_telemetry_decoder_cc.cc | 168 +++++++++--------- 9 files changed, 411 insertions(+), 413 deletions(-) diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc index 0eb0cd3dd..62e55dd31 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc @@ -335,84 +335,6 @@ void pcps_acquisition::send_negative_acquisition() } -int pcps_acquisition::general_work(int noutput_items __attribute__((unused)), - gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items __attribute__((unused))) -{ - /* - * By J.Arribas, L.Esteve and M.Molina - * Acquisition strategy (Kay Borre book + CFAR threshold): - * 1. Compute the input signal power estimation - * 2. Doppler serial search loop - * 3. Perform the FFT-based circular convolution (parallel time search) - * 4. Record the maximum peak and the associated synchronization parameters - * 5. Compute the test statistics and compare to the threshold - * 6. Declare positive or negative acquisition using a message port - */ - - gr::thread::scoped_lock lk(d_setlock); - if (!d_active or d_worker_active) - { - d_sample_counter += d_fft_size * ninput_items[0]; - consume_each(ninput_items[0]); - if (d_step_two) - { - d_doppler_center_step_two = static_cast(d_gnss_synchro->Acq_doppler_hz); - update_grid_doppler_wipeoffs_step2(); - d_state = 0; - d_active = true; - } - return 0; - } - - switch (d_state) - { - case 0: - { - //restart acquisition variables - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; - d_well_count = 0; - d_mag = 0.0; - d_input_power = 0.0; - d_test_statistics = 0.0; - d_state = 1; - d_sample_counter += d_fft_size * ninput_items[0]; // sample counter - consume_each(ninput_items[0]); - break; - } - - case 1: - { - // Copy the data to the core and let it know that new data is available - if (d_cshort) - { - memcpy(d_data_buffer_sc, input_items[0], d_fft_size * sizeof(lv_16sc_t)); - } - else - { - memcpy(d_data_buffer, input_items[0], d_fft_size * sizeof(gr_complex)); - } - if (acq_parameters.blocking) - { - lk.unlock(); - acquisition_core(d_sample_counter); - } - else - { - gr::thread::thread d_worker(&pcps_acquisition::acquisition_core, this, d_sample_counter); - d_worker_active = true; - } - d_sample_counter += d_fft_size; - consume_each(1); - break; - } - } - return 0; -} - - void pcps_acquisition::acquisition_core(unsigned long int samp_count) { gr::thread::scoped_lock lk(d_setlock); @@ -686,3 +608,81 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count) } d_worker_active = false; } + + +int pcps_acquisition::general_work(int noutput_items __attribute__((unused)), + gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, + gr_vector_void_star& output_items __attribute__((unused))) +{ + /* + * By J.Arribas, L.Esteve and M.Molina + * Acquisition strategy (Kay Borre book + CFAR threshold): + * 1. Compute the input signal power estimation + * 2. Doppler serial search loop + * 3. Perform the FFT-based circular convolution (parallel time search) + * 4. Record the maximum peak and the associated synchronization parameters + * 5. Compute the test statistics and compare to the threshold + * 6. Declare positive or negative acquisition using a message port + */ + + gr::thread::scoped_lock lk(d_setlock); + if (!d_active or d_worker_active) + { + d_sample_counter += d_fft_size * ninput_items[0]; + consume_each(ninput_items[0]); + if (d_step_two) + { + d_doppler_center_step_two = static_cast(d_gnss_synchro->Acq_doppler_hz); + update_grid_doppler_wipeoffs_step2(); + d_state = 0; + d_active = true; + } + return 0; + } + + switch (d_state) + { + case 0: + { + //restart acquisition variables + d_gnss_synchro->Acq_delay_samples = 0.0; + d_gnss_synchro->Acq_doppler_hz = 0.0; + d_gnss_synchro->Acq_samplestamp_samples = 0; + d_well_count = 0; + d_mag = 0.0; + d_input_power = 0.0; + d_test_statistics = 0.0; + d_state = 1; + d_sample_counter += d_fft_size * ninput_items[0]; // sample counter + consume_each(ninput_items[0]); + break; + } + + case 1: + { + // Copy the data to the core and let it know that new data is available + if (d_cshort) + { + memcpy(d_data_buffer_sc, input_items[0], d_fft_size * sizeof(lv_16sc_t)); + } + else + { + memcpy(d_data_buffer, input_items[0], d_fft_size * sizeof(gr_complex)); + } + if (acq_parameters.blocking) + { + lk.unlock(); + acquisition_core(d_sample_counter); + } + else + { + gr::thread::thread d_worker(&pcps_acquisition::acquisition_core, this, d_sample_counter); + d_worker_active = true; + } + d_sample_counter += d_fft_size; + consume_each(1); + break; + } + } + return 0; +} diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc index 286ca0c68..6f2242454 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc @@ -272,6 +272,41 @@ void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols, in } +void galileo_e1b_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) +{ + d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); + DLOG(INFO) << "Setting decoder Finite State Machine to satellite " << d_satellite; + DLOG(INFO) << "Navigation Satellite set to " << d_satellite; +} + + +void galileo_e1b_telemetry_decoder_cc::set_channel(int channel) +{ + d_channel = channel; + LOG(INFO) << "Navigation channel set to " << channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename = "telemetry"; + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); + } + } + } +} + + int galileo_e1b_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -467,38 +502,3 @@ int galileo_e1b_telemetry_decoder_cc::general_work(int noutput_items __attribute //std::cout<<"GPS L1 TLM output on CH="<d_channel << " SAMPLE STAMP="<(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); - } - } - } -} diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc index 8e032956e..c828fb859 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc @@ -245,6 +245,41 @@ galileo_e5a_telemetry_decoder_cc::~galileo_e5a_telemetry_decoder_cc() } +void galileo_e5a_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) +{ + d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); + DLOG(INFO) << "Setting decoder Finite State Machine to satellite " << d_satellite; + DLOG(INFO) << "Navigation Satellite set to " << d_satellite; +} + + +void galileo_e5a_telemetry_decoder_cc::set_channel(int channel) +{ + d_channel = channel; + LOG(INFO) << "Navigation channel set to " << channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename = "telemetry"; + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); + } + } + } +} + + int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -491,38 +526,3 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute return 0; } } - - -void galileo_e5a_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) -{ - d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - DLOG(INFO) << "Setting decoder Finite State Machine to satellite " << d_satellite; - DLOG(INFO) << "Navigation Satellite set to " << d_satellite; -} - - -void galileo_e5a_telemetry_decoder_cc::set_channel(int channel) -{ - d_channel = channel; - LOG(INFO) << "Navigation channel set to " << channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename = "telemetry"; - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); - } - } - } -} diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc index ca6dc8681..09429a7e1 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc @@ -221,6 +221,41 @@ void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in } +void glonass_l1_ca_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) +{ + d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); + DLOG(INFO) << "Setting decoder Finite State Machine to satellite " << d_satellite; + DLOG(INFO) << "Navigation Satellite set to " << d_satellite; +} + + +void glonass_l1_ca_telemetry_decoder_cc::set_channel(int channel) +{ + d_channel = channel; + LOG(INFO) << "Navigation channel set to " << channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename = "telemetry"; + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "channel " << d_channel << ": exception opening Glonass TLM dump file. " << e.what(); + } + } + } +} + + int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -408,38 +443,3 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu return 1; } - - -void glonass_l1_ca_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) -{ - d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - DLOG(INFO) << "Setting decoder Finite State Machine to satellite " << d_satellite; - DLOG(INFO) << "Navigation Satellite set to " << d_satellite; -} - - -void glonass_l1_ca_telemetry_decoder_cc::set_channel(int channel) -{ - d_channel = channel; - LOG(INFO) << "Navigation channel set to " << channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename = "telemetry"; - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "channel " << d_channel << ": exception opening Glonass TLM dump file. " << e.what(); - } - } - } -} diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc index e2a362974..b446b6e7e 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc @@ -220,6 +220,41 @@ void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in } +void glonass_l2_ca_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) +{ + d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); + DLOG(INFO) << "Setting decoder Finite State Machine to satellite " << d_satellite; + DLOG(INFO) << "Navigation Satellite set to " << d_satellite; +} + + +void glonass_l2_ca_telemetry_decoder_cc::set_channel(int channel) +{ + d_channel = channel; + LOG(INFO) << "Navigation channel set to " << channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename = "telemetry"; + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "channel " << d_channel << ": exception opening Glonass TLM dump file. " << e.what(); + } + } + } +} + + int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -407,38 +442,3 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu return 1; } - - -void glonass_l2_ca_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) -{ - d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - DLOG(INFO) << "Setting decoder Finite State Machine to satellite " << d_satellite; - DLOG(INFO) << "Navigation Satellite set to " << d_satellite; -} - - -void glonass_l2_ca_telemetry_decoder_cc::set_channel(int channel) -{ - d_channel = channel; - LOG(INFO) << "Navigation channel set to " << channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename = "telemetry"; - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "channel " << d_channel << ": exception opening Glonass TLM dump file. " << e.what(); - } - } - } -} diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc index 955d180d7..1070dca28 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc @@ -152,6 +152,44 @@ bool gps_l1_ca_telemetry_decoder_cc::gps_word_parityCheck(unsigned int gpsword) } +void gps_l1_ca_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) +{ + d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); + DLOG(INFO) << "Setting decoder Finite State Machine to satellite " << d_satellite; + d_GPS_FSM.i_satellite_PRN = d_satellite.get_PRN(); + DLOG(INFO) << "Navigation Satellite set to " << d_satellite; +} + + +void gps_l1_ca_telemetry_decoder_cc::set_channel(int channel) +{ + d_channel = channel; + d_GPS_FSM.i_channel_ID = channel; + DLOG(INFO) << "Navigation channel set to " << channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename = "telemetry"; + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel + << " Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); + } + } + } +} + + int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -411,41 +449,3 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ return 1; } - - -void gps_l1_ca_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) -{ - d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - DLOG(INFO) << "Setting decoder Finite State Machine to satellite " << d_satellite; - d_GPS_FSM.i_satellite_PRN = d_satellite.get_PRN(); - DLOG(INFO) << "Navigation Satellite set to " << d_satellite; -} - - -void gps_l1_ca_telemetry_decoder_cc::set_channel(int channel) -{ - d_channel = channel; - d_GPS_FSM.i_channel_ID = channel; - DLOG(INFO) << "Navigation channel set to " << channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename = "telemetry"; - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel - << " Log file: " << d_dump_filename.c_str(); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); - } - } - } -} diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc index dee30987e..f06d19b6f 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc @@ -90,6 +90,41 @@ gps_l2c_telemetry_decoder_cc::~gps_l2c_telemetry_decoder_cc() } +void gps_l2c_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) +{ + d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); + DLOG(INFO) << "GPS L2C CNAV telemetry decoder in channel " << this->d_channel << " set to satellite " << d_satellite; +} + + +void gps_l2c_telemetry_decoder_cc::set_channel(int channel) +{ + d_channel = channel; + LOG(INFO) << "GPS L2C CNAV channel set to " << channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename = "telemetry_L2CM_"; + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel + << " Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening Telemetry GPS L2 dump file " << e.what(); + } + } + } +} + + int gps_l2c_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -193,38 +228,3 @@ int gps_l2c_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( out[0] = current_synchro_data; return 1; } - - -void gps_l2c_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) -{ - d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - DLOG(INFO) << "GPS L2C CNAV telemetry decoder in channel " << this->d_channel << " set to satellite " << d_satellite; -} - - -void gps_l2c_telemetry_decoder_cc::set_channel(int channel) -{ - d_channel = channel; - LOG(INFO) << "GPS L2C CNAV channel set to " << channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename = "telemetry_L2CM_"; - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel - << " Log file: " << d_dump_filename.c_str(); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "channel " << d_channel << " Exception opening Telemetry GPS L2 dump file " << e.what(); - } - } - } -} diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc index 1cfd20162..0793428fa 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc @@ -100,6 +100,43 @@ gps_l5_telemetry_decoder_cc::~gps_l5_telemetry_decoder_cc() } +void gps_l5_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) +{ + d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); + LOG(INFO) << "GPS L5 CNAV telemetry decoder in channel " << this->d_channel << " set to satellite " << d_satellite; + d_CNAV_Message.reset(); +} + + +void gps_l5_telemetry_decoder_cc::set_channel(int channel) +{ + d_channel = channel; + d_CNAV_Message.reset(); + LOG(INFO) << "GPS L5 CNAV channel set to " << channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename = "telemetry_L5_"; + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel + << " Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening Telemetry GPS L5 dump file " << e.what(); + } + } + } +} + + int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -243,40 +280,3 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u out[0] = current_synchro_data; return 1; } - - -void gps_l5_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) -{ - d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - LOG(INFO) << "GPS L5 CNAV telemetry decoder in channel " << this->d_channel << " set to satellite " << d_satellite; - d_CNAV_Message.reset(); -} - - -void gps_l5_telemetry_decoder_cc::set_channel(int channel) -{ - d_channel = channel; - d_CNAV_Message.reset(); - LOG(INFO) << "GPS L5 CNAV channel set to " << channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename = "telemetry_L5_"; - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel - << " Log file: " << d_dump_filename.c_str(); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "channel " << d_channel << " Exception opening Telemetry GPS L5 dump file " << e.what(); - } - } - } -} diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc index 194db3c11..830a02636 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc @@ -87,88 +87,6 @@ sbas_l1_telemetry_decoder_cc::~sbas_l1_telemetry_decoder_cc() } -int sbas_l1_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), - gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) -{ - VLOG(FLOW) << "general_work(): " - << "noutput_items=" << noutput_items << "\toutput_items real size=" << output_items.size() << "\tninput_items size=" << ninput_items.size() << "\tinput_items real size=" << input_items.size() << "\tninput_items[0]=" << ninput_items[0]; - // get pointers on in- and output gnss-synchro objects - Gnss_Synchro *out = reinterpret_cast(output_items[0]); // Get the output buffer pointer - const Gnss_Synchro *in = reinterpret_cast(input_items[0]); // Get the input buffer pointer - - Gnss_Synchro current_symbol; //structure to save the synchronization information and send the output object to the next block - //1. Copy the current tracking output - current_symbol = in[0]; - // copy correlation samples into samples vector - d_sample_buf.push_back(current_symbol.Prompt_I); //add new symbol to the symbol queue - - // store the time stamp of the first sample in the processed sample block - double sample_stamp = static_cast(in[0].Tracking_sample_counter) / static_cast(in[0].fs); - - // decode only if enough samples in buffer - if (d_sample_buf.size() >= d_block_size) - { - // align correlation samples in pairs - // and obtain the symbols by summing the paired correlation samples - std::vector symbols; - bool sample_alignment = d_sample_aligner.get_symbols(d_sample_buf, symbols); - - // align symbols in pairs - // and obtain the bits by decoding the symbol pairs - std::vector bits; - bool symbol_alignment = d_symbol_aligner_and_decoder.get_bits(symbols, bits); - - // search for preambles - // and extract the corresponding message candidates - std::vector msg_candidates; - d_frame_detector.get_frame_candidates(bits, msg_candidates); - - // verify checksum - // and return the valid messages - std::vector valid_msgs; - d_crc_verifier.get_valid_frames(msg_candidates, valid_msgs); - - // compute message sample stamp - // and fill messages in SBAS raw message objects - //std::vector sbas_raw_msgs; - for (std::vector::const_iterator it = valid_msgs.cbegin(); - it != valid_msgs.cend(); ++it) - { - int message_sample_offset = - (sample_alignment ? 0 : -1) + d_samples_per_symbol * (symbol_alignment ? -1 : 0) + d_samples_per_symbol * d_symbols_per_bit * it->first; - double message_sample_stamp = sample_stamp + static_cast(message_sample_offset) / 1000.0; - VLOG(EVENT) << "message_sample_stamp=" << message_sample_stamp - << " (sample_stamp=" << sample_stamp - << " sample_alignment=" << sample_alignment - << " symbol_alignment=" << symbol_alignment - << " relative_preamble_start=" << it->first - << " message_sample_offset=" << message_sample_offset - << ")"; - //Sbas_Raw_Msg sbas_raw_msg(message_sample_stamp, this->d_satellite.get_PRN(), it->second); - //sbas_raw_msgs.push_back(sbas_raw_msg); - } - - // parse messages - // and send them to the SBAS raw message queue - //for(std::vector::iterator it = sbas_raw_msgs.begin(); it != sbas_raw_msgs.end(); it++) - // { - //std::cout << "SBAS message type " << it->get_msg_type() << " from PRN" << it->get_prn() << " received" << std::endl; - //sbas_telemetry_data.update(*it); - // } - - // clear all processed samples in the input buffer - d_sample_buf.clear(); - } - - // UPDATE GNSS SYNCHRO DATA - // actually the SBAS telemetry decoder doesn't support ranging - current_symbol.Flag_valid_word = false; // indicate to observable block that this synchro object isn't valid for pseudorange computation - out[0] = current_symbol; - consume_each(1); // tell scheduler input items consumed - return 1; // tell scheduler output items produced -} - - void sbas_l1_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) { d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); @@ -184,7 +102,6 @@ void sbas_l1_telemetry_decoder_cc::set_channel(int channel) // ### helper class for sample alignment ### - sbas_l1_telemetry_decoder_cc::sample_aligner::sample_aligner() { d_n_smpls_in_history = 3; @@ -403,12 +320,11 @@ void sbas_l1_telemetry_decoder_cc::frame_detector::get_frame_candidates(const st // ### helper class for checking the CRC of the message candidates ### - - void sbas_l1_telemetry_decoder_cc::crc_verifier::reset() { } + void sbas_l1_telemetry_decoder_cc::crc_verifier::get_valid_frames(const std::vector msg_candidates, std::vector &valid_msgs) { std::stringstream ss; @@ -500,3 +416,85 @@ void sbas_l1_telemetry_decoder_cc::crc_verifier::zerropad_front_and_convert_to_b << std::setfill('0') << std::hex << static_cast(byte) << std::setfill(' ') << std::resetiosflags(std::ios::hex); } + + +int sbas_l1_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), + gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) +{ + VLOG(FLOW) << "general_work(): " + << "noutput_items=" << noutput_items << "\toutput_items real size=" << output_items.size() << "\tninput_items size=" << ninput_items.size() << "\tinput_items real size=" << input_items.size() << "\tninput_items[0]=" << ninput_items[0]; + // get pointers on in- and output gnss-synchro objects + Gnss_Synchro *out = reinterpret_cast(output_items[0]); // Get the output buffer pointer + const Gnss_Synchro *in = reinterpret_cast(input_items[0]); // Get the input buffer pointer + + Gnss_Synchro current_symbol; //structure to save the synchronization information and send the output object to the next block + //1. Copy the current tracking output + current_symbol = in[0]; + // copy correlation samples into samples vector + d_sample_buf.push_back(current_symbol.Prompt_I); //add new symbol to the symbol queue + + // store the time stamp of the first sample in the processed sample block + double sample_stamp = static_cast(in[0].Tracking_sample_counter) / static_cast(in[0].fs); + + // decode only if enough samples in buffer + if (d_sample_buf.size() >= d_block_size) + { + // align correlation samples in pairs + // and obtain the symbols by summing the paired correlation samples + std::vector symbols; + bool sample_alignment = d_sample_aligner.get_symbols(d_sample_buf, symbols); + + // align symbols in pairs + // and obtain the bits by decoding the symbol pairs + std::vector bits; + bool symbol_alignment = d_symbol_aligner_and_decoder.get_bits(symbols, bits); + + // search for preambles + // and extract the corresponding message candidates + std::vector msg_candidates; + d_frame_detector.get_frame_candidates(bits, msg_candidates); + + // verify checksum + // and return the valid messages + std::vector valid_msgs; + d_crc_verifier.get_valid_frames(msg_candidates, valid_msgs); + + // compute message sample stamp + // and fill messages in SBAS raw message objects + //std::vector sbas_raw_msgs; + for (std::vector::const_iterator it = valid_msgs.cbegin(); + it != valid_msgs.cend(); ++it) + { + int message_sample_offset = + (sample_alignment ? 0 : -1) + d_samples_per_symbol * (symbol_alignment ? -1 : 0) + d_samples_per_symbol * d_symbols_per_bit * it->first; + double message_sample_stamp = sample_stamp + static_cast(message_sample_offset) / 1000.0; + VLOG(EVENT) << "message_sample_stamp=" << message_sample_stamp + << " (sample_stamp=" << sample_stamp + << " sample_alignment=" << sample_alignment + << " symbol_alignment=" << symbol_alignment + << " relative_preamble_start=" << it->first + << " message_sample_offset=" << message_sample_offset + << ")"; + //Sbas_Raw_Msg sbas_raw_msg(message_sample_stamp, this->d_satellite.get_PRN(), it->second); + //sbas_raw_msgs.push_back(sbas_raw_msg); + } + + // parse messages + // and send them to the SBAS raw message queue + //for(std::vector::iterator it = sbas_raw_msgs.begin(); it != sbas_raw_msgs.end(); it++) + // { + //std::cout << "SBAS message type " << it->get_msg_type() << " from PRN" << it->get_prn() << " received" << std::endl; + //sbas_telemetry_data.update(*it); + // } + + // clear all processed samples in the input buffer + d_sample_buf.clear(); + } + + // UPDATE GNSS SYNCHRO DATA + // actually the SBAS telemetry decoder doesn't support ranging + current_symbol.Flag_valid_word = false; // indicate to observable block that this synchro object isn't valid for pseudorange computation + out[0] = current_symbol; + consume_each(1); // tell scheduler input items consumed + return 1; // tell scheduler output items produced +} From c01d8d0dd90d6a8121691d849c7dc2514fa4ade7 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 13 Apr 2018 11:39:05 +0200 Subject: [PATCH 23/44] Move general_work to the bottom of the file --- .../rtl_tcp_signal_source_c.cc | 70 +++++++++---------- .../unpack_spir_gss6450_samples.cc | 29 ++++---- 2 files changed, 50 insertions(+), 49 deletions(-) diff --git a/src/algorithms/signal_source/gnuradio_blocks/rtl_tcp_signal_source_c.cc b/src/algorithms/signal_source/gnuradio_blocks/rtl_tcp_signal_source_c.cc index e874e8a14..4ec4420ce 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/rtl_tcp_signal_source_c.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/rtl_tcp_signal_source_c.cc @@ -158,41 +158,6 @@ rtl_tcp_signal_source_c::~rtl_tcp_signal_source_c() } -int rtl_tcp_signal_source_c::work(int noutput_items, - gr_vector_const_void_star & /*input_items*/, - gr_vector_void_star &output_items) -{ - gr_complex *out = reinterpret_cast(output_items[0]); - int i = 0; - if (io_service_.stopped()) - { - return -1; - } - - { - boost::mutex::scoped_lock lock(mutex_); - not_empty_.wait(lock, boost::bind(&rtl_tcp_signal_source_c::not_empty, - this)); - - for (; i < noutput_items && unread_ > 1; i++) - { - float re = buffer_[--unread_]; - float im = buffer_[--unread_]; - if (flip_iq_) - { - out[i] = gr_complex(im, re); - } - else - { - out[i] = gr_complex(re, im); - } - } - } - not_full_.notify_one(); - return i == 0 ? -1 : i; -} - - void rtl_tcp_signal_source_c::set_frequency(int frequency) { boost::system::error_code ec = @@ -359,3 +324,38 @@ void rtl_tcp_signal_source_c::handle_read(const boost::system::error_code &ec, this, _1, _2)); } } + + +int rtl_tcp_signal_source_c::work(int noutput_items, + gr_vector_const_void_star & /*input_items*/, + gr_vector_void_star &output_items) +{ + gr_complex *out = reinterpret_cast(output_items[0]); + int i = 0; + if (io_service_.stopped()) + { + return -1; + } + + { + boost::mutex::scoped_lock lock(mutex_); + not_empty_.wait(lock, boost::bind(&rtl_tcp_signal_source_c::not_empty, + this)); + + for (; i < noutput_items && unread_ > 1; i++) + { + float re = buffer_[--unread_]; + float im = buffer_[--unread_]; + if (flip_iq_) + { + out[i] = gr_complex(im, re); + } + else + { + out[i] = gr_complex(re, im); + } + } + } + not_full_.notify_one(); + return i == 0 ? -1 : i; +} diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.cc b/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.cc index a5bca6ee7..bd725b219 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.cc @@ -57,6 +57,21 @@ unpack_spir_gss6450_samples::~unpack_spir_gss6450_samples() } +int unpack_spir_gss6450_samples::compute_two_complement(unsigned long data) +{ + int res = 0; + if (static_cast(data) < two_compl_thres) + { + res = static_cast(data); + } + else + { + res = static_cast(data) - adc_bits_two_pow; + } + return res; +} + + int unpack_spir_gss6450_samples::work(int noutput_items, gr_vector_const_void_star& input_items, gr_vector_void_star& output_items) { @@ -86,17 +101,3 @@ int unpack_spir_gss6450_samples::work(int noutput_items, } return noutput_items; } - -int unpack_spir_gss6450_samples::compute_two_complement(unsigned long data) -{ - int res = 0; - if (static_cast(data) < two_compl_thres) - { - res = static_cast(data); - } - else - { - res = static_cast(data) - adc_bits_two_pow; - } - return res; -} From 44c6d8622ce1c57a8c6274e547464a53dad6c31a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 13 Apr 2018 12:11:41 +0200 Subject: [PATCH 24/44] Make the test to correctly fail if no kml file is generated --- src/tests/system-tests/position_test.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/tests/system-tests/position_test.cc b/src/tests/system-tests/position_test.cc index 350055d2f..bf0925dda 100644 --- a/src/tests/system-tests/position_test.cc +++ b/src/tests/system-tests/position_test.cc @@ -277,8 +277,8 @@ int StaticPositionSystemTest::configure_receiver() const float dll_bw_narrow_hz = 2.0; const int extend_correlation_ms = 1; - const int display_rate_ms = 1000; - const int output_rate_ms = 1000; + const int display_rate_ms = 500; + const int output_rate_ms = 500; config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(sampling_rate_internal)); @@ -358,10 +358,10 @@ int StaticPositionSystemTest::configure_receiver() config->set_property("Tracking_1C.pll_bw_hz", std::to_string(pll_bw_hz)); config->set_property("Tracking_1C.dll_bw_hz", std::to_string(dll_bw_hz)); config->set_property("Tracking_1C.early_late_space_chips", std::to_string(early_late_space_chips)); - + config->set_property("Tracking_1Cearly_late_space_narrow_chips", std::to_string(early_late_space_chips / 5.0)); config->set_property("Tracking_1C.pll_bw_narrow_hz", std::to_string(pll_bw_narrow_hz)); config->set_property("Tracking_1C.dll_bw_narrow_hz", std::to_string(dll_bw_narrow_hz)); - config->set_property("Tracking_1C.extend_correlation_ms", std::to_string(extend_correlation_ms)); + config->set_property("Tracking_1C.extend_correlation_symbols", std::to_string(extend_correlation_ms)); // Set Telemetry config->set_property("TelemetryDecoder_1C.implementation", "GPS_L1_CA_Telemetry_Decoder"); @@ -454,6 +454,7 @@ int StaticPositionSystemTest::run_receiver() void StaticPositionSystemTest::check_results() { std::fstream myfile(StaticPositionSystemTest::generated_kml_file, std::ios_base::in); + ASSERT_TRUE(myfile.is_open()) << "No valid kml file could be opened"; std::string line; std::vector pos_e; @@ -466,6 +467,7 @@ void StaticPositionSystemTest::check_results() while (is_header) { std::getline(myfile, line); + ASSERT_FALSE(myfile.eof()) << "No valid kml file found."; std::size_t found = line.find(""); if (found != std::string::npos) is_header = false; } @@ -474,7 +476,11 @@ void StaticPositionSystemTest::check_results() //read data while (is_data) { - std::getline(myfile, line); + if (!std::getline(myfile, line)) + { + is_data = false; + break; + } std::size_t found = line.find(""); if (found != std::string::npos) is_data = false; @@ -504,6 +510,7 @@ void StaticPositionSystemTest::check_results() } } myfile.close(); + ASSERT_FALSE(pos_e.size() == 0) << "KML file is empty"; double sigma_E_2_precision = std::pow(compute_stdev_precision(pos_e), 2.0); double sigma_N_2_precision = std::pow(compute_stdev_precision(pos_n), 2.0); From 26467a0f29dfc10448166616b600f707c226182a Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Fri, 13 Apr 2018 12:30:06 +0200 Subject: [PATCH 25/44] Increase fixed latency in order to avoid loss of observables --- .../observables/gnuradio_blocks/hybrid_observables_cc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index 0fdd85c31..06f0efdcd 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -64,7 +64,7 @@ hybrid_observables_cc::hybrid_observables_cc(unsigned int nchannels_in, T_rx_s = 0.0; T_rx_step_s = 0.001; // 1 ms max_delta = 1.5; // 1.5 s - d_latency = 0.175; // 175 ms + d_latency = 0.3; // 300 ms valid_channels.resize(d_nchannels, false); d_num_valid_channels = 0; d_gnss_synchro_history = new Gnss_circular_deque(static_cast(max_delta * 1000.0), d_nchannels); From fec1e374075df1851bd8b0a28de227015c859c4f Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 14 Apr 2018 11:19:52 +0200 Subject: [PATCH 26/44] Fix Typo --- src/tests/system-tests/position_test.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tests/system-tests/position_test.cc b/src/tests/system-tests/position_test.cc index bf0925dda..4018552bc 100644 --- a/src/tests/system-tests/position_test.cc +++ b/src/tests/system-tests/position_test.cc @@ -358,7 +358,7 @@ int StaticPositionSystemTest::configure_receiver() config->set_property("Tracking_1C.pll_bw_hz", std::to_string(pll_bw_hz)); config->set_property("Tracking_1C.dll_bw_hz", std::to_string(dll_bw_hz)); config->set_property("Tracking_1C.early_late_space_chips", std::to_string(early_late_space_chips)); - config->set_property("Tracking_1Cearly_late_space_narrow_chips", std::to_string(early_late_space_chips / 5.0)); + config->set_property("Tracking_1C.pll_bw_narrow_hz", std::to_string(pll_bw_narrow_hz)); config->set_property("Tracking_1C.dll_bw_narrow_hz", std::to_string(dll_bw_narrow_hz)); config->set_property("Tracking_1C.extend_correlation_symbols", std::to_string(extend_correlation_ms)); @@ -366,7 +366,6 @@ int StaticPositionSystemTest::configure_receiver() // Set Telemetry config->set_property("TelemetryDecoder_1C.implementation", "GPS_L1_CA_Telemetry_Decoder"); config->set_property("TelemetryDecoder_1C.dump", "false"); - config->set_property("TelemetryDecoder_1C.decimation_factor", std::to_string(decimation_factor)); // Set Observables config->set_property("Observables.implementation", "Hybrid_Observables"); From b1695375a854bda08df9c2f509b3af574171417a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 14 Apr 2018 16:04:33 +0200 Subject: [PATCH 27/44] Improve finding of gnuradio-iio library --- cmake/Modules/Findiio.cmake | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/cmake/Modules/Findiio.cmake b/cmake/Modules/Findiio.cmake index 817e9f9f7..a1d526ae5 100644 --- a/cmake/Modules/Findiio.cmake +++ b/cmake/Modules/Findiio.cmake @@ -22,6 +22,28 @@ FIND_LIBRARY( /usr/local/lib64 /usr/lib /usr/lib64 + /usr/lib/x86_64-linux-gnu + /usr/lib/gcc/alpha-linux-gnu + /usr/lib/gcc/aarch64-linux-gnu + /usr/lib/gcc/arm-linux-gnueabi + /usr/lib/gcc/arm-linux-gnueabihf + /usr/lib/gcc/hppa-linux-gnu + /usr/lib/gcc/i686-gnu + /usr/lib/gcc/i686-linux-gnu + /usr/lib/gcc/x86_64-kfreebsd-gnu + /usr/lib/gcc/i686-kfreebsd-gnu + /usr/lib/gcc/m68k-linux-gnu + /usr/lib/gcc/mips-linux-gnu + /usr/lib/gcc/mips64el-linux-gnuabi64 + /usr/lib/gcc/mipsel-linux-gnu + /usr/lib/gcc/powerpc-linux-gnu + /usr/lib/gcc/powerpc-linux-gnuspe + /usr/lib/gcc/powerpc64-linux-gnu + /usr/lib/gcc/powerpc64le-linux-gnu + /usr/lib/gcc/s390x-linux-gnu + /usr/lib/gcc/sparc64-linux-gnu + /usr/lib/gcc/x86_64-linux-gnux32 + /usr/lib/gcc/sh4-linux-gnu ) INCLUDE(FindPackageHandleStandardArgs) From bce730f68da4c93d05a26aceed409e23d8acedb1 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 14 Apr 2018 16:12:21 +0200 Subject: [PATCH 28/44] Improve finding of gnuradio-iio and libiio libraries --- cmake/Modules/Findiio.cmake | 42 +++++++++++++++++----------------- cmake/Modules/Findlibiio.cmake | 42 +++++++++++++++++----------------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/cmake/Modules/Findiio.cmake b/cmake/Modules/Findiio.cmake index a1d526ae5..fc7af0d45 100644 --- a/cmake/Modules/Findiio.cmake +++ b/cmake/Modules/Findiio.cmake @@ -23,27 +23,27 @@ FIND_LIBRARY( /usr/lib /usr/lib64 /usr/lib/x86_64-linux-gnu - /usr/lib/gcc/alpha-linux-gnu - /usr/lib/gcc/aarch64-linux-gnu - /usr/lib/gcc/arm-linux-gnueabi - /usr/lib/gcc/arm-linux-gnueabihf - /usr/lib/gcc/hppa-linux-gnu - /usr/lib/gcc/i686-gnu - /usr/lib/gcc/i686-linux-gnu - /usr/lib/gcc/x86_64-kfreebsd-gnu - /usr/lib/gcc/i686-kfreebsd-gnu - /usr/lib/gcc/m68k-linux-gnu - /usr/lib/gcc/mips-linux-gnu - /usr/lib/gcc/mips64el-linux-gnuabi64 - /usr/lib/gcc/mipsel-linux-gnu - /usr/lib/gcc/powerpc-linux-gnu - /usr/lib/gcc/powerpc-linux-gnuspe - /usr/lib/gcc/powerpc64-linux-gnu - /usr/lib/gcc/powerpc64le-linux-gnu - /usr/lib/gcc/s390x-linux-gnu - /usr/lib/gcc/sparc64-linux-gnu - /usr/lib/gcc/x86_64-linux-gnux32 - /usr/lib/gcc/sh4-linux-gnu + /usr/lib/alpha-linux-gnu + /usr/lib/aarch64-linux-gnu + /usr/lib/arm-linux-gnueabi + /usr/lib/arm-linux-gnueabihf + /usr/lib/hppa-linux-gnu + /usr/lib/i686-gnu + /usr/lib/i686-linux-gnu + /usr/lib/x86_64-kfreebsd-gnu + /usr/lib/i686-kfreebsd-gnu + /usr/lib/m68k-linux-gnu + /usr/lib/mips-linux-gnu + /usr/lib/mips64el-linux-gnuabi64 + /usr/lib/mipsel-linux-gnu + /usr/lib/powerpc-linux-gnu + /usr/lib/powerpc-linux-gnuspe + /usr/lib/powerpc64-linux-gnu + /usr/lib/powerpc64le-linux-gnu + /usr/lib/s390x-linux-gnu + /usr/lib/sparc64-linux-gnu + /usr/lib/x86_64-linux-gnux32 + /usr/lib/sh4-linux-gnu ) INCLUDE(FindPackageHandleStandardArgs) diff --git a/cmake/Modules/Findlibiio.cmake b/cmake/Modules/Findlibiio.cmake index 4ce6ca9c5..22eccf4b2 100644 --- a/cmake/Modules/Findlibiio.cmake +++ b/cmake/Modules/Findlibiio.cmake @@ -24,27 +24,27 @@ FIND_LIBRARY( /usr/lib /usr/lib64 /usr/lib/x86_64-linux-gnu - /usr/lib/gcc/alpha-linux-gnu - /usr/lib/gcc/aarch64-linux-gnu - /usr/lib/gcc/arm-linux-gnueabi - /usr/lib/gcc/arm-linux-gnueabihf - /usr/lib/gcc/hppa-linux-gnu - /usr/lib/gcc/i686-gnu - /usr/lib/gcc/i686-linux-gnu - /usr/lib/gcc/x86_64-kfreebsd-gnu - /usr/lib/gcc/i686-kfreebsd-gnu - /usr/lib/gcc/m68k-linux-gnu - /usr/lib/gcc/mips-linux-gnu - /usr/lib/gcc/mips64el-linux-gnuabi64 - /usr/lib/gcc/mipsel-linux-gnu - /usr/lib/gcc/powerpc-linux-gnu - /usr/lib/gcc/powerpc-linux-gnuspe - /usr/lib/gcc/powerpc64-linux-gnu - /usr/lib/gcc/powerpc64le-linux-gnu - /usr/lib/gcc/s390x-linux-gnu - /usr/lib/gcc/sparc64-linux-gnu - /usr/lib/gcc/x86_64-linux-gnux32 - /usr/lib/gcc/sh4-linux-gnu + /usr/lib/alpha-linux-gnu + /usr/lib/aarch64-linux-gnu + /usr/lib/arm-linux-gnueabi + /usr/lib/arm-linux-gnueabihf + /usr/lib/hppa-linux-gnu + /usr/lib/i686-gnu + /usr/lib/i686-linux-gnu + /usr/lib/x86_64-kfreebsd-gnu + /usr/lib/i686-kfreebsd-gnu + /usr/lib/m68k-linux-gnu + /usr/lib/mips-linux-gnu + /usr/lib/mips64el-linux-gnuabi64 + /usr/lib/mipsel-linux-gnu + /usr/lib/powerpc-linux-gnu + /usr/lib/powerpc-linux-gnuspe + /usr/lib/powerpc64-linux-gnu + /usr/lib/powerpc64le-linux-gnu + /usr/lib/s390x-linux-gnu + /usr/lib/sparc64-linux-gnu + /usr/lib/x86_64-linux-gnux32 + /usr/lib/sh4-linux-gnu /Library/Frameworks/iio.framework/ ) From ddb7a6f3e0eb7d9cff863ae5d12f85e433d57621 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 14 Apr 2018 17:54:36 +0200 Subject: [PATCH 29/44] Fix detection of libiio package --- cmake/Modules/Findlibiio.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Modules/Findlibiio.cmake b/cmake/Modules/Findlibiio.cmake index 22eccf4b2..c3fa42366 100644 --- a/cmake/Modules/Findlibiio.cmake +++ b/cmake/Modules/Findlibiio.cmake @@ -14,7 +14,7 @@ FIND_PATH( FIND_LIBRARY( LIBIIO_LIBRARIES - NAMES libiio.so iio + NAMES iio libiio.so.0 HINTS $ENV{LIBIIO_DIR}/lib ${PC_LIBIIO_LIBDIR} PATHS ${CMAKE_INSTALL_PREFIX}/lib From 6740ac42c82c1709d38d28f040367c609304bd6a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 14 Apr 2018 18:16:38 +0200 Subject: [PATCH 30/44] Fix detection of libiio-dev package --- cmake/Modules/Findlibiio.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Modules/Findlibiio.cmake b/cmake/Modules/Findlibiio.cmake index c3fa42366..334dcf8d7 100644 --- a/cmake/Modules/Findlibiio.cmake +++ b/cmake/Modules/Findlibiio.cmake @@ -3,7 +3,7 @@ PKG_CHECK_MODULES(PC_LIBIIO libiio) FIND_PATH( LIBIIO_INCLUDE_DIRS - NAMES gnuradio/iio/api.h + NAMES iio.h HINTS $ENV{LIBIIO_DIR}/include ${PC_LIBIIO_INCLUDEDIR} PATHS ${CMAKE_INSTALL_PREFIX}/include From 4db5f9165f4fcc002c99657a2eb7689b21ed4837 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 18 Apr 2018 11:18:58 +0200 Subject: [PATCH 31/44] Fix bug counting channels when using Gal E5a configurations --- src/core/receiver/gnss_flowgraph.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index eec75d2f0..adda1183d 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -556,10 +556,9 @@ void GNSSFlowgraph::set_signals_list() */ unsigned int total_channels = configuration_->property("Channels_1C.count", 0) + - configuration_->property("Channels_2S.count", 0) + configuration_->property("Channels_1B.count", 0) + - configuration_->property("Channels_5X.count", 0) + configuration_->property("Channels_1G.count", 0) + + configuration_->property("Channels_2S.count", 0) + configuration_->property("Channels_2G.count", 0) + configuration_->property("Channels_5X.count", 0) + configuration_->property("Channels_L5.count", 0); From 514fde256aa9a7b57131a864a8bf373c5fa20d13 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 20 Apr 2018 12:50:32 +0200 Subject: [PATCH 32/44] Fix assignment of a channel to a given satellite with ChannelN.satellite=PRN --- src/core/receiver/gnss_flowgraph.cc | 158 ++++++++++++++-------------- 1 file changed, 81 insertions(+), 77 deletions(-) diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index adda1183d..255cb7609 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -9,7 +9,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -61,6 +61,8 @@ GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr configurati GNSSFlowgraph::~GNSSFlowgraph() {} + + void GNSSFlowgraph::start() { if (running_) @@ -93,10 +95,9 @@ void GNSSFlowgraph::stop() void GNSSFlowgraph::connect() { - /* Connects the blocks in the flowgraph - * - * Signal Source > Signal conditioner >> Channels >> Observables >> PVT - */ + // Connects the blocks in the flowgraph + // Signal Source > Signal conditioner >> Channels >> Observables >> PVT + LOG(INFO) << "Connecting flowgraph"; if (connected_) { @@ -184,8 +185,8 @@ void GNSSFlowgraph::connect() { try { - //TODO: Remove this array implementation and create generic multistream connector - //(if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) + // TODO: Remove this array implementation and create generic multistream connector + // (if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) if (sig_source_.at(i)->implementation().compare("Raw_Array_Signal_Source") == 0) { //Multichannel Array @@ -198,14 +199,14 @@ void GNSSFlowgraph::connect() } else { - //TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. - //Include GetRFChannels in the interface to avoid read config parameters here - //read the number of RF channels for each front-end + // TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. + // Include GetRFChannels in the interface to avoid read config parameters here + // read the number of RF channels for each front-end RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); for (int j = 0; j < RF_Channels; j++) { - //Connect the multichannel signal source to multiple signal conditioners + // Connect the multichannel signal source to multiple signal conditioners // GNURADIO max_streams=-1 means infinite ports! LOG(INFO) << "sig_source_.at(i)->get_right_block()->output_signature()->max_streams()=" << sig_source_.at(i)->get_right_block()->output_signature()->max_streams(); LOG(INFO) << "sig_conditioner_.at(signal_conditioner_ID)->get_left_block()->input_signature()=" << sig_conditioner_.at(signal_conditioner_ID)->get_left_block()->input_signature()->max_streams(); @@ -244,8 +245,8 @@ void GNSSFlowgraph::connect() } DLOG(INFO) << "Signal source connected to signal conditioner"; - //connect the signal source to sample counter - //connect the sample counter to Observables + // connect the signal source to sample counter + // connect the sample counter to Observables try { double fs = static_cast(configuration_->property("GNSS-SDR.internal_fs_sps", 0)); @@ -267,7 +268,6 @@ void GNSSFlowgraph::connect() return; } - // Signal conditioner (selected_signal_source) >> channels (i) (dependent of their associated SignalSource_ID) int selected_signal_conditioner_ID; for (unsigned int i = 0; i < channels_count_; i++) @@ -301,26 +301,46 @@ void GNSSFlowgraph::connect() top_block_->disconnect_all(); return; } + } - std::string gnss_signal = channels_.at(i)->get_signal().get_signal_str(); // use channel's implicit signal! - channels_.at(i)->set_signal(search_next_signal(gnss_signal, false)); - - if (channels_state_[i] == 1) + // Put channels fixed to a given satellite at the beginning of the vector, then the rest + std::vector vector_of_channels; + for (unsigned int i = 0; i < channels_count_; i++) + { + unsigned int sat = configuration_->property("Channel" + boost::lexical_cast(i) + ".satellite", 0); + if (sat == 0) { - channels_.at(i)->start_acquisition(); - available_GNSS_signals_.pop_front(); - LOG(INFO) << "Channel " << i << " assigned to " << channels_.at(i)->get_signal(); - LOG(INFO) << "Channel " << i << " connected to observables and ready for acquisition"; + vector_of_channels.push_back(i); } else { - LOG(INFO) << "Channel " << i << " connected to observables in standby mode"; + auto it = vector_of_channels.begin(); + it = vector_of_channels.insert(it, i); } } - /* - * Connect the observables output of each channel to the PVT block - */ + // Assign satellites to channels in the initialization + for (unsigned int& i : vector_of_channels) + { + std::string gnss_signal = channels_.at(i)->get_signal().get_signal_str(); // use channel's implicit signal + unsigned int sat = configuration_->property("Channel" + boost::lexical_cast(i) + ".satellite", 0); + if (sat == 0) + { + channels_.at(i)->set_signal(search_next_signal(gnss_signal, true)); + } + else + { + std::string gnss_system; + if ((gnss_signal.compare("1C") == 0) or (gnss_signal.compare("2S") == 0) or (gnss_signal.compare("L5") == 0)) gnss_system = "GPS"; + if ((gnss_signal.compare("1B") == 0) or (gnss_signal.compare("5X") == 0)) gnss_system = "Galileo"; + if ((gnss_signal.compare("1G") == 0) or (gnss_signal.compare("2G") == 0)) gnss_system = "Glonass"; + Gnss_Signal signal_value = Gnss_Signal(Gnss_Satellite(gnss_system, sat), gnss_signal); + available_GNSS_signals_.remove(signal_value); + channels_.at(i)->set_signal(signal_value); + } + } + + // Connect the observables output of each channel to the PVT block try { for (unsigned int i = 0; i < channels_count_; i++) @@ -337,6 +357,21 @@ void GNSSFlowgraph::connect() return; } + // Activate acquisition in enabled channels + for (unsigned int i = 0; i < channels_count_; i++) + { + LOG(INFO) << "Channel " << i << " assigned to " << channels_.at(i)->get_signal(); + if (channels_state_[i] == 1) + { + channels_.at(i)->start_acquisition(); + LOG(INFO) << "Channel " << i << " connected to observables and ready for acquisition"; + } + else + { + LOG(INFO) << "Channel " << i << " connected to observables in standby mode"; + } + } + connected_ = true; LOG(INFO) << "Flowgraph connected"; top_block_->dump(); @@ -374,12 +409,16 @@ bool GNSSFlowgraph::send_telemetry_msg(pmt::pmt_t msg) void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) { DLOG(INFO) << "Received " << what << " from " << who << ". Number of applied actions = " << applied_actions_; + unsigned int sat = configuration_->property("Channel" + boost::lexical_cast(who) + ".satellite", 0); switch (what) { case 0: DLOG(INFO) << "Channel " << who << " ACQ FAILED satellite " << channels_.at(who)->get_signal().get_satellite() << ", Signal " << channels_.at(who)->get_signal().get_signal_str(); - available_GNSS_signals_.push_back(channels_.at(who)->get_signal()); - channels_.at(who)->set_signal(search_next_signal(channels_.at(who)->get_signal().get_signal_str(), true)); + if (sat == 0) + { + available_GNSS_signals_.push_back(channels_.at(who)->get_signal()); + channels_.at(who)->set_signal(search_next_signal(channels_.at(who)->get_signal().get_signal_str(), true)); + } DLOG(INFO) << "Channel " << who << " Starting acquisition " << channels_.at(who)->get_signal().get_satellite() << ", Signal " << channels_.at(who)->get_signal().get_signal_str(); channels_.at(who)->start_acquisition(); break; @@ -390,10 +429,14 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) acq_channels_count_--; for (unsigned int i = 0; i < channels_count_; i++) { + unsigned int sat_ = configuration_->property("Channel" + boost::lexical_cast(i) + ".satellite", 0); if (!available_GNSS_signals_.empty() && (acq_channels_count_ < max_acq_channels_) && (channels_state_[i] == 0)) { channels_state_[i] = 1; - channels_.at(i)->set_signal(search_next_signal(channels_.at(i)->get_signal().get_signal_str(), true)); + if (sat_ == 0) + { + channels_.at(i)->set_signal(search_next_signal(channels_.at(i)->get_signal().get_signal_str(), true)); + } acq_channels_count_++; DLOG(INFO) << "Channel " << i << " Starting acquisition " << channels_.at(i)->get_signal().get_satellite() << ", Signal " << channels_.at(i)->get_signal().get_signal_str(); channels_.at(i)->start_acquisition(); @@ -417,7 +460,10 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) { channels_state_[who] = 0; LOG(INFO) << "Channel " << who << " Idle state"; - available_GNSS_signals_.push_back(channels_.at(who)->get_signal()); + if (sat == 0) + { + available_GNSS_signals_.push_back(channels_.at(who)->get_signal()); + } } break; @@ -436,7 +482,6 @@ void GNSSFlowgraph::set_configuration(std::shared_ptr co LOG(WARNING) << "Unable to update configuration while flowgraph running"; return; } - if (connected_) { LOG(WARNING) << "Unable to update configuration while flowgraph connected"; @@ -541,20 +586,10 @@ void GNSSFlowgraph::init() void GNSSFlowgraph::set_signals_list() { - /* - * Sets a sequential list of GNSS satellites - */ + // Set a sequential list of GNSS satellites std::set::const_iterator available_gnss_prn_iter; - /* - * \TODO Describe GNSS satellites more nicely, with RINEX notation - * See http://igscb.jpl.nasa.gov/igscb/data/format/rinex301.pdf (page 5) - */ - - /* - * Read GNSS-SDR default GNSS system and signal - */ - + // Read GNSS systems and signals unsigned int total_channels = configuration_->property("Channels_1C.count", 0) + configuration_->property("Channels_1B.count", 0) + configuration_->property("Channels_1G.count", 0) + @@ -563,11 +598,7 @@ void GNSSFlowgraph::set_signals_list() configuration_->property("Channels_5X.count", 0) + configuration_->property("Channels_L5.count", 0); - /* - * Loop to create the list of GNSS Signals - * To add signals from other systems, add another loop 'for' - */ - + // Create the lists of GNSS satellites std::set available_gps_prn = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}; @@ -689,6 +720,7 @@ void GNSSFlowgraph::set_signals_list() std::string("L5"))); } } + if (configuration_->property("Channels_SBAS.count", 0) > 0) { /* @@ -704,7 +736,6 @@ void GNSSFlowgraph::set_signals_list() } } - if (configuration_->property("Channels_1B.count", 0) > 0) { /* @@ -764,39 +795,12 @@ void GNSSFlowgraph::set_signals_list() std::string("2G"))); } } - /* - * Ordering the list of signals from configuration file - */ - std::list::iterator gnss_it = available_GNSS_signals_.begin(); - - // Pre-assignation if not defined at ChannelX.signal=1C ...? In what order? - - for (unsigned int i = 0; i < total_channels; i++) - { - std::string gnss_signal = (configuration_->property("Channel" + boost::lexical_cast(i) + ".signal", std::string("1C"))); - std::string gnss_system; - if ((gnss_signal.compare("1C") == 0) or (gnss_signal.compare("2S") == 0) or (gnss_signal.compare("L5") == 0)) gnss_system = "GPS"; - if ((gnss_signal.compare("1B") == 0) or (gnss_signal.compare("5X") == 0)) gnss_system = "Galileo"; - if ((gnss_signal.compare("1G") == 0) or (gnss_signal.compare("2G") == 0)) gnss_system = "Glonass"; - unsigned int sat = configuration_->property("Channel" + boost::lexical_cast(i) + ".satellite", 0); - LOG(INFO) << "Channel " << i << " system " << gnss_system << ", signal " << gnss_signal << ", sat " << sat; - if (sat == 0) // 0 = not PRN in configuration file - { - gnss_it++; - } - else - { - Gnss_Signal signal_value = Gnss_Signal(Gnss_Satellite(gnss_system, sat), gnss_signal); - available_GNSS_signals_.remove(signal_value); - gnss_it = available_GNSS_signals_.insert(gnss_it, signal_value); - } - } } void GNSSFlowgraph::set_channels_state() { - max_acq_channels_ = (configuration_->property("Channels.in_acquisition", channels_count_)); + max_acq_channels_ = configuration_->property("Channels.in_acquisition", channels_count_); if (max_acq_channels_ > channels_count_) { max_acq_channels_ = channels_count_; From b4cb0cc76bfb0b2249158c18babe1d810489044a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 20 Apr 2018 12:56:32 +0200 Subject: [PATCH 33/44] Improve wording --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7a87240cb..262feeb0c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -75,7 +75,7 @@ the actual username of your GitHub account): 4. Your forked repository https://github.com/YOUR_USERNAME/gnss-sdr will receive the default name of `origin`. You can also add the original -gnss-sdr repository, which is usually called `upstream`: +gnss-sdr repository, which is usually referred to as `upstream`: $ cd gnss-sdr $ git remote add upstream https://github.com/gnss-sdr/gnss-sdr.git From 2cd1bed90c8de81f40236d7739e16d3aa6e02963 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 20 Apr 2018 13:20:10 +0200 Subject: [PATCH 34/44] Fix headers and documentation --- src/core/receiver/gnss_flowgraph.cc | 25 +++++++++++-------------- src/core/receiver/gnss_flowgraph.h | 21 ++++++++++++--------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 255cb7609..4df4c0727 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -1,12 +1,10 @@ /*! * \file gnss_flowgraph.cc - * \brief Implementation of a GNSS receiver flowgraph + * \brief Implementation of a GNSS receiver flow graph * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com * Luis Esteve, 2012. luis(at)epsilon-formacion.com * Carles Fernandez-Prades, 2014. cfernandez(at)cttc.es * - * Detailed description of the file here if needed. - * * ------------------------------------------------------------------------- * * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) @@ -95,7 +93,7 @@ void GNSSFlowgraph::stop() void GNSSFlowgraph::connect() { - // Connects the blocks in the flowgraph + // Connects the blocks in the flow graph // Signal Source > Signal conditioner >> Channels >> Observables >> PVT LOG(INFO) << "Connecting flowgraph"; @@ -401,7 +399,7 @@ bool GNSSFlowgraph::send_telemetry_msg(pmt::pmt_t msg) /* - * Applies an action to the flowgraph + * Applies an action to the flow graph * * \param[in] who Who generated the action * \param[in] what What is the action 0: acquisition failed @@ -509,9 +507,9 @@ void GNSSFlowgraph::init() { std::cout << "Creating source " << i << std::endl; sig_source_.push_back(block_factory_->GetSignalSource(configuration_, queue_, i)); - //TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. - //Include GetRFChannels in the interface to avoid read config parameters here - //read the number of RF channels for each front-end + // TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. + // Include GetRFChannels in the interface to avoid read config parameters here + // read the number of RF channels for each front-end RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); std::cout << "RF Channels " << RF_Channels << std::endl; for (int j = 0; j < RF_Channels; j++) @@ -523,11 +521,11 @@ void GNSSFlowgraph::init() } else { - //backwards compatibility for old config files + // backwards compatibility for old config files sig_source_.push_back(block_factory_->GetSignalSource(configuration_, queue_, -1)); - //TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. - //Include GetRFChannels in the interface to avoid read config parameters here - //read the number of RF channels for each front-end + // TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. + // Include GetRFChannels in the interface to avoid read config parameters here + // read the number of RF channels for each front-end RF_Channels = configuration_->property(sig_source_.at(0)->role() + ".RF_channels", 0); if (RF_Channels != 0) { @@ -539,7 +537,7 @@ void GNSSFlowgraph::init() } else { - //old config file, single signal source and single channel, not specified + // old config file, single signal source and single channel, not specified sig_conditioner_.push_back(block_factory_->GetSignalConditioner(configuration_, -1)); } } @@ -566,7 +564,6 @@ void GNSSFlowgraph::init() std::shared_ptr>> channels = block_factory_->GetChannels(configuration_, queue_); - //todo:check smart pointer coherence... channels_count_ = channels->size(); for (unsigned int i = 0; i < channels_count_; i++) { diff --git a/src/core/receiver/gnss_flowgraph.h b/src/core/receiver/gnss_flowgraph.h index 7f8891f29..df041c8e8 100644 --- a/src/core/receiver/gnss_flowgraph.h +++ b/src/core/receiver/gnss_flowgraph.h @@ -1,12 +1,12 @@ /*! * \file gnss_flowgraph.h - * \brief Interface of a GNSS receiver flowgraph. + * \brief Interface of a GNSS receiver flow graph. * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com * Luis Esteve, 2011. luis(at)epsilon-formacion.com * Carles Fernandez-Prades, 2014. cfernandez(at)cttc.es * * It contains a signal source, - * a signal conditioner, a set of channels, a pvt and an output filter. + * a signal conditioner, a set of channels, an observables block and a pvt. * * ------------------------------------------------------------------------- * @@ -53,7 +53,7 @@ class ChannelInterface; class ConfigurationInterface; class GNSSBlockFactory; -/*! \brief This class represents a GNSS flowgraph. +/*! \brief This class represents a GNSS flow graph. * * It contains a signal source, * a signal conditioner, a set of channels, a PVT and an output filter. @@ -62,7 +62,7 @@ class GNSSFlowgraph { public: /*! - * \brief Constructor that initializes the receiver flowgraph + * \brief Constructor that initializes the receiver flow graph */ GNSSFlowgraph(std::shared_ptr configuration, gr::msg_queue::sptr queue); @@ -71,14 +71,14 @@ public: */ virtual ~GNSSFlowgraph(); - //! \brief Start the flowgraph + //! \brief Start the flow graph void start(); - //! \brief Stop the flowgraph + //! \brief Stop the flow graph void stop(); /*! - * \brief Connects the defined blocks in the flowgraph + * \brief Connects the defined blocks in the flow graph * * Signal Source > Signal conditioner > Channels >> Observables >> PVT > Output filter */ @@ -87,10 +87,10 @@ public: void wait(); /*! - * \brief Applies an action to the flowgraph + * \brief Applies an action to the flow graph * * \param[in] who Who generated the action - * \param[in] what What is the action 0: acquisition failed + * \param[in] what What is the action. 0: acquisition failed; 1: acquisition success; 2: tracking lost */ void apply_action(unsigned int who, unsigned int what); @@ -100,14 +100,17 @@ public: { return applied_actions_; } + bool connected() { return connected_; } + bool running() { return running_; } + /*! * \brief Sends a GNURadio asynchronous message from telemetry to PVT * From a584e8e51dfcba0a433820cf762ec2d462a7bca3 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 22 Apr 2018 19:49:13 +0200 Subject: [PATCH 35/44] Add mutex to protect list of available signals Disconnect the flowgraph when leaving --- src/core/receiver/gnss_flowgraph.cc | 214 ++++++++++++++++++++++++++-- src/core/receiver/gnss_flowgraph.h | 8 +- 2 files changed, 206 insertions(+), 16 deletions(-) diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 4df4c0727..3303d15b6 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -58,7 +58,13 @@ GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr configurati } -GNSSFlowgraph::~GNSSFlowgraph() {} +GNSSFlowgraph::~GNSSFlowgraph() +{ + if (connected_) + { + GNSSFlowgraph::disconnect(); + } +} void GNSSFlowgraph::start() @@ -376,6 +382,183 @@ void GNSSFlowgraph::connect() } +void GNSSFlowgraph::disconnect() +{ + LOG(INFO) << "Disconnecting flowgraph"; + + if (!connected_) + { + LOG(INFO) << "flowgraph was not connected"; + return; + } + + // Signal Source (i) > Signal conditioner (i) > + int RF_Channels = 0; + int signal_conditioner_ID = 0; + + for (int i = 0; i < sources_count_; i++) + { + try + { + // TODO: Remove this array implementation and create generic multistream connector + // (if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) + if (sig_source_.at(i)->implementation().compare("Raw_Array_Signal_Source") == 0) + { + //Multichannel Array + for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) + { + top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); + } + } + else + { + // TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. + // Include GetRFChannels in the interface to avoid read config parameters here + // read the number of RF channels for each front-end + RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); + + for (int j = 0; j < RF_Channels; j++) + { + if (sig_source_.at(i)->get_right_block()->output_signature()->max_streams() > 1) + { + top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + else + { + if (j == 0) + { + // RF_channel 0 backward compatibility with single channel sources + top_block_->disconnect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + else + { + // Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) + top_block_->disconnect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + } + signal_conditioner_ID++; + } + } + } + catch (const std::exception& e) + { + LOG(INFO) << "Can't disconnect signal source " << i << " to signal conditioner " << i << ": " << e.what(); + } + } + + try + { + top_block_->disconnect(sig_conditioner_.at(0)->get_right_block(), 0, ch_out_sample_counter, 0); + top_block_->disconnect(ch_out_sample_counter, 0, observables_->get_left_block(), channels_count_); //extra port for the sample counter pulse + } + catch (const std::exception& e) + { + LOG(INFO) << "Can't disconnect sample counter: " << e.what(); + } + + // Signal conditioner (selected_signal_source) >> channels (i) (dependent of their associated SignalSource_ID) + int selected_signal_conditioner_ID; + for (unsigned int i = 0; i < channels_count_; i++) + { + selected_signal_conditioner_ID = configuration_->property("Channel" + boost::lexical_cast(i) + ".RF_channel_ID", 0); + try + { + top_block_->disconnect(sig_conditioner_.at(selected_signal_conditioner_ID)->get_right_block(), 0, + channels_.at(i)->get_left_block(), 0); + } + catch (const std::exception& e) + { + LOG(INFO) << "Can't disconnect signal conditioner " << selected_signal_conditioner_ID << " to channel " << i << ": " << e.what(); + } + + // Signal Source > Signal conditioner >> Channels >> Observables + try + { + top_block_->disconnect(channels_.at(i)->get_right_block(), 0, + observables_->get_left_block(), i); + } + catch (const std::exception& e) + { + LOG(INFO) << "Can't disconnect channel " << i << " to observables: " << e.what(); + } + } + + try + { + for (unsigned int i = 0; i < channels_count_; i++) + { + top_block_->disconnect(observables_->get_right_block(), i, pvt_->get_left_block(), i); + top_block_->msg_disconnect(channels_.at(i)->get_right_block(), pmt::mp("telemetry"), pvt_->get_left_block(), pmt::mp("telemetry")); + } + } + catch (const std::exception& e) + { + LOG(INFO) << "Can't disconnect observables to PVT: " << e.what(); + } + + for (int i = 0; i < sources_count_; i++) + { + try + { + sig_source_.at(i)->disconnect(top_block_); + } + catch (const std::exception& e) + { + LOG(INFO) << "Can't disconnect signal source block " << i << " internally: " << e.what(); + } + } + + // Signal Source > Signal conditioner > + for (unsigned int i = 0; i < sig_conditioner_.size(); i++) + { + try + { + sig_conditioner_.at(i)->disconnect(top_block_); + } + catch (const std::exception& e) + { + LOG(INFO) << "Can't disconnect signal conditioner block " << i << " internally: " << e.what(); + } + } + + for (unsigned int i = 0; i < channels_count_; i++) + { + try + { + channels_.at(i)->disconnect(top_block_); + } + catch (const std::exception& e) + { + LOG(INFO) << "Can't disconnect channel " << i << " internally: " << e.what(); + } + } + + try + { + observables_->disconnect(top_block_); + } + catch (const std::exception& e) + { + LOG(INFO) << "Can't disconnect observables block internally: " << e.what(); + } + + // Signal Source > Signal conditioner >> Channels >> Observables > PVT + try + { + pvt_->disconnect(top_block_); + } + catch (const std::exception& e) + { + LOG(INFO) << "Can't disconnect PVT block internally: " << e.what(); + } + + DLOG(INFO) << "blocks disconnected internally"; + + connected_ = false; + LOG(INFO) << "Flowgraph disconnected"; +} + + void GNSSFlowgraph::wait() { if (!running_) @@ -411,18 +594,19 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) switch (what) { case 0: - DLOG(INFO) << "Channel " << who << " ACQ FAILED satellite " << channels_.at(who)->get_signal().get_satellite() << ", Signal " << channels_.at(who)->get_signal().get_signal_str(); + DLOG(INFO) << "Channel " << who << " ACQ FAILED satellite " << channels_[who]->get_signal().get_satellite() << ", Signal " << channels_[who]->get_signal().get_signal_str(); if (sat == 0) { - available_GNSS_signals_.push_back(channels_.at(who)->get_signal()); - channels_.at(who)->set_signal(search_next_signal(channels_.at(who)->get_signal().get_signal_str(), true)); + std::lock_guard lock(signal_list_mutex); + available_GNSS_signals_.push_back(channels_[who]->get_signal()); + channels_[who]->set_signal(search_next_signal(channels_[who]->get_signal().get_signal_str(), true)); } - DLOG(INFO) << "Channel " << who << " Starting acquisition " << channels_.at(who)->get_signal().get_satellite() << ", Signal " << channels_.at(who)->get_signal().get_signal_str(); - channels_.at(who)->start_acquisition(); + DLOG(INFO) << "Channel " << who << " Starting acquisition " << channels_[who]->get_signal().get_satellite() << ", Signal " << channels_[who]->get_signal().get_signal_str(); + channels_[who]->start_acquisition(); break; case 1: - LOG(INFO) << "Channel " << who << " ACQ SUCCESS satellite " << channels_.at(who)->get_signal().get_satellite(); + LOG(INFO) << "Channel " << who << " ACQ SUCCESS satellite " << channels_[who]->get_signal().get_satellite(); channels_state_[who] = 2; acq_channels_count_--; for (unsigned int i = 0; i < channels_count_; i++) @@ -433,26 +617,27 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) channels_state_[i] = 1; if (sat_ == 0) { - channels_.at(i)->set_signal(search_next_signal(channels_.at(i)->get_signal().get_signal_str(), true)); + std::lock_guard lock(signal_list_mutex); + channels_[i]->set_signal(search_next_signal(channels_[i]->get_signal().get_signal_str(), true)); } acq_channels_count_++; - DLOG(INFO) << "Channel " << i << " Starting acquisition " << channels_.at(i)->get_signal().get_satellite() << ", Signal " << channels_.at(i)->get_signal().get_signal_str(); - channels_.at(i)->start_acquisition(); + DLOG(INFO) << "Channel " << i << " Starting acquisition " << channels_[i]->get_signal().get_satellite() << ", Signal " << channels_[i]->get_signal().get_signal_str(); + channels_[i]->start_acquisition(); } DLOG(INFO) << "Channel " << i << " in state " << channels_state_[i]; } break; case 2: - LOG(INFO) << "Channel " << who << " TRK FAILED satellite " << channels_.at(who)->get_signal().get_satellite(); + LOG(INFO) << "Channel " << who << " TRK FAILED satellite " << channels_[who]->get_signal().get_satellite(); DLOG(INFO) << "Number of channels in acquisition = " << acq_channels_count_; if (acq_channels_count_ < max_acq_channels_) { channels_state_[who] = 1; acq_channels_count_++; - LOG(INFO) << "Channel " << who << " Starting acquisition " << channels_.at(who)->get_signal().get_satellite() << ", Signal " << channels_.at(who)->get_signal().get_signal_str(); - channels_.at(who)->start_acquisition(); + LOG(INFO) << "Channel " << who << " Starting acquisition " << channels_[who]->get_signal().get_satellite() << ", Signal " << channels_[who]->get_signal().get_signal_str(); + channels_[who]->start_acquisition(); } else { @@ -460,7 +645,8 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) LOG(INFO) << "Channel " << who << " Idle state"; if (sat == 0) { - available_GNSS_signals_.push_back(channels_.at(who)->get_signal()); + std::lock_guard lock(signal_list_mutex); + available_GNSS_signals_.push_back(channels_[who]->get_signal()); } } break; diff --git a/src/core/receiver/gnss_flowgraph.h b/src/core/receiver/gnss_flowgraph.h index df041c8e8..a6915e97e 100644 --- a/src/core/receiver/gnss_flowgraph.h +++ b/src/core/receiver/gnss_flowgraph.h @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -67,9 +68,9 @@ public: GNSSFlowgraph(std::shared_ptr configuration, gr::msg_queue::sptr queue); /*! - * \brief Virtual destructor + * \brief Destructor */ - virtual ~GNSSFlowgraph(); + ~GNSSFlowgraph(); //! \brief Start the flow graph void start(); @@ -84,6 +85,8 @@ public: */ void connect(); + void disconnect(); + void wait(); /*! @@ -147,6 +150,7 @@ private: gr::msg_queue::sptr queue_; std::list available_GNSS_signals_; std::vector channels_state_; + std::mutex signal_list_mutex; }; #endif /*GNSS_SDR_GNSS_FLOWGRAPH_H_*/ From bed15db08d4759c92e3582e6005f88385c47b5be Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 22 Apr 2018 22:51:02 +0200 Subject: [PATCH 36/44] Use volk_gnsssdr to reserve memory --- .../telemetry_decoder/gnuradio_blocks/CMakeLists.txt | 7 ++++++- .../gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc | 9 ++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt b/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt index 335ae52df..26dae1cdf 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt @@ -37,10 +37,15 @@ include_directories( ${GFlags_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${GNURADIO_RUNTIME_INCLUDE_DIRS} + ${VOLK_GNSSSDR_INCLUDE_DIRS} ) file(GLOB TELEMETRY_DECODER_GR_BLOCKS_HEADERS "*.h") list(SORT TELEMETRY_DECODER_GR_BLOCKS_HEADERS) add_library(telemetry_decoder_gr_blocks ${TELEMETRY_DECODER_GR_BLOCKS_SOURCES} ${TELEMETRY_DECODER_GR_BLOCKS_HEADERS}) source_group(Headers FILES ${TELEMETRY_DECODER_GR_BLOCKS_HEADERS}) -target_link_libraries(telemetry_decoder_gr_blocks telemetry_decoder_libswiftcnav telemetry_decoder_lib gnss_system_parameters ${GNURADIO_RUNTIME_LIBRARIES}) +target_link_libraries(telemetry_decoder_gr_blocks telemetry_decoder_libswiftcnav telemetry_decoder_lib gnss_system_parameters ${GNURADIO_RUNTIME_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES}) + +if(NOT VOLK_GNSSSDR_FOUND) + add_dependencies(telemetry_decoder_gr_blocks volk_gnsssdr_module) +endif(NOT VOLK_GNSSSDR_FOUND) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc index 1070dca28..5c0071307 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc @@ -32,8 +32,9 @@ #include "gps_l1_ca_telemetry_decoder_cc.h" #include "control_message_factory.h" #include -#include #include +#include +#include #ifndef _rotl @@ -63,10 +64,8 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc( // set the preamble unsigned short int preambles_bits[GPS_CA_PREAMBLE_LENGTH_BITS] = GPS_PREAMBLE; - //memcpy((unsigned short int*)this->d_preambles_bits, (unsigned short int*)preambles_bits, GPS_CA_PREAMBLE_LENGTH_BITS*sizeof(unsigned short int)); - // preamble bits to sampled symbols - d_preambles_symbols = static_cast(malloc(sizeof(signed int) * GPS_CA_PREAMBLE_LENGTH_SYMBOLS)); + d_preambles_symbols = static_cast(volk_gnsssdr_malloc(GPS_CA_PREAMBLE_LENGTH_SYMBOLS * sizeof(int), volk_gnsssdr_get_alignment())); int n = 0; for (int i = 0; i < GPS_CA_PREAMBLE_LENGTH_BITS; i++) { @@ -112,7 +111,7 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc( gps_l1_ca_telemetry_decoder_cc::~gps_l1_ca_telemetry_decoder_cc() { - delete d_preambles_symbols; + volk_gnsssdr_free(d_preambles_symbols); if (d_dump_file.is_open() == true) { try From 9339ec4874af8c11644d874ca3531e2e7952a497 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 22 Apr 2018 22:53:33 +0200 Subject: [PATCH 37/44] Display channel number when decoding data --- .../gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc index f06d19b6f..c27214c52 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc @@ -166,20 +166,20 @@ int gps_l2c_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( { // get ephemeris object for this SV std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_ephemeris()); - std::cout << TEXT_BLUE << "New GPS CNAV message received: ephemeris from satellite " << d_satellite << TEXT_RESET << std::endl; + std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << TEXT_RESET << std::endl; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } if (d_CNAV_Message.have_new_iono() == true) { std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_iono()); - std::cout << TEXT_BLUE << "New GPS CNAV message received: iono model parameters from satellite " << d_satellite << TEXT_RESET << std::endl; + std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel << ": iono model parameters from satellite " << d_satellite << TEXT_RESET << std::endl; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } if (d_CNAV_Message.have_new_utc_model() == true) { std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_utc_model()); - std::cout << TEXT_BLUE << "New GPS CNAV message received: UTC model parameters from satellite " << d_satellite << TEXT_RESET << std::endl; + std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << TEXT_RESET << std::endl; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } From 61fbbc9abb393422e5bd9dd6640ca6c639213c9e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 22 Apr 2018 23:07:34 +0200 Subject: [PATCH 38/44] Add color to GPS L5 CNAV message demodulation --- .../gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc | 14 +++++++------- .../gnuradio_blocks/gps_l5_telemetry_decoder_cc.h | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc index 0793428fa..1f2a8decf 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc @@ -1,7 +1,6 @@ /*! * \file gps_l5_telemetry_decoder_cc.cc - * \brief Implementation of a NAV message demodulator block based on - * Kay Borre book MATLAB-based GPS receiver + * \brief Implementation of a CNAV message demodulator block * \author Antonio Ramos, 2017. antonio.ramos(at)cttc.es * * ------------------------------------------------------------------------- @@ -31,12 +30,13 @@ #include "gps_l5_telemetry_decoder_cc.h" +#include "display.h" #include "gnss_synchro.h" #include "gps_cnav_ephemeris.h" #include "gps_cnav_iono.h" -#include -#include #include +#include +#include #include #include #include @@ -218,20 +218,20 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u { // get ephemeris object for this SV std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_ephemeris()); - std::cout << "New GPS L5 CNAV message received: ephemeris from satellite " << d_satellite << std::endl; + std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << TEXT_RESET << std::endl; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } if (d_CNAV_Message.have_new_iono() == true) { std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_iono()); - std::cout << "New GPS L5 CNAV message received: iono model parameters from satellite " << d_satellite << std::endl; + std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel << ": iono model parameters from satellite " << d_satellite << TEXT_RESET << std::endl; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } if (d_CNAV_Message.have_new_utc_model() == true) { std::shared_ptr tmp_obj = std::make_shared(d_CNAV_Message.get_utc_model()); - std::cout << "New GPS L5 CNAV message received: UTC model parameters from satellite " << d_satellite << std::endl; + std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << TEXT_RESET << std::endl; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h index 59f0bf108..8afa6569e 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h @@ -1,7 +1,6 @@ /*! * \file gps_l5_telemetry_decoder_cc.h - * \brief Interface of a CNAV message demodulator block based on - * Kay Borre book MATLAB-based GPS receiver + * \brief Interface of a CNAV message demodulator block * \author Antonio Ramos, 2017. antonio.ramos(at)cttc.es * ------------------------------------------------------------------------- * @@ -42,7 +41,8 @@ #include #include -extern "C" { +extern "C" +{ #include "cnav_msg.h" #include "edc.h" #include "bits.h" From 616812867feb62df72dc66aa56f4161c4c1388e5 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 22 Apr 2018 23:10:05 +0200 Subject: [PATCH 39/44] Report channel when decoding a NAV message --- .../telemetry_decoder/libs/gps_l1_ca_subframe_fsm.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.cc b/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.cc index d4980a532..e7379f7e0 100644 --- a/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.cc +++ b/src/algorithms/telemetry_decoder/libs/gps_l1_ca_subframe_fsm.cc @@ -39,13 +39,16 @@ //************ GPS WORD TO SUBFRAME DECODER STATE MACHINE ********** - struct Ev_gps_word_valid : sc::event { }; + + struct Ev_gps_word_invalid : sc::event { }; + + struct Ev_gps_word_preamble : sc::event { }; @@ -245,16 +248,20 @@ void GpsL1CaSubframeFsm::gps_word_to_subframe(int position) std::memcpy(&d_subframe[position * GPS_WORD_LENGTH], &d_GPS_frame_4bytes, sizeof(char) * GPS_WORD_LENGTH); } + void GpsL1CaSubframeFsm::clear_flag_new_subframe() { d_flag_new_subframe = false; } + + void GpsL1CaSubframeFsm::gps_subframe_to_nav_msg() { //int subframe_ID; // NEW GPS SUBFRAME HAS ARRIVED! d_subframe_ID = d_nav.subframe_decoder(this->d_subframe); //decode the subframe - std::cout << "New GPS NAV message received: subframe " + std::cout << "New GPS NAV message received in channel " << i_channel_ID << ": " + << "subframe " << d_subframe_ID << " from satellite " << Gnss_Satellite(std::string("GPS"), i_satellite_PRN) << std::endl; d_nav.i_satellite_PRN = i_satellite_PRN; @@ -263,6 +270,7 @@ void GpsL1CaSubframeFsm::gps_subframe_to_nav_msg() d_flag_new_subframe = true; } + void GpsL1CaSubframeFsm::Event_gps_word_valid() { this->process_event(Ev_gps_word_valid()); From 6f9fafcef06a82ae70d707752f42438a4bfbe823 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 23 Apr 2018 07:41:13 +0200 Subject: [PATCH 40/44] Disconnect flowgraph when finished --- src/core/receiver/control_thread.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index db3e3841b..b2d1838f4 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -148,6 +148,7 @@ void ControlThread::run() std::cout << "Stopping GNSS-SDR, please wait!" << std::endl; flowgraph_->stop(); stop_ = true; + flowgraph_->disconnect(); //Join keyboard thread #ifdef OLD_BOOST From 3e0587b28c0551e86633056844cbff9ca19c67c1 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 23 Apr 2018 07:41:53 +0200 Subject: [PATCH 41/44] Display channel when decoding GNAV messages --- .../glonass_l2_ca_telemetry_decoder_cc.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc index b446b6e7e..a57307850 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc @@ -31,9 +31,10 @@ #include "glonass_l2_ca_telemetry_decoder_cc.h" +#include "display.h" #include -#include #include +#include #define CRC_ERROR_LIMIT 6 @@ -180,11 +181,11 @@ void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in // 3. Check operation executed correctly if (d_nav.flag_CRC_test == true) { - LOG(INFO) << "GLONASS GNAV CRC correct on channel " << d_channel << " from satellite " << d_satellite; + LOG(INFO) << "GLONASS GNAV CRC correct in channel " << d_channel << " from satellite " << d_satellite; } else { - LOG(INFO) << "GLONASS GNAV CRC error on channel " << d_channel << " from satellite " << d_satellite; + LOG(INFO) << "GLONASS GNAV CRC error in channel " << d_channel << " from satellite " << d_satellite; } // 4. Push the new navigation data to the queues if (d_nav.have_new_ephemeris() == true) @@ -193,26 +194,29 @@ void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in d_nav.gnav_ephemeris.i_satellite_freq_channel = d_satellite.get_rf_link(); std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - LOG(INFO) << "GLONASS GNAV Ephemeris have been received on channel" << d_channel << " from satellite " << d_satellite; + LOG(INFO) << "GLONASS GNAV Ephemeris have been received in channel" << d_channel << " from satellite " << d_satellite; + std::cout << TEXT_CYAN << "New GLONASS L2 GNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << TEXT_RESET << std::endl; } if (d_nav.have_new_utc_model() == true) { // get object for this SV (mandatory) 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)); - LOG(INFO) << "GLONASS GNAV UTC Model have been received on channel" << d_channel << " from satellite " << d_satellite; + LOG(INFO) << "GLONASS GNAV UTC Model have been received in channel" << d_channel << " from satellite " << d_satellite; + std::cout << TEXT_CYAN << "New GLONASS L2 GNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << TEXT_RESET << std::endl; } if (d_nav.have_new_almanac() == true) { unsigned int slot_nbr = d_nav.i_alm_satellite_slot_number; std::shared_ptr tmp_obj = std::make_shared(d_nav.get_almanac(slot_nbr)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - LOG(INFO) << "GLONASS GNAV Almanac have been received on channel" << d_channel << " in slot number " << slot_nbr; + LOG(INFO) << "GLONASS GNAV Almanac have been received in channel" << d_channel << " in slot number " << slot_nbr; + std::cout << TEXT_CYAN << "New GLONASS L2 GNAV almanac received in channel " << d_channel << " from satellite " << d_satellite << TEXT_RESET << std::endl; } // 5. Update satellite information on system if (d_nav.flag_update_slot_number == true) { - LOG(INFO) << "GLONASS GNAV Slot Number Identified on channel " << d_channel; + LOG(INFO) << "GLONASS GNAV Slot Number Identified in channel " << d_channel; d_satellite.update_PRN(d_nav.gnav_ephemeris.d_n); d_satellite.what_block(d_satellite.get_system(), d_nav.gnav_ephemeris.d_n); d_nav.flag_update_slot_number = false; From 1b852336c6918ce3a0a1082992a61284210a141a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 23 Apr 2018 07:52:49 +0200 Subject: [PATCH 42/44] Improve memory management in Viterbi decoder --- .../galileo_e1b_telemetry_decoder_cc.cc | 65 ++++++++----------- .../galileo_e1b_telemetry_decoder_cc.h | 9 +++ .../galileo_e5a_telemetry_decoder_cc.cc | 64 +++++++----------- .../galileo_e5a_telemetry_decoder_cc.h | 9 +++ 4 files changed, 68 insertions(+), 79 deletions(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc index 6f2242454..b9aee4196 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc @@ -37,6 +37,7 @@ #include #include #include +#include #include @@ -54,38 +55,8 @@ galileo_e1b_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump void galileo_e1b_telemetry_decoder_cc::viterbi_decoder(double *page_part_symbols, int *page_part_bits) { - int CodeLength = 240; - int DataLength; - int nn, KK, mm, max_states; - int g_encoder[2]; - - nn = 2; // Coding rate 1/n - KK = 7; // Constraint Length - g_encoder[0] = 121; // Polynomial G1 - g_encoder[1] = 91; // Polynomial G2 - - mm = KK - 1; - max_states = 1 << mm; /* 2^mm */ - DataLength = (CodeLength / nn) - mm; - - /* create appropriate transition matrices */ - int *out0, *out1, *state0, *state1; - out0 = static_cast(calloc(max_states, sizeof(int))); - out1 = static_cast(calloc(max_states, sizeof(int))); - state0 = static_cast(calloc(max_states, sizeof(int))); - state1 = static_cast(calloc(max_states, sizeof(int))); - - nsc_transit(out0, state0, 0, g_encoder, KK, nn); - nsc_transit(out1, state1, 1, g_encoder, KK, nn); - Viterbi(page_part_bits, out0, state0, out1, state1, page_part_symbols, KK, nn, DataLength); - - /* Clean up memory */ - free(out0); - free(out1); - free(state0); - free(state1); } @@ -122,7 +93,7 @@ galileo_e1b_telemetry_decoder_cc::galileo_e1b_telemetry_decoder_cc( memcpy(static_cast(this->d_preambles_bits), static_cast(preambles_bits), GALILEO_INAV_PREAMBLE_LENGTH_BITS * sizeof(unsigned short int)); // preamble bits to sampled symbols - d_preambles_symbols = static_cast(malloc(sizeof(signed int) * d_symbols_per_preamble)); + d_preambles_symbols = static_cast(volk_gnsssdr_malloc(d_symbols_per_preamble * sizeof(int), volk_gnsssdr_get_alignment())); int n = 0; for (int i = 0; i < GALILEO_INAV_PREAMBLE_LENGTH_BITS; i++) { @@ -153,12 +124,28 @@ galileo_e1b_telemetry_decoder_cc::galileo_e1b_telemetry_decoder_cc( d_flag_preamble = false; d_channel = 0; flag_TOW_set = false; + + // vars for Viterbi decoder + int max_states = 1 << mm; /* 2^mm */ + g_encoder[0] = 121; // Polynomial G1 + g_encoder[1] = 91; // Polynomial G2 + out0 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment())); + out1 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment())); + state0 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment())); + state1 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment())); + /* create appropriate transition matrices */ + nsc_transit(out0, state0, 0, g_encoder, KK, nn); + nsc_transit(out1, state1, 1, g_encoder, KK, nn); } galileo_e1b_telemetry_decoder_cc::~galileo_e1b_telemetry_decoder_cc() { - delete d_preambles_symbols; + volk_gnsssdr_free(d_preambles_symbols); + volk_gnsssdr_free(out0); + volk_gnsssdr_free(out1); + volk_gnsssdr_free(state0); + volk_gnsssdr_free(state1); if (d_dump_file.is_open() == true) { try @@ -213,13 +200,13 @@ void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols, in d_nav.split_page(page_String, flag_even_word_arrived); if (d_nav.flag_CRC_test == true) { - LOG(INFO) << "Galileo E1 CRC correct on channel " << d_channel << " from satellite " << d_satellite; + LOG(INFO) << "Galileo E1 CRC correct in channel " << d_channel << " from satellite " << d_satellite; //std::cout << "Galileo E1 CRC correct on channel " << d_channel << " from satellite " << d_satellite << std::endl; } else { - std::cout << "Galileo E1 CRC error on channel " << d_channel << " from satellite " << d_satellite << std::endl; - LOG(INFO) << "Galileo E1 CRC error on channel " << d_channel << " from satellite " << d_satellite; + std::cout << "Galileo E1 CRC error in channel " << d_channel << " from satellite " << d_satellite << std::endl; + LOG(INFO) << "Galileo E1 CRC error in channel " << d_channel << " from satellite " << d_satellite; } flag_even_word_arrived = 0; } @@ -235,21 +222,21 @@ void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols, in { // get object for this SV (mandatory) std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); - std::cout << "New Galileo E1 I/NAV message received: ephemeris from satellite " << d_satellite << std::endl; + std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << std::endl; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } if (d_nav.have_new_iono_and_GST() == true) { // get object for this SV (mandatory) std::shared_ptr tmp_obj = std::make_shared(d_nav.get_iono()); - std::cout << "New Galileo E1 I/NAV message received: iono/GST model parameters from satellite " << d_satellite << std::endl; + std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": iono/GST model parameters from satellite " << d_satellite << std::endl; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } if (d_nav.have_new_utc_model() == true) { // get object for this SV (mandatory) std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); - std::cout << "New Galileo E1 I/NAV message received: UTC model parameters from satellite " << d_satellite << std::endl; + std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << std::endl; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } if (d_nav.have_new_almanac() == true) @@ -257,7 +244,7 @@ void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols, in std::shared_ptr tmp_obj = std::make_shared(d_nav.get_almanac()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); //debug - std::cout << "Galileo E1 I/NAV almanac received!" << std::endl; + std::cout << "Galileo E1 I/NAV almanac received in channel " << d_channel << " from satellite " << d_satellite << std::endl; DLOG(INFO) << "GPS_to_Galileo time conversion:"; DLOG(INFO) << "A0G=" << tmp_obj->A_0G_10; DLOG(INFO) << "A1G=" << tmp_obj->A_1G_10; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.h index 33900b7d1..6caf0aa6c 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.h @@ -112,6 +112,15 @@ private: std::string d_dump_filename; std::ofstream d_dump_file; + + // vars for Viterbi decoder + int *out0, *out1, *state0, *state1; + int g_encoder[2]; + const int nn = 2; // Coding rate 1/n + const int KK = 7; // Constraint Length + int mm = KK - 1; + const int CodeLength = 240; + int DataLength = (CodeLength / nn) - mm; }; #endif diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc index c828fb859..647647698 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc @@ -37,9 +37,11 @@ #include "galileo_e5a_telemetry_decoder_cc.h" #include "control_message_factory.h" #include "convolutional.h" +#include "display.h" #include #include #include +#include #include #include @@ -58,42 +60,8 @@ galileo_e5a_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump void galileo_e5a_telemetry_decoder_cc::viterbi_decoder(double *page_part_symbols, int *page_part_bits) { - // int CodeLength = 240; - int CodeLength = 488; - int DataLength; - int nn, KK, mm, max_states; - int g_encoder[2]; - - nn = 2; // Coding rate 1/n - KK = 7; // Constraint Length - g_encoder[0] = 121; // Polynomial G1 - g_encoder[1] = 91; // Polynomial G2 - // g_encoder[0] = 171; // Polynomial G1 - // g_encoder[1] = 133; // Polynomial G2 - - mm = KK - 1; - max_states = 1 << mm; // 2^mm - DataLength = (CodeLength / nn) - mm; - - //create appropriate transition matrices - - int *out0, *out1, *state0, *state1; - out0 = static_cast(calloc(max_states, sizeof(int))); - out1 = static_cast(calloc(max_states, sizeof(int))); - state0 = static_cast(calloc(max_states, sizeof(int))); - state1 = static_cast(calloc(max_states, sizeof(int))); - - nsc_transit(out0, state0, 0, g_encoder, KK, nn); - nsc_transit(out1, state1, 1, g_encoder, KK, nn); - Viterbi(page_part_bits, out0, state0, out1, state1, page_part_symbols, KK, nn, DataLength); - - //Clean up memory - free(out0); - free(out1); - free(state0); - free(state1); } @@ -147,32 +115,32 @@ void galileo_e5a_telemetry_decoder_cc::decode_word(double *page_symbols, int fra d_nav.split_page(page_String); if (d_nav.flag_CRC_test == true) { - LOG(INFO) << "Galileo E5a CRC correct on channel " << d_channel << " from satellite " << d_satellite; + LOG(INFO) << "Galileo E5a CRC correct in channel " << d_channel << " from satellite " << d_satellite; //std::cout << "Galileo E5a CRC correct on channel " << d_channel << " from satellite " << d_satellite << std::endl; } else { - std::cout << "Galileo E5a CRC error on channel " << d_channel << " from satellite " << d_satellite << std::endl; - LOG(INFO) << "Galileo E5a CRC error on channel " << d_channel << " from satellite " << d_satellite; + std::cout << "Galileo E5a CRC error in channel " << d_channel << " from satellite " << d_satellite << std::endl; + LOG(INFO) << "Galileo E5a CRC error in channel " << d_channel << " from satellite " << d_satellite; } // 4. Push the new navigation data to the queues if (d_nav.have_new_ephemeris() == true) { std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); - std::cout << "New Galileo E5a F/NAV message received: ephemeris from satellite " << d_satellite << std::endl; + std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << TEXT_RESET << std::endl; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } if (d_nav.have_new_iono_and_GST() == true) { std::shared_ptr tmp_obj = std::make_shared(d_nav.get_iono()); - std::cout << "New Galileo E5a F/NAV message received: iono/GST model parameters from satellite " << d_satellite << std::endl; + std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": iono/GST model parameters from satellite " << d_satellite << TEXT_RESET << std::endl; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } if (d_nav.have_new_utc_model() == true) { std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); - std::cout << "New Galileo E5a F/NAV message received: UTC model parameters from satellite " << d_satellite << std::endl; + std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << TEXT_RESET << std::endl; this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } } @@ -226,11 +194,27 @@ galileo_e5a_telemetry_decoder_cc::galileo_e5a_telemetry_decoder_cc( flag_bit_start = false; new_symbol = false; required_symbols = GALILEO_FNAV_SYMBOLS_PER_PAGE + GALILEO_FNAV_PREAMBLE_LENGTH_BITS; + + // vars for Viterbi decoder + int max_states = 1 << mm; /* 2^mm */ + g_encoder[0] = 121; // Polynomial G1 + g_encoder[1] = 91; // Polynomial G2 + out0 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment())); + out1 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment())); + state0 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment())); + state1 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment())); + /* create appropriate transition matrices */ + nsc_transit(out0, state0, 0, g_encoder, KK, nn); + nsc_transit(out1, state1, 1, g_encoder, KK, nn); } galileo_e5a_telemetry_decoder_cc::~galileo_e5a_telemetry_decoder_cc() { + volk_gnsssdr_free(out0); + volk_gnsssdr_free(out1); + volk_gnsssdr_free(state0); + volk_gnsssdr_free(state1); if (d_dump_file.is_open() == true) { try diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.h index 5579f701a..5c004f18b 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.h @@ -112,6 +112,15 @@ private: Gnss_Satellite d_satellite; // navigation message vars Galileo_Fnav_Message d_nav; + + // vars for Viterbi decoder + int *out0, *out1, *state0, *state1; + int g_encoder[2]; + const int nn = 2; // Coding rate 1/n + const int KK = 7; // Constraint Length + int mm = KK - 1; + const int CodeLength = 488; + int DataLength = (CodeLength / nn) - mm; }; #endif /* GNSS_SDR_GALILEO_E5A_TELEMETRY_DECODER_CC_H_ */ From 2c972b517b9652a5ad5818453f5c7bd33b7744a6 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 23 Apr 2018 07:53:47 +0200 Subject: [PATCH 43/44] Display info when decoding GNAV messages --- .../glonass_l1_ca_telemetry_decoder_cc.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc index 09429a7e1..a99daba1e 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc @@ -181,11 +181,11 @@ void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in // 3. Check operation executed correctly if (d_nav.flag_CRC_test == true) { - LOG(INFO) << "GLONASS GNAV CRC correct on channel " << d_channel << " from satellite " << d_satellite; + LOG(INFO) << "GLONASS GNAV CRC correct in channel " << d_channel << " from satellite " << d_satellite; } else { - LOG(INFO) << "GLONASS GNAV CRC error on channel " << d_channel << " from satellite " << d_satellite; + LOG(INFO) << "GLONASS GNAV CRC error in channel " << d_channel << " from satellite " << d_satellite; } // 4. Push the new navigation data to the queues if (d_nav.have_new_ephemeris() == true) @@ -194,26 +194,29 @@ void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in d_nav.gnav_ephemeris.i_satellite_freq_channel = d_satellite.get_rf_link(); std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - LOG(INFO) << "GLONASS GNAV Ephemeris have been received on channel" << d_channel << " from satellite " << d_satellite; + LOG(INFO) << "GLONASS GNAV Ephemeris have been received in channel" << d_channel << " from satellite " << d_satellite; + std::cout << "New GLONASS L1 GNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << std::endl; } if (d_nav.have_new_utc_model() == true) { // get object for this SV (mandatory) 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)); - LOG(INFO) << "GLONASS GNAV UTC Model have been received on channel" << d_channel << " from satellite " << d_satellite; + LOG(INFO) << "GLONASS GNAV UTC Model have been received in channel" << d_channel << " from satellite " << d_satellite; + std::cout << "New GLONASS L1 GNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << std::endl; } if (d_nav.have_new_almanac() == true) { unsigned int slot_nbr = d_nav.i_alm_satellite_slot_number; std::shared_ptr tmp_obj = std::make_shared(d_nav.get_almanac(slot_nbr)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - LOG(INFO) << "GLONASS GNAV Almanac have been received on channel" << d_channel << " in slot number " << slot_nbr; + LOG(INFO) << "GLONASS GNAV Almanac have been received in channel" << d_channel << " in slot number " << slot_nbr; + std::cout << "New GLONASS L1 GNAV almanac received in channel " << d_channel << " from satellite " << d_satellite << std::endl; } // 5. Update satellite information on system if (d_nav.flag_update_slot_number == true) { - LOG(INFO) << "GLONASS GNAV Slot Number Identified on channel " << d_channel; + LOG(INFO) << "GLONASS GNAV Slot Number Identified in channel " << d_channel; d_satellite.update_PRN(d_nav.gnav_ephemeris.d_n); d_satellite.what_block(d_satellite.get_system(), d_nav.gnav_ephemeris.d_n); d_nav.flag_update_slot_number = false; From c0375c99ff1d0af815f61651dd489596dc2aa594 Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Mon, 23 Apr 2018 12:37:43 +0200 Subject: [PATCH 44/44] Adding GPS L1 C/A CN0 control in GPS DLL/PLL unit test --- .../gps_l1_ca_dll_pll_tracking_test.cc | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc index 89f70f914..0d0bf4cf0 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc @@ -54,7 +54,8 @@ #include "test_flags.h" DEFINE_bool(plot_gps_l1_tracking_test, false, "Plots results of GpsL1CADllPllTrackingTest with gnuplot"); - +DEFINE_double(CN0_dBHz, std::numeric_limits::infinity(), "Enable noise generator and set the CN0 [dB-Hz]"); +DEFINE_int32(extend_correlation_symbols, 1, "Set the tracking coherent correlation to N symbols (up to 20 for GPS L1 C/A)"); // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GpsL1CADllPllTrackingTest_msg_rx; @@ -121,7 +122,7 @@ public: std::string p3; std::string p4; std::string p5; - + std::string p6; std::string implementation = "GPS_L1_CA_DLL_PLL_Tracking"; //"GPS_L1_CA_DLL_PLL_C_Aid_Tracking"; const int baseband_sampling_freq = FLAGS_fs_gen_sps; @@ -183,6 +184,7 @@ int GpsL1CADllPllTrackingTest::configure_generator() p3 = std::string("-rinex_obs_file=") + FLAGS_filename_rinex_obs; // RINEX 2.10 observation file output p4 = std::string("-sig_out_file=") + FLAGS_filename_raw_data; // Baseband signal output file. Will be stored in int8_t IQ multiplexed samples p5 = std::string("-sampling_freq=") + std::to_string(baseband_sampling_freq); //Baseband sampling frequency [MSps] + p6 = std::string("-CN0_dBHz=") + std::to_string(FLAGS_CN0_dBHz); // Signal generator CN0 return 0; } @@ -191,7 +193,7 @@ int GpsL1CADllPllTrackingTest::generate_signal() { int child_status; - char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], NULL}; + char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0],&p6[0], NULL}; int pid; if ((pid = fork()) == -1) @@ -223,12 +225,12 @@ void GpsL1CADllPllTrackingTest::configure_receiver() config->set_property("Tracking_1C.implementation", implementation); config->set_property("Tracking_1C.item_type", "gr_complex"); config->set_property("Tracking_1C.pll_bw_hz", "20.0"); - config->set_property("Tracking_1C.dll_bw_hz", "2.0"); + config->set_property("Tracking_1C.dll_bw_hz", "1.5"); config->set_property("Tracking_1C.early_late_space_chips", "0.5"); - config->set_property("Tracking_1C.pll_bw_narrow_hz", "20.0"); - config->set_property("Tracking_1C.dll_bw_narrow_hz", "2.0"); + config->set_property("Tracking_1C.extend_correlation_symbols", std::to_string(FLAGS_extend_correlation_symbols)); + config->set_property("Tracking_1C.pll_bw_narrow_hz", "2.0"); + config->set_property("Tracking_1C.dll_bw_narrow_hz", "1.0"); config->set_property("Tracking_1C.early_late_space_narrow_chips", "0.5"); - config->set_property("Tracking_1C.extend_correlation_ms", "1"); config->set_property("Tracking_1C.dump", "true"); config->set_property("Tracking_1C.dump_filename", "./tracking_ch_"); } @@ -471,6 +473,7 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults) std::vector late; std::vector promptI; std::vector promptQ; + std::vector CN0_dBHz; epoch_counter = 0; while (trk_dump.read_binary_obs()) @@ -488,6 +491,7 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults) late.push_back(trk_dump.abs_L); promptI.push_back(trk_dump.prompt_I); promptQ.push_back(trk_dump.prompt_Q); + CN0_dBHz.push_back(trk_dump.CN0_SNV_dB_Hz); } // Align initial measurements and cut the tracking pull-in transitory @@ -555,6 +559,17 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults) g2.savetops("Constellation"); g2.savetopdf("Constellation", 18); g2.showonscreen(); // window output + + Gnuplot g3("linespoints"); + g3.set_title("GPS L1 C/A tracking CN0 output (satellite PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Reported CN0 [dB-Hz]"); + g3.cmd("set key box opaque"); + g3.plot_xy(timevec, CN0_dBHz, "Prompt", decimate); + g3.savetops("CN0_output"); + g3.savetopdf("CN0_output", 18); + g3.showonscreen(); // window output } catch (const GnuplotException& ge) {