diff --git a/src/algorithms/input_filter/gnuradio_blocks/notch_cc.cc b/src/algorithms/input_filter/gnuradio_blocks/notch_cc.cc index 5e7870cd4..d7cc09c33 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/notch_cc.cc +++ b/src/algorithms/input_filter/gnuradio_blocks/notch_cc.cc @@ -39,7 +39,7 @@ using google::LogMessage; notch_sptr make_notch_filter(float pfa, float p_c_factor, - int length_, int n_segments_est, int n_segments_reset) + int32_t length_, int32_t n_segments_est, int32_t n_segments_reset) { return notch_sptr(new Notch(pfa, p_c_factor, length_, n_segments_est, n_segments_reset)); } @@ -47,31 +47,31 @@ notch_sptr make_notch_filter(float pfa, float p_c_factor, Notch::Notch(float pfa, float p_c_factor, - int length_, - int n_segments_est, - int n_segments_reset) : gr::block("Notch", - gr::io_signature::make(1, 1, sizeof(gr_complex)), - gr::io_signature::make(1, 1, sizeof(gr_complex))) + int32_t length_, + int32_t n_segments_est, + int32_t n_segments_reset) : gr::block("Notch", + gr::io_signature::make(1, 1, sizeof(gr_complex)), + gr::io_signature::make(1, 1, sizeof(gr_complex))) { - const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex); + const int32_t alignment_multiple = volk_get_alignment() / sizeof(gr_complex); set_alignment(std::max(1, alignment_multiple)); set_history(2); this->pfa = pfa; noise_pow_est = 0.0; - this->p_c_factor = gr_complex(p_c_factor, 0); - this->length_ = length_; //Set the number of samples per segment - filter_state_ = false; //Initial state of the filter - n_deg_fred = 2 * length_; //Number of dregrees of freedom + this->p_c_factor = gr_complex(p_c_factor, 0.0); + this->length_ = length_; // Set the number of samples per segment + filter_state_ = false; // Initial state of the filter + n_deg_fred = 2 * length_; // Number of dregrees of freedom n_segments = 0; this->n_segments_est = n_segments_est; // Set the number of segments for noise power estimation this->n_segments_reset = n_segments_reset; // Set the period (in segments) when the noise power is estimated - z_0 = gr_complex(0, 0); + z_0 = gr_complex(0.0, 0.0); boost::math::chi_squared_distribution my_dist_(n_deg_fred); thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa)); c_samples = static_cast(volk_malloc(length_ * sizeof(gr_complex), volk_get_alignment())); angle_ = static_cast(volk_malloc(length_ * sizeof(float), volk_get_alignment())); power_spect = static_cast(volk_malloc(length_ * sizeof(float), volk_get_alignment())); - last_out = gr_complex(0, 0); + last_out = gr_complex(0.0, 0.0); d_fft = std::unique_ptr(new gr::fft::fft_complex(length_, true)); } @@ -86,7 +86,7 @@ Notch::~Notch() void Notch::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required) { - for (unsigned int aux = 0; aux < ninput_items_required.size(); aux++) + for (uint32_t aux = 0; aux < ninput_items_required.size(); aux++) { ninput_items_required[aux] = length_; } @@ -96,7 +96,7 @@ void Notch::forecast(int noutput_items __attribute__((unused)), gr_vector_int &n int Notch::general_work(int noutput_items, gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - int index_out = 0; + int32_t index_out = 0; float sig2dB = 0.0; float sig2lin = 0.0; lv_32fc_t dot_prod_; @@ -127,7 +127,7 @@ int Notch::general_work(int noutput_items, gr_vector_int &ninput_items __attribu } volk_32fc_x2_multiply_conjugate_32fc(c_samples, in, (in - 1), length_); volk_32fc_s32f_atan2_32f(angle_, c_samples, static_cast(1.0), length_); - for (int aux = 0; aux < length_; aux++) + for (int32_t aux = 0; aux < length_; aux++) { z_0 = std::exp(gr_complex(0, 1) * (*(angle_ + aux))); *(out + aux) = *(in + aux) - z_0 * (*(in + aux - 1)) + p_c_factor * z_0 * last_out; diff --git a/src/algorithms/input_filter/gnuradio_blocks/notch_cc.h b/src/algorithms/input_filter/gnuradio_blocks/notch_cc.h index 160494346..ab8f3b693 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/notch_cc.h +++ b/src/algorithms/input_filter/gnuradio_blocks/notch_cc.h @@ -34,6 +34,7 @@ #include #include #include +#include #include class Notch; @@ -41,7 +42,7 @@ class Notch; typedef boost::shared_ptr notch_sptr; notch_sptr make_notch_filter(float pfa, float p_c_factor, - int length_, int n_segments_est, int n_segments_reset); + int32_t length_, int32_t n_segments_est, int32_t n_segments_reset); /*! * \brief This class implements a real-time software-defined multi state notch filter @@ -53,11 +54,11 @@ private: float pfa; float noise_pow_est; float thres_; - int length_; - int n_deg_fred; - unsigned int n_segments; - unsigned int n_segments_est; - unsigned int n_segments_reset; + int32_t length_; + int32_t n_deg_fred; + uint32_t n_segments; + uint32_t n_segments_est; + uint32_t n_segments_reset; bool filter_state_; gr_complex last_out; gr_complex z_0; @@ -68,7 +69,7 @@ private: std::unique_ptr d_fft; public: - Notch(float pfa, float p_c_factor, int length_, int n_segments_est, int n_segments_reset); + Notch(float pfa, float p_c_factor, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset); ~Notch(); diff --git a/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.cc b/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.cc index 41d684a2a..435b36470 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.cc +++ b/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.cc @@ -38,7 +38,7 @@ using google::LogMessage; -notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int length_, int n_segments_est, int n_segments_reset, int n_segments_coeff) +notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff) { return notch_lite_sptr(new NotchLite(p_c_factor, pfa, length_, n_segments_est, n_segments_reset, n_segments_coeff)); } @@ -46,17 +46,17 @@ notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int length_, NotchLite::NotchLite(float p_c_factor, float pfa, - int length_, - int n_segments_est, - int n_segments_reset, - int n_segments_coeff) : gr::block("NotchLite", - gr::io_signature::make(1, 1, sizeof(gr_complex)), - gr::io_signature::make(1, 1, sizeof(gr_complex))) + int32_t length_, + int32_t n_segments_est, + int32_t n_segments_reset, + int32_t n_segments_coeff) : gr::block("NotchLite", + gr::io_signature::make(1, 1, sizeof(gr_complex)), + gr::io_signature::make(1, 1, sizeof(gr_complex))) { - const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex); + const int32_t alignment_multiple = volk_get_alignment() / sizeof(gr_complex); set_alignment(std::max(1, alignment_multiple)); set_history(2); - this->p_c_factor = gr_complex(p_c_factor, 0); + this->p_c_factor = gr_complex(p_c_factor, 0.0); this->n_segments_est = n_segments_est; this->n_segments_reset = n_segments_reset; this->n_segments_coeff_reset = n_segments_coeff; @@ -68,12 +68,12 @@ NotchLite::NotchLite(float p_c_factor, n_deg_fred = 2 * length_; noise_pow_est = 0.0; filter_state_ = false; - z_0 = gr_complex(0, 0); - last_out = gr_complex(0, 0); + z_0 = gr_complex(0.0, 0.0); + last_out = gr_complex(0.0, 0.0); boost::math::chi_squared_distribution my_dist_(n_deg_fred); thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa)); - c_samples1 = gr_complex(0, 0); - c_samples2 = gr_complex(0, 0); + c_samples1 = gr_complex(0.0, 0.0); + c_samples2 = gr_complex(0.0, 0.0); angle1 = 0.0; angle2 = 0.0; power_spect = static_cast(volk_malloc(length_ * sizeof(float), volk_get_alignment())); @@ -89,7 +89,7 @@ NotchLite::~NotchLite() void NotchLite::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required) { - for (unsigned int aux = 0; aux < ninput_items_required.size(); aux++) + for (uint32_t aux = 0; aux < ninput_items_required.size(); aux++) { ninput_items_required[aux] = length_; } @@ -99,7 +99,7 @@ void NotchLite::forecast(int noutput_items __attribute__((unused)), gr_vector_in int NotchLite::general_work(int noutput_items, gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - int index_out = 0; + int32_t index_out = 0; float sig2dB = 0.0; float sig2lin = 0.0; lv_32fc_t dot_prod_; @@ -138,7 +138,7 @@ int NotchLite::general_work(int noutput_items, gr_vector_int &ninput_items __att float angle_ = (angle1 + angle2) / 2.0; z_0 = std::exp(gr_complex(0, 1) * angle_); } - for (int aux = 0; aux < length_; aux++) + for (int32_t aux = 0; aux < length_; aux++) { *(out + aux) = *(in + aux) - z_0 * (*(in + aux - 1)) + p_c_factor * z_0 * last_out; last_out = *(out + aux); diff --git a/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h b/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h index 531bedc13..c312c2b98 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h +++ b/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h @@ -34,13 +34,14 @@ #include #include #include +#include #include class NotchLite; typedef boost::shared_ptr notch_lite_sptr; -notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int length_, int n_segments_est, int n_segments_reset, int n_segments_coeff); +notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff); /*! * \brief This class implements a real-time software-defined multi state notch filter light version @@ -49,13 +50,13 @@ notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int length_, class NotchLite : public gr::block { private: - int length_; - int n_segments; - int n_segments_est; - int n_segments_reset; - int n_segments_coeff_reset; - int n_segments_coeff; - int n_deg_fred; + int32_t length_; + int32_t n_segments; + int32_t n_segments_est; + int32_t n_segments_reset; + int32_t n_segments_coeff_reset; + int32_t n_segments_coeff; + int32_t n_deg_fred; float pfa; float thres_; float noise_pow_est; @@ -71,7 +72,7 @@ private: std::unique_ptr d_fft; public: - NotchLite(float p_c_factor, float pfa, int length_, int n_segments_est, int n_segments_reset, int n_segments_coeff); + NotchLite(float p_c_factor, float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff); ~NotchLite(); diff --git a/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.cc b/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.cc index 4a65097d0..ea1232c30 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.cc +++ b/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.cc @@ -37,21 +37,21 @@ using google::LogMessage; -pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int length_, - int n_segments_est, int n_segments_reset) +pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int32_t length_, + int32_t n_segments_est, int32_t n_segments_reset) { return pulse_blanking_cc_sptr(new pulse_blanking_cc(pfa, length_, n_segments_est, n_segments_reset)); } pulse_blanking_cc::pulse_blanking_cc(float pfa, - int length_, - int n_segments_est, - int n_segments_reset) : gr::block("pulse_blanking_cc", - gr::io_signature::make(1, 1, sizeof(gr_complex)), - gr::io_signature::make(1, 1, sizeof(gr_complex))) + int32_t length_, + int32_t n_segments_est, + int32_t n_segments_reset) : gr::block("pulse_blanking_cc", + gr::io_signature::make(1, 1, sizeof(gr_complex)), + gr::io_signature::make(1, 1, sizeof(gr_complex))) { - const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex); + const int32_t alignment_multiple = volk_get_alignment() / sizeof(gr_complex); set_alignment(std::max(1, alignment_multiple)); this->pfa = pfa; this->length_ = length_; @@ -64,9 +64,9 @@ pulse_blanking_cc::pulse_blanking_cc(float pfa, boost::math::chi_squared_distribution my_dist_(n_deg_fred); thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa)); zeros_ = static_cast(volk_malloc(length_ * sizeof(gr_complex), volk_get_alignment())); - for (int aux = 0; aux < length_; aux++) + for (int32_t aux = 0; aux < length_; aux++) { - zeros_[aux] = gr_complex(0, 0); + zeros_[aux] = gr_complex(0.0, 0.0); } } @@ -79,7 +79,7 @@ pulse_blanking_cc::~pulse_blanking_cc() void pulse_blanking_cc::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required) { - for (unsigned int aux = 0; aux < ninput_items_required.size(); aux++) + for (uint32_t aux = 0; aux < ninput_items_required.size(); aux++) { ninput_items_required[aux] = length_; } @@ -93,7 +93,7 @@ int pulse_blanking_cc::general_work(int noutput_items, gr_vector_int &ninput_ite gr_complex *out = reinterpret_cast(output_items[0]); float *magnitude = static_cast(volk_malloc(noutput_items * sizeof(float), volk_get_alignment())); volk_32fc_magnitude_squared_32f(magnitude, in, noutput_items); - int sample_index = 0; + int32_t sample_index = 0; float segment_energy; while ((sample_index + length_) < noutput_items) { diff --git a/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.h b/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.h index 62e8ee0a7..4d0f72f00 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.h +++ b/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.h @@ -33,22 +33,23 @@ #include #include +#include class pulse_blanking_cc; typedef boost::shared_ptr pulse_blanking_cc_sptr; -pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int length_, int n_segments_est, int n_segments_reset); +pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset); class pulse_blanking_cc : public gr::block { private: - int length_; - int n_segments; - int n_segments_est; - int n_segments_reset; - int n_deg_fred; + int32_t length_; + int32_t n_segments; + int32_t n_segments_est; + int32_t n_segments_reset; + int32_t n_deg_fred; bool last_filtered; float noise_power_estimation; float thres_; @@ -56,7 +57,7 @@ private: gr_complex *zeros_; public: - pulse_blanking_cc(float pfa, int length_, int n_segments_est, int n_segments_reset); + pulse_blanking_cc(float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset); ~pulse_blanking_cc(); 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 6b6e76a2a..fa6de2de2 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 @@ -53,18 +53,18 @@ 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) +void galileo_e1b_telemetry_decoder_cc::viterbi_decoder(double *page_part_symbols, int32_t *page_part_bits) { Viterbi(page_part_bits, out0, state0, out1, state1, page_part_symbols, KK, nn, DataLength); } -void galileo_e1b_telemetry_decoder_cc::deinterleaver(int rows, int cols, double *in, double *out) +void galileo_e1b_telemetry_decoder_cc::deinterleaver(int32_t rows, int32_t cols, double *in, double *out) { - for (int r = 0; r < rows; r++) + for (int32_t r = 0; r < rows; r++) { - for (int c = 0; c < cols; c++) + for (int32_t c = 0; c < cols; c++) { out[c * rows + r] = in[r * cols + c]; } @@ -86,18 +86,18 @@ galileo_e1b_telemetry_decoder_cc::galileo_e1b_telemetry_decoder_cc( d_samples_per_symbol = (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS) / Galileo_E1_B_SYMBOL_RATE_BPS; // set the preamble - unsigned short int preambles_bits[GALILEO_INAV_PREAMBLE_LENGTH_BITS] = GALILEO_INAV_PREAMBLE; + uint16_t preambles_bits[GALILEO_INAV_PREAMBLE_LENGTH_BITS] = GALILEO_INAV_PREAMBLE; d_symbols_per_preamble = GALILEO_INAV_PREAMBLE_LENGTH_BITS * d_samples_per_symbol; - memcpy(static_cast(this->d_preambles_bits), static_cast(preambles_bits), GALILEO_INAV_PREAMBLE_LENGTH_BITS * sizeof(unsigned short int)); + memcpy(static_cast(this->d_preambles_bits), static_cast(preambles_bits), GALILEO_INAV_PREAMBLE_LENGTH_BITS * sizeof(uint16_t)); // preamble bits to sampled symbols - 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++) + d_preambles_symbols = static_cast(volk_gnsssdr_malloc(d_symbols_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment())); + int32_t n = 0; + for (int32_t i = 0; i < GALILEO_INAV_PREAMBLE_LENGTH_BITS; i++) { - for (unsigned int j = 0; j < d_samples_per_symbol; j++) + for (uint32_t j = 0; j < d_samples_per_symbol; j++) { if (d_preambles_bits[i] == 1) { @@ -110,9 +110,9 @@ galileo_e1b_telemetry_decoder_cc::galileo_e1b_telemetry_decoder_cc( n++; } } - d_sample_counter = 0; + d_sample_counter = 0ULL; d_stat = 0; - d_preamble_index = 0; + d_preamble_index = 0ULL; d_flag_frame_sync = false; @@ -127,14 +127,14 @@ galileo_e1b_telemetry_decoder_cc::galileo_e1b_telemetry_decoder_cc( 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 */ + int32_t 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(int32_t), volk_gnsssdr_get_alignment())); + out1 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment())); + state0 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment())); + state1 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int32_t), 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); } @@ -161,7 +161,7 @@ galileo_e1b_telemetry_decoder_cc::~galileo_e1b_telemetry_decoder_cc() } -void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols, int frame_length) +void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols, int32_t frame_length) { double page_part_symbols_deint[frame_length]; // 1. De-interleave @@ -169,8 +169,8 @@ void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols, in // 2. Viterbi decoder // 2.1 Take into account the NOT gate in G2 polynomial (Galileo ICD Figure 13, FEC encoder) - // 2.2 Take into account the possible inversion of the polarity due to PLL lock at 180� - for (int i = 0; i < frame_length; i++) + // 2.2 Take into account the possible inversion of the polarity due to PLL lock at 180º + for (int32_t i = 0; i < frame_length; i++) { if ((i + 1) % 2 == 0) { @@ -178,12 +178,12 @@ void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols, in } } - int page_part_bits[frame_length / 2]; + int32_t page_part_bits[frame_length / 2]; viterbi_decoder(page_part_symbols_deint, page_part_bits); // 3. Call the Galileo page decoder std::string page_String; - for (int i = 0; i < (frame_length / 2); i++) + for (int32_t i = 0; i < (frame_length / 2); i++) { if (page_part_bits[i] > 0) { @@ -268,7 +268,7 @@ void galileo_e1b_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satel } -void galileo_e1b_telemetry_decoder_cc::set_channel(int channel) +void galileo_e1b_telemetry_decoder_cc::set_channel(int32_t channel) { d_channel = channel; LOG(INFO) << "Navigation channel set to " << channel; @@ -298,8 +298,8 @@ void galileo_e1b_telemetry_decoder_cc::set_channel(int channel) 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) { - int corr_value = 0; - int preamble_diff = 0; + int32_t corr_value = 0; + int32_t preamble_diff = 0; 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 @@ -312,13 +312,13 @@ int galileo_e1b_telemetry_decoder_cc::general_work(int noutput_items __attribute consume_each(1); d_flag_preamble = false; - unsigned int required_symbols = GALILEO_INAV_PAGE_SYMBOLS + d_symbols_per_preamble; + uint32_t required_symbols = GALILEO_INAV_PAGE_SYMBOLS + d_symbols_per_preamble; if (d_symbol_history.size() > required_symbols) { // TODO Optimize me! // ******* preamble correlation ******** - for (int i = 0; i < d_symbols_per_preamble; i++) + for (int32_t i = 0; i < d_symbols_per_preamble; i++) { if (d_symbol_history.at(i).Prompt_I < 0) // symbols clipping { @@ -346,7 +346,7 @@ int galileo_e1b_telemetry_decoder_cc::general_work(int noutput_items __attribute if (abs(corr_value) >= d_symbols_per_preamble) { // check preamble separation - preamble_diff = d_sample_counter - d_preamble_index; + preamble_diff = static_cast(d_sample_counter - d_preamble_index); if (abs(preamble_diff - GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS) == 0) { // try to decode frame @@ -365,14 +365,14 @@ int galileo_e1b_telemetry_decoder_cc::general_work(int noutput_items __attribute } else if (d_stat == 2) { - if (d_sample_counter == d_preamble_index + GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS) + if (d_sample_counter == d_preamble_index + static_cast(GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS)) { // NEW Galileo page part is received // 0. fetch the symbols into an array - int frame_length = GALILEO_INAV_PAGE_PART_SYMBOLS - d_symbols_per_preamble; + int32_t frame_length = GALILEO_INAV_PAGE_PART_SYMBOLS - d_symbols_per_preamble; double page_part_symbols[frame_length]; - for (int i = 0; i < frame_length; i++) + for (int32_t i = 0; i < frame_length; i++) { if (corr_value > 0) { @@ -423,7 +423,7 @@ int galileo_e1b_telemetry_decoder_cc::general_work(int noutput_items __attribute if (d_nav.flag_TOW_5 == true) // page 5 arrived and decoded, so we are in the odd page (since Tow refers to the even page, we have to add 1 sec) { // TOW_5 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later plus the decoding delay - d_TOW_at_Preamble_ms = static_cast(d_nav.TOW_5 * 1000.0); + d_TOW_at_Preamble_ms = static_cast(d_nav.TOW_5 * 1000.0); d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + GALILEO_INAV_PAGE_PART_MS + (required_symbols + 1) * GALILEO_E1_CODE_PERIOD_MS; d_nav.flag_TOW_5 = false; } @@ -431,7 +431,7 @@ int galileo_e1b_telemetry_decoder_cc::general_work(int noutput_items __attribute else if (d_nav.flag_TOW_6 == true) // page 6 arrived and decoded, so we are in the odd page (since Tow refers to the even page, we have to add 1 sec) { // TOW_6 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later plus the decoding delay - d_TOW_at_Preamble_ms = static_cast(d_nav.TOW_6 * 1000.0); + d_TOW_at_Preamble_ms = static_cast(d_nav.TOW_6 * 1000.0); d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + GALILEO_INAV_PAGE_PART_MS + (required_symbols + 1) * GALILEO_E1_CODE_PERIOD_MS; d_nav.flag_TOW_6 = false; } 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 061855994..663c365b2 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 @@ -61,8 +61,8 @@ class galileo_e1b_telemetry_decoder_cc : public gr::block public: ~galileo_e1b_telemetry_decoder_cc(); void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int channel); //!< Set receiver's channel - int flag_even_word_arrived; + void set_channel(int32_t channel); //!< Set receiver's channel + int32_t flag_even_word_arrived; /*! * \brief This is where all signal processing takes place @@ -75,38 +75,38 @@ private: galileo_e1b_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); galileo_e1b_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); - void viterbi_decoder(double *page_part_symbols, int *page_part_bits); + void viterbi_decoder(double *page_part_symbols, int32_t *page_part_bits); - void deinterleaver(int rows, int cols, double *in, double *out); + void deinterleaver(int32_t rows, int32_t cols, double *in, double *out); - void decode_word(double *symbols, int frame_length); + void decode_word(double *symbols, int32_t frame_length); - unsigned short int d_preambles_bits[GALILEO_INAV_PREAMBLE_LENGTH_BITS]; + uint16_t d_preambles_bits[GALILEO_INAV_PREAMBLE_LENGTH_BITS]; - int *d_preambles_symbols; - unsigned int d_samples_per_symbol; - int d_symbols_per_preamble; + int32_t *d_preambles_symbols; + uint32_t d_samples_per_symbol; + int32_t d_symbols_per_preamble; std::deque d_symbol_history; uint64_t d_sample_counter; uint64_t d_preamble_index; - unsigned int d_stat; + uint32_t d_stat; bool d_flag_frame_sync; bool d_flag_parity; bool d_flag_preamble; - int d_CRC_error_counter; + int32_t d_CRC_error_counter; // navigation message vars Galileo_Navigation_Message d_nav; bool d_dump; Gnss_Satellite d_satellite; - int d_channel; + int32_t d_channel; - unsigned int d_TOW_at_Preamble_ms; - unsigned int d_TOW_at_current_symbol_ms; + uint32_t d_TOW_at_Preamble_ms; + uint32_t d_TOW_at_current_symbol_ms; bool flag_TOW_set; double delta_t; //GPS-GALILEO time offset @@ -115,13 +115,13 @@ private: 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; + int32_t *out0, *out1, *state0, *state1; + int32_t g_encoder[2]; + const int32_t nn = 2; // Coding rate 1/n + const int32_t KK = 7; // Constraint Length + int32_t mm = KK - 1; + const int32_t CodeLength = 240; + int32_t 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 e9a96343b..ccf4ef5ef 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 @@ -58,18 +58,18 @@ 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) +void galileo_e5a_telemetry_decoder_cc::viterbi_decoder(double *page_part_symbols, int32_t *page_part_bits) { Viterbi(page_part_bits, out0, state0, out1, state1, page_part_symbols, KK, nn, DataLength); } -void galileo_e5a_telemetry_decoder_cc::deinterleaver(int rows, int cols, double *in, double *out) +void galileo_e5a_telemetry_decoder_cc::deinterleaver(int32_t rows, int32_t cols, double *in, double *out) { - for (int r = 0; r < rows; r++) + for (int32_t r = 0; r < rows; r++) { - for (int c = 0; c < cols; c++) + for (int32_t c = 0; c < cols; c++) { out[c * rows + r] = in[r * cols + c]; } @@ -77,7 +77,7 @@ void galileo_e5a_telemetry_decoder_cc::deinterleaver(int rows, int cols, double } -void galileo_e5a_telemetry_decoder_cc::decode_word(double *page_symbols, int frame_length) +void galileo_e5a_telemetry_decoder_cc::decode_word(double *page_symbols, int32_t frame_length) { double page_symbols_deint[frame_length]; // 1. De-interleave @@ -86,19 +86,19 @@ void galileo_e5a_telemetry_decoder_cc::decode_word(double *page_symbols, int fra // 2. Viterbi decoder // 2.1 Take into account the NOT gate in G2 polynomial (Galileo ICD Figure 13, FEC encoder) // 2.2 Take into account the possible inversion of the polarity due to PLL lock at 180� - for (int i = 0; i < frame_length; i++) + for (int32_t i = 0; i < frame_length; i++) { if ((i + 1) % 2 == 0) { page_symbols_deint[i] = -page_symbols_deint[i]; } } - int page_bits[frame_length / 2]; + int32_t page_bits[frame_length / 2]; viterbi_decoder(page_symbols_deint, page_bits); // 3. Call the Galileo page decoder std::string page_String; - for (int i = 0; i < frame_length; i++) + for (int32_t i = 0; i < frame_length; i++) { if (page_bits[i] > 0) { @@ -156,7 +156,7 @@ galileo_e5a_telemetry_decoder_cc::galileo_e5a_telemetry_decoder_cc( d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); // set the preamble - for (int i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++) + for (int32_t i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++) { if (GALILEO_FNAV_PREAMBLE.at(i) == '0') { @@ -167,19 +167,19 @@ galileo_e5a_telemetry_decoder_cc::galileo_e5a_telemetry_decoder_cc( d_preambles_bits[i] = -1; } } - for (int i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++) + for (int32_t i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++) { - for (int k = 0; k < GALILEO_FNAV_CODES_PER_SYMBOL; k++) + for (int32_t k = 0; k < GALILEO_FNAV_CODES_PER_SYMBOL; k++) { d_preamble_samples[(i * GALILEO_FNAV_CODES_PER_SYMBOL) + k] = d_preambles_bits[i]; } } - d_sample_counter = 0; + d_sample_counter = 0ULL; d_stat = 0; corr_value = 0; d_flag_preamble = false; - d_preamble_index = 0; + d_preamble_index = 0ULL; d_flag_frame_sync = false; d_TOW_at_current_symbol_ms = 0; d_TOW_at_Preamble_ms = 0; @@ -194,13 +194,13 @@ galileo_e5a_telemetry_decoder_cc::galileo_e5a_telemetry_decoder_cc( 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())); + int32_t 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(int32_t), volk_gnsssdr_get_alignment())); + out1 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment())); + state0 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment())); + state1 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int32_t), 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); @@ -235,7 +235,7 @@ void galileo_e5a_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satel } -void galileo_e5a_telemetry_decoder_cc::set_channel(int channel) +void galileo_e5a_telemetry_decoder_cc::set_channel(int32_t channel) { d_channel = channel; LOG(INFO) << "Navigation channel set to " << channel; @@ -265,7 +265,7 @@ void galileo_e5a_telemetry_decoder_cc::set_channel(int channel) 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) { - int preamble_diff = 0; + int32_t preamble_diff = 0; 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 @@ -298,8 +298,8 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute if (d_preamble_init.size() == GALILEO_FNAV_CODES_PER_PREAMBLE) { - std::deque::iterator iter; - int k = 0; + std::deque::iterator iter; + int32_t k = 0; corr_value = 0; for (iter = d_preamble_init.begin(); iter != d_preamble_init.end(); iter++) { @@ -330,7 +330,7 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute { // ****************** Preamble orrelation ****************** corr_value = 0; - for (int i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++) + for (int32_t i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++) { if (d_symbol_history.at(i).Prompt_I < 0.0) // symbols clipping { @@ -357,7 +357,7 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute if (abs(corr_value) == GALILEO_FNAV_PREAMBLE_LENGTH_BITS) { // check preamble separation - preamble_diff = d_sample_counter - d_preamble_index; + preamble_diff = static_cast(d_sample_counter - d_preamble_index); if (preamble_diff == GALILEO_FNAV_CODES_PER_PAGE) { // try to decode frame @@ -375,11 +375,11 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute } else if ((d_stat == 2) && new_symbol) { - if (d_sample_counter == (d_preamble_index + GALILEO_FNAV_CODES_PER_PAGE)) + if (d_sample_counter == (d_preamble_index + static_cast(GALILEO_FNAV_CODES_PER_PAGE))) { // NEW Galileo page part is received // 0. fetch the symbols into an array - int frame_length = GALILEO_FNAV_SYMBOLS_PER_PAGE - GALILEO_FNAV_PREAMBLE_LENGTH_BITS; + int32_t frame_length = GALILEO_FNAV_SYMBOLS_PER_PAGE - GALILEO_FNAV_PREAMBLE_LENGTH_BITS; double corr_sign = 0.0; if (corr_value > 0) { @@ -389,7 +389,7 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute { corr_sign = 1.0; } - for (int i = 0; i < frame_length; i++) + for (int32_t i = 0; i < frame_length; i++) { page_symbols[i] = corr_sign * d_symbol_history.at(i + GALILEO_FNAV_PREAMBLE_LENGTH_BITS).Prompt_I; // because last symbol of the preamble is just received now! } @@ -435,25 +435,25 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute { if (d_nav.flag_TOW_1 == true) { - d_TOW_at_Preamble_ms = static_cast(d_nav.FNAV_TOW_1 * 1000.0); + d_TOW_at_Preamble_ms = static_cast(d_nav.FNAV_TOW_1 * 1000.0); d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + (GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD_MS; d_nav.flag_TOW_1 = false; } else if (d_nav.flag_TOW_2 == true) { - d_TOW_at_Preamble_ms = static_cast(d_nav.FNAV_TOW_2 * 1000.0); + d_TOW_at_Preamble_ms = static_cast(d_nav.FNAV_TOW_2 * 1000.0); d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + (GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD_MS; d_nav.flag_TOW_2 = false; } else if (d_nav.flag_TOW_3 == true) { - d_TOW_at_Preamble_ms = static_cast(d_nav.FNAV_TOW_3 * 1000.0); + d_TOW_at_Preamble_ms = static_cast(d_nav.FNAV_TOW_3 * 1000.0); d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + (GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD_MS; d_nav.flag_TOW_3 = false; } else if (d_nav.flag_TOW_4 == true) { - d_TOW_at_Preamble_ms = static_cast(d_nav.FNAV_TOW_4 * 1000.0); + d_TOW_at_Preamble_ms = static_cast(d_nav.FNAV_TOW_4 * 1000.0); d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + (GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD_MS; d_nav.flag_TOW_4 = false; } 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 88f7b49fa..522f5777e 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 @@ -67,7 +67,7 @@ class galileo_e5a_telemetry_decoder_cc : public gr::block public: ~galileo_e5a_telemetry_decoder_cc(); void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int channel); //!< Set receiver's channel + void set_channel(int32_t channel); //!< Set receiver's channel /*! * \brief This is where all signal processing takes place */ @@ -79,21 +79,21 @@ private: galileo_e5a_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); galileo_e5a_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); - void viterbi_decoder(double *page_part_symbols, int *page_part_bits); + void viterbi_decoder(double *page_part_symbols, int32_t *page_part_bits); - void deinterleaver(int rows, int cols, double *in, double *out); + void deinterleaver(int32_t rows, int32_t cols, double *in, double *out); - void decode_word(double *page_symbols, int frame_length); + void decode_word(double *page_symbols, int32_t frame_length); - int d_preambles_bits[GALILEO_FNAV_PREAMBLE_LENGTH_BITS]; - int d_preamble_samples[GALILEO_FNAV_CODES_PER_PREAMBLE]; + int32_t d_preambles_bits[GALILEO_FNAV_PREAMBLE_LENGTH_BITS]; + int32_t d_preamble_samples[GALILEO_FNAV_CODES_PER_PREAMBLE]; std::deque d_preamble_init; - int d_stat; - int d_CRC_error_counter; - int d_channel; - int d_symbol_counter; - int corr_value; - unsigned int required_symbols; + int32_t d_stat; + int32_t d_CRC_error_counter; + int32_t d_channel; + int32_t d_symbol_counter; + int32_t corr_value; + uint32_t required_symbols; uint64_t d_sample_counter; uint64_t d_preamble_index; bool d_flag_frame_sync; @@ -104,8 +104,8 @@ private: bool new_symbol; double d_prompt_acum; double page_symbols[GALILEO_FNAV_SYMBOLS_PER_PAGE - GALILEO_FNAV_PREAMBLE_LENGTH_BITS]; - unsigned int d_TOW_at_Preamble_ms; - unsigned int d_TOW_at_current_symbol_ms; + uint32_t d_TOW_at_Preamble_ms; + uint32_t d_TOW_at_current_symbol_ms; double delta_t; //GPS-GALILEO time offset std::string d_dump_filename; std::ofstream d_dump_file; @@ -115,13 +115,13 @@ private: 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; + int32_t *out0, *out1, *state0, *state1; + int32_t g_encoder[2]; + const int32_t nn = 2; // Coding rate 1/n + const int32_t KK = 7; // Constraint Length + int32_t mm = KK - 1; + const int32_t CodeLength = 488; + int32_t DataLength = (CodeLength / nn) - mm; }; #endif /* GNSS_SDR_GALILEO_E5A_TELEMETRY_DECODER_CC_H_ */ 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 5244a0fed..49c40a082 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 @@ -65,18 +65,18 @@ glonass_l1_ca_telemetry_decoder_cc::glonass_l1_ca_telemetry_decoder_cc( d_samples_per_symbol = (GLONASS_L1_CA_CODE_RATE_HZ / GLONASS_L1_CA_CODE_LENGTH_CHIPS) / GLONASS_L1_CA_SYMBOL_RATE_BPS; // Set the preamble information - unsigned short int preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS] = GLONASS_GNAV_PREAMBLE; + uint16_t preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS] = GLONASS_GNAV_PREAMBLE; // Since preamble rate is different than navigation data rate we use a constant d_symbols_per_preamble = GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS; - memcpy(static_cast(this->d_preambles_bits), static_cast(preambles_bits), GLONASS_GNAV_PREAMBLE_LENGTH_BITS * sizeof(unsigned short int)); + memcpy(static_cast(this->d_preambles_bits), static_cast(preambles_bits), GLONASS_GNAV_PREAMBLE_LENGTH_BITS * sizeof(uint16_t)); // preamble bits to sampled symbols - d_preambles_symbols = static_cast(malloc(sizeof(signed int) * d_symbols_per_preamble)); - int n = 0; - for (int i = 0; i < GLONASS_GNAV_PREAMBLE_LENGTH_BITS; i++) + d_preambles_symbols = static_cast(malloc(sizeof(int32_t) * d_symbols_per_preamble)); + int32_t n = 0; + for (int32_t i = 0; i < GLONASS_GNAV_PREAMBLE_LENGTH_BITS; i++) { - for (unsigned int j = 0; j < GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT; j++) + for (uint32_t j = 0; j < GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT; j++) { if (d_preambles_bits[i] == 1) { @@ -89,9 +89,9 @@ glonass_l1_ca_telemetry_decoder_cc::glonass_l1_ca_telemetry_decoder_cc( n++; } } - d_sample_counter = 0; + d_sample_counter = 0ULL; d_stat = 0; - d_preamble_index = 0; + d_preamble_index = 0ULL; d_flag_frame_sync = false; @@ -124,10 +124,10 @@ glonass_l1_ca_telemetry_decoder_cc::~glonass_l1_ca_telemetry_decoder_cc() } -void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, int frame_length) +void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, int32_t frame_length) { double chip_acc = 0.0; - int chip_acc_counter = 0; + int32_t chip_acc_counter = 0; // 1. Transform from symbols to bits std::string bi_binary_code; @@ -135,7 +135,7 @@ void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in std::string data_bits; // Group samples into bi-binary code - for (int i = 0; i < (frame_length); i++) + for (int32_t i = 0; i < (frame_length); i++) { chip_acc += frame_symbols[i]; chip_acc_counter += 1; @@ -157,7 +157,7 @@ void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in } } // Convert from bi-binary code to relative code - for (int i = 0; i < (GLONASS_GNAV_STRING_BITS); i++) + for (int32_t i = 0; i < (GLONASS_GNAV_STRING_BITS); i++) { if (bi_binary_code[2 * i] == '1' && bi_binary_code[2 * i + 1] == '0') { @@ -170,7 +170,7 @@ void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in } // Convert from relative code to data bits data_bits.push_back('0'); - for (int i = 1; i < (GLONASS_GNAV_STRING_BITS); i++) + for (int32_t i = 1; i < (GLONASS_GNAV_STRING_BITS); i++) { data_bits.push_back(((relative_code[i - 1] - '0') ^ (relative_code[i] - '0')) + '0'); } @@ -207,7 +207,7 @@ void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in } if (d_nav.have_new_almanac() == true) { - unsigned int slot_nbr = d_nav.i_alm_satellite_slot_number; + uint32_t 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 in channel" << d_channel << " in slot number " << slot_nbr; @@ -232,7 +232,7 @@ void glonass_l1_ca_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &sat } -void glonass_l1_ca_telemetry_decoder_cc::set_channel(int channel) +void glonass_l1_ca_telemetry_decoder_cc::set_channel(int32_t channel) { d_channel = channel; LOG(INFO) << "Navigation channel set to " << channel; @@ -262,8 +262,8 @@ void glonass_l1_ca_telemetry_decoder_cc::set_channel(int channel) 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) { - int corr_value = 0; - int preamble_diff = 0; + int32_t corr_value = 0; + int32_t preamble_diff = 0; 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 @@ -276,12 +276,12 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu consume_each(1); d_flag_preamble = false; - unsigned int required_symbols = GLONASS_GNAV_STRING_SYMBOLS; + uint32_t required_symbols = GLONASS_GNAV_STRING_SYMBOLS; if (d_symbol_history.size() > required_symbols) { // ******* preamble correlation ******** - for (int i = 0; i < d_symbols_per_preamble; i++) + for (int32_t i = 0; i < d_symbols_per_preamble; i++) { if (d_symbol_history.at(i).Prompt_I < 0) // symbols clipping { @@ -312,9 +312,9 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu if (abs(corr_value) >= d_symbols_per_preamble) { // check preamble separation - preamble_diff = d_sample_counter - d_preamble_index; + preamble_diff = static_cast(d_sample_counter - d_preamble_index); // Record the PRN start sample index associated to the preamble - d_preamble_time_samples = d_symbol_history.at(0).Tracking_sample_counter; + d_preamble_time_samples = static_cast(d_symbol_history.at(0).Tracking_sample_counter); if (abs(preamble_diff - GLONASS_GNAV_PREAMBLE_PERIOD_SYMBOLS) == 0) { // try to decode frame @@ -335,15 +335,15 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu else if (d_stat == 2) { // FIXME: The preamble index marks the first symbol of the string count. Here I just wait for another full string to be received before processing - if (d_sample_counter == d_preamble_index + GLONASS_GNAV_STRING_SYMBOLS) + if (d_sample_counter == d_preamble_index + static_cast(GLONASS_GNAV_STRING_SYMBOLS)) { // NEW GLONASS string received // 0. fetch the symbols into an array - int string_length = GLONASS_GNAV_STRING_SYMBOLS - d_symbols_per_preamble; + int32_t string_length = GLONASS_GNAV_STRING_SYMBOLS - d_symbols_per_preamble; double string_symbols[GLONASS_GNAV_DATA_SYMBOLS] = {0}; // ******* SYMBOL TO BIT ******* - for (int i = 0; i < string_length; i++) + for (int32_t i = 0; i < string_length; i++) { if (corr_value > 0) { @@ -415,7 +415,7 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu current_symbol.PRN = this->d_satellite.get_PRN(); current_symbol.TOW_at_current_symbol_ms = round(d_TOW_at_current_symbol * 1000.0); // todo: glonass time to gps time should be done in observables block - // current_symbol.TOW_at_current_symbol_ms -= -= static_cast(delta_t) * 1000; // Galileo to GPS TOW + // current_symbol.TOW_at_current_symbol_ms -= -= static_cast(delta_t) * 1000; // Galileo to GPS TOW if (d_dump == true) { diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h index ff16a10d2..4c8e6b57b 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h @@ -63,7 +63,7 @@ class glonass_l1_ca_telemetry_decoder_cc : public gr::block public: ~glonass_l1_ca_telemetry_decoder_cc(); //!< Class destructor void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int channel); //!< Set receiver's channel + void set_channel(int32_t channel); //!< Set receiver's channel /*! * \brief This is where all signal processing takes place @@ -76,30 +76,30 @@ private: glonass_l1_ca_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); glonass_l1_ca_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); - void decode_string(double *symbols, int frame_length); + void decode_string(double *symbols, int32_t frame_length); //!< Help with coherent tracking double d_preamble_time_samples; //!< Preamble decoding - unsigned short int d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS]; - int *d_preambles_symbols; - unsigned int d_samples_per_symbol; - int d_symbols_per_preamble; + uint16_t d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS]; + int32_t *d_preambles_symbols; + uint32_t d_samples_per_symbol; + int32_t d_symbols_per_preamble; //!< Storage for incoming data std::deque d_symbol_history; //!< Variables for internal functionality - uint64_t d_sample_counter; //!< Sample counter as an index (1,2,3,..etc) indicating number of samples processed - uint64_t d_preamble_index; //!< Index of sample number where preamble was found - unsigned int d_stat; //!< Status of decoder - bool d_flag_frame_sync; //!< Indicate when a frame sync is achieved - bool d_flag_parity; //!< Flag indicating when parity check was achieved (crc check) - bool d_flag_preamble; //!< Flag indicating when preamble was found - int d_CRC_error_counter; //!< Number of failed CRC operations - bool flag_TOW_set; //!< Indicates when time of week is set - double delta_t; //!< GPS-GLONASS time offset + uint64_t d_sample_counter; //!< Sample counter as an index (1,2,3,..etc) indicating number of samples processed + uint64_t d_preamble_index; //!< Index of sample number where preamble was found + uint32_t d_stat; //!< Status of decoder + bool d_flag_frame_sync; //!< Indicate when a frame sync is achieved + bool d_flag_parity; //!< Flag indicating when parity check was achieved (crc check) + bool d_flag_preamble; //!< Flag indicating when preamble was found + int32_t d_CRC_error_counter; //!< Number of failed CRC operations + bool flag_TOW_set; //!< Indicates when time of week is set + double delta_t; //!< GPS-GLONASS time offset //!< Navigation Message variable Glonass_Gnav_Navigation_Message d_nav; @@ -110,7 +110,7 @@ private: //!< Satellite Information and logging capacity Gnss_Satellite d_satellite; - int d_channel; + int32_t d_channel; bool d_dump; std::string d_dump_filename; std::ofstream d_dump_file; 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 7e9f03258..29b4f14d3 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 @@ -65,18 +65,18 @@ glonass_l2_ca_telemetry_decoder_cc::glonass_l2_ca_telemetry_decoder_cc( d_samples_per_symbol = (GLONASS_L2_CA_CODE_RATE_HZ / GLONASS_L2_CA_CODE_LENGTH_CHIPS) / GLONASS_L2_CA_SYMBOL_RATE_BPS; // Set the preamble information - unsigned short int preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS] = GLONASS_GNAV_PREAMBLE; + uint16_t preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS] = GLONASS_GNAV_PREAMBLE; // Since preamble rate is different than navigation data rate we use a constant d_symbols_per_preamble = GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS; - memcpy(static_cast(this->d_preambles_bits), static_cast(preambles_bits), GLONASS_GNAV_PREAMBLE_LENGTH_BITS * sizeof(unsigned short int)); + memcpy(static_cast(this->d_preambles_bits), static_cast(preambles_bits), GLONASS_GNAV_PREAMBLE_LENGTH_BITS * sizeof(uint16_t)); // preamble bits to sampled symbols - d_preambles_symbols = static_cast(malloc(sizeof(signed int) * d_symbols_per_preamble)); - int n = 0; - for (int i = 0; i < GLONASS_GNAV_PREAMBLE_LENGTH_BITS; i++) + d_preambles_symbols = static_cast(malloc(sizeof(int32_t) * d_symbols_per_preamble)); + int32_t n = 0; + for (int32_t i = 0; i < GLONASS_GNAV_PREAMBLE_LENGTH_BITS; i++) { - for (unsigned int j = 0; j < GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT; j++) + for (uint32_t j = 0; j < GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT; j++) { if (d_preambles_bits[i] == 1) { @@ -89,9 +89,9 @@ glonass_l2_ca_telemetry_decoder_cc::glonass_l2_ca_telemetry_decoder_cc( n++; } } - d_sample_counter = 0; + d_sample_counter = 0ULL; d_stat = 0; - d_preamble_index = 0; + d_preamble_index = 0ULL; d_flag_frame_sync = false; @@ -124,10 +124,10 @@ glonass_l2_ca_telemetry_decoder_cc::~glonass_l2_ca_telemetry_decoder_cc() } -void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, int frame_length) +void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, int32_t frame_length) { double chip_acc = 0.0; - int chip_acc_counter = 0; + int32_t chip_acc_counter = 0; // 1. Transform from symbols to bits std::string bi_binary_code; @@ -135,7 +135,7 @@ void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in std::string data_bits; // Group samples into bi-binary code - for (int i = 0; i < (frame_length); i++) + for (int32_t i = 0; i < (frame_length); i++) { chip_acc += frame_symbols[i]; chip_acc_counter += 1; @@ -157,7 +157,7 @@ void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in } } // Convert from bi-binary code to relative code - for (int i = 0; i < (GLONASS_GNAV_STRING_BITS); i++) + for (int32_t i = 0; i < (GLONASS_GNAV_STRING_BITS); i++) { if (bi_binary_code[2 * i] == '1' && bi_binary_code[2 * i + 1] == '0') { @@ -170,7 +170,7 @@ void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in } // Convert from relative code to data bits data_bits.push_back('0'); - for (int i = 1; i < (GLONASS_GNAV_STRING_BITS); i++) + for (int32_t i = 1; i < (GLONASS_GNAV_STRING_BITS); i++) { data_bits.push_back(((relative_code[i - 1] - '0') ^ (relative_code[i] - '0')) + '0'); } @@ -207,7 +207,7 @@ void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in } if (d_nav.have_new_almanac() == true) { - unsigned int slot_nbr = d_nav.i_alm_satellite_slot_number; + uint32_t 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 in channel" << d_channel << " in slot number " << slot_nbr; @@ -232,7 +232,7 @@ void glonass_l2_ca_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &sat } -void glonass_l2_ca_telemetry_decoder_cc::set_channel(int channel) +void glonass_l2_ca_telemetry_decoder_cc::set_channel(int32_t channel) { d_channel = channel; LOG(INFO) << "Navigation channel set to " << channel; @@ -262,8 +262,8 @@ void glonass_l2_ca_telemetry_decoder_cc::set_channel(int channel) 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) { - int corr_value = 0; - int preamble_diff = 0; + int32_t corr_value = 0; + int32_t preamble_diff = 0; 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 @@ -276,12 +276,12 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu consume_each(1); d_flag_preamble = false; - unsigned int required_symbols = GLONASS_GNAV_STRING_SYMBOLS; + uint32_t required_symbols = GLONASS_GNAV_STRING_SYMBOLS; if (d_symbol_history.size() > required_symbols) { // ******* preamble correlation ******** - for (int i = 0; i < d_symbols_per_preamble; i++) + for (int32_t i = 0; i < d_symbols_per_preamble; i++) { if (d_symbol_history.at(i).Prompt_I < 0) // symbols clipping { @@ -312,9 +312,9 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu if (abs(corr_value) >= d_symbols_per_preamble) { // check preamble separation - preamble_diff = d_sample_counter - d_preamble_index; + preamble_diff = static_cast(d_sample_counter - d_preamble_index); // Record the PRN start sample index associated to the preamble - d_preamble_time_samples = d_symbol_history.at(0).Tracking_sample_counter; + d_preamble_time_samples = static_cast(d_symbol_history.at(0).Tracking_sample_counter); if (abs(preamble_diff - GLONASS_GNAV_PREAMBLE_PERIOD_SYMBOLS) == 0) { // try to decode frame @@ -335,15 +335,15 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu else if (d_stat == 2) { // FIXME: The preamble index marks the first symbol of the string count. Here I just wait for another full string to be received before processing - if (d_sample_counter == d_preamble_index + GLONASS_GNAV_STRING_SYMBOLS) + if (d_sample_counter == d_preamble_index + static_cast(GLONASS_GNAV_STRING_SYMBOLS)) { // NEW GLONASS string received // 0. fetch the symbols into an array - int string_length = GLONASS_GNAV_STRING_SYMBOLS - d_symbols_per_preamble; + int32_t string_length = GLONASS_GNAV_STRING_SYMBOLS - d_symbols_per_preamble; double string_symbols[GLONASS_GNAV_DATA_SYMBOLS] = {0}; // ******* SYMBOL TO BIT ******* - for (int i = 0; i < string_length; i++) + for (int32_t i = 0; i < string_length; i++) { if (corr_value > 0) { @@ -415,7 +415,7 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu current_symbol.PRN = this->d_satellite.get_PRN(); current_symbol.TOW_at_current_symbol_ms = round(d_TOW_at_current_symbol * 1000.0); // todo: glonass time to gps time should be done in observables block - // current_symbol.TOW_at_current_symbol_ms -= static_cast(delta_t) * 1000; + // current_symbol.TOW_at_current_symbol_ms -= static_cast(delta_t) * 1000; if (d_dump == true) { diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.h index e55699856..8b834228a 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.h @@ -61,7 +61,7 @@ class glonass_l2_ca_telemetry_decoder_cc : public gr::block public: ~glonass_l2_ca_telemetry_decoder_cc(); //!< Class destructor void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int channel); //!< Set receiver's channel + void set_channel(int32_t channel); //!< Set receiver's channel /*! * \brief This is where all signal processing takes place @@ -74,30 +74,30 @@ private: glonass_l2_ca_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); glonass_l2_ca_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); - void decode_string(double *symbols, int frame_length); + void decode_string(double *symbols, int32_t frame_length); //!< Help with coherent tracking double d_preamble_time_samples; //!< Preamble decoding - unsigned short int d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS]; - int *d_preambles_symbols; - unsigned int d_samples_per_symbol; - int d_symbols_per_preamble; + uint16_t d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS]; + int32_t *d_preambles_symbols; + uint32_t d_samples_per_symbol; + int32_t d_symbols_per_preamble; //!< Storage for incoming data std::deque d_symbol_history; //!< Variables for internal functionality - uint64_t d_sample_counter; //!< Sample counter as an index (1,2,3,..etc) indicating number of samples processed - uint64_t d_preamble_index; //!< Index of sample number where preamble was found - unsigned int d_stat; //!< Status of decoder - bool d_flag_frame_sync; //!< Indicate when a frame sync is achieved - bool d_flag_parity; //!< Flag indicating when parity check was achieved (crc check) - bool d_flag_preamble; //!< Flag indicating when preamble was found - int d_CRC_error_counter; //!< Number of failed CRC operations - bool flag_TOW_set; //!< Indicates when time of week is set - double delta_t; //!< GPS-GLONASS time offset + uint64_t d_sample_counter; //!< Sample counter as an index (1,2,3,..etc) indicating number of samples processed + uint64_t d_preamble_index; //!< Index of sample number where preamble was found + uint32_t d_stat; //!< Status of decoder + bool d_flag_frame_sync; //!< Indicate when a frame sync is achieved + bool d_flag_parity; //!< Flag indicating when parity check was achieved (crc check) + bool d_flag_preamble; //!< Flag indicating when preamble was found + int32_t d_CRC_error_counter; //!< Number of failed CRC operations + bool flag_TOW_set; //!< Indicates when time of week is set + double delta_t; //!< GPS-GLONASS time offset //!< Navigation Message variable Glonass_Gnav_Navigation_Message d_nav; @@ -108,7 +108,7 @@ private: //!< Satellite Information and logging capacity Gnss_Satellite d_satellite; - int d_channel; + int32_t d_channel; bool d_dump; std::string d_dump_filename; std::ofstream d_dump_file; 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 07bd802cb..f540f20a1 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 @@ -62,14 +62,14 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc( d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); // set the preamble - unsigned short int preambles_bits[GPS_CA_PREAMBLE_LENGTH_BITS] = GPS_PREAMBLE; + uint16_t preambles_bits[GPS_CA_PREAMBLE_LENGTH_BITS] = GPS_PREAMBLE; // preamble bits to sampled 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++) + d_preambles_symbols = static_cast(volk_gnsssdr_malloc(GPS_CA_PREAMBLE_LENGTH_SYMBOLS * sizeof(int32_t), volk_gnsssdr_get_alignment())); + int32_t n = 0; + for (int32_t i = 0; i < GPS_CA_PREAMBLE_LENGTH_BITS; i++) { - for (unsigned int j = 0; j < GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; j++) + for (uint32_t j = 0; j < GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; j++) { if (preambles_bits[i] == 1) { @@ -91,7 +91,7 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc( d_flag_new_tow_available = false; d_channel = 0; flag_PLL_180_deg_phase_locked = false; - d_preamble_time_samples = 0; + d_preamble_time_samples = 0ULL; d_TOW_at_current_symbol_ms = 0; d_symbol_history.resize(GPS_CA_PREAMBLE_LENGTH_SYMBOLS); // Change fixed buffer size d_symbol_history.clear(); // Clear all the elements in the buffer @@ -117,13 +117,13 @@ gps_l1_ca_telemetry_decoder_cc::~gps_l1_ca_telemetry_decoder_cc() } -bool gps_l1_ca_telemetry_decoder_cc::gps_word_parityCheck(unsigned int gpsword) +bool gps_l1_ca_telemetry_decoder_cc::gps_word_parityCheck(uint32_t gpsword) { - unsigned int d1, d2, d3, d4, d5, d6, d7, t, parity; - /* XOR as many bits in parallel as possible. The magic constants pick - up bits which are to be XOR'ed together to implement the GPS parity - check algorithm described in IS-GPS-200E. This avoids lengthy shift- - and-xor loops. */ + uint32_t d1, d2, d3, d4, d5, d6, d7, t, parity; + // XOR as many bits in parallel as possible. The magic constants pick + // up bits which are to be XOR'ed together to implement the GPS parity + // check algorithm described in IS-GPS-200E. This avoids lengthy shift- + // and-xor loops. d1 = gpsword & 0xFBFFBF00; d2 = _rotl(gpsword, 1) & 0x07FFBF01; d3 = _rotl(gpsword, 2) & 0xFC0F8100; @@ -152,7 +152,7 @@ void gps_l1_ca_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satelli } -void gps_l1_ca_telemetry_decoder_cc::set_channel(int channel) +void gps_l1_ca_telemetry_decoder_cc::set_channel(int32_t channel) { d_channel = channel; d_nav.i_channel_ID = channel; @@ -185,28 +185,28 @@ bool gps_l1_ca_telemetry_decoder_cc::decode_subframe() { char subframe[GPS_SUBFRAME_LENGTH]; - int symbol_accumulator_counter = 0; - int frame_bit_index = 0; - int word_index = 0; + int32_t symbol_accumulator_counter = 0; + int32_t frame_bit_index = 0; + int32_t word_index = 0; uint32_t GPS_frame_4bytes = 0; float symbol_accumulator = 0; bool subframe_synchro_confirmation = false; bool CRC_ok = true; - for (int n = 0; n < GPS_SUBFRAME_MS; n++) + for (int32_t n = 0; n < GPS_SUBFRAME_MS; n++) { - //******* SYMBOL TO BIT ******* + // ******* SYMBOL TO BIT ******* // extended correlation to bit period is enabled in tracking! symbol_accumulator += d_subframe_symbols[n]; // accumulate the input value in d_symbol_accumulator symbol_accumulator_counter++; if (symbol_accumulator_counter == 20) { - //symbol to bit - if (symbol_accumulator > 0) GPS_frame_4bytes += 1; //insert the telemetry bit in LSB + // symbol to bit + if (symbol_accumulator > 0) GPS_frame_4bytes += 1; // insert the telemetry bit in LSB symbol_accumulator = 0; symbol_accumulator_counter = 0; - //******* bits to words ****** + // ******* bits to words ****** frame_bit_index++; if (frame_bit_index == 30) { @@ -224,8 +224,8 @@ bool gps_l1_ca_telemetry_decoder_cc::decode_subframe() { GPS_frame_4bytes = GPS_frame_4bytes | 0x80000000; } - /* Check that the 2 most recently logged words pass parity. Have to first - invert the data bits according to bit 30 of the previous word. */ + // Check that the 2 most recently logged words pass parity. Have to first + // invert the data bits according to bit 30 of the previous word. if (GPS_frame_4bytes & 0x40000000) { GPS_frame_4bytes ^= 0x3FFFFFC0; // invert the data bits (using XOR) @@ -236,10 +236,10 @@ bool gps_l1_ca_telemetry_decoder_cc::decode_subframe() } else { - //std::cout << "word invalid sat " << this->d_satellite << std::endl; + // std::cout << "word invalid sat " << this->d_satellite << std::endl; CRC_ok = false; } - //add word to subframe + // add word to subframe // insert the word in the correct position of the subframe std::memcpy(&subframe[word_index * GPS_WORD_LENGTH], &GPS_frame_4bytes, sizeof(uint32_t)); word_index++; @@ -248,17 +248,16 @@ bool gps_l1_ca_telemetry_decoder_cc::decode_subframe() } else { - GPS_frame_4bytes <<= 1; //shift 1 bit left the telemetry word + GPS_frame_4bytes <<= 1; // shift 1 bit left the telemetry word } } } - - //decode subframe + // decode subframe // NEW GPS SUBFRAME HAS ARRIVED! if (CRC_ok) { - int subframe_ID = d_nav.subframe_decoder(subframe); //decode the subframe + int32_t subframe_ID = d_nav.subframe_decoder(subframe); //d ecode the subframe if (subframe_ID > 0 and subframe_ID < 6) { std::cout << "New GPS NAV message received in channel " << this->d_channel << ": " @@ -268,7 +267,7 @@ bool gps_l1_ca_telemetry_decoder_cc::decode_subframe() switch (subframe_ID) { - case 3: //we have a new set of ephemeris data for the current SV + case 3: // we have a new set of ephemeris data for the current SV if (d_nav.satellite_validation() == true) { // get ephemeris object for this SV (mandatory) @@ -306,37 +305,37 @@ bool gps_l1_ca_telemetry_decoder_cc::decode_subframe() return subframe_synchro_confirmation; } + 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) { - int preamble_diff_ms = 0; + int32_t preamble_diff_ms = 0; 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 + 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][0]; - //record the oldest subframe symbol before inserting a new symbol into the circular buffer + // record the oldest subframe symbol before inserting a new symbol into the circular buffer if (d_current_subframe_symbol < GPS_SUBFRAME_MS and d_symbol_history.size() > 0) { d_subframe_symbols[d_current_subframe_symbol] = d_symbol_history.at(0).Prompt_I; d_current_subframe_symbol++; } - d_symbol_history.push_back(current_symbol); //add new symbol to the symbol queue + d_symbol_history.push_back(current_symbol); // add new symbol to the symbol queue consume_each(1); d_flag_preamble = false; - - //******* preamble correlation ******** - int corr_value = 0; + // ******* preamble correlation ******** + int32_t corr_value = 0; if ((d_symbol_history.size() == GPS_CA_PREAMBLE_LENGTH_SYMBOLS)) // and (d_make_correlation or !d_flag_frame_sync)) { - // std::cout << "-------\n"; - for (unsigned int i = 0; i < GPS_CA_PREAMBLE_LENGTH_SYMBOLS; i++) + // std::cout << "-------\n"; + for (uint32_t i = 0; i < GPS_CA_PREAMBLE_LENGTH_SYMBOLS; i++) { if (d_symbol_history.at(i).Flag_valid_symbol_output == true) { @@ -352,21 +351,20 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ } } - - //******* frame sync ****************** + // ******* frame sync ****************** if (std::abs(corr_value) == GPS_CA_PREAMBLE_LENGTH_SYMBOLS) { //TODO: Rewrite with state machine if (d_stat == 0) { - //record the preamble sample stamp + // record the preamble sample stamp d_preamble_time_samples = d_symbol_history.at(0).Tracking_sample_counter; // record the preamble sample stamp DLOG(INFO) << "Preamble detection for SAT " << this->d_satellite << "d_symbol_history.at(0).Tracking_sample_counter=" << d_symbol_history.at(0).Tracking_sample_counter; d_stat = 1; // enter into frame pre-detection status } - else if (d_stat == 1) //check 6 seconds of preamble separation + else if (d_stat == 1) // check 6 seconds of preamble separation { - 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); + preamble_diff_ms = std::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); if (std::abs(preamble_diff_ms - GPS_SUBFRAME_MS) % GPS_SUBFRAME_MS == 0) { DLOG(INFO) << "Preamble confirmation for SAT " << this->d_satellite; @@ -388,14 +386,14 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ << static_cast(d_preamble_time_samples) / static_cast(d_symbol_history.at(0).fs) << " [s]"; } - //try to decode the subframe: + // try to decode the subframe: if (decode_subframe() == false) { d_crc_error_synchronization_counter++; if (d_crc_error_synchronization_counter > 3) { DLOG(INFO) << "TOO MANY CRC ERRORS: Lost of frame sync SAT " << this->d_satellite << std::endl; - d_stat = 0; //lost of frame sync + d_stat = 0; // lost of frame sync d_flag_frame_sync = false; flag_TOW_set = false; d_crc_error_synchronization_counter = 0; @@ -413,8 +411,8 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ if (preamble_diff_ms > GPS_SUBFRAME_MS) { DLOG(INFO) << "Lost of frame sync SAT " << this->d_satellite << " preamble_diff= " << preamble_diff_ms; - // std::cout << "Lost of frame sync SAT " << this->d_satellite << " preamble_diff= " << preamble_diff_ms << std::endl; - d_stat = 0; //lost of frame sync + // std::cout << "Lost of frame sync SAT " << this->d_satellite << " preamble_diff= " << preamble_diff_ms << std::endl; + d_stat = 0; // lost of frame sync d_flag_frame_sync = false; flag_TOW_set = false; d_current_subframe_symbol = 0; @@ -424,11 +422,11 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ } } - //2. Add the telemetry decoder information + // 2. Add the telemetry decoder information if (this->d_flag_preamble == true and d_flag_new_tow_available == true) { - d_TOW_at_current_symbol_ms = static_cast(d_nav.d_TOW * 1000.0) + GPS_CA_PREAMBLE_DURATION_MS; - d_TOW_at_Preamble_ms = static_cast(d_nav.d_TOW * 1000.0); + d_TOW_at_current_symbol_ms = static_cast(d_nav.d_TOW * 1000.0) + GPS_CA_PREAMBLE_DURATION_MS; + d_TOW_at_Preamble_ms = static_cast(d_nav.d_TOW * 1000.0); flag_TOW_set = true; d_flag_new_tow_available = false; } @@ -447,7 +445,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ if (flag_PLL_180_deg_phase_locked == true) { - //correct the accumulated phase for the Costas loop phase shift, if required + // correct the accumulated phase for the Costas loop phase shift, if required current_symbol.Carrier_phase_rads += GPS_PI; } @@ -471,7 +469,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ } } - //3. Make the output (copy the object contents to the GNURadio reserved memory) + // 3. Make the output (copy the object contents to the GNURadio reserved memory) *out[0] = current_symbol; return 1; 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 d7e6bd21a..745128047 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 @@ -70,23 +70,23 @@ private: gps_l1_ca_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); - bool gps_word_parityCheck(unsigned int gpsword); + bool gps_word_parityCheck(uint32_t gpsword); bool decode_subframe(); bool new_decoder(); int d_crc_error_synchronization_counter; int *d_preambles_symbols; - unsigned int d_stat; + uint32_t d_stat; bool d_flag_frame_sync; // symbols boost::circular_buffer d_symbol_history; - float d_subframe_symbols[GPS_SUBFRAME_MS]; //symbols per subframe + float d_subframe_symbols[GPS_SUBFRAME_MS]; // symbols per subframe int d_current_subframe_symbol; - //bits and frame - unsigned int d_prev_GPS_frame_4bytes; + // bits and frame + uint32_t d_prev_GPS_frame_4bytes; bool d_flag_preamble; bool d_flag_new_tow_available; @@ -99,8 +99,8 @@ private: uint64_t d_preamble_time_samples; - unsigned int d_TOW_at_Preamble_ms; - unsigned int d_TOW_at_current_symbol_ms; + uint32_t d_TOW_at_Preamble_ms; + uint32_t d_TOW_at_current_symbol_ms; bool flag_TOW_set; bool flag_PLL_180_deg_phase_locked; 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 69f23bcf2..6790c8559 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 @@ -61,7 +61,7 @@ gps_l2c_telemetry_decoder_cc::gps_l2c_telemetry_decoder_cc( d_dump = dump; d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); DLOG(INFO) << "GPS L2C M TELEMETRY PROCESSING: satellite " << d_satellite; - //set_output_multiple (1); + // set_output_multiple (1); d_channel = 0; d_flag_valid_word = false; d_TOW_at_current_symbol = 0; @@ -69,7 +69,7 @@ gps_l2c_telemetry_decoder_cc::gps_l2c_telemetry_decoder_cc( d_state = 0; //initial state d_crc_error_count = 0; - //initialize the CNAV frame decoder (libswiftcnav) + // initialize the CNAV frame decoder (libswiftcnav) cnav_msg_decoder_init(&d_cnav_decoder); } @@ -134,34 +134,34 @@ int gps_l2c_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( bool flag_new_cnav_frame = false; cnav_msg_t msg; - u32 delay = 0; + uint32_t delay = 0; - //add the symbol to the decoder - u8 symbol_clip = static_cast(in[0].Prompt_I > 0) * 255; + // add the symbol to the decoder + uint8_t symbol_clip = static_cast(in[0].Prompt_I > 0) * 255; flag_new_cnav_frame = cnav_msg_decoder_add_symbol(&d_cnav_decoder, symbol_clip, &msg, &delay); - consume_each(1); //one by one + consume_each(1); // one by one // UPDATE GNSS SYNCHRO DATA - Gnss_Synchro current_synchro_data; //structure to save the synchronization information and send the output object to the next block + Gnss_Synchro current_synchro_data; // structure to save the synchronization information and send the output object to the next block - //1. Copy the current tracking output + // 1. Copy the current tracking output current_synchro_data = in[0]; - //2. Add the telemetry decoder information - //check if new CNAV frame is available + // 2. Add the telemetry decoder information + // check if new CNAV frame is available if (flag_new_cnav_frame == true) { std::bitset raw_bits; - //Expand packet bits to bitsets. Notice the reverse order of the bits sequence, required by the CNAV message decoder - for (u32 i = 0; i < GPS_L2_CNAV_DATA_PAGE_BITS; i++) + // Expand packet bits to bitsets. Notice the reverse order of the bits sequence, required by the CNAV message decoder + for (uint32_t i = 0; i < GPS_L2_CNAV_DATA_PAGE_BITS; i++) { raw_bits[GPS_L2_CNAV_DATA_PAGE_BITS - 1 - i] = ((msg.raw_msg[i / 8] >> (7 - i % 8)) & 1u); } d_CNAV_Message.decode_page(raw_bits); - //Push the new navigation data to the queues + // Push the new navigation data to the queues if (d_CNAV_Message.have_new_ephemeris() == true) { // get ephemeris object for this SV @@ -183,12 +183,12 @@ int gps_l2c_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } - //update TOW at the preamble instant + // update TOW at the preamble instant d_TOW_at_Preamble = static_cast(msg.tow); - //* The time of the last input symbol can be computed from the message ToW and - //* delay by the formulae: - //* \code - //* symbolTime_ms = msg->tow * 6000 + *pdelay * 20 + (12 * 20); 12 symbols of the encoder's transitory + // The time of the last input symbol can be computed from the message ToW and + // delay by the formulae: + // \code + // symbolTime_ms = msg->tow * 6000 + *pdelay * 20 + (12 * 20); 12 symbols of the encoder's transitory d_TOW_at_current_symbol = static_cast(msg.tow) * 6.0 + static_cast(delay) * GPS_L2_M_PERIOD + 12 * GPS_L2_M_PERIOD; //d_TOW_at_current_symbol = floor(d_TOW_at_current_symbol * 1000.0) / 1000.0; d_flag_valid_word = true; @@ -224,7 +224,7 @@ int gps_l2c_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( } } - //3. Make the output (copy the object contents to the GNURadio reserved memory) + // 3. Make the output (copy the object contents to the GNURadio reserved memory) out[0] = current_synchro_data; return 1; } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.h index 9235c5c2d..932fb6db7 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.h @@ -38,6 +38,7 @@ #include "gps_cnav_iono.h" #include #include // for copy +#include #include #include #include @@ -70,7 +71,7 @@ class gps_l2c_telemetry_decoder_cc : public gr::block public: ~gps_l2c_telemetry_decoder_cc(); void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int channel); //!< Set receiver's channel + void set_channel(int32_t channel); //!< Set receiver's channel /*! * \brief This is where all signal processing takes place @@ -78,7 +79,6 @@ public: int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); - private: friend gps_l2c_telemetry_decoder_cc_sptr gps_l2c_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); @@ -86,15 +86,15 @@ private: bool d_dump; Gnss_Satellite d_satellite; - int d_channel; + int32_t d_channel; std::string d_dump_filename; std::ofstream d_dump_file; cnav_msg_decoder_t d_cnav_decoder; - int d_state; - int d_crc_error_count; + int32_t d_state; + int32_t d_crc_error_count; double d_TOW_at_current_symbol; double d_TOW_at_Preamble; 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 425cfdc1d..ed235933f 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 @@ -66,9 +66,9 @@ gps_l5_telemetry_decoder_cc::gps_l5_telemetry_decoder_cc( d_flag_valid_word = false; d_TOW_at_current_symbol_ms = 0; d_TOW_at_Preamble_ms = 0; - //initialize the CNAV frame decoder (libswiftcnav) + // initialize the CNAV frame decoder (libswiftcnav) cnav_msg_decoder_init(&d_cnav_decoder); - for (int aux = 0; aux < GPS_L5i_NH_CODE_LENGTH; aux++) + for (int32_t aux = 0; aux < GPS_L5i_NH_CODE_LENGTH; aux++) { if (GPS_L5i_NH_CODE[aux] == 0) { @@ -108,7 +108,7 @@ void gps_l5_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) } -void gps_l5_telemetry_decoder_cc::set_channel(int channel) +void gps_l5_telemetry_decoder_cc::set_channel(int32_t channel) { d_channel = channel; d_CNAV_Message.reset(); @@ -146,17 +146,17 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u // UPDATE GNSS SYNCHRO DATA Gnss_Synchro current_synchro_data; //structure to save the synchronization information and send the output object to the next block - //1. Copy the current tracking output + // 1. Copy the current tracking output current_synchro_data = in[0]; consume_each(1); //one by one sym_hist.push_back(in[0].Prompt_I); - int corr_NH = 0; - int symbol_value = 0; + int32_t corr_NH = 0; + int32_t symbol_value = 0; - //Search correlation with Neuman-Hofman Code (see IS-GPS-705D) + // Search correlation with Neuman-Hofman Code (see IS-GPS-705D) if (sym_hist.size() == GPS_L5i_NH_CODE_LENGTH) { - for (int i = 0; i < GPS_L5i_NH_CODE_LENGTH; i++) + for (int32_t i = 0; i < GPS_L5i_NH_CODE_LENGTH; i++) { if ((bits_NH[i] * sym_hist.at(i)) > 0.0) { @@ -191,29 +191,29 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u bool flag_new_cnav_frame = false; cnav_msg_t msg; - u32 delay = 0; + uint32_t delay = 0; - //add the symbol to the decoder + // add the symbol to the decoder if (new_sym) { - u8 symbol_clip = static_cast(symbol_value > 0) * 255; + uint8_t symbol_clip = static_cast(symbol_value > 0) * 255; flag_new_cnav_frame = cnav_msg_decoder_add_symbol(&d_cnav_decoder, symbol_clip, &msg, &delay); new_sym = false; } - //2. Add the telemetry decoder information - //check if new CNAV frame is available + // 2. Add the telemetry decoder information + // check if new CNAV frame is available if (flag_new_cnav_frame == true) { std::bitset raw_bits; - //Expand packet bits to bitsets. Notice the reverse order of the bits sequence, required by the CNAV message decoder - for (u32 i = 0; i < GPS_L5_CNAV_DATA_PAGE_BITS; i++) + // Expand packet bits to bitsets. Notice the reverse order of the bits sequence, required by the CNAV message decoder + for (uint32_t i = 0; i < GPS_L5_CNAV_DATA_PAGE_BITS; i++) { raw_bits[GPS_L5_CNAV_DATA_PAGE_BITS - 1 - i] = ((msg.raw_msg[i / 8] >> (7 - i % 8)) & 1u); } d_CNAV_Message.decode_page(raw_bits); - //Push the new navigation data to the queues + // Push the new navigation data to the queues if (d_CNAV_Message.have_new_ephemeris() == true) { // get ephemeris object for this SV @@ -235,14 +235,12 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); } - //update TOW at the preamble instant + // update TOW at the preamble instant d_TOW_at_Preamble_ms = msg.tow * 6000; - //* The time of the last input symbol can be computed from the message ToW and - //* delay by the formulae: - //* \code - //* symbolTime_ms = msg->tow * 6000 + *pdelay * 10 + (12 * 10); 12 symbols of the encoder's transitory - //d_TOW_at_current_symbol_ms = msg.tow * 6000 + (delay + 12) * GPS_L5i_SYMBOL_PERIOD_MS; - + // The time of the last input symbol can be computed from the message ToW and + // delay by the formulae: + // \code + // symbolTime_ms = msg->tow * 6000 + *pdelay * 10 + (12 * 10); 12 symbols of the encoder's transitory d_TOW_at_current_symbol_ms = msg.tow * 6000 + (delay + 12) * GPS_L5i_SYMBOL_PERIOD_MS; d_flag_valid_word = true; } @@ -280,7 +278,7 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u } } - //3. Make the output (copy the object contents to the GNURadio reserved memory) + // 3. Make the output (copy the object contents to the GNURadio reserved memory) out[0] = current_synchro_data; return 1; } 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 2970fe7c9..e5e98cde6 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 @@ -35,13 +35,15 @@ #include "gps_cnav_navigation_message.h" #include #include +#include #include #include #include #include #include -extern "C" { +extern "C" +{ #include "cnav_msg.h" #include "edc.h" #include "bits.h" @@ -65,11 +67,10 @@ class gps_l5_telemetry_decoder_cc : public gr::block public: ~gps_l5_telemetry_decoder_cc(); void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int channel); //!< Set receiver's channel + void set_channel(int32_t channel); //!< Set receiver's channel int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); - private: friend gps_l5_telemetry_decoder_cc_sptr gps_l5_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); @@ -77,15 +78,15 @@ private: bool d_dump; Gnss_Satellite d_satellite; - int d_channel; + int32_t d_channel; std::string d_dump_filename; std::ofstream d_dump_file; cnav_msg_decoder_t d_cnav_decoder; - unsigned int d_TOW_at_current_symbol_ms; - unsigned int d_TOW_at_Preamble_ms; + uint32_t d_TOW_at_current_symbol_ms; + uint32_t d_TOW_at_Preamble_ms; bool d_flag_valid_word; Gps_CNAV_Navigation_Message d_CNAV_Message; 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 ba65ce7df..97246efae 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 @@ -94,7 +94,7 @@ void sbas_l1_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite } -void sbas_l1_telemetry_decoder_cc::set_channel(int channel) +void sbas_l1_telemetry_decoder_cc::set_channel(int32_t channel) { d_channel = channel; LOG(INFO) << "SBAS channel set to " << channel; @@ -137,12 +137,12 @@ bool sbas_l1_telemetry_decoder_cc::sample_aligner::get_symbols(const std::vector VLOG(FLOW) << "get_symbols(): " << "d_past_sample=" << d_past_sample << "\tsamples size=" << samples.size(); - for (unsigned int i_sym = 0; i_sym < samples.size() / sbas_l1_telemetry_decoder_cc::d_samples_per_symbol; i_sym++) + for (uint32_t i_sym = 0; i_sym < samples.size() / sbas_l1_telemetry_decoder_cc::d_samples_per_symbol; i_sym++) { // get the next samples - for (int i = 0; i < d_n_smpls_in_history; i++) + for (int32_t i = 0; i < d_n_smpls_in_history; i++) { - smpls[i] = static_cast(i_sym) * sbas_l1_telemetry_decoder_cc::d_samples_per_symbol + i - 1 == -1 ? d_past_sample : samples[i_sym * sbas_l1_telemetry_decoder_cc::d_samples_per_symbol + i - 1]; + smpls[i] = static_cast(i_sym) * sbas_l1_telemetry_decoder_cc::d_samples_per_symbol + i - 1 == -1 ? d_past_sample : samples[i_sym * sbas_l1_telemetry_decoder_cc::d_samples_per_symbol + i - 1]; } // update the pseudo correlations (IIR method) of the two possible alignments @@ -158,7 +158,7 @@ bool sbas_l1_telemetry_decoder_cc::sample_aligner::get_symbols(const std::vector } // sum the correct pair of samples to a symbol, depending on the current alignment d_align - sym = smpls[0 + int(d_aligned) * 2] + smpls[1]; + sym = smpls[0 + int32_t(d_aligned) * 2] + smpls[1]; symbols.push_back(sym); // sample alignment debug output @@ -189,8 +189,8 @@ sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::symbol_aligner_and_dec { // convolutional code properties d_KK = 7; - int nn = 2; - int g_encoder[nn]; + int32_t nn = 2; + int32_t g_encoder[nn]; g_encoder[0] = 121; g_encoder[1] = 91; @@ -215,11 +215,11 @@ void sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::reset() } -bool sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::get_bits(const std::vector symbols, std::vector &bits) +bool sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::get_bits(const std::vector symbols, std::vector &bits) { - const int traceback_depth = 5 * d_KK; - int nbits_requested = symbols.size() / d_symbols_per_bit; - int nbits_decoded; + const int32_t traceback_depth = 5 * d_KK; + int32_t nbits_requested = symbols.size() / d_symbols_per_bit; + int32_t nbits_decoded; // fill two vectors with the two possible symbol alignments std::vector symbols_vd1(symbols); // aligned symbol vector -> copy input symbol vector std::vector symbols_vd2; // shifted symbol vector -> add past sample in front of input vector @@ -229,13 +229,13 @@ bool sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::get_bits(const st symbols_vd2.push_back(*symbol_it); } // arrays for decoded bits - int *bits_vd1 = new int[nbits_requested]; - int *bits_vd2 = new int[nbits_requested]; + int32_t *bits_vd1 = new int32_t[nbits_requested]; + int32_t *bits_vd2 = new int32_t[nbits_requested]; // decode float metric_vd1 = d_vd1->decode_continuous(symbols_vd1.data(), traceback_depth, bits_vd1, nbits_requested, nbits_decoded); float metric_vd2 = d_vd2->decode_continuous(symbols_vd2.data(), traceback_depth, bits_vd2, nbits_requested, nbits_decoded); // choose the bits with the better metric - for (int i = 0; i < nbits_decoded; i++) + for (int32_t i = 0; i < nbits_decoded; i++) { if (metric_vd1 > metric_vd2) { // symbols aligned @@ -260,35 +260,35 @@ void sbas_l1_telemetry_decoder_cc::frame_detector::reset() } -void sbas_l1_telemetry_decoder_cc::frame_detector::get_frame_candidates(const std::vector bits, std::vector>> &msg_candidates) +void sbas_l1_telemetry_decoder_cc::frame_detector::get_frame_candidates(const std::vector bits, std::vector>> &msg_candidates) { std::stringstream ss; - unsigned int sbas_msg_length = 250; - std::vector> preambles = {{0, 1, 0, 1, 0, 0, 1, 1}, + uint32_t sbas_msg_length = 250; + std::vector> preambles = {{0, 1, 0, 1, 0, 0, 1, 1}, {1, 0, 0, 1, 1, 0, 1, 0}, {1, 1, 0, 0, 0, 1, 1, 0}}; VLOG(FLOW) << "get_frame_candidates(): " << "d_buffer.size()=" << d_buffer.size() << "\tbits.size()=" << bits.size(); ss << "copy bits "; - int count = 0; + int32_t count = 0; // copy new bits into the working buffer - for (std::vector::const_iterator bit_it = bits.cbegin(); bit_it < bits.cend(); ++bit_it) + for (std::vector::const_iterator bit_it = bits.cbegin(); bit_it < bits.cend(); ++bit_it) { d_buffer.push_back(*bit_it); ss << *bit_it; count++; } VLOG(SAMP_SYNC) << ss.str() << " into working buffer (" << count << " bits)"; - int relative_preamble_start = 0; + int32_t relative_preamble_start = 0; while (d_buffer.size() >= sbas_msg_length) { // compare with all preambles - for (std::vector>::iterator preample_it = preambles.begin(); preample_it < preambles.end(); ++preample_it) + for (std::vector>::iterator preample_it = preambles.begin(); preample_it < preambles.end(); ++preample_it) { bool preamble_detected = true; bool inv_preamble_detected = true; // compare the buffer bits with the preamble bits - for (std::vector::iterator preample_bit_it = preample_it->begin(); preample_bit_it < preample_it->end(); ++preample_bit_it) + for (std::vector::iterator preample_bit_it = preample_it->begin(); preample_bit_it < preample_it->end(); ++preample_bit_it) { preamble_detected = *preample_bit_it == d_buffer[preample_bit_it - preample_it->begin()] ? preamble_detected : false; inv_preamble_detected = *preample_bit_it != d_buffer[preample_bit_it - preample_it->begin()] ? inv_preamble_detected : false; @@ -296,18 +296,18 @@ void sbas_l1_telemetry_decoder_cc::frame_detector::get_frame_candidates(const st if (preamble_detected || inv_preamble_detected) { // copy candidate - std::vector candidate; + std::vector candidate; std::copy(d_buffer.begin(), d_buffer.begin() + sbas_msg_length, std::back_inserter(candidate)); if (inv_preamble_detected) { // invert bits - for (std::vector::iterator candidate_bit_it = candidate.begin(); candidate_bit_it != candidate.end(); candidate_bit_it++) + for (std::vector::iterator candidate_bit_it = candidate.begin(); candidate_bit_it != candidate.end(); candidate_bit_it++) *candidate_bit_it = *candidate_bit_it == 0 ? 1 : 0; } - msg_candidates.push_back(std::pair>(relative_preamble_start, candidate)); + msg_candidates.push_back(std::pair>(relative_preamble_start, candidate)); ss.str(""); ss << "preamble " << preample_it - preambles.begin() << (inv_preamble_detected ? " inverted" : " normal") << " detected! candidate="; - for (std::vector::iterator bit_it = candidate.begin(); bit_it < candidate.end(); ++bit_it) + for (std::vector::iterator bit_it = candidate.begin(); bit_it < candidate.end(); ++bit_it) ss << *bit_it; VLOG(EVENT) << ss.str(); } @@ -334,12 +334,12 @@ void sbas_l1_telemetry_decoder_cc::crc_verifier::get_valid_frames(const std::vec for (std::vector::const_iterator candidate_it = msg_candidates.cbegin(); candidate_it < msg_candidates.cend(); ++candidate_it) { // convert to bytes - std::vector candidate_bytes; + std::vector candidate_bytes; zerropad_back_and_convert_to_bytes(candidate_it->second, candidate_bytes); // verify CRC d_checksum_agent.reset(0); d_checksum_agent.process_bytes(candidate_bytes.data(), candidate_bytes.size()); - unsigned int crc = d_checksum_agent.checksum(); + uint32_t crc = d_checksum_agent.checksum(); VLOG(SAMP_SYNC) << "candidate " << candidate_it - msg_candidates.begin() << ": final crc remainder= " << std::hex << crc << std::setfill(' ') << std::resetiosflags(std::ios::hex); @@ -354,66 +354,66 @@ void sbas_l1_telemetry_decoder_cc::crc_verifier::get_valid_frames(const std::vec ss << "Not a valid message."; } ss << " Relbitoffset=" << candidate_it->first << " content="; - for (std::vector::iterator byte_it = candidate_bytes.begin(); byte_it < candidate_bytes.end(); ++byte_it) + for (std::vector::iterator byte_it = candidate_bytes.begin(); byte_it < candidate_bytes.end(); ++byte_it) { - ss << std::setw(2) << std::setfill('0') << std::hex << static_cast((*byte_it)); + ss << std::setw(2) << std::setfill('0') << std::hex << static_cast((*byte_it)); } VLOG(SAMP_SYNC) << ss.str() << std::setfill(' ') << std::resetiosflags(std::ios::hex) << std::endl; } } -void sbas_l1_telemetry_decoder_cc::crc_verifier::zerropad_back_and_convert_to_bytes(const std::vector msg_candidate, std::vector &bytes) +void sbas_l1_telemetry_decoder_cc::crc_verifier::zerropad_back_and_convert_to_bytes(const std::vector msg_candidate, std::vector &bytes) { std::stringstream ss; const size_t bits_per_byte = 8; - unsigned char byte = 0; + uint8_t byte = 0; VLOG(LMORE) << "zerropad_back_and_convert_to_bytes():" << byte; for (std::vector::const_iterator candidate_bit_it = msg_candidate.cbegin(); candidate_bit_it < msg_candidate.cend(); ++candidate_bit_it) { - int idx_bit = candidate_bit_it - msg_candidate.begin(); - int bit_pos_in_current_byte = (bits_per_byte - 1) - (idx_bit % bits_per_byte); - byte |= static_cast(*candidate_bit_it) << bit_pos_in_current_byte; + int32_t idx_bit = candidate_bit_it - msg_candidate.begin(); + int32_t bit_pos_in_current_byte = (bits_per_byte - 1) - (idx_bit % bits_per_byte); + byte |= static_cast(*candidate_bit_it) << bit_pos_in_current_byte; ss << *candidate_bit_it; if (idx_bit % bits_per_byte == bits_per_byte - 1) { bytes.push_back(byte); - VLOG(LMORE) << ss.str() << " -> byte=" << std::setw(2) << std::setfill('0') << std::hex << static_cast(byte); + VLOG(LMORE) << ss.str() << " -> byte=" << std::setw(2) << std::setfill('0') << std::hex << static_cast(byte); ss.str(""); byte = 0; } } bytes.push_back(byte); // implies: insert 6 zeros at the end to fit the 250bits into a multiple of bytes VLOG(LMORE) << " -> byte=" << std::setw(2) - << std::setfill('0') << std::hex << static_cast(byte) + << std::setfill('0') << std::hex << static_cast(byte) << std::setfill(' ') << std::resetiosflags(std::ios::hex); } -void sbas_l1_telemetry_decoder_cc::crc_verifier::zerropad_front_and_convert_to_bytes(const std::vector msg_candidate, std::vector &bytes) +void sbas_l1_telemetry_decoder_cc::crc_verifier::zerropad_front_and_convert_to_bytes(const std::vector msg_candidate, std::vector &bytes) { std::stringstream ss; const size_t bits_per_byte = 8; - unsigned char byte = 0; - int idx_bit = 6; // insert 6 zeros at the front to fit the 250bits into a multiple of bytes + uint8_t byte = 0; + int32_t idx_bit = 6; // insert 6 zeros at the front to fit the 250bits into a multiple of bytes VLOG(LMORE) << "zerropad_front_and_convert_to_bytes():" << byte; - for (std::vector::const_iterator candidate_bit_it = msg_candidate.cbegin(); candidate_bit_it < msg_candidate.cend(); ++candidate_bit_it) + for (std::vector::const_iterator candidate_bit_it = msg_candidate.cbegin(); candidate_bit_it < msg_candidate.cend(); ++candidate_bit_it) { - int bit_pos_in_current_byte = (bits_per_byte - 1) - (idx_bit % bits_per_byte); - byte |= static_cast(*candidate_bit_it) << bit_pos_in_current_byte; + int32_t bit_pos_in_current_byte = (bits_per_byte - 1) - (idx_bit % bits_per_byte); + byte |= static_cast(*candidate_bit_it) << bit_pos_in_current_byte; ss << *candidate_bit_it; if (idx_bit % bits_per_byte == bits_per_byte - 1) { bytes.push_back(byte); VLOG(LMORE) << ss.str() << " -> byte=" << std::setw(2) - << std::setfill('0') << std::hex << static_cast(byte); + << std::setfill('0') << std::hex << static_cast(byte); ss.str(""); byte = 0; } idx_bit++; } VLOG(LMORE) << " -> byte=" << std::setw(2) - << std::setfill('0') << std::hex << static_cast(byte) + << std::setfill('0') << std::hex << static_cast(byte) << std::setfill(' ') << std::resetiosflags(std::ios::hex); } @@ -427,8 +427,8 @@ int sbas_l1_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( 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 + 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 @@ -446,7 +446,7 @@ int sbas_l1_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( // align symbols in pairs // and obtain the bits by decoding the symbol pairs - std::vector bits; + std::vector bits; bool symbol_alignment = d_symbol_aligner_and_decoder.get_bits(symbols, bits); // search for preambles @@ -465,7 +465,7 @@ int sbas_l1_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( for (std::vector::const_iterator it = valid_msgs.cbegin(); it != valid_msgs.cend(); ++it) { - int message_sample_offset = + int32_t 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 diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.h index 39a315015..27853723f 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.h @@ -36,6 +36,7 @@ #include #include #include // for copy +#include #include #include #include @@ -59,7 +60,7 @@ class sbas_l1_telemetry_decoder_cc : public gr::block public: ~sbas_l1_telemetry_decoder_cc(); void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int channel); //!< Set receiver's channel + void set_channel(int32_t channel); //!< Set receiver's channel /*! * \brief This is where all signal processing takes place @@ -72,16 +73,16 @@ private: sbas_l1_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); sbas_l1_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); - void viterbi_decoder(double *page_part_symbols, int *page_part_bits); + void viterbi_decoder(double *page_part_symbols, int32_t *page_part_bits); void align_samples(); - static const int d_samples_per_symbol = 2; - static const int d_symbols_per_bit = 2; - static const int d_block_size_in_bits = 30; + static const int32_t d_samples_per_symbol = 2; + static const int32_t d_symbols_per_bit = 2; + static const int32_t d_block_size_in_bits = 30; bool d_dump; Gnss_Satellite d_satellite; - int d_channel; + int32_t d_channel; std::string d_dump_filename; std::ofstream d_dump_file; @@ -89,8 +90,8 @@ private: size_t d_block_size; //!< number of samples which are processed during one invocation of the algorithms std::vector d_sample_buf; //!< input buffer holding the samples to be processed in one block - typedef std::pair> msg_candiate_int_t; - typedef std::pair> msg_candiate_char_t; + typedef std::pair> msg_candiate_int_t; + typedef std::pair> msg_candiate_char_t; // helper class for sample alignment class sample_aligner @@ -106,7 +107,7 @@ private: bool get_symbols(const std::vector samples, std::vector &symbols); private: - int d_n_smpls_in_history; + int32_t d_n_smpls_in_history; double d_iir_par; double d_corr_paired; double d_corr_shifted; @@ -121,10 +122,10 @@ private: symbol_aligner_and_decoder(); ~symbol_aligner_and_decoder(); void reset(); - bool get_bits(const std::vector symbols, std::vector &bits); + bool get_bits(const std::vector symbols, std::vector &bits); private: - int d_KK; + int32_t d_KK; Viterbi_Decoder *d_vd1; Viterbi_Decoder *d_vd2; double d_past_symbol; @@ -136,10 +137,10 @@ private: { public: void reset(); - void get_frame_candidates(const std::vector bits, std::vector>> &msg_candidates); + void get_frame_candidates(const std::vector bits, std::vector>> &msg_candidates); private: - std::deque d_buffer; + std::deque d_buffer; } d_frame_detector; @@ -153,8 +154,8 @@ private: private: typedef boost::crc_optimal<24, 0x1864CFBu, 0x0, 0x0, false, false> crc_24_q_type; crc_24_q_type d_checksum_agent; - void zerropad_front_and_convert_to_bytes(const std::vector msg_candidate, std::vector &bytes); - void zerropad_back_and_convert_to_bytes(const std::vector msg_candidate, std::vector &bytes); + void zerropad_front_and_convert_to_bytes(const std::vector msg_candidate, std::vector &bytes); + void zerropad_back_and_convert_to_bytes(const std::vector msg_candidate, std::vector &bytes); } d_crc_verifier; }; diff --git a/src/core/system_parameters/GLONASS_L1_L2_CA.h b/src/core/system_parameters/GLONASS_L1_L2_CA.h index be2564d57..27a7425d8 100644 --- a/src/core/system_parameters/GLONASS_L1_L2_CA.h +++ b/src/core/system_parameters/GLONASS_L1_L2_CA.h @@ -35,6 +35,7 @@ #include "gnss_frequencies.h" #include "MATH_CONSTANTS.h" +#include #include #include #include // std::pair @@ -96,7 +97,7 @@ const double GLONASS_L1_CA_CODE_PERIOD = 0.001; //!< GLONASS L1 C/A code const double GLONASS_L1_CA_CHIP_PERIOD = 1.9569e-06; //!< GLONASS L1 C/A chip period [seconds] const double GLONASS_L1_CA_SYMBOL_RATE_BPS = 1000; -const int GLONASS_CA_NBR_SATS = 24; // STRING DATA WITHOUT PREAMBLE +const int32_t GLONASS_CA_NBR_SATS = 24; // STRING DATA WITHOUT PREAMBLE /*! * \brief Record of leap seconds definition for GLOT to GPST conversion and vice versa @@ -125,7 +126,7 @@ const double GLONASS_LEAP_SECONDS[19][7] = { {}}; //!< GLONASS SV's orbital slots PRN = (orbital_slot - 1) -const std::map GLONASS_PRN = { +const std::map GLONASS_PRN = { { 0, 8, @@ -227,7 +228,7 @@ const std::map GLONASS_PRN = { const double GLONASS_STARTOFFSET_ms = 68.802; //[ms] Initial sign. travel time (this cannot go here) // OBSERVABLE HISTORY DEEP FOR INTERPOLATION -const int GLONASS_L1_CA_HISTORY_DEEP = 100; +const int32_t GLONASS_L1_CA_HISTORY_DEEP = 100; // NAVIGATION MESSAGE DEMODULATION AND DECODING #define GLONASS_GNAV_PREAMBLE \ @@ -235,96 +236,96 @@ const int GLONASS_L1_CA_HISTORY_DEEP = 100; 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0 \ } const double GLONASS_GNAV_PREAMBLE_DURATION_S = 0.300; -const int GLONASS_GNAV_PREAMBLE_LENGTH_BITS = 30; -const int GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS = 300; -const int GLONASS_GNAV_PREAMBLE_PERIOD_SYMBOLS = 2000; -const int GLONASS_GNAV_TELEMETRY_RATE_BITS_SECOND = 50; //!< NAV message bit rate [bits/s] -const int GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_BIT = 10; -const int GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT = 10; -const int GLONASS_GNAV_TELEMETRY_RATE_SYMBOLS_SECOND = GLONASS_GNAV_TELEMETRY_RATE_BITS_SECOND * GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_BIT; //!< NAV message bit rate [symbols/s] -const int GLONASS_GNAV_STRING_SYMBOLS = 2000; //!< Number of bits per string in the GNAV message (85 data bits + 30 time mark bits) [bits] -const int GLONASS_GNAV_STRING_BITS = 85; //!< Number of bits per string in the GNAV message (85 data bits + 30 time mark bits) [bits] -const int GLONASS_GNAV_HAMMING_CODE_BITS = 8; //!< Number of bits in hamming code sequence of GNAV message -const int GLONASS_GNAV_DATA_SYMBOLS = 1700; // STRING DATA WITHOUT PREAMBLE +const int32_t GLONASS_GNAV_PREAMBLE_LENGTH_BITS = 30; +const int32_t GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS = 300; +const int32_t GLONASS_GNAV_PREAMBLE_PERIOD_SYMBOLS = 2000; +const int32_t GLONASS_GNAV_TELEMETRY_RATE_BITS_SECOND = 50; //!< NAV message bit rate [bits/s] +const int32_t GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_BIT = 10; +const int32_t GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT = 10; +const int32_t GLONASS_GNAV_TELEMETRY_RATE_SYMBOLS_SECOND = GLONASS_GNAV_TELEMETRY_RATE_BITS_SECOND * GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_BIT; //!< NAV message bit rate [symbols/s] +const int32_t GLONASS_GNAV_STRING_SYMBOLS = 2000; //!< Number of bits per string in the GNAV message (85 data bits + 30 time mark bits) [bits] +const int32_t GLONASS_GNAV_STRING_BITS = 85; //!< Number of bits per string in the GNAV message (85 data bits + 30 time mark bits) [bits] +const int32_t GLONASS_GNAV_HAMMING_CODE_BITS = 8; //!< Number of bits in hamming code sequence of GNAV message +const int32_t GLONASS_GNAV_DATA_SYMBOLS = 1700; // STRING DATA WITHOUT PREAMBLE -const std::vector GLONASS_GNAV_CRC_I_INDEX{9, 10, 12, 13, 15, 17, 19, 20, 22, 24, 26, 28, 30, 32, 34, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84}; -const std::vector GLONASS_GNAV_CRC_J_INDEX{9, 11, 12, 14, 15, 18, 19, 21, 22, 25, 26, 29, 30, 33, 34, 36, 37, 40, 41, 44, 45, 48, 49, 52, 53, 56, 57, 60, 61, 64, 65, 67, 68, 71, 72, 75, 76, 79, 80, 83, 84}; -const std::vector GLONASS_GNAV_CRC_K_INDEX{10, 11, 12, 16, 17, 18, 19, 23, 24, 25, 26, 31, 32, 33, 34, 38, 39, 40, 41, 46, 47, 48, 49, 54, 55, 56, 57, 62, 63, 64, 65, 69, 70, 71, 72, 77, 78, 79, 80, 85}; -const std::vector GLONASS_GNAV_CRC_L_INDEX{13, 14, 15, 16, 17, 18, 19, 27, 28, 29, 30, 31, 32, 33, 34, 42, 43, 44, 45, 46, 47, 48, 49, 58, 59, 60, 61, 62, 63, 64, 65, 73, 74, 75, 76, 77, 78, 79, 80}; -const std::vector GLONASS_GNAV_CRC_M_INDEX{20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 81, 82, 83, 84, 85}; -const std::vector GLONASS_GNAV_CRC_N_INDEX{35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65}; -const std::vector GLONASS_GNAV_CRC_P_INDEX{66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85}; -const std::vector GLONASS_GNAV_CRC_Q_INDEX{9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85}; +const std::vector GLONASS_GNAV_CRC_I_INDEX{9, 10, 12, 13, 15, 17, 19, 20, 22, 24, 26, 28, 30, 32, 34, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84}; +const std::vector GLONASS_GNAV_CRC_J_INDEX{9, 11, 12, 14, 15, 18, 19, 21, 22, 25, 26, 29, 30, 33, 34, 36, 37, 40, 41, 44, 45, 48, 49, 52, 53, 56, 57, 60, 61, 64, 65, 67, 68, 71, 72, 75, 76, 79, 80, 83, 84}; +const std::vector GLONASS_GNAV_CRC_K_INDEX{10, 11, 12, 16, 17, 18, 19, 23, 24, 25, 26, 31, 32, 33, 34, 38, 39, 40, 41, 46, 47, 48, 49, 54, 55, 56, 57, 62, 63, 64, 65, 69, 70, 71, 72, 77, 78, 79, 80, 85}; +const std::vector GLONASS_GNAV_CRC_L_INDEX{13, 14, 15, 16, 17, 18, 19, 27, 28, 29, 30, 31, 32, 33, 34, 42, 43, 44, 45, 46, 47, 48, 49, 58, 59, 60, 61, 62, 63, 64, 65, 73, 74, 75, 76, 77, 78, 79, 80}; +const std::vector GLONASS_GNAV_CRC_M_INDEX{20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 81, 82, 83, 84, 85}; +const std::vector GLONASS_GNAV_CRC_N_INDEX{35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65}; +const std::vector GLONASS_GNAV_CRC_P_INDEX{66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85}; +const std::vector GLONASS_GNAV_CRC_Q_INDEX{9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85}; // GLONASS GNAV NAVIGATION MESSAGE STRUCTURE // NAVIGATION MESSAGE FIELDS POSITIONS (from IS-GPS-200E Appendix II) // FRAME 1-4 // COMMON FIELDS -const std::vector> STRING_ID({{2, 4}}); -const std::vector> KX({{78, 8}}); +const std::vector> STRING_ID({{2, 4}}); +const std::vector> KX({{78, 8}}); //STRING 1 -const std::vector> P1({{8, 2}}); -const std::vector> T_K_HR({{10, 5}}); -const std::vector> T_K_MIN({{15, 6}}); -const std::vector> T_K_SEC({{21, 1}}); -const std::vector> X_N_DOT({{22, 24}}); -const std::vector> X_N_DOT_DOT({{46, 5}}); -const std::vector> X_N({{51, 27}}); +const std::vector> P1({{8, 2}}); +const std::vector> T_K_HR({{10, 5}}); +const std::vector> T_K_MIN({{15, 6}}); +const std::vector> T_K_SEC({{21, 1}}); +const std::vector> X_N_DOT({{22, 24}}); +const std::vector> X_N_DOT_DOT({{46, 5}}); +const std::vector> X_N({{51, 27}}); //STRING 2 -const std::vector> B_N({{6, 3}}); -const std::vector> P2({{9, 1}}); -const std::vector> T_B({{10, 7}}); -const std::vector> Y_N_DOT({{22, 24}}); -const std::vector> Y_N_DOT_DOT({{46, 5}}); -const std::vector> Y_N({{51, 27}}); +const std::vector> B_N({{6, 3}}); +const std::vector> P2({{9, 1}}); +const std::vector> T_B({{10, 7}}); +const std::vector> Y_N_DOT({{22, 24}}); +const std::vector> Y_N_DOT_DOT({{46, 5}}); +const std::vector> Y_N({{51, 27}}); //STRING 3 -const std::vector> P3({{6, 1}}); -const std::vector> GAMMA_N({{7, 11}}); -const std::vector> P({{19, 2}}); -const std::vector> EPH_L_N({{21, 1}}); -const std::vector> Z_N_DOT({{22, 24}}); -const std::vector> Z_N_DOT_DOT({{46, 5}}); -const std::vector> Z_N({{51, 27}}); +const std::vector> P3({{6, 1}}); +const std::vector> GAMMA_N({{7, 11}}); +const std::vector> P({{19, 2}}); +const std::vector> EPH_L_N({{21, 1}}); +const std::vector> Z_N_DOT({{22, 24}}); +const std::vector> Z_N_DOT_DOT({{46, 5}}); +const std::vector> Z_N({{51, 27}}); // STRING 4 -const std::vector> TAU_N({{6, 22}}); -const std::vector> DELTA_TAU_N({{28, 5}}); -const std::vector> E_N({{33, 5}}); -const std::vector> P4({{52, 1}}); -const std::vector> F_T({{53, 4}}); -const std::vector> N_T({{60, 11}}); -const std::vector> N({{71, 5}}); -const std::vector> M({{76, 2}}); +const std::vector> TAU_N({{6, 22}}); +const std::vector> DELTA_TAU_N({{28, 5}}); +const std::vector> E_N({{33, 5}}); +const std::vector> P4({{52, 1}}); +const std::vector> F_T({{53, 4}}); +const std::vector> N_T({{60, 11}}); +const std::vector> N({{71, 5}}); +const std::vector> M({{76, 2}}); // STRING 5 -const std::vector> N_A({{6, 11}}); -const std::vector> TAU_C({{17, 32}}); -const std::vector> N_4({{50, 5}}); -const std::vector> TAU_GPS({{55, 22}}); -const std::vector> ALM_L_N({{77, 1}}); +const std::vector> N_A({{6, 11}}); +const std::vector> TAU_C({{17, 32}}); +const std::vector> N_4({{50, 5}}); +const std::vector> TAU_GPS({{55, 22}}); +const std::vector> ALM_L_N({{77, 1}}); // STRING 6, 8, 10, 12, 14 -const std::vector> C_N({{6, 1}}); -const std::vector> M_N_A({{7, 2}}); -const std::vector> n_A({{9, 5}}); -const std::vector> TAU_N_A({{14, 10}}); -const std::vector> LAMBDA_N_A({{24, 21}}); -const std::vector> DELTA_I_N_A({{45, 18}}); -const std::vector> EPSILON_N_A({{63, 15}}); +const std::vector> C_N({{6, 1}}); +const std::vector> M_N_A({{7, 2}}); +const std::vector> n_A({{9, 5}}); +const std::vector> TAU_N_A({{14, 10}}); +const std::vector> LAMBDA_N_A({{24, 21}}); +const std::vector> DELTA_I_N_A({{45, 18}}); +const std::vector> EPSILON_N_A({{63, 15}}); //STRING 7, 9, 11, 13, 15 -const std::vector> OMEGA_N_A({{6, 16}}); -const std::vector> T_LAMBDA_N_A({{22, 21}}); -const std::vector> DELTA_T_N_A({{43, 22}}); -const std::vector> DELTA_T_DOT_N_A({{65, 7}}); -const std::vector> H_N_A({{72, 5}}); +const std::vector> OMEGA_N_A({{6, 16}}); +const std::vector> T_LAMBDA_N_A({{22, 21}}); +const std::vector> DELTA_T_N_A({{43, 22}}); +const std::vector> DELTA_T_DOT_N_A({{65, 7}}); +const std::vector> H_N_A({{72, 5}}); // STRING 14 FRAME 5 -const std::vector> B1({{6, 11}}); -const std::vector> B2({{17, 10}}); +const std::vector> B1({{6, 11}}); +const std::vector> B2({{17, 10}}); #endif /* GNSS_SDR_GLONASS_L1_L2_CA_H_ */ diff --git a/src/core/system_parameters/GPS_CNAV.h b/src/core/system_parameters/GPS_CNAV.h index 343ab3f5c..2fbad6e2d 100644 --- a/src/core/system_parameters/GPS_CNAV.h +++ b/src/core/system_parameters/GPS_CNAV.h @@ -48,135 +48,135 @@ #define GPS_CNAV_PREAMBLE_STR "10001011" #define GPS_CNAV_INV_PREAMBLE_STR "01110100" -const int GPS_CNAV_DATA_PAGE_BITS = 300; +const int32_t GPS_CNAV_DATA_PAGE_BITS = 300; // common to all messages -const std::vector > CNAV_PRN({{9, 6}}); -const std::vector > CNAV_MSG_TYPE({{15, 6}}); -const std::vector > CNAV_TOW({{21, 17}}); //GPS Time Of Week in seconds +const std::vector > CNAV_PRN({{9, 6}}); +const std::vector > CNAV_MSG_TYPE({{15, 6}}); +const std::vector > CNAV_TOW({{21, 17}}); // GPS Time Of Week in seconds const double CNAV_TOW_LSB = 6.0; -const std::vector > CNAV_ALERT_FLAG({{38, 1}}); +const std::vector > CNAV_ALERT_FLAG({{38, 1}}); // MESSAGE TYPE 10 (Ephemeris 1) -const std::vector > CNAV_WN({{39, 13}}); -const std::vector > CNAV_HEALTH({{52, 3}}); -const std::vector > CNAV_TOP1({{55, 11}}); +const std::vector > CNAV_WN({{39, 13}}); +const std::vector > CNAV_HEALTH({{52, 3}}); +const std::vector > CNAV_TOP1({{55, 11}}); const double CNAV_TOP1_LSB = 300.0; -const std::vector > CNAV_URA({{66, 5}}); +const std::vector > CNAV_URA({{66, 5}}); -const std::vector > CNAV_TOE1({{71, 11}}); +const std::vector > CNAV_TOE1({{71, 11}}); const double CNAV_TOE1_LSB = 300.0; -const std::vector > CNAV_DELTA_A({{82, 26}}); //Relative to AREF = 26,559,710 meters +const std::vector > CNAV_DELTA_A({{82, 26}}); // Relative to AREF = 26,559,710 meters const double CNAV_DELTA_A_LSB = TWO_N9; -const std::vector > CNAV_A_DOT({{108, 25}}); +const std::vector > CNAV_A_DOT({{108, 25}}); const double CNAV_A_DOT_LSB = TWO_N21; -const std::vector > CNAV_DELTA_N0({{133, 17}}); -const double CNAV_DELTA_N0_LSB = TWO_N44 * PI; //semi-circles to radians -const std::vector > CNAV_DELTA_N0_DOT({{150, 23}}); +const std::vector > CNAV_DELTA_N0({{133, 17}}); +const double CNAV_DELTA_N0_LSB = TWO_N44 * PI; // semi-circles to radians +const std::vector > CNAV_DELTA_N0_DOT({{150, 23}}); const double CNAV_DELTA_N0_DOT_LSB = TWO_N57 * PI; //semi-circles to radians -const std::vector > CNAV_M0({{173, 33}}); -const double CNAV_M0_LSB = TWO_N32 * PI; //semi-circles to radians -const std::vector > CNAV_E_ECCENTRICITY({{206, 33}}); +const std::vector > CNAV_M0({{173, 33}}); +const double CNAV_M0_LSB = TWO_N32 * PI; // semi-circles to radians +const std::vector > CNAV_E_ECCENTRICITY({{206, 33}}); const double CNAV_E_ECCENTRICITY_LSB = TWO_N34; -const std::vector > CNAV_OMEGA({{239, 33}}); -const double CNAV_OMEGA_LSB = TWO_N32 * PI; //semi-circles to radians -const std::vector > CNAV_INTEGRITY_FLAG({{272, 1}}); -const std::vector > CNAV_L2_PHASING_FLAG({{273, 1}}); +const std::vector > CNAV_OMEGA({{239, 33}}); +const double CNAV_OMEGA_LSB = TWO_N32 * PI; // semi-circles to radians +const std::vector > CNAV_INTEGRITY_FLAG({{272, 1}}); +const std::vector > CNAV_L2_PHASING_FLAG({{273, 1}}); // MESSAGE TYPE 11 (Ephemeris 2) -const std::vector > CNAV_TOE2({{39, 11}}); +const std::vector > CNAV_TOE2({{39, 11}}); const double CNAV_TOE2_LSB = 300.0; -const std::vector > CNAV_OMEGA0({{50, 33}}); -const double CNAV_OMEGA0_LSB = TWO_N32 * PI; //semi-circles to radians -const std::vector > CNAV_I0({{83, 33}}); -const double CNAV_I0_LSB = TWO_N32 * PI; //semi-circles to radians -const std::vector > CNAV_DELTA_OMEGA_DOT({{116, 17}}); //Relative to REF = -2.6 x 10-9 semi-circles/second. -const double CNAV_DELTA_OMEGA_DOT_LSB = TWO_N44 * PI; //semi-circles to radians -const std::vector > CNAV_I0_DOT({{133, 15}}); -const double CNAV_I0_DOT_LSB = TWO_N44 * PI; //semi-circles to radians -const std::vector > CNAV_CIS({{148, 16}}); +const std::vector > CNAV_OMEGA0({{50, 33}}); +const double CNAV_OMEGA0_LSB = TWO_N32 * PI; // semi-circles to radians +const std::vector > CNAV_I0({{83, 33}}); +const double CNAV_I0_LSB = TWO_N32 * PI; // semi-circles to radians +const std::vector > CNAV_DELTA_OMEGA_DOT({{116, 17}}); // Relative to REF = -2.6 x 10-9 semi-circles/second. +const double CNAV_DELTA_OMEGA_DOT_LSB = TWO_N44 * PI; // semi-circles to radians +const std::vector > CNAV_I0_DOT({{133, 15}}); +const double CNAV_I0_DOT_LSB = TWO_N44 * PI; // semi-circles to radians +const std::vector > CNAV_CIS({{148, 16}}); const double CNAV_CIS_LSB = TWO_N30; -const std::vector > CNAV_CIC({{164, 16}}); +const std::vector > CNAV_CIC({{164, 16}}); const double CNAV_CIC_LSB = TWO_N30; -const std::vector > CNAV_CRS({{180, 24}}); +const std::vector > CNAV_CRS({{180, 24}}); const double CNAV_CRS_LSB = TWO_N8; -const std::vector > CNAV_CRC({{204, 24}}); +const std::vector > CNAV_CRC({{204, 24}}); const double CNAV_CRC_LSB = TWO_N8; -const std::vector > CNAV_CUS({{228, 21}}); +const std::vector > CNAV_CUS({{228, 21}}); const double CNAV_CUS_LSB = TWO_N30; -const std::vector > CNAV_CUC({{249, 21}}); +const std::vector > CNAV_CUC({{249, 21}}); const double CNAV_CUC_LSB = TWO_N30; // MESSAGE TYPE 30 (CLOCK, IONO, GRUP DELAY) -const std::vector > CNAV_TOP2({{39, 11}}); +const std::vector > CNAV_TOP2({{39, 11}}); const double CNAV_TOP2_LSB = 300.0; -const std::vector > CNAV_URA_NED0({{50, 5}}); -const std::vector > CNAV_URA_NED1({{55, 3}}); -const std::vector > CNAV_URA_NED2({{58, 3}}); -const std::vector > CNAV_TOC({{61, 11}}); +const std::vector > CNAV_URA_NED0({{50, 5}}); +const std::vector > CNAV_URA_NED1({{55, 3}}); +const std::vector > CNAV_URA_NED2({{58, 3}}); +const std::vector > CNAV_TOC({{61, 11}}); const double CNAV_TOC_LSB = 300.0; -const std::vector > CNAV_AF0({{72,26}}); +const std::vector > CNAV_AF0({{72, 26}}); const double CNAV_AF0_LSB = TWO_N35; -const std::vector > CNAV_AF1({{98,20}}); +const std::vector > CNAV_AF1({{98, 20}}); const double CNAV_AF1_LSB = TWO_N48; -const std::vector > CNAV_AF2({{118,10}}); +const std::vector > CNAV_AF2({{118, 10}}); const double CNAV_AF2_LSB = TWO_N60; -const std::vector > CNAV_TGD({{128,13}}); +const std::vector > CNAV_TGD({{128, 13}}); const double CNAV_TGD_LSB = TWO_N35; -const std::vector > CNAV_ISCL1({{141, 13}}); +const std::vector > CNAV_ISCL1({{141, 13}}); const double CNAV_ISCL1_LSB = TWO_N35; -const std::vector > CNAV_ISCL2({{154, 13}}); +const std::vector > CNAV_ISCL2({{154, 13}}); const double CNAV_ISCL2_LSB = TWO_N35; -const std::vector > CNAV_ISCL5I({{167, 13}}); +const std::vector > CNAV_ISCL5I({{167, 13}}); const double CNAV_ISCL5I_LSB = TWO_N35; -const std::vector > CNAV_ISCL5Q({{180, 13}}); +const std::vector > CNAV_ISCL5Q({{180, 13}}); const double CNAV_ISCL5Q_LSB = TWO_N35; -//Ionospheric parameters -const std::vector > CNAV_ALPHA0({{193, 8}}); +// Ionospheric parameters +const std::vector > CNAV_ALPHA0({{193, 8}}); const double CNAV_ALPHA0_LSB = TWO_N30; -const std::vector > CNAV_ALPHA1({{201, 8}}); +const std::vector > CNAV_ALPHA1({{201, 8}}); const double CNAV_ALPHA1_LSB = TWO_N27; -const std::vector > CNAV_ALPHA2({{209, 8}}); +const std::vector > CNAV_ALPHA2({{209, 8}}); const double CNAV_ALPHA2_LSB = TWO_N24; -const std::vector > CNAV_ALPHA3({{217, 8}}); +const std::vector > CNAV_ALPHA3({{217, 8}}); const double CNAV_ALPHA3_LSB = TWO_N24; -const std::vector > CNAV_BETA0({{225, 8}}); +const std::vector > CNAV_BETA0({{225, 8}}); const double CNAV_BETA0_LSB = TWO_P11; -const std::vector > CNAV_BETA1({{233, 8}}); +const std::vector > CNAV_BETA1({{233, 8}}); const double CNAV_BETA1_LSB = TWO_P14; -const std::vector > CNAV_BETA2({{241, 8}}); +const std::vector > CNAV_BETA2({{241, 8}}); const double CNAV_BETA2_LSB = TWO_P16; -const std::vector > CNAV_BETA3({{249, 8}}); +const std::vector > CNAV_BETA3({{249, 8}}); const double CNAV_BETA3_LSB = TWO_P16; -const std::vector > CNAV_WNOP({{257, 8}}); +const std::vector > CNAV_WNOP({{257, 8}}); // MESSAGE TYPE 33 (CLOCK and UTC) -const std::vector > CNAV_A0({{128, 16}}); +const std::vector > CNAV_A0({{128, 16}}); const double CNAV_A0_LSB = TWO_N35; -const std::vector > CNAV_A1({{144, 13}}); +const std::vector > CNAV_A1({{144, 13}}); const double CNAV_A1_LSB = TWO_N51; -const std::vector > CNAV_A2({{157, 7}}); +const std::vector > CNAV_A2({{157, 7}}); const double CNAV_A2_LSB = TWO_N68; -const std::vector > CNAV_DELTA_TLS({{164, 8}}); +const std::vector > CNAV_DELTA_TLS({{164, 8}}); const double CNAV_DELTA_TLS_LSB = 1; -const std::vector > CNAV_TOT({{172, 16}}); +const std::vector > CNAV_TOT({{172, 16}}); const double CNAV_TOT_LSB = TWO_P4; -const std::vector > CNAV_WN_OT({{188, 13}}); +const std::vector > CNAV_WN_OT({{188, 13}}); const double CNAV_WN_OT_LSB = 1; -const std::vector > CNAV_WN_LSF({{201, 13}}); +const std::vector > CNAV_WN_LSF({{201, 13}}); const double CNAV_WN_LSF_LSB = 1; -const std::vector > CNAV_DN({{214, 4}}); +const std::vector > CNAV_DN({{214, 4}}); const double CNAV_DN_LSB = 1; -const std::vector > CNAV_DELTA_TLSF({{218, 8}}); +const std::vector > CNAV_DELTA_TLSF({{218, 8}}); const double CNAV_DELTA_TLSF_LSB = 1; diff --git a/src/core/system_parameters/GPS_L1_CA.h b/src/core/system_parameters/GPS_L1_CA.h index d0b377cc0..244a2afef 100644 --- a/src/core/system_parameters/GPS_L1_CA.h +++ b/src/core/system_parameters/GPS_L1_CA.h @@ -34,6 +34,7 @@ #include "gnss_frequencies.h" #include "MATH_CONSTANTS.h" +#include #include #include // std::pair @@ -53,7 +54,7 @@ const double GPS_L1_FREQ_HZ = FREQ1; //!< L1 [Hz] const double GPS_L1_CA_CODE_RATE_HZ = 1.023e6; //!< GPS L1 C/A code rate [chips/s] const double GPS_L1_CA_CODE_LENGTH_CHIPS = 1023.0; //!< GPS L1 C/A code length [chips] const double GPS_L1_CA_CODE_PERIOD = 0.001; //!< GPS L1 C/A code period [seconds] -const unsigned int GPS_L1_CA_CODE_PERIOD_MS = 1; //!< GPS L1 C/A code period [ms] +const uint32_t GPS_L1_CA_CODE_PERIOD_MS = 1; //!< GPS L1 C/A code period [ms] const double GPS_L1_CA_CHIP_PERIOD = 9.7752e-07; //!< GPS L1 C/A chip period [seconds] /*! @@ -71,7 +72,7 @@ const double MAX_TOA_DELAY_MS = 20; const double GPS_STARTOFFSET_ms = 60.0; // OBSERVABLE HISTORY DEEP FOR INTERPOLATION -const int GPS_L1_CA_HISTORY_DEEP = 100; +const int32_t GPS_L1_CA_HISTORY_DEEP = 100; // NAVIGATION MESSAGE DEMODULATION AND DECODING @@ -79,172 +80,172 @@ const int GPS_L1_CA_HISTORY_DEEP = 100; { \ 1, 0, 0, 0, 1, 0, 1, 1 \ } -const int GPS_CA_PREAMBLE_LENGTH_BITS = 8; -const int GPS_CA_PREAMBLE_LENGTH_SYMBOLS = 160; +const int32_t GPS_CA_PREAMBLE_LENGTH_BITS = 8; +const int32_t GPS_CA_PREAMBLE_LENGTH_SYMBOLS = 160; const double GPS_CA_PREAMBLE_DURATION_S = 0.160; -const int GPS_CA_PREAMBLE_DURATION_MS = 160; -const int GPS_CA_TELEMETRY_RATE_BITS_SECOND = 50; //!< NAV message bit rate [bits/s] -const int GPS_CA_TELEMETRY_SYMBOLS_PER_BIT = 20; -const int GPS_CA_TELEMETRY_RATE_SYMBOLS_SECOND = GPS_CA_TELEMETRY_RATE_BITS_SECOND * GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; //!< NAV message bit rate [symbols/s] -const int GPS_WORD_LENGTH = 4; //!< CRC + GPS WORD (-2 -1 0 ... 29) Bits = 4 bytes -const int GPS_SUBFRAME_LENGTH = 40; //!< GPS_WORD_LENGTH x 10 = 40 bytes -const int GPS_SUBFRAME_BITS = 300; //!< Number of bits per subframe in the NAV message [bits] -const int GPS_SUBFRAME_SECONDS = 6; //!< Subframe duration [seconds] -const int GPS_SUBFRAME_MS = 6000; //!< Subframe duration [seconds] -const int GPS_WORD_BITS = 30; //!< Number of bits per word in the NAV message [bits] +const int32_t GPS_CA_PREAMBLE_DURATION_MS = 160; +const int32_t GPS_CA_TELEMETRY_RATE_BITS_SECOND = 50; //!< NAV message bit rate [bits/s] +const int32_t GPS_CA_TELEMETRY_SYMBOLS_PER_BIT = 20; +const int32_t GPS_CA_TELEMETRY_RATE_SYMBOLS_SECOND = GPS_CA_TELEMETRY_RATE_BITS_SECOND * GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; //!< NAV message bit rate [symbols/s] +const int32_t GPS_WORD_LENGTH = 4; //!< CRC + GPS WORD (-2 -1 0 ... 29) Bits = 4 bytes +const int32_t GPS_SUBFRAME_LENGTH = 40; //!< GPS_WORD_LENGTH x 10 = 40 bytes +const int32_t GPS_SUBFRAME_BITS = 300; //!< Number of bits per subframe in the NAV message [bits] +const int32_t GPS_SUBFRAME_SECONDS = 6; //!< Subframe duration [seconds] +const int32_t GPS_SUBFRAME_MS = 6000; //!< Subframe duration [seconds] +const int32_t GPS_WORD_BITS = 30; //!< Number of bits per word in the NAV message [bits] // GPS NAVIGATION MESSAGE STRUCTURE // NAVIGATION MESSAGE FIELDS POSITIONS (from IS-GPS-200E Appendix II) // SUBFRAME 1-5 (TLM and HOW) -const std::vector> TOW({{31, 17}}); -const std::vector> INTEGRITY_STATUS_FLAG({{23, 1}}); -const std::vector> ALERT_FLAG({{48, 1}}); -const std::vector> ANTI_SPOOFING_FLAG({{49, 1}}); -const std::vector> SUBFRAME_ID({{50, 3}}); +const std::vector> TOW({{31, 17}}); +const std::vector> INTEGRITY_STATUS_FLAG({{23, 1}}); +const std::vector> ALERT_FLAG({{48, 1}}); +const std::vector> ANTI_SPOOFING_FLAG({{49, 1}}); +const std::vector> SUBFRAME_ID({{50, 3}}); // SUBFRAME 1 -const std::vector> GPS_WEEK({{61, 10}}); -const std::vector> CA_OR_P_ON_L2({{71, 2}}); //* -const std::vector> SV_ACCURACY({{73, 4}}); -const std::vector> SV_HEALTH({{77, 6}}); -const std::vector> L2_P_DATA_FLAG({{91, 1}}); -const std::vector> T_GD({{197, 8}}); +const std::vector> GPS_WEEK({{61, 10}}); +const std::vector> CA_OR_P_ON_L2({{71, 2}}); //* +const std::vector> SV_ACCURACY({{73, 4}}); +const std::vector> SV_HEALTH({{77, 6}}); +const std::vector> L2_P_DATA_FLAG({{91, 1}}); +const std::vector> T_GD({{197, 8}}); const double T_GD_LSB = TWO_N31; -const std::vector> IODC({{83, 2}, {211, 8}}); -const std::vector> T_OC({{219, 16}}); +const std::vector> IODC({{83, 2}, {211, 8}}); +const std::vector> T_OC({{219, 16}}); const double T_OC_LSB = TWO_P4; -const std::vector> A_F2({{241, 8}}); +const std::vector> A_F2({{241, 8}}); const double A_F2_LSB = TWO_N55; -const std::vector> A_F1({{249, 16}}); +const std::vector> A_F1({{249, 16}}); const double A_F1_LSB = TWO_N43; -const std::vector> A_F0({{271, 22}}); +const std::vector> A_F0({{271, 22}}); const double A_F0_LSB = TWO_N31; // SUBFRAME 2 -const std::vector> IODE_SF2({{61, 8}}); -const std::vector> C_RS({{69, 16}}); +const std::vector> IODE_SF2({{61, 8}}); +const std::vector> C_RS({{69, 16}}); const double C_RS_LSB = TWO_N5; -const std::vector> DELTA_N({{91, 16}}); +const std::vector> DELTA_N({{91, 16}}); const double DELTA_N_LSB = PI_TWO_N43; -const std::vector> M_0({{107, 8}, {121, 24}}); +const std::vector> M_0({{107, 8}, {121, 24}}); const double M_0_LSB = PI_TWO_N31; -const std::vector> C_UC({{151, 16}}); +const std::vector> C_UC({{151, 16}}); const double C_UC_LSB = TWO_N29; -const std::vector> E({{167, 8}, {181, 24}}); +const std::vector> E({{167, 8}, {181, 24}}); const double E_LSB = TWO_N33; -const std::vector> C_US({{211, 16}}); +const std::vector> C_US({{211, 16}}); const double C_US_LSB = TWO_N29; -const std::vector> SQRT_A({{227, 8}, {241, 24}}); +const std::vector> SQRT_A({{227, 8}, {241, 24}}); const double SQRT_A_LSB = TWO_N19; -const std::vector> T_OE({{271, 16}}); +const std::vector> T_OE({{271, 16}}); const double T_OE_LSB = TWO_P4; -const std::vector> FIT_INTERVAL_FLAG({{271, 1}}); -const std::vector> AODO({{272, 5}}); -const int AODO_LSB = 900; +const std::vector> FIT_INTERVAL_FLAG({{271, 1}}); +const std::vector> AODO({{272, 5}}); +const int32_t AODO_LSB = 900; // SUBFRAME 3 -const std::vector> C_IC({{61, 16}}); +const std::vector> C_IC({{61, 16}}); const double C_IC_LSB = TWO_N29; -const std::vector> OMEGA_0({{77, 8}, {91, 24}}); +const std::vector> OMEGA_0({{77, 8}, {91, 24}}); const double OMEGA_0_LSB = PI_TWO_N31; -const std::vector> C_IS({{121, 16}}); +const std::vector> C_IS({{121, 16}}); const double C_IS_LSB = TWO_N29; -const std::vector> I_0({{137, 8}, {151, 24}}); +const std::vector> I_0({{137, 8}, {151, 24}}); const double I_0_LSB = PI_TWO_N31; -const std::vector> C_RC({{181, 16}}); +const std::vector> C_RC({{181, 16}}); const double C_RC_LSB = TWO_N5; -const std::vector> OMEGA({{197, 8}, {211, 24}}); +const std::vector> OMEGA({{197, 8}, {211, 24}}); const double OMEGA_LSB = PI_TWO_N31; -const std::vector> OMEGA_DOT({{241, 24}}); +const std::vector> OMEGA_DOT({{241, 24}}); const double OMEGA_DOT_LSB = PI_TWO_N43; -const std::vector> IODE_SF3({{271, 8}}); -const std::vector> I_DOT({{279, 14}}); +const std::vector> IODE_SF3({{271, 8}}); +const std::vector> I_DOT({{279, 14}}); const double I_DOT_LSB = PI_TWO_N43; // SUBFRAME 4-5 -const std::vector> SV_DATA_ID({{61, 2}}); -const std::vector> SV_PAGE({{63, 6}}); +const std::vector> SV_DATA_ID({{61, 2}}); +const std::vector> SV_PAGE({{63, 6}}); // SUBFRAME 4 //! \todo read all pages of subframe 4 // Page 18 - Ionospheric and UTC data -const std::vector> ALPHA_0({{69, 8}}); +const std::vector> ALPHA_0({{69, 8}}); const double ALPHA_0_LSB = TWO_N30; -const std::vector> ALPHA_1({{77, 8}}); +const std::vector> ALPHA_1({{77, 8}}); const double ALPHA_1_LSB = TWO_N27; -const std::vector> ALPHA_2({{91, 8}}); +const std::vector> ALPHA_2({{91, 8}}); const double ALPHA_2_LSB = TWO_N24; -const std::vector> ALPHA_3({{99, 8}}); +const std::vector> ALPHA_3({{99, 8}}); const double ALPHA_3_LSB = TWO_N24; -const std::vector> BETA_0({{107, 8}}); +const std::vector> BETA_0({{107, 8}}); const double BETA_0_LSB = TWO_P11; -const std::vector> BETA_1({{121, 8}}); +const std::vector> BETA_1({{121, 8}}); const double BETA_1_LSB = TWO_P14; -const std::vector> BETA_2({{129, 8}}); +const std::vector> BETA_2({{129, 8}}); const double BETA_2_LSB = TWO_P16; -const std::vector> BETA_3({{137, 8}}); +const std::vector> BETA_3({{137, 8}}); const double BETA_3_LSB = TWO_P16; -const std::vector> A_1({{151, 24}}); +const std::vector> A_1({{151, 24}}); const double A_1_LSB = TWO_N50; -const std::vector> A_0({{181, 24}, {211, 8}}); +const std::vector> A_0({{181, 24}, {211, 8}}); const double A_0_LSB = TWO_N30; -const std::vector> T_OT({{219, 8}}); +const std::vector> T_OT({{219, 8}}); const double T_OT_LSB = TWO_P12; -const std::vector> WN_T({{227, 8}}); +const std::vector> WN_T({{227, 8}}); const double WN_T_LSB = 1; -const std::vector> DELTAT_LS({{241, 8}}); +const std::vector> DELTAT_LS({{241, 8}}); const double DELTAT_LS_LSB = 1; -const std::vector> WN_LSF({{249, 8}}); +const std::vector> WN_LSF({{249, 8}}); const double WN_LSF_LSB = 1; -const std::vector> DN({{257, 8}}); +const std::vector> DN({{257, 8}}); const double DN_LSB = 1; -const std::vector> DELTAT_LSF({{271, 8}}); +const std::vector> DELTAT_LSF({{271, 8}}); const double DELTAT_LSF_LSB = 1; // Page 25 - Antispoofing, SV config and SV health (PRN 25 -32) -const std::vector> HEALTH_SV25({{229, 6}}); -const std::vector> HEALTH_SV26({{241, 6}}); -const std::vector> HEALTH_SV27({{247, 6}}); -const std::vector> HEALTH_SV28({{253, 6}}); -const std::vector> HEALTH_SV29({{259, 6}}); -const std::vector> HEALTH_SV30({{271, 6}}); -const std::vector> HEALTH_SV31({{277, 6}}); -const std::vector> HEALTH_SV32({{283, 6}}); +const std::vector> HEALTH_SV25({{229, 6}}); +const std::vector> HEALTH_SV26({{241, 6}}); +const std::vector> HEALTH_SV27({{247, 6}}); +const std::vector> HEALTH_SV28({{253, 6}}); +const std::vector> HEALTH_SV29({{259, 6}}); +const std::vector> HEALTH_SV30({{271, 6}}); +const std::vector> HEALTH_SV31({{277, 6}}); +const std::vector> HEALTH_SV32({{283, 6}}); // SUBFRAME 5 //! \todo read all pages of subframe 5 // page 25 - Health (PRN 1 - 24) -const std::vector> T_OA({{69, 8}}); +const std::vector> T_OA({{69, 8}}); const double T_OA_LSB = TWO_P12; -const std::vector> WN_A({{77, 8}}); -const std::vector> HEALTH_SV1({{91, 6}}); -const std::vector> HEALTH_SV2({{97, 6}}); -const std::vector> HEALTH_SV3({{103, 6}}); -const std::vector> HEALTH_SV4({{109, 6}}); -const std::vector> HEALTH_SV5({{121, 6}}); -const std::vector> HEALTH_SV6({{127, 6}}); -const std::vector> HEALTH_SV7({{133, 6}}); -const std::vector> HEALTH_SV8({{139, 6}}); -const std::vector> HEALTH_SV9({{151, 6}}); -const std::vector> HEALTH_SV10({{157, 6}}); -const std::vector> HEALTH_SV11({{163, 6}}); -const std::vector> HEALTH_SV12({{169, 6}}); -const std::vector> HEALTH_SV13({{181, 6}}); -const std::vector> HEALTH_SV14({{187, 6}}); -const std::vector> HEALTH_SV15({{193, 6}}); -const std::vector> HEALTH_SV16({{199, 6}}); -const std::vector> HEALTH_SV17({{211, 6}}); -const std::vector> HEALTH_SV18({{217, 6}}); -const std::vector> HEALTH_SV19({{223, 6}}); -const std::vector> HEALTH_SV20({{229, 6}}); -const std::vector> HEALTH_SV21({{241, 6}}); -const std::vector> HEALTH_SV22({{247, 6}}); -const std::vector> HEALTH_SV23({{253, 6}}); -const std::vector> HEALTH_SV24({{259, 6}}); +const std::vector> WN_A({{77, 8}}); +const std::vector> HEALTH_SV1({{91, 6}}); +const std::vector> HEALTH_SV2({{97, 6}}); +const std::vector> HEALTH_SV3({{103, 6}}); +const std::vector> HEALTH_SV4({{109, 6}}); +const std::vector> HEALTH_SV5({{121, 6}}); +const std::vector> HEALTH_SV6({{127, 6}}); +const std::vector> HEALTH_SV7({{133, 6}}); +const std::vector> HEALTH_SV8({{139, 6}}); +const std::vector> HEALTH_SV9({{151, 6}}); +const std::vector> HEALTH_SV10({{157, 6}}); +const std::vector> HEALTH_SV11({{163, 6}}); +const std::vector> HEALTH_SV12({{169, 6}}); +const std::vector> HEALTH_SV13({{181, 6}}); +const std::vector> HEALTH_SV14({{187, 6}}); +const std::vector> HEALTH_SV15({{193, 6}}); +const std::vector> HEALTH_SV16({{199, 6}}); +const std::vector> HEALTH_SV17({{211, 6}}); +const std::vector> HEALTH_SV18({{217, 6}}); +const std::vector> HEALTH_SV19({{223, 6}}); +const std::vector> HEALTH_SV20({{229, 6}}); +const std::vector> HEALTH_SV21({{241, 6}}); +const std::vector> HEALTH_SV22({{247, 6}}); +const std::vector> HEALTH_SV23({{253, 6}}); +const std::vector> HEALTH_SV24({{259, 6}}); #endif /* GNSS_SDR_GPS_L1_CA_H_ */ diff --git a/src/core/system_parameters/GPS_L2C.h b/src/core/system_parameters/GPS_L2C.h index 67a467192..b156dfe4a 100644 --- a/src/core/system_parameters/GPS_L2C.h +++ b/src/core/system_parameters/GPS_L2C.h @@ -50,19 +50,18 @@ const double GPS_L2_OMEGA_EARTH_DOT = 7.2921151467e-5; //!< Earth rotation rate const double GPS_L2_GM = 3.986005e14; //!< Universal gravitational constant times the mass of the Earth, [m^3/s^2] const double GPS_L2_F = -4.442807633e-10; //!< Constant, [s/(m)^(1/2)] - // carrier and code frequencies const double GPS_L2_FREQ_HZ = FREQ2; //!< L2 [Hz] -const double GPS_L2_M_CODE_RATE_HZ = 0.5115e6; //!< GPS L2 M code rate [chips/s] -const int GPS_L2_M_CODE_LENGTH_CHIPS = 10230; //!< GPS L2 M code length [chips] -const double GPS_L2_M_PERIOD = 0.02; //!< GPS L2 M code period [seconds] +const double GPS_L2_M_CODE_RATE_HZ = 0.5115e6; //!< GPS L2 M code rate [chips/s] +const int32_t GPS_L2_M_CODE_LENGTH_CHIPS = 10230; //!< GPS L2 M code length [chips] +const double GPS_L2_M_PERIOD = 0.02; //!< GPS L2 M code period [seconds] -const double GPS_L2_L_CODE_RATE_HZ = 0.5115e6; //!< GPS L2 L code rate [chips/s] -const int GPS_L2_L_CODE_LENGTH_CHIPS = 767250; //!< GPS L2 L code length [chips] -const double GPS_L2_L_PERIOD = 1.5; //!< GPS L2 L code period [seconds] +const double GPS_L2_L_CODE_RATE_HZ = 0.5115e6; //!< GPS L2 L code rate [chips/s] +const int32_t GPS_L2_L_CODE_LENGTH_CHIPS = 767250; //!< GPS L2 L code length [chips] +const double GPS_L2_L_PERIOD = 1.5; //!< GPS L2 L code period [seconds] -const int GPS_L2C_HISTORY_DEEP = 5; +const int32_t GPS_L2C_HISTORY_DEEP = 5; const int32_t GPS_L2C_M_INIT_REG[115] = {0742417664, 0756014035, 0002747144, 0066265724, // 1:4 @@ -79,9 +78,9 @@ const int32_t GPS_L2C_M_INIT_REG[115] = 0047457275, 0266333164, 0713167356, 0060546335, 0355173035, 0617201036, 0157465571, 0767360553, 0023127030, 0431343777, 0747317317, 0045706125, - 0002744276, 0060036467, 0217744147, 0603340174, //57:60 - 0326616775, 0063240065, 0111460621, //61:63 - 0604055104, 0157065232, 0013305707, 0603552017, //159:162 + 0002744276, 0060036467, 0217744147, 0603340174, // 57:60 + 0326616775, 0063240065, 0111460621, // 61:63 + 0604055104, 0157065232, 0013305707, 0603552017, // 159:162 0230461355, 0603653437, 0652346475, 0743107103, 0401521277, 0167335110, 0014013575, 0362051132, 0617753265, 0216363634, 0755561123, 0365304033, @@ -95,10 +94,10 @@ const int32_t GPS_L2C_M_INIT_REG[115] = 0706202440, 0705056276, 0020373522, 0746013617, 0132720621, 0434015513, 0566721727, 0140633660}; -const int GPS_L2_CNAV_DATA_PAGE_BITS = 300; //!< GPS L2 CNAV page length, including preamble and CRC [bits] -const int GPS_L2_SYMBOLS_PER_BIT = 2; -const int GPS_L2_SAMPLES_PER_SYMBOL = 1; -const int GPS_L2_CNAV_DATA_PAGE_SYMBOLS = 600; -const int GPS_L2_CNAV_DATA_PAGE_DURATION_S = 12; +const int32_t GPS_L2_CNAV_DATA_PAGE_BITS = 300; //!< GPS L2 CNAV page length, including preamble and CRC [bits] +const int32_t GPS_L2_SYMBOLS_PER_BIT = 2; +const int32_t GPS_L2_SAMPLES_PER_SYMBOL = 1; +const int32_t GPS_L2_CNAV_DATA_PAGE_SYMBOLS = 600; +const int32_t GPS_L2_CNAV_DATA_PAGE_DURATION_S = 12; #endif /* GNSS_SDR_GPS_L2C_H_ */ diff --git a/src/core/system_parameters/GPS_L5.h b/src/core/system_parameters/GPS_L5.h index 31d36e89d..fe270f204 100644 --- a/src/core/system_parameters/GPS_L5.h +++ b/src/core/system_parameters/GPS_L5.h @@ -48,22 +48,21 @@ const double GPS_L5_OMEGA_EARTH_DOT = 7.2921151467e-5; //!< Earth rotation rate const double GPS_L5_GM = 3.986005e14; //!< Universal gravitational constant times the mass of the Earth, [m^3/s^2] const double GPS_L5_F = -4.442807633e-10; //!< Constant, [s/(m)^(1/2)] - // carrier and code frequencies const double GPS_L5_FREQ_HZ = FREQ5; //!< L5 [Hz] -const double GPS_L5i_CODE_RATE_HZ = 10.23e6; //!< GPS L5i code rate [chips/s] -const int GPS_L5i_CODE_LENGTH_CHIPS = 10230; //!< GPS L5i code length [chips] -const double GPS_L5i_PERIOD = 0.001; //!< GPS L5 code period [seconds] -const int GPS_L5i_PERIOD_MS = 1; //!< GPS L5 code period [ms] -const double GPS_L5i_SYMBOL_PERIOD = 0.01; //!< GPS L5 symbol period [seconds] -const int GPS_L5i_SYMBOL_PERIOD_MS = 10; //!< GPS L5 symbol period [ms] +const double GPS_L5i_CODE_RATE_HZ = 10.23e6; //!< GPS L5i code rate [chips/s] +const int32_t GPS_L5i_CODE_LENGTH_CHIPS = 10230; //!< GPS L5i code length [chips] +const double GPS_L5i_PERIOD = 0.001; //!< GPS L5 code period [seconds] +const int32_t GPS_L5i_PERIOD_MS = 1; //!< GPS L5 code period [ms] +const double GPS_L5i_SYMBOL_PERIOD = 0.01; //!< GPS L5 symbol period [seconds] +const int32_t GPS_L5i_SYMBOL_PERIOD_MS = 10; //!< GPS L5 symbol period [ms] -const double GPS_L5q_CODE_RATE_HZ = 10.23e6; //!< GPS L5i code rate [chips/s] -const int GPS_L5q_CODE_LENGTH_CHIPS = 10230; //!< GPS L5i code length [chips] -const double GPS_L5q_PERIOD = 0.001; //!< GPS L5 code period [seconds] +const double GPS_L5q_CODE_RATE_HZ = 10.23e6; //!< GPS L5i code rate [chips/s] +const int32_t GPS_L5q_CODE_LENGTH_CHIPS = 10230; //!< GPS L5i code length [chips] +const double GPS_L5q_PERIOD = 0.001; //!< GPS L5 code period [seconds] -const int GPS_L5_HISTORY_DEEP = 5; +const int32_t GPS_L5_HISTORY_DEEP = 5; const int32_t GPS_L5i_INIT_REG[210] = {266, 365, 804, 1138, @@ -179,16 +178,16 @@ const int32_t GPS_L5q_INIT_REG[210] = 2765, 37, 1943, 7977, 2512, 4451, 4071}; -const int GPS_L5_CNAV_DATA_PAGE_BITS = 300; //!< GPS L5 CNAV page length, including preamble and CRC [bits] -const int GPS_L5_SYMBOLS_PER_BIT = 2; -const int GPS_L5_SAMPLES_PER_SYMBOL = 10; -const int GPS_L5_CNAV_DATA_PAGE_SYMBOLS = 600; -const int GPS_L5_CNAV_DATA_PAGE_DURATION_S = 6; -const int GPS_L5i_NH_CODE_LENGTH = 10; -const int GPS_L5i_NH_CODE[10] = {0, 0, 0, 0, 1, 1, 0, 1, 0, 1}; +const int32_t GPS_L5_CNAV_DATA_PAGE_BITS = 300; //!< GPS L5 CNAV page length, including preamble and CRC [bits] +const int32_t GPS_L5_SYMBOLS_PER_BIT = 2; +const int32_t GPS_L5_SAMPLES_PER_SYMBOL = 10; +const int32_t GPS_L5_CNAV_DATA_PAGE_SYMBOLS = 600; +const int32_t GPS_L5_CNAV_DATA_PAGE_DURATION_S = 6; +const int32_t GPS_L5i_NH_CODE_LENGTH = 10; +const int32_t GPS_L5i_NH_CODE[10] = {0, 0, 0, 0, 1, 1, 0, 1, 0, 1}; const std::string GPS_L5i_NH_CODE_STR = "0000110101"; -const int GPS_L5q_NH_CODE_LENGTH = 20; -const int GPS_L5q_NH_CODE[20] = {0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0}; +const int32_t GPS_L5q_NH_CODE_LENGTH = 20; +const int32_t GPS_L5q_NH_CODE[20] = {0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0}; const std::string GPS_L5q_NH_CODE_STR = "00000100110101001110"; #endif /* GNSS_SDR_GPS_L5_H_ */ diff --git a/src/core/system_parameters/Galileo_E1.h b/src/core/system_parameters/Galileo_E1.h index da005c877..b1d2e6191 100644 --- a/src/core/system_parameters/Galileo_E1.h +++ b/src/core/system_parameters/Galileo_E1.h @@ -35,6 +35,7 @@ #include "gnss_frequencies.h" #include "MATH_CONSTANTS.h" +#include #include #include #include // std::pair @@ -53,19 +54,19 @@ const double GALILEO_F = -4.442807309e-10; //!< Constant, [s/(m)^( const double Galileo_E1_FREQ_HZ = FREQ1; //!< Galileo E1 carrier frequency [Hz] const double Galileo_E1_CODE_CHIP_RATE_HZ = 1.023e6; //!< Galileo E1 code rate [chips/s] const double Galileo_E1_CODE_PERIOD = 0.004; //!< Galileo E1 code period [s] -const int Galileo_E1_CODE_PERIOD_MS = 4; //!< Galileo E1 code period [ms] +const int32_t Galileo_E1_CODE_PERIOD_MS = 4; //!< Galileo E1 code period [ms] const double Galileo_E1_SUB_CARRIER_A_RATE_HZ = 1.023e6; //!< Galileo E1 sub-carrier 'a' rate [Hz] const double Galileo_E1_SUB_CARRIER_B_RATE_HZ = 6.138e6; //!< Galileo E1 sub-carrier 'b' rate [Hz] const double Galileo_E1_B_CODE_LENGTH_CHIPS = 4092.0; //!< Galileo E1-B code length [chips] const double Galileo_E1_B_SYMBOL_RATE_BPS = 250.0; //!< Galileo E1-B symbol rate [bits/second] -const int Galileo_E1_C_SECONDARY_CODE_LENGTH = 25; //!< Galileo E1-C secondary code length [chips] -const int Galileo_E1_NUMBER_OF_CODES = 50; +const int32_t Galileo_E1_C_SECONDARY_CODE_LENGTH = 25; //!< Galileo E1-C secondary code length [chips] +const int32_t Galileo_E1_NUMBER_OF_CODES = 50; const double GALILEO_STARTOFFSET_ms = 68.802; //[ms] Initial sign. travel time (this cannot go here) // OBSERVABLE HISTORY DEEP FOR INTERPOLATION -const int GALILEO_E1_HISTORY_DEEP = 100; +const int32_t GALILEO_E1_HISTORY_DEEP = 100; // Galileo INAV Telemetry structure @@ -74,230 +75,230 @@ const int GALILEO_E1_HISTORY_DEEP = 100; 0, 1, 0, 1, 1, 0, 0, 0, 0, 0 \ } -const int GALILEO_INAV_PREAMBLE_LENGTH_BITS = 10; +const int32_t GALILEO_INAV_PREAMBLE_LENGTH_BITS = 10; const double GALILEO_INAV_PAGE_PART_WITH_PREABLE_SECONDS = 2.0 + GALILEO_INAV_PREAMBLE_LENGTH_BITS * Galileo_E1_CODE_PERIOD; -const int GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS = 250; -const int GALILEO_INAV_PAGE_PART_SYMBOLS = 250; //!< Each Galileo INAV pages are composed of two parts (even and odd) each of 250 symbols, including preamble. See Galileo ICD 4.3.2 -const int GALILEO_INAV_PAGE_SYMBOLS = 500; //!< The complete Galileo INAV page length -const int GALILEO_INAV_PAGE_PART_SECONDS = 1; // a page part last 1 sec -const int GALILEO_INAV_PAGE_PART_MS = 1000; // a page part last 1 sec -const int GALILEO_INAV_PAGE_SECONDS = 2; // a full page last 2 sec -const int GALILEO_INAV_INTERLEAVER_ROWS = 8; -const int GALILEO_INAV_INTERLEAVER_COLS = 30; -const int GALILEO_TELEMETRY_RATE_BITS_SECOND = 250; //bps -const int GALILEO_PAGE_TYPE_BITS = 6; -const int GALILEO_DATA_JK_BITS = 128; -const int GALILEO_DATA_FRAME_BITS = 196; -const int GALILEO_DATA_FRAME_BYTES = 25; +const int32_t GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS = 250; +const int32_t GALILEO_INAV_PAGE_PART_SYMBOLS = 250; //!< Each Galileo INAV pages are composed of two parts (even and odd) each of 250 symbols, including preamble. See Galileo ICD 4.3.2 +const int32_t GALILEO_INAV_PAGE_SYMBOLS = 500; //!< The complete Galileo INAV page length +const int32_t GALILEO_INAV_PAGE_PART_SECONDS = 1; // a page part last 1 sec +const int32_t GALILEO_INAV_PAGE_PART_MS = 1000; // a page part last 1 sec +const int32_t GALILEO_INAV_PAGE_SECONDS = 2; // a full page last 2 sec +const int32_t GALILEO_INAV_INTERLEAVER_ROWS = 8; +const int32_t GALILEO_INAV_INTERLEAVER_COLS = 30; +const int32_t GALILEO_TELEMETRY_RATE_BITS_SECOND = 250; //bps +const int32_t GALILEO_PAGE_TYPE_BITS = 6; +const int32_t GALILEO_DATA_JK_BITS = 128; +const int32_t GALILEO_DATA_FRAME_BITS = 196; +const int32_t GALILEO_DATA_FRAME_BYTES = 25; const double GALILEO_E1_CODE_PERIOD = 0.004; -const int GALILEO_E1_CODE_PERIOD_MS = 4; +const int32_t GALILEO_E1_CODE_PERIOD_MS = 4; -const std::vector> type({{1, 6}}); -const std::vector> PAGE_TYPE_bit({{1, 6}}); +const std::vector> type({{1, 6}}); +const std::vector> PAGE_TYPE_bit({{1, 6}}); ; /*Page 1 - Word type 1: Ephemeris (1/4)*/ -const std::vector> IOD_nav_1_bit({{7, 10}}); -const std::vector> T0E_1_bit({{17, 14}}); +const std::vector> IOD_nav_1_bit({{7, 10}}); +const std::vector> T0E_1_bit({{17, 14}}); const double t0e_1_LSB = 60; -const std::vector> M0_1_bit({{31, 32}}); +const std::vector> M0_1_bit({{31, 32}}); const double M0_1_LSB = PI_TWO_N31; -const std::vector> e_1_bit({{63, 32}}); +const std::vector> e_1_bit({{63, 32}}); const double e_1_LSB = TWO_N33; -const std::vector> A_1_bit({{95, 32}}); +const std::vector> A_1_bit({{95, 32}}); const double A_1_LSB_gal = TWO_N19; //last two bits are reserved /*Page 2 - Word type 2: Ephemeris (2/4)*/ -const std::vector> IOD_nav_2_bit({{7, 10}}); -const std::vector> OMEGA_0_2_bit({{17, 32}}); +const std::vector> IOD_nav_2_bit({{7, 10}}); +const std::vector> OMEGA_0_2_bit({{17, 32}}); const double OMEGA_0_2_LSB = PI_TWO_N31; -const std::vector> i_0_2_bit({{49, 32}}); +const std::vector> i_0_2_bit({{49, 32}}); const double i_0_2_LSB = PI_TWO_N31; -const std::vector> omega_2_bit({{81, 32}}); +const std::vector> omega_2_bit({{81, 32}}); const double omega_2_LSB = PI_TWO_N31; -const std::vector> iDot_2_bit({{113, 14}}); +const std::vector> iDot_2_bit({{113, 14}}); const double iDot_2_LSB = PI_TWO_N43; //last two bits are reserved /*Word type 3: Ephemeris (3/4) and SISA*/ -const std::vector> IOD_nav_3_bit({{7, 10}}); -const std::vector> OMEGA_dot_3_bit({{17, 24}}); +const std::vector> IOD_nav_3_bit({{7, 10}}); +const std::vector> OMEGA_dot_3_bit({{17, 24}}); const double OMEGA_dot_3_LSB = PI_TWO_N43; -const std::vector> delta_n_3_bit({{41, 16}}); +const std::vector> delta_n_3_bit({{41, 16}}); const double delta_n_3_LSB = PI_TWO_N43; -const std::vector> C_uc_3_bit({{57, 16}}); +const std::vector> C_uc_3_bit({{57, 16}}); const double C_uc_3_LSB = TWO_N29; -const std::vector> C_us_3_bit({{73, 16}}); +const std::vector> C_us_3_bit({{73, 16}}); const double C_us_3_LSB = TWO_N29; -const std::vector> C_rc_3_bit({{89, 16}}); +const std::vector> C_rc_3_bit({{89, 16}}); const double C_rc_3_LSB = TWO_N5; -const std::vector> C_rs_3_bit({{105, 16}}); +const std::vector> C_rs_3_bit({{105, 16}}); const double C_rs_3_LSB = TWO_N5; -const std::vector> SISA_3_bit({{121, 8}}); +const std::vector> SISA_3_bit({{121, 8}}); /*Word type 4: Ephemeris (4/4) and Clock correction parameters*/ -const std::vector> IOD_nav_4_bit({{7, 10}}); -const std::vector> SV_ID_PRN_4_bit({{17, 6}}); -const std::vector> C_ic_4_bit({{23, 16}}); +const std::vector> IOD_nav_4_bit({{7, 10}}); +const std::vector> SV_ID_PRN_4_bit({{17, 6}}); +const std::vector> C_ic_4_bit({{23, 16}}); const double C_ic_4_LSB = TWO_N29; -const std::vector> C_is_4_bit({{39, 16}}); +const std::vector> C_is_4_bit({{39, 16}}); const double C_is_4_LSB = TWO_N29; -const std::vector> t0c_4_bit({{55, 14}}); // +const std::vector> t0c_4_bit({{55, 14}}); // const double t0c_4_LSB = 60; -const std::vector> af0_4_bit({{69, 31}}); // +const std::vector> af0_4_bit({{69, 31}}); // const double af0_4_LSB = TWO_N34; -const std::vector> af1_4_bit({{100, 21}}); // +const std::vector> af1_4_bit({{100, 21}}); // const double af1_4_LSB = TWO_N46; -const std::vector> af2_4_bit({{121, 6}}); +const std::vector> af2_4_bit({{121, 6}}); const double af2_4_LSB = TWO_N59; -const std::vector> spare_4_bit({{127, 2}}); +const std::vector> spare_4_bit({{127, 2}}); //last two bits are reserved /*Word type 5: Ionospheric correction, BGD, signal health and data validity status and GST*/ /*Ionospheric correction*/ /*Az*/ -const std::vector> ai0_5_bit({{7, 11}}); // +const std::vector> ai0_5_bit({{7, 11}}); // const double ai0_5_LSB = TWO_N2; -const std::vector> ai1_5_bit({{18, 11}}); // +const std::vector> ai1_5_bit({{18, 11}}); // const double ai1_5_LSB = TWO_N8; -const std::vector> ai2_5_bit({{29, 14}}); // +const std::vector> ai2_5_bit({{29, 14}}); // const double ai2_5_LSB = TWO_N15; /*Ionospheric disturbance flag*/ -const std::vector> Region1_5_bit({{43, 1}}); // -const std::vector> Region2_5_bit({{44, 1}}); // -const std::vector> Region3_5_bit({{45, 1}}); // -const std::vector> Region4_5_bit({{46, 1}}); // -const std::vector> Region5_5_bit({{47, 1}}); // -const std::vector> BGD_E1E5a_5_bit({{48, 10}}); // +const std::vector> Region1_5_bit({{43, 1}}); // +const std::vector> Region2_5_bit({{44, 1}}); // +const std::vector> Region3_5_bit({{45, 1}}); // +const std::vector> Region4_5_bit({{46, 1}}); // +const std::vector> Region5_5_bit({{47, 1}}); // +const std::vector> BGD_E1E5a_5_bit({{48, 10}}); // const double BGD_E1E5a_5_LSB = TWO_N32; -const std::vector> BGD_E1E5b_5_bit({{58, 10}}); // +const std::vector> BGD_E1E5b_5_bit({{58, 10}}); // const double BGD_E1E5b_5_LSB = TWO_N32; -const std::vector> E5b_HS_5_bit({{68, 2}}); // -const std::vector> E1B_HS_5_bit({{70, 2}}); // -const std::vector> E5b_DVS_5_bit({{72, 1}}); // -const std::vector> E1B_DVS_5_bit({{73, 1}}); // +const std::vector> E5b_HS_5_bit({{68, 2}}); // +const std::vector> E1B_HS_5_bit({{70, 2}}); // +const std::vector> E5b_DVS_5_bit({{72, 1}}); // +const std::vector> E1B_DVS_5_bit({{73, 1}}); // /*GST*/ -const std::vector> WN_5_bit({{74, 12}}); -const std::vector> TOW_5_bit({{86, 20}}); -const std::vector> spare_5_bit({{106, 23}}); +const std::vector> WN_5_bit({{74, 12}}); +const std::vector> TOW_5_bit({{86, 20}}); +const std::vector> spare_5_bit({{106, 23}}); /* Page 6 */ -const std::vector> A0_6_bit({{7, 32}}); +const std::vector> A0_6_bit({{7, 32}}); const double A0_6_LSB = TWO_N30; -const std::vector> A1_6_bit({{39, 24}}); +const std::vector> A1_6_bit({{39, 24}}); const double A1_6_LSB = TWO_N50; -const std::vector> Delta_tLS_6_bit({{63, 8}}); -const std::vector> t0t_6_bit({{71, 8}}); +const std::vector> Delta_tLS_6_bit({{63, 8}}); +const std::vector> t0t_6_bit({{71, 8}}); const double t0t_6_LSB = 3600; -const std::vector> WNot_6_bit({{79, 8}}); -const std::vector> WN_LSF_6_bit({{87, 8}}); -const std::vector> DN_6_bit({{95, 3}}); -const std::vector> Delta_tLSF_6_bit({{98, 8}}); -const std::vector> TOW_6_bit({{106, 20}}); +const std::vector> WNot_6_bit({{79, 8}}); +const std::vector> WN_LSF_6_bit({{87, 8}}); +const std::vector> DN_6_bit({{95, 3}}); +const std::vector> Delta_tLSF_6_bit({{98, 8}}); +const std::vector> TOW_6_bit({{106, 20}}); /* Page 7 */ -const std::vector> IOD_a_7_bit({{7, 4}}); -const std::vector> WN_a_7_bit({{11, 2}}); -const std::vector> t0a_7_bit({{13, 10}}); +const std::vector> IOD_a_7_bit({{7, 4}}); +const std::vector> WN_a_7_bit({{11, 2}}); +const std::vector> t0a_7_bit({{13, 10}}); const double t0a_7_LSB = 600; -const std::vector> SVID1_7_bit({{23, 6}}); -const std::vector> DELTA_A_7_bit({{29, 13}}); +const std::vector> SVID1_7_bit({{23, 6}}); +const std::vector> DELTA_A_7_bit({{29, 13}}); const double DELTA_A_7_LSB = TWO_N9; -const std::vector> e_7_bit({{42, 11}}); +const std::vector> e_7_bit({{42, 11}}); const double e_7_LSB = TWO_N16; -const std::vector> omega_7_bit({{53, 16}}); +const std::vector> omega_7_bit({{53, 16}}); const double omega_7_LSB = TWO_N15; -const std::vector> delta_i_7_bit({{69, 11}}); +const std::vector> delta_i_7_bit({{69, 11}}); const double delta_i_7_LSB = TWO_N14; -const std::vector> Omega0_7_bit({{80, 16}}); +const std::vector> Omega0_7_bit({{80, 16}}); const double Omega0_7_LSB = TWO_N15; -const std::vector> Omega_dot_7_bit({{96, 11}}); +const std::vector> Omega_dot_7_bit({{96, 11}}); const double Omega_dot_7_LSB = TWO_N33; -const std::vector> M0_7_bit({{107, 16}}); +const std::vector> M0_7_bit({{107, 16}}); const double M0_7_LSB = TWO_N15; /* Page 8 */ -const std::vector> IOD_a_8_bit({{7, 4}}); -const std::vector> af0_8_bit({{11, 16}}); +const std::vector> IOD_a_8_bit({{7, 4}}); +const std::vector> af0_8_bit({{11, 16}}); const double af0_8_LSB = TWO_N19; -const std::vector> af1_8_bit({{27, 13}}); +const std::vector> af1_8_bit({{27, 13}}); const double af1_8_LSB = TWO_N38; -const std::vector> E5b_HS_8_bit({{40, 2}}); -const std::vector> E1B_HS_8_bit({{42, 2}}); -const std::vector> SVID2_8_bit({{44, 6}}); -const std::vector> DELTA_A_8_bit({{50, 13}}); +const std::vector> E5b_HS_8_bit({{40, 2}}); +const std::vector> E1B_HS_8_bit({{42, 2}}); +const std::vector> SVID2_8_bit({{44, 6}}); +const std::vector> DELTA_A_8_bit({{50, 13}}); const double DELTA_A_8_LSB = TWO_N9; -const std::vector> e_8_bit({{63, 11}}); +const std::vector> e_8_bit({{63, 11}}); const double e_8_LSB = TWO_N16; -const std::vector> omega_8_bit({{74, 16}}); +const std::vector> omega_8_bit({{74, 16}}); const double omega_8_LSB = TWO_N15; -const std::vector> delta_i_8_bit({{90, 11}}); +const std::vector> delta_i_8_bit({{90, 11}}); const double delta_i_8_LSB = TWO_N14; -const std::vector> Omega0_8_bit({{101, 16}}); +const std::vector> Omega0_8_bit({{101, 16}}); const double Omega0_8_LSB = TWO_N15; -const std::vector> Omega_dot_8_bit({{117, 11}}); +const std::vector> Omega_dot_8_bit({{117, 11}}); const double Omega_dot_8_LSB = TWO_N33; /* Page 9 */ -const std::vector> IOD_a_9_bit({{7, 4}}); -const std::vector> WN_a_9_bit({{11, 2}}); -const std::vector> t0a_9_bit({{13, 10}}); +const std::vector> IOD_a_9_bit({{7, 4}}); +const std::vector> WN_a_9_bit({{11, 2}}); +const std::vector> t0a_9_bit({{13, 10}}); const double t0a_9_LSB = 600; -const std::vector> M0_9_bit({{23, 16}}); +const std::vector> M0_9_bit({{23, 16}}); const double M0_9_LSB = TWO_N15; -const std::vector> af0_9_bit({{39, 16}}); +const std::vector> af0_9_bit({{39, 16}}); const double af0_9_LSB = TWO_N19; -const std::vector> af1_9_bit({{55, 13}}); +const std::vector> af1_9_bit({{55, 13}}); const double af1_9_LSB = TWO_N38; -const std::vector> E5b_HS_9_bit({{68, 2}}); -const std::vector> E1B_HS_9_bit({{70, 2}}); -const std::vector> SVID3_9_bit({{72, 6}}); -const std::vector> DELTA_A_9_bit({{78, 13}}); +const std::vector> E5b_HS_9_bit({{68, 2}}); +const std::vector> E1B_HS_9_bit({{70, 2}}); +const std::vector> SVID3_9_bit({{72, 6}}); +const std::vector> DELTA_A_9_bit({{78, 13}}); const double DELTA_A_9_LSB = TWO_N9; -const std::vector> e_9_bit({{91, 11}}); +const std::vector> e_9_bit({{91, 11}}); const double e_9_LSB = TWO_N16; -const std::vector> omega_9_bit({{102, 16}}); +const std::vector> omega_9_bit({{102, 16}}); const double omega_9_LSB = TWO_N15; -const std::vector> delta_i_9_bit({{118, 11}}); +const std::vector> delta_i_9_bit({{118, 11}}); const double delta_i_9_LSB = TWO_N14; /* Page 10 */ -const std::vector> IOD_a_10_bit({{7, 4}}); -const std::vector> Omega0_10_bit({{11, 16}}); +const std::vector> IOD_a_10_bit({{7, 4}}); +const std::vector> Omega0_10_bit({{11, 16}}); const double Omega0_10_LSB = TWO_N15; -const std::vector> Omega_dot_10_bit({{27, 11}}); +const std::vector> Omega_dot_10_bit({{27, 11}}); const double Omega_dot_10_LSB = TWO_N33; -const std::vector> M0_10_bit({{38, 16}}); +const std::vector> M0_10_bit({{38, 16}}); const double M0_10_LSB = TWO_N15; -const std::vector> af0_10_bit({{54, 16}}); +const std::vector> af0_10_bit({{54, 16}}); const double af0_10_LSB = TWO_N19; -const std::vector> af1_10_bit({{70, 13}}); +const std::vector> af1_10_bit({{70, 13}}); const double af1_10_LSB = TWO_N38; -const std::vector> E5b_HS_10_bit({{83, 2}}); -const std::vector> E1B_HS_10_bit({{85, 2}}); -const std::vector> A_0G_10_bit({{87, 16}}); +const std::vector> E5b_HS_10_bit({{83, 2}}); +const std::vector> E1B_HS_10_bit({{85, 2}}); +const std::vector> A_0G_10_bit({{87, 16}}); const double A_0G_10_LSB = TWO_N35; -const std::vector> A_1G_10_bit({{103, 12}}); +const std::vector> A_1G_10_bit({{103, 12}}); const double A_1G_10_LSB = TWO_N51; -const std::vector> t_0G_10_bit({{115, 8}}); +const std::vector> t_0G_10_bit({{115, 8}}); const double t_0G_10_LSB = 3600; -const std::vector> WN_0G_10_bit({{123, 6}}); +const std::vector> WN_0G_10_bit({{123, 6}}); /* Page 0 */ -const std::vector> Time_0_bit({{7, 2}}); -const std::vector> WN_0_bit({{97, 12}}); -const std::vector> TOW_0_bit({{109, 20}}); +const std::vector> Time_0_bit({{7, 2}}); +const std::vector> WN_0_bit({{97, 12}}); +const std::vector> TOW_0_bit({{109, 20}}); // Galileo E1 primary codes diff --git a/src/core/system_parameters/Galileo_E5a.h b/src/core/system_parameters/Galileo_E5a.h index 79ad94f81..ea84ab3c9 100644 --- a/src/core/system_parameters/Galileo_E5a.h +++ b/src/core/system_parameters/Galileo_E5a.h @@ -33,193 +33,194 @@ #include "gnss_frequencies.h" #include "MATH_CONSTANTS.h" +#include #include #include #include // std::pair // Carrier and code frequencies -const double Galileo_E5a_FREQ_HZ = FREQ5; //!< Galileo E5a carrier frequency [Hz] -const double Galileo_E5a_CODE_CHIP_RATE_HZ = 1.023e7; //!< Galileo E5a code rate [chips/s] -const double Galileo_E5a_I_TIERED_CODE_PERIOD = 0.020; //!< Galileo E5a-I tiered code period [s] -const double Galileo_E5a_Q_TIERED_CODE_PERIOD = 0.100; //!< Galileo E5a-Q tiered code period [s] -const int Galileo_E5a_CODE_LENGTH_CHIPS = 10230; //!< Galileo E5a primary code length [chips] -const int Galileo_E5a_I_SECONDARY_CODE_LENGTH = 20; //!< Galileo E5a-I secondary code length [chips] -const int Galileo_E5a_Q_SECONDARY_CODE_LENGTH = 100; //!< Galileo E5a-Q secondary code length [chips] -const double GALILEO_E5a_CODE_PERIOD = 0.001; //!< Galileo E1 primary code period [s] -const int GALILEO_E5a_CODE_PERIOD_MS = 1; //!< Galileo E1 primary code period [ms] -const int Galileo_E5a_SYMBOL_RATE_BPS = 50; //!< Galileo E5a symbol rate [bits/second] -const int Galileo_E5a_NUMBER_OF_CODES = 50; +const double Galileo_E5a_FREQ_HZ = FREQ5; //!< Galileo E5a carrier frequency [Hz] +const double Galileo_E5a_CODE_CHIP_RATE_HZ = 1.023e7; //!< Galileo E5a code rate [chips/s] +const double Galileo_E5a_I_TIERED_CODE_PERIOD = 0.020; //!< Galileo E5a-I tiered code period [s] +const double Galileo_E5a_Q_TIERED_CODE_PERIOD = 0.100; //!< Galileo E5a-Q tiered code period [s] +const int32_t Galileo_E5a_CODE_LENGTH_CHIPS = 10230; //!< Galileo E5a primary code length [chips] +const int32_t Galileo_E5a_I_SECONDARY_CODE_LENGTH = 20; //!< Galileo E5a-I secondary code length [chips] +const int32_t Galileo_E5a_Q_SECONDARY_CODE_LENGTH = 100; //!< Galileo E5a-Q secondary code length [chips] +const double GALILEO_E5a_CODE_PERIOD = 0.001; //!< Galileo E1 primary code period [s] +const int32_t GALILEO_E5a_CODE_PERIOD_MS = 1; //!< Galileo E1 primary code period [ms] +const int32_t Galileo_E5a_SYMBOL_RATE_BPS = 50; //!< Galileo E5a symbol rate [bits/second] +const int32_t Galileo_E5a_NUMBER_OF_CODES = 50; // OBSERVABLE HISTORY DEEP FOR INTERPOLATION AND CRC ERROR LIMIT -const int GALILEO_E5A_HISTORY_DEEP = 20; -const int GALILEO_E5A_CRC_ERROR_LIMIT = 6; +const int32_t GALILEO_E5A_HISTORY_DEEP = 20; +const int32_t GALILEO_E5A_CRC_ERROR_LIMIT = 6; // F/NAV message structure -const int GALILEO_FNAV_PREAMBLE_LENGTH_BITS = 12; +const int32_t GALILEO_FNAV_PREAMBLE_LENGTH_BITS = 12; const std::string GALILEO_FNAV_PREAMBLE = {"101101110000"}; -const int GALILEO_FNAV_CODES_PER_SYMBOL = 20; // (chip rate/ code length)/telemetry bps -const int GALILEO_FNAV_CODES_PER_PREAMBLE = 240; // bits preamble * codes/symbol -const int GALILEO_FNAV_SYMBOLS_PER_PAGE = 500; //Total symbols per page including preamble. See Galileo ICD 4.2.2 -const int GALILEO_FNAV_SECONDS_PER_PAGE = 10; -const int GALILEO_FNAV_CODES_PER_PAGE = 10000; // symbols * codes/symbol, where code stands for primary code +const int32_t GALILEO_FNAV_CODES_PER_SYMBOL = 20; // (chip rate/ code length)/telemetry bps +const int32_t GALILEO_FNAV_CODES_PER_PREAMBLE = 240; // bits preamble * codes/symbol +const int32_t GALILEO_FNAV_SYMBOLS_PER_PAGE = 500; // Total symbols per page including preamble. See Galileo ICD 4.2.2 +const int32_t GALILEO_FNAV_SECONDS_PER_PAGE = 10; +const int32_t GALILEO_FNAV_CODES_PER_PAGE = 10000; // symbols * codes/symbol, where code stands for primary code -const int GALILEO_FNAV_INTERLEAVER_ROWS = 8; -const int GALILEO_FNAV_INTERLEAVER_COLS = 61; -const int GALILEO_FNAV_PAGE_TYPE_BITS = 6; +const int32_t GALILEO_FNAV_INTERLEAVER_ROWS = 8; +const int32_t GALILEO_FNAV_INTERLEAVER_COLS = 61; +const int32_t GALILEO_FNAV_PAGE_TYPE_BITS = 6; -const int GALILEO_FNAV_DATA_FRAME_BITS = 214; -const int GALILEO_FNAV_DATA_FRAME_BYTES = 27; +const int32_t GALILEO_FNAV_DATA_FRAME_BITS = 214; +const int32_t GALILEO_FNAV_DATA_FRAME_BYTES = 27; -const std::vector> FNAV_PAGE_TYPE_bit({{1, 6}}); +const std::vector> FNAV_PAGE_TYPE_bit({{1, 6}}); /* WORD 1 iono corrections. FNAV (Galileo E5a message)*/ -const std::vector> FNAV_SV_ID_PRN_1_bit({{7, 6}}); -const std::vector> FNAV_IODnav_1_bit({{13, 10}}); -const std::vector> FNAV_t0c_1_bit({{23, 14}}); +const std::vector> FNAV_SV_ID_PRN_1_bit({{7, 6}}); +const std::vector> FNAV_IODnav_1_bit({{13, 10}}); +const std::vector> FNAV_t0c_1_bit({{23, 14}}); const double FNAV_t0c_1_LSB = 60; -const std::vector> FNAV_af0_1_bit({{37, 31}}); +const std::vector> FNAV_af0_1_bit({{37, 31}}); const double FNAV_af0_1_LSB = TWO_N34; -const std::vector> FNAV_af1_1_bit({{68, 21}}); +const std::vector> FNAV_af1_1_bit({{68, 21}}); const double FNAV_af1_1_LSB = TWO_N46; -const std::vector> FNAV_af2_1_bit({{89, 6}}); +const std::vector> FNAV_af2_1_bit({{89, 6}}); const double FNAV_af2_1_LSB = TWO_N59; -const std::vector> FNAV_SISA_1_bit({{95, 8}}); -const std::vector> FNAV_ai0_1_bit({{103, 11}}); +const std::vector> FNAV_SISA_1_bit({{95, 8}}); +const std::vector> FNAV_ai0_1_bit({{103, 11}}); const double FNAV_ai0_1_LSB = TWO_N2; -const std::vector> FNAV_ai1_1_bit({{114, 11}}); +const std::vector> FNAV_ai1_1_bit({{114, 11}}); const double FNAV_ai1_1_LSB = TWO_N8; -const std::vector> FNAV_ai2_1_bit({{125, 14}}); +const std::vector> FNAV_ai2_1_bit({{125, 14}}); const double FNAV_ai2_1_LSB = TWO_N15; -const std::vector> FNAV_region1_1_bit({{139, 1}}); -const std::vector> FNAV_region2_1_bit({{140, 1}}); -const std::vector> FNAV_region3_1_bit({{141, 1}}); -const std::vector> FNAV_region4_1_bit({{142, 1}}); -const std::vector> FNAV_region5_1_bit({{143, 1}}); -const std::vector> FNAV_BGD_1_bit({{144, 10}}); +const std::vector> FNAV_region1_1_bit({{139, 1}}); +const std::vector> FNAV_region2_1_bit({{140, 1}}); +const std::vector> FNAV_region3_1_bit({{141, 1}}); +const std::vector> FNAV_region4_1_bit({{142, 1}}); +const std::vector> FNAV_region5_1_bit({{143, 1}}); +const std::vector> FNAV_BGD_1_bit({{144, 10}}); const double FNAV_BGD_1_LSB = TWO_N32; -const std::vector> FNAV_E5ahs_1_bit({{154, 2}}); -const std::vector> FNAV_WN_1_bit({{156, 12}}); -const std::vector> FNAV_TOW_1_bit({{168, 20}}); -const std::vector> FNAV_E5advs_1_bit({{188, 1}}); +const std::vector> FNAV_E5ahs_1_bit({{154, 2}}); +const std::vector> FNAV_WN_1_bit({{156, 12}}); +const std::vector> FNAV_TOW_1_bit({{168, 20}}); +const std::vector> FNAV_E5advs_1_bit({{188, 1}}); // WORD 2 Ephemeris (1/3) -const std::vector> FNAV_IODnav_2_bit({{7, 10}}); -const std::vector> FNAV_M0_2_bit({{17, 32}}); +const std::vector> FNAV_IODnav_2_bit({{7, 10}}); +const std::vector> FNAV_M0_2_bit({{17, 32}}); const double FNAV_M0_2_LSB = PI_TWO_N31; -const std::vector> FNAV_omegadot_2_bit({{49, 24}}); +const std::vector> FNAV_omegadot_2_bit({{49, 24}}); const double FNAV_omegadot_2_LSB = PI_TWO_N43; -const std::vector> FNAV_e_2_bit({{73, 32}}); +const std::vector> FNAV_e_2_bit({{73, 32}}); const double FNAV_e_2_LSB = TWO_N33; -const std::vector> FNAV_a12_2_bit({{105, 32}}); +const std::vector> FNAV_a12_2_bit({{105, 32}}); const double FNAV_a12_2_LSB = TWO_N19; -const std::vector> FNAV_omega0_2_bit({{137, 32}}); +const std::vector> FNAV_omega0_2_bit({{137, 32}}); const double FNAV_omega0_2_LSB = PI_TWO_N31; -const std::vector> FNAV_idot_2_bit({{169, 14}}); +const std::vector> FNAV_idot_2_bit({{169, 14}}); const double FNAV_idot_2_LSB = PI_TWO_N43; -const std::vector> FNAV_WN_2_bit({{183, 12}}); -const std::vector> FNAV_TOW_2_bit({{195, 20}}); +const std::vector> FNAV_WN_2_bit({{183, 12}}); +const std::vector> FNAV_TOW_2_bit({{195, 20}}); // WORD 3 Ephemeris (2/3) -const std::vector> FNAV_IODnav_3_bit({{7, 10}}); -const std::vector> FNAV_i0_3_bit({{17, 32}}); +const std::vector> FNAV_IODnav_3_bit({{7, 10}}); +const std::vector> FNAV_i0_3_bit({{17, 32}}); const double FNAV_i0_3_LSB = PI_TWO_N31; -const std::vector> FNAV_w_3_bit({{49, 32}}); +const std::vector> FNAV_w_3_bit({{49, 32}}); const double FNAV_w_3_LSB = PI_TWO_N31; -const std::vector> FNAV_deltan_3_bit({{81, 16}}); +const std::vector> FNAV_deltan_3_bit({{81, 16}}); const double FNAV_deltan_3_LSB = PI_TWO_N43; -const std::vector> FNAV_Cuc_3_bit({{97, 16}}); +const std::vector> FNAV_Cuc_3_bit({{97, 16}}); const double FNAV_Cuc_3_LSB = TWO_N29; -const std::vector> FNAV_Cus_3_bit({{113, 16}}); +const std::vector> FNAV_Cus_3_bit({{113, 16}}); const double FNAV_Cus_3_LSB = TWO_N29; -const std::vector> FNAV_Crc_3_bit({{129, 16}}); +const std::vector> FNAV_Crc_3_bit({{129, 16}}); const double FNAV_Crc_3_LSB = TWO_N5; -const std::vector> FNAV_Crs_3_bit({{145, 16}}); +const std::vector> FNAV_Crs_3_bit({{145, 16}}); const double FNAV_Crs_3_LSB = TWO_N5; -const std::vector> FNAV_t0e_3_bit({{161, 14}}); +const std::vector> FNAV_t0e_3_bit({{161, 14}}); const double FNAV_t0e_3_LSB = 60; -const std::vector> FNAV_WN_3_bit({{175, 12}}); -const std::vector> FNAV_TOW_3_bit({{187, 20}}); +const std::vector> FNAV_WN_3_bit({{175, 12}}); +const std::vector> FNAV_TOW_3_bit({{187, 20}}); // WORD 4 Ephemeris (3/3) -const std::vector> FNAV_IODnav_4_bit({{7, 10}}); -const std::vector> FNAV_Cic_4_bit({{17, 16}}); +const std::vector> FNAV_IODnav_4_bit({{7, 10}}); +const std::vector> FNAV_Cic_4_bit({{17, 16}}); const double FNAV_Cic_4_LSB = TWO_N29; -const std::vector> FNAV_Cis_4_bit({{33, 16}}); +const std::vector> FNAV_Cis_4_bit({{33, 16}}); const double FNAV_Cis_4_LSB = TWO_N29; -const std::vector> FNAV_A0_4_bit({{49, 32}}); +const std::vector> FNAV_A0_4_bit({{49, 32}}); const double FNAV_A0_4_LSB = TWO_N30; -const std::vector> FNAV_A1_4_bit({{81, 24}}); +const std::vector> FNAV_A1_4_bit({{81, 24}}); const double FNAV_A1_4_LSB = TWO_N50; -const std::vector> FNAV_deltatls_4_bit({{105, 8}}); -const std::vector> FNAV_t0t_4_bit({{113, 8}}); +const std::vector> FNAV_deltatls_4_bit({{105, 8}}); +const std::vector> FNAV_t0t_4_bit({{113, 8}}); const double FNAV_t0t_4_LSB = 3600; -const std::vector> FNAV_WNot_4_bit({{121, 8}}); -const std::vector> FNAV_WNlsf_4_bit({{129, 8}}); -const std::vector> FNAV_DN_4_bit({{137, 3}}); -const std::vector> FNAV_deltatlsf_4_bit({{140, 8}}); -const std::vector> FNAV_t0g_4_bit({{148, 8}}); +const std::vector> FNAV_WNot_4_bit({{121, 8}}); +const std::vector> FNAV_WNlsf_4_bit({{129, 8}}); +const std::vector> FNAV_DN_4_bit({{137, 3}}); +const std::vector> FNAV_deltatlsf_4_bit({{140, 8}}); +const std::vector> FNAV_t0g_4_bit({{148, 8}}); const double FNAV_t0g_4_LSB = 3600; -const std::vector> FNAV_A0g_4_bit({{156, 16}}); +const std::vector> FNAV_A0g_4_bit({{156, 16}}); const double FNAV_A0g_4_LSB = TWO_N35; -const std::vector> FNAV_A1g_4_bit({{172, 12}}); +const std::vector> FNAV_A1g_4_bit({{172, 12}}); const double FNAV_A1g_4_LSB = TWO_N51; -const std::vector> FNAV_WN0g_4_bit({{184, 6}}); -const std::vector> FNAV_TOW_4_bit({{190, 20}}); +const std::vector> FNAV_WN0g_4_bit({{184, 6}}); +const std::vector> FNAV_TOW_4_bit({{190, 20}}); // WORD 5 Almanac SVID1 SVID2(1/2) -const std::vector> FNAV_IODa_5_bit({{7, 4}}); -const std::vector> FNAV_WNa_5_bit({{11, 2}}); -const std::vector> FNAV_t0a_5_bit({{13, 10}}); +const std::vector> FNAV_IODa_5_bit({{7, 4}}); +const std::vector> FNAV_WNa_5_bit({{11, 2}}); +const std::vector> FNAV_t0a_5_bit({{13, 10}}); const double FNAV_t0a_5_LSB = 600; -const std::vector> FNAV_SVID1_5_bit({{23, 6}}); -const std::vector> FNAV_Deltaa12_1_5_bit({{29, 13}}); +const std::vector> FNAV_SVID1_5_bit({{23, 6}}); +const std::vector> FNAV_Deltaa12_1_5_bit({{29, 13}}); const double FNAV_Deltaa12_5_LSB = TWO_N9; -const std::vector> FNAV_e_1_5_bit({{42, 11}}); +const std::vector> FNAV_e_1_5_bit({{42, 11}}); const double FNAV_e_5_LSB = TWO_N16; -const std::vector> FNAV_w_1_5_bit({{53, 16}}); +const std::vector> FNAV_w_1_5_bit({{53, 16}}); const double FNAV_w_5_LSB = TWO_N15; -const std::vector> FNAV_deltai_1_5_bit({{69, 11}}); +const std::vector> FNAV_deltai_1_5_bit({{69, 11}}); const double FNAV_deltai_5_LSB = TWO_N14; -const std::vector> FNAV_Omega0_1_5_bit({{80, 16}}); +const std::vector> FNAV_Omega0_1_5_bit({{80, 16}}); const double FNAV_Omega0_5_LSB = TWO_N15; -const std::vector> FNAV_Omegadot_1_5_bit({{96, 11}}); +const std::vector> FNAV_Omegadot_1_5_bit({{96, 11}}); const double FNAV_Omegadot_5_LSB = TWO_N33; -const std::vector> FNAV_M0_1_5_bit({{107, 16}}); +const std::vector> FNAV_M0_1_5_bit({{107, 16}}); const double FNAV_M0_5_LSB = TWO_N15; -const std::vector> FNAV_af0_1_5_bit({{123, 16}}); +const std::vector> FNAV_af0_1_5_bit({{123, 16}}); const double FNAV_af0_5_LSB = TWO_N19; -const std::vector> FNAV_af1_1_5_bit({{139, 13}}); +const std::vector> FNAV_af1_1_5_bit({{139, 13}}); const double FNAV_af1_5_LSB = TWO_N38; -const std::vector> FNAV_E5ahs_1_5_bit({{152, 2}}); -const std::vector> FNAV_SVID2_5_bit({{154, 6}}); -const std::vector> FNAV_Deltaa12_2_5_bit({{160, 13}}); -const std::vector> FNAV_e_2_5_bit({{173, 11}}); -const std::vector> FNAV_w_2_5_bit({{184, 16}}); -const std::vector> FNAV_deltai_2_5_bit({{200, 11}}); +const std::vector> FNAV_E5ahs_1_5_bit({{152, 2}}); +const std::vector> FNAV_SVID2_5_bit({{154, 6}}); +const std::vector> FNAV_Deltaa12_2_5_bit({{160, 13}}); +const std::vector> FNAV_e_2_5_bit({{173, 11}}); +const std::vector> FNAV_w_2_5_bit({{184, 16}}); +const std::vector> FNAV_deltai_2_5_bit({{200, 11}}); //const std::vector> FNAV_Omega012_2_5_bit({{210,4}}); // WORD 6 Almanac SVID2(1/2) SVID3 -const std::vector> FNAV_IODa_6_bit({{7, 4}}); +const std::vector> FNAV_IODa_6_bit({{7, 4}}); //const std::vector> FNAV_Omega022_2_6_bit({{10,12}}); -const std::vector> FNAV_Omegadot_2_6_bit({{23, 11}}); -const std::vector> FNAV_M0_2_6_bit({{34, 16}}); -const std::vector> FNAV_af0_2_6_bit({{50, 16}}); -const std::vector> FNAV_af1_2_6_bit({{66, 13}}); -const std::vector> FNAV_E5ahs_2_6_bit({{79, 2}}); -const std::vector> FNAV_SVID3_6_bit({{81, 6}}); -const std::vector> FNAV_Deltaa12_3_6_bit({{87, 13}}); -const std::vector> FNAV_e_3_6_bit({{100, 11}}); -const std::vector> FNAV_w_3_6_bit({{111, 16}}); -const std::vector> FNAV_deltai_3_6_bit({{127, 11}}); -const std::vector> FNAV_Omega0_3_6_bit({{138, 16}}); -const std::vector> FNAV_Omegadot_3_6_bit({{154, 11}}); -const std::vector> FNAV_M0_3_6_bit({{165, 16}}); -const std::vector> FNAV_af0_3_6_bit({{181, 16}}); -const std::vector> FNAV_af1_3_6_bit({{197, 13}}); -const std::vector> FNAV_E5ahs_3_6_bit({{210, 2}}); +const std::vector> FNAV_Omegadot_2_6_bit({{23, 11}}); +const std::vector> FNAV_M0_2_6_bit({{34, 16}}); +const std::vector> FNAV_af0_2_6_bit({{50, 16}}); +const std::vector> FNAV_af1_2_6_bit({{66, 13}}); +const std::vector> FNAV_E5ahs_2_6_bit({{79, 2}}); +const std::vector> FNAV_SVID3_6_bit({{81, 6}}); +const std::vector> FNAV_Deltaa12_3_6_bit({{87, 13}}); +const std::vector> FNAV_e_3_6_bit({{100, 11}}); +const std::vector> FNAV_w_3_6_bit({{111, 16}}); +const std::vector> FNAV_deltai_3_6_bit({{127, 11}}); +const std::vector> FNAV_Omega0_3_6_bit({{138, 16}}); +const std::vector> FNAV_Omegadot_3_6_bit({{154, 11}}); +const std::vector> FNAV_M0_3_6_bit({{165, 16}}); +const std::vector> FNAV_af0_3_6_bit({{181, 16}}); +const std::vector> FNAV_af1_3_6_bit({{197, 13}}); +const std::vector> FNAV_E5ahs_3_6_bit({{210, 2}}); // Galileo E5a-I primary codes const std::string Galileo_E5a_I_PRIMARY_CODE[Galileo_E5a_NUMBER_OF_CODES] = { @@ -274,6 +275,7 @@ const std::string Galileo_E5a_I_PRIMARY_CODE[Galileo_E5a_NUMBER_OF_CODES] = { "84D5B404488AFCC35CFC6EF1CF7A848EE5EE527B7D2D2081EBD8FA8432414FCCB271A43FD618EF95CAF1CEF445B50F02AFDC6B41D5C1F1FF4B6B8F2AB94F90F259383F44246B2D400C3012FD76E2980827C9B5476C4651293CBE9FAA77EFC53E369B94F51BE480EEAA389D88AE421E75EC67C76E30A6FA7EF02500372E4C9AB875EBA1C357C003938B979859B0A914D58F21B3BF1BE8C33A1AF079C5A0A4EA532F93A10F6D96D0A63F3C99E6F06CBC072CC5D71A517FFF40BC260A26E3A46688E79E733E1E2F0010846937689E2998BC769186E0B977AE0A1689245D255AE7D5F34715AD526E824838B62546D9569009A191BA5192535E23142236F4035C90D1405C8530A57B402118FDED2A5DA4B40635D2F95AC7CEAA370686F0AB23AB31DED369BEFB066909B76F2C04039E49FF0CFD323628D03C26F0BD4054C127F21355C33B49F86895D5354C3BBD2C0D38ECD169289F7D8403AA1753B393AC06C887F98315324DBD78F9BFD1AD8880D41D4EA98956EC89BBDAD08F7CFEBF26988EB5AB01D4E49AA8273CAB6AFDFA1CC1C95EDF85284E6570332A0B8242FBA495D87A01A945E61CD36E865CD4F430F04A3B3EE74CE0486B5676F7A938B18E1DB2DAE2FE1C04B3D56892C7394D0B07C5A2F7698D196711DC83FFF6ABDD4E8131E1106EBA23245FB0E2A696E440FB6B0B1CB4DD22C9720AC76F09863711647A7E369FDE5D6911A5FCF987470B8C06C4EF7063B08A8320B4371866789147E9D7C5D477A662A501627F91E95C6E2CB6814651E9DFACD67CA0B1FE62F44081E3BDDB964C1E5ADDC093AD185F0203B4C0F7E3E96811F14C79BC54F2919FCE5B653F6845CF1AC34DA9E4CF52EBA626B739246E25204F9EF2CCF4F5ADBFC53CD8F629FDB82186CB52BEB7136F105D3CFF9CCCC2610BF2C8F943DF5BD03877ED7AFA25CA81C4063E1B97452A937FCF77F1AA068FE2A26F6ECDF662ACDF18391AF7D627C2AA07CF5597B5F33AA0ED4DAC98AA73C8321EBF6918EE568ADEB1A823527AD75CD5BF7ED3EB5633A4EDC8C59DB0A91DA79C248D6894CAF9CB411F302635BEEF1A1C7916C7545B8BE7C577692245E285D32B4FD18E1478F88F8373E22A5CEC6D22EACAD2A41612F05AB2C54A1C03C0512359B0F9C5F91615EF2EA80DE97230480F489FEDA38D52FC84E2F1258CB20FF0E850639B31C2958BA6C064D0D0F4AAEFF313E43C65EFFFBB47CF09F2A122D15F76E8B704DA8F2B8C71449AA49774EBB7B2DC97CF6004D2FF6D37B9C689261189B85CFD50C20C961F22A644F51497377426556B956DB8C899045B175A8B9CB22EFDE535CF487E9D958281E0467539853054FC3475D2E142D58F9201C1DC6B2C1A12B2878F9366E2216405069B7D03852AB37EE83112EF2EE172F4E5317A41653A656A06F6633AF59062A47263A9977A50B9115456A58F9C3424FE7E0CC57DA70FEE0411C1479B4CC2E6E720B01432CFB3C503983B37FFBE38C92E50D6C5795443F73244F6D28AE6270E27D46A25621F86A2BC4259DE6C04CCAA657FE656C640833B290F00A1660329A3F09FFE60152A23925F4D8B0933AC016B5802CA863F66F8CEB5C8383B1180A515AE6C51B5F56597C3A004F8D25F8A6235C97B4DE38468B63E3B859A487AFC4320598EB6D143E5C914409D25F6DFF6E957D575C71D3ECBC6743CCCC03E5F34791744637A994F3ADF86966B4FE911C06F7BA1A6C20A2971D82B64E49721A530D9D5A2319D5BE0F47B8119C5A835CABEC735A935E23CB439970437C6F4CCDE2525EF0D7B1555CBE70280D5E760", "A5029C9EB4623226D321FF78D3C4EAB1F672A8B2B24A09CAEF21F561A851323C05A3C5E136A2DA7104ED19FBFFCAC3FC49B6D598F3060E93552EA6C700B837F7CE04721919B9C96A57B42AA1D832307C7A847091848066CB84947BE5F6B54654479E39F654819D3EF7AF4939FB9F4C9B20CA7F83DA0FDA2F171FDB72455B7ED0D43206992520CDD86B29C48BCC687573AAC4217D0B7DCF852811ADC3ECADDB2B34B4572675CCAEFDAAA01F83561E6E240878F229698185A80E6FECEE89455A72A377C24CE3FECAEC2A34B9CA98D288596D1C769CDEAB06871316CA7D1DDC5862E6282DECE33F362C64A73E57AB266715068932ECC31E62AD2ECFF7C6FBFE213384DA086ADF49E30F432EE2C715D9AC4DEF53A7B09B0D722CAC560FE8CF0059B80428458282F7E81717647D72E321A3E4BEF16FAEF76009BD98B8D9822B771EB62F1D0748E462FB7F3BEE9B12AA86D9629085AEDF8E43E1252EE59970CFF66A6F865C7651EF83F8FE10EB0E2615BF8F5C7F12FC601B0CF795C0D8B7057F54408BEFF86747C0F6F23EF212A9086EADD464A25341AB71FBA4ADED8F599C38FC15E790A5B86E64977C5AC718DD0B47C1A476AC9D7369396144F6288E84F7FFBDE02EC00EEAE8ED415C84648364ECBEC42164514D3E26BFD3187E0641C216FFC57E00DD752CDA581686916221DCD1AF07582391C5FBEF047FD1B7B956B458DE925C02A756FE197233E0304D0E034FF9A176B5B3F5FB683AB41D2691E13F97B3F4EB33238851331197C49C60233232DA0E2610430461876FF6F77FF3CCAF1BB2424B8B347588667B48480476D40BD9E487468CD5AFEB597C750A5E665B4E7C4C169ED08ADFC731FEA928052C4FB85B3064EC07B0CB988E324893B3F084291D964403F0350B7E1B06DFB73362C38318B762A972972BFB76CC5C08B5D47DBA0F3A2473D7749DE9F49F50C4C1620A9EE9FE56296124D72906497411DB87D4D8EC4E1F79BEF27232008A2299F5317FC1A6F455F1B827F1712BC01814F0B9D0CC162B25B804278B9C7BC5FC5616B317F2050234A7AF92FE35A59E22C959C7163DFA5F142022BE5CC4D5EF16D218216C57C2E29DA926436C00DCB82E68E16CA5A07158D8B8864D38A765D14E82175114A28CD97D11D564C8C7B87411589A4FBD49F9900D08939B7A73B5E6466B6F607F8AD22120A559A02BFCEF6456E7AECE8C9B7C9D2B322D2197124C05363B2CBFA58B74CD88877F22A5E5C202FC2C33531125F1518F4F0F38FA788E5E6B3307A75EC73E545391CEA200243DD6D25A5B8654A00B82BA57437BF0ACCB0ED37ED2FED221E54EC12B93AFA6E3939223596075F4C47340355D7222A8234A1F65EDDA42FFF5D19F7FACBF09AA77E7962F4CFBF61A0F26FB18E31A504B371714048874BEB286AFF71B43E4739A17E8AC25FA77121ABBE6E99754AF42F1D0021EA1E3FF088D0734BB191F91A520C96E22B4A28F9A2BD7DF81E8079EE5D0DDCBD517046F12098FAF6920E0EBA10DE8CFB391C63C60D62C1F4BB26BF8B6E421A830575731F67D306CEB5D6FF04637144790EC4AA2F435906320114CB81EB40C22B271FBB065474687AA5880F1DBAAA1744AB3E9B831A932A9208BEA9F5D526C52F5FDA56320E123CFB553E2B71A595DDED2ECBBD6E890B0421D765D2E9FD0D3995DF2A9523A65FE2040710DF16F2A83F510DCA08493DC138541E5681B51EE87D84C9AC11612EB5C06F5A63E22BD6275E35216766D79B215DBD087E9CADA0CEB09BFE435DF9B7809A76DE323B373682B8C58CB4F08D9C708EB050DEC", }; + // Galileo E5a-Q primary codes const std::string Galileo_E5a_Q_PRIMARY_CODE[Galileo_E5a_NUMBER_OF_CODES] = { "515537AD5E5F4216C16046FB0AC50DCDBE5CEE7E3CBB51B6ABB4E87A407B90E0EFD49DE1DE5ED29184E7FF0DC31F75FBB94F46FF6586B36C7771E5A68D060A965ACCF8D640C6B6E4530FDF19DD2491BCAB69ACBCFD3EC7281CCC31253A471B652E21C4CB0B43613EC542266460F0A6199B436BEFD95572DEBEE920A915FD854D17FFD0DF8C74E23B21B28493A0927709709B07C65878C43B69DC501E9D0AA21061ECF173876CAE708C764435832D9D6FCFE62DDF2543016D6325A56D9BF1007886E62E8A832BC32063CB0717D723C5E8C5F0C0EB3960577D364C93060B64EE04A539B7601CC3113E0AEC53CF21AFAD0154DC5CCECF038474E0F4004A65B1EE2801F81968B88C3D35E87CBB126C02D770CC3D32A552883D351DEF47847391484F80646728221F993921BFC14126EE3D9527DE607152724C6D2DD305D3FEA0AAAEDF6509A2FE3248494A54FDA8E3CE7E6BBCE234E4686BA5A19724BA2CB78CFE71A6AF45532EFB286C5BB47BC3C1EEF4E4A8C757786AE974F30A86CD60EBCBFDF5502AA8F643819CBA4301E731ADBA1345B61C0B444FE7B817EA86F8DD749C451AE7D24A68D914F26C918238953E8AE61CC8553213DD6856C7863F9F6BAB1B4C84B225911E7B92BFFC12AC211B2B2CD905877FE976E07057963D47C437FE47D89648053F81AC39E8FD2F3A726866F6693E503CB6F0C3F0AA9B3EE2EA3BCDB16D726E1C6D8B073AA15F64EB68D53B1F8CDAC19C7AC33361226E81F1C793BF188755A3FE1BAC38B91ABBD4F077F7A28983EAFADC346CB941D49492625893453B364D07FE06FE42B160C16FE0462AB6366FFDEE54DC9CE4DCCA21E4E4AE5E92C872D1E4EC6FF6D3063C98A5AA5EE72481A0BDF15152E2A5425AB722101474D0E1EC8401273EA1BE1DAF7403190A94305BD1C7DFBE1F35F65D5CB97E82B7A297047507FFA0012FB73360FB8719C174E78A989A96E60A9184B3F3A8188DE100AB361921D38E8142859C8F0F7D441DB1B2E9687BBD1086643987C83DEE0BE8CED4C83BCC82B62B45311CE4F13ABC55BF5EB1ECDF15F5A07F8B2C42F07FACE0E299E87727E2D534FEBF7B9C3894CC3E2E4127A294B9FA2A671273B174DBB81D247CD2846116500A072DC3962C65FFECD0C0B46DC2AF52882058259C26FDE50BEB319AEECFA1FABA34C069680B9EBAA9D96EEBD7EA30E748213E1283396A2AFC63527624641D4E1F1022A973B1898BD4CEF4D712B49371A51D60E08F42ED1EA90AC49EEFBCC53E7F9E899DD1AA4056F11462DF1A4C81620A73C831CEB897430A22252B901EC3D6F3DF58EF26422F796EA31AA4E0E9CE5B4A9C312A22305E298FEB3B3628283D405EDF726937327D90C542434BA3B60684584A9DB244839D2ACBCD7EF147A541E35687B5B8F5F07764973112D20D1ED75DC31F6A938542B42EFAAEE0F11B0583AA4925C3132356200E8D6BDB3127B975F4115A7A8A1C471836E3C5450B501A24D4A1308BB319AA827222B550F253F64B6F7D2322C6A2D3012FEC265A66A60102A3340CBDAB900DFDB36693D41DAD8DDB8875F8C3BE76AD5355DD81D67AAEBFFFE9458E522BE0312E60F63DD92F25C0D7CF82F223AEC0BD7456752CBD5151FEB5368F8857EAFAA90E8C7499B75D46EC4CA20BA8A24C90C016B5BD2CD7864828C6140E98EDB9509AD1194F56D49675D077DE92CD481B469E3A37F7DF0D5392DA4CE4CB282530F1C73482CC0926B877B00B0CE49FAD21E4C26194C7E950E0078F3854EF88755E08E9380165C584A3DBF1ECEF6A31B224FC321326B93797BFE8", @@ -327,8 +329,10 @@ const std::string Galileo_E5a_Q_PRIMARY_CODE[Galileo_E5a_NUMBER_OF_CODES] = { "71BB1B2E833793D854F8A9A81E6A6947057B9571F2BA99380DDB25D878D6B48F09ED7DBFACE92B6B82F413E038128F6128AF3BC467E9A4DF2861DAAC674B6D948A10F28F7D43657FEE26577AF438A2F4422186930702EBC6C9173E661D59CE7594DF95B861F9D12EB060FCD3BA43159C9A1BDC1EF13E04893E411267331588CF4831978469FF569C1A738C54001BB5CF4FABD289075A165EDE0A58F6CF6D215D306A7840CBECD0E87E3AD186F7A67A967373551E13D2956E5C578A7F5BD50E2D570F9B914848D46A640913EBED2E2ABFB86916BC34EEB3E8A671AD771F6D3780B6FEC143E26F53B02977255314BAE9A2CD9E5BA2B49C73226FDC724A859F8BAD3A9FACA1B0E5F2DFE7E1E45DB6D4BE2B76535A817F94594A4541C01BB62AA83A690B6D84FC13B632972C61D940F2C9D32837413AF8E42045ECA3072CD044B2183400CE63C418879D13FD281A8D0835256DDD2BC3C9750C1D44CF1037FD7264B7716398FCF1D31CFFD0B7C52C6370E4CE6FC163B40436490A757465B20B8890C3B5C0AFB971ABFD01796569E3BC73C13D1E4B1FBC1CDCE59D21B6B110272E5770C589603FE67779A49AD0EC66910A2BF4D8C8ECC18A32EF92F502126A5DC3DE618233B9914A9608B2F17E5161115D9A3BEF1D5701A9D465A1437DE24371C9179800CB5728A7F3D734A2A706BC64D356BDF591389970B6CC139AC510A98E3C75F20120450CE45373AAEA6A279BBD17221BCD32ECF82C11B4C1CEE0A44792CF56978D3D2399F7ECDE9F8D9217F8BA22770E210D0F1AA852178B872E296762873765A73DEC08873C04ED69C995C5751B97DEC23B94CA674FE3F66211317B074D8203EC530A20B6E6DD21AB55895BEE1CBD0876183D652F4A0D2EFC95749F8F192F860BEA534598FD709B396C209CEAE4D9190980733E7E98C8ABE52A53C68D86053B56BA6FCAB5C827292D729CB8BFD1FC8CAFCDE15E4527B604018F28AA16C1E913F55461AF87C9A7BE1A742002E52B3A14EC30B259DDE7BB892CEAF77D25B7670B339B334878F697C00CE6740117AE7C67DF3F8A7BEAC89D4872682C47F368F835AFD7ECF0D8471AD01468B7BBB0A974EC469A8F79ECF8D379DC13685D2A8F6F19CE102C3DE34B11422AFB42E894C8D00F606296DABA7123FCE039ED27324D60E853BA94DC638454088281335D437A954333FF1A8D08E2A4D25CB3BA0D08BF6625E25EAD3C1EBFA2666AA49550578D3763ECDCE81303B53F18B00C8900AF4E0532C5ECBC94513DD9F50BE511CFE4D3DDBB3F112AE148DB062B2EADDB901CDA6AB6BF59D37F356AB34AF97D3DAAAA417642E87C9B95AA546C682ED641214605F82A4F486C9C72576106F76D7152615EC8E77187D4485071CFC6B0AE44880442790696E057A3AE20C860691353B3F6BEC5F1C2DA07563B423BC01E0334099571158A432441256D7C409B7B6EF26442075ED17E2BE37F8EBC049CFBE0FA89CDA7A58DD32C417B34E899FBE86E2FAB8D30846DA17144A6A66AAE1C24FCFABDA5B573FD2D6337226B5E49BB031B4D2B455B6DB871076F67AC03C3A73CEC01BD0B1EC42ABD177127E62A66FE8E475B982B4490F0877466EEFC7317A703C5C07937340ED4B53E5DE5325197FA31B8C8E05AA2222064EE5D7C06D4A1EB53151F75C94A2E259688CA0716548465C5C255D81FF10BACC2C13098ED8CF7F5B15193EE14FB5D258E95EDCC93E9796FA823892C705A5771D561787C12592D269D657FBB71F021F365B7453D50C35F748FB2B7F36DF28769B81EF12A26A237FB0239C173559540", "53DA0E7B84741AA9E225483630169ACBCC03EB8CDA28B7BDA685C756D66B14488A2D0AEF7E6CB2D80F2726327257B7284B93EA1B56AB80FAE668C04FA49FCD658D896A997685E1EDB4DDF85456B37F32FC8CDE50882EF0F09BE4ED4AB9A425806A49E8347A42A50B38FA8D1DA2FD2C9438618B6701DEE159060C186D50170F24F38E07B185E3272EAEA4A0A7CA41A69C69E9D95E271287D3AB8284146A58440EA131A7F47D73CB2BCF40FE3A58E1B998C2E5EF9CEEC8EA2F8467BB7757C03A99FC8F014EE933A7080CD46625A2A7A251B7A37E4208956A8C9BD35E6F8674BC06FCAA5DD04A2558C9665C7985014D3AD95ED256FAFA358962EF5BB26AE2FCE899392DF858F99303E2417BCA7672E991FEB891F5DFCA2D461148367C5C0DE1460BF557194533DAF01A5E8E0E43D57B825AF7EEFF163DAA23B9F95C063A26B3D213459D885AA96023715CD21DFA2A2250F7610B78A77123443BD06EFB7DC85D1F16D0019D2937C3DEC4DE6389485ABB21642B6E41ADD43CE96F228C08DF6288A647EC2FE96032B6DCD651FF950B72964EE08FC2030272E3F601DB7F7E770E655389CA6CFA2F9B87CE76FB0E0CDCA4EEE5E80FC756BE46CC09F84BDB34ADA2AFC024ABDE0066ED939F8EBC236CB3F577C1BFD741F9D101A038EC86AB0A85462BAFB2E484D6722499A6310FA449D979030B2A21206D44225800BE2228FA00AE6D92C8DA652E1B003BD2734D30557B735CC2A591E090394DB791245C22B4D29E706476593B6F90C694C5B87BBB0FA2C479E292A768A9687A713336A21D1199186F852C41F586E9BBC64004D8BB6814BFE739834C99923177AAF87B926D56A7AFC0879C027332A60951C84E9314380A5A78E1196D094F15D856AA36742825D2B397156BCAD8ABE7291FB41DB4365AAE49CA82CA066D3B4366D3122ABBC00F05559DAFEBA9F98361DDAEF068D60B18265E7184C4D6BC9C3619CFF5C758090FF6398CCCEB78176D2A8A2A4B9854C4ACF5CB614DC1CA0E15E7E85442241D48FD3D6E851A5D3947FA769560928948FA26FA16EFBD2159994BD92B3D6B0C62818C91D4724413A7F40B2A2D67F4FC97B5DF6A7E3CEC03158E201D6643F402D3DD6995A42900D46C2881198CAD28A27489F5116ECEC3E38D999B2020E0C381DB3B8230811270D75950D9BB61548802DBBCB68ED8C7BCCB50D606BE400BECF873498621E66ABD2AA179B3E90E055C3719CE2FE047F815B95B065BA086B467AF4124E276F8CEAD000BCA5499D36217B250009A7B43E81CB3F8B1A3238EE436FE61F2F942796DBCBE570BB4FC783B35C3CA31BDD432B33AD75B08107253E8F910EFE0D0B5453A8A055D884892278688B3ECA612452B590AF38DBDD9A7070C5610E7A3CA6C91D24438E7F45E7A2A330F164AEDFFF1789D5E875EEF121298DB79C77278ABFEC3FE3DF843C46F40E847272EB2669BABA808C38E31F13516D5066AF4DFCDE6EDB2FF0B0A4CE9FA9B4101F6F144B02384868617CD39175852E065473D6F566CD18D7403FFD24DD33ADDB52C7CC22167E49102C46DC369A92CE2D2FCB81B4D1F14B7CD2F80A65D8FBD20FDAA23219873ACB8CF934E68D6F8FED6B41193CFAB1F44CE4BFC7C67DE1E8804B47DFD7E8AE281E19846AEB6FF94AE7E7CF6FFAB46242843811E6C5BDB78157C76DF4F92FD3653D7FA5978316EB055059C6A2B6306C957418860A88F63355E76D96F4727128D9B3EB98501AF5B093F2C314F98EA2CDB89468E1BD51138CBF25E8B911C26B97DCCA47F1A1D6C1CD415A5079A756B8A8715DD3164", }; + // Galileo E5a-I secondary code const std::string Galileo_E5a_I_SECONDARY_CODE = "10000100001011101001"; + // Galileo E5a-Q secondary codes const std::string Galileo_E5a_Q_SECONDARY_CODE[Galileo_E5a_NUMBER_OF_CODES] = { "1000001111110110111101101001110110001111011011100001010101000001000111111011100011001001101100011100", diff --git a/src/core/system_parameters/galileo_almanac.cc b/src/core/system_parameters/galileo_almanac.cc index bce27a9aa..805e8b6e3 100644 --- a/src/core/system_parameters/galileo_almanac.cc +++ b/src/core/system_parameters/galileo_almanac.cc @@ -32,7 +32,7 @@ Galileo_Almanac::Galileo_Almanac() { - /*Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number*/ + // Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number IOD_a_7 = 0; WN_a_7 = 0.0; t0a_7 = 0.0; @@ -45,7 +45,7 @@ Galileo_Almanac::Galileo_Almanac() Omega_dot_7 = 0.0; M0_7 = 0.0; - /*Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2)*/ + // Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2) IOD_a_8 = 0; af0_8 = 0.0; af1_8 = 0.0; @@ -60,7 +60,7 @@ Galileo_Almanac::Galileo_Almanac() Omega0_8 = 0.0; Omega_dot_8 = 0.0; - /*Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2)*/ + // Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2) IOD_a_9 = 0; WN_a_9 = 0.0; t0a_9 = 0.0; @@ -76,7 +76,7 @@ Galileo_Almanac::Galileo_Almanac() omega_9 = 0.0; delta_i_9 = 0.0; - /*Word type 10: Almanac for SVID3 (2/2)*/ + // Word type 10: Almanac for SVID3 (2/2) IOD_a_10 = 0; Omega0_10 = 0.0; Omega_dot_10 = 0.0; @@ -87,7 +87,7 @@ Galileo_Almanac::Galileo_Almanac() E1B_HS_10 = 0.0; E5a_HS_10 = 0.0; - /*GPS to Galileo GST conversion parameters*/ + // GPS to Galileo GST conversion parameters A_0G_10 = 0.0; A_1G_10 = 0.0; t_0G_10 = 0.0; diff --git a/src/core/system_parameters/galileo_almanac.h b/src/core/system_parameters/galileo_almanac.h index 3744ed87d..c8fb51e70 100644 --- a/src/core/system_parameters/galileo_almanac.h +++ b/src/core/system_parameters/galileo_almanac.h @@ -31,6 +31,7 @@ #ifndef GNSS_SDR_GALILEO_ALMANAC_H_ #define GNSS_SDR_GALILEO_ALMANAC_H_ +#include /*! * \brief This class is a storage for the GALILEO ALMANAC data as described in GALILEO ICD @@ -40,11 +41,11 @@ class Galileo_Almanac { public: - /*Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number*/ - int IOD_a_7; + // Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number + int32_t IOD_a_7; double WN_a_7; double t0a_7; - int SVID1_7; + int32_t SVID1_7; double DELTA_A_7; double e_7; double omega_7; @@ -53,14 +54,14 @@ public: double Omega_dot_7; double M0_7; - /*Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2)*/ - int IOD_a_8; + // Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2) + int32_t IOD_a_8; double af0_8; double af1_8; double E5b_HS_8; double E1B_HS_8; double E5a_HS_8; - int SVID2_8; + int32_t SVID2_8; double DELTA_A_8; double e_8; double omega_8; @@ -68,8 +69,8 @@ public: double Omega0_8; double Omega_dot_8; - /*Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2)*/ - int IOD_a_9; + // Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2) + int32_t IOD_a_9; double WN_a_9; double t0a_9; double M0_9; @@ -78,14 +79,14 @@ public: double E5b_HS_9; double E1B_HS_9; double E5a_HS_9; - int SVID3_9; + int32_t SVID3_9; double DELTA_A_9; double e_9; double omega_9; double delta_i_9; - /*Word type 10: Almanac for SVID3 (2/2)*/ - int IOD_a_10; + // Word type 10: Almanac for SVID3 (2/2) + int32_t IOD_a_10; double Omega0_10; double Omega_dot_10; double M0_10; @@ -95,7 +96,7 @@ public: double E1B_HS_10; double E5a_HS_10; - /*GPS to Galileo GST conversion parameters*/ + // GPS to Galileo GST conversion parameters double A_0G_10; double A_1G_10; double t_0G_10; diff --git a/src/core/system_parameters/galileo_ephemeris.cc b/src/core/system_parameters/galileo_ephemeris.cc index 926257933..0c1021048 100644 --- a/src/core/system_parameters/galileo_ephemeris.cc +++ b/src/core/system_parameters/galileo_ephemeris.cc @@ -39,40 +39,43 @@ Galileo_Ephemeris::Galileo_Ephemeris() IOD_ephemeris = 0; IOD_nav_1 = 0; SV_ID_PRN_4 = 0; - M0_1 = 0; // Mean anomaly at reference time [semi-circles] - delta_n_3 = 0; // Mean motion difference from computed value [semi-circles/sec] - e_1 = 0; // Eccentricity - A_1 = 0; // Square root of the semi-major axis [meters^1/2] - OMEGA_0_2 = 0; // Longitude of ascending node of orbital plane at weekly epoch [semi-circles] - i_0_2 = 0; // Inclination angle at reference time [semi-circles] - omega_2 = 0; // Argument of perigee [semi-circles] - OMEGA_dot_3 = 0; // Rate of right ascension [semi-circles/sec] - iDot_2 = 0; // Rate of inclination angle [semi-circles/sec] - C_uc_3 = 0; // Amplitude of the cosine harmonic correction term to the argument of latitude [radians] - C_us_3 = 0; // Amplitude of the sine harmonic correction term to the argument of latitude [radians] - C_rc_3 = 0; // Amplitude of the cosine harmonic correction term to the orbit radius [meters] - C_rs_3 = 0; // Amplitude of the sine harmonic correction term to the orbit radius [meters] - C_ic_4 = 0; // Amplitude of the cosine harmonic correction term to the angle of inclination [radians] - C_is_4 = 0; // Amplitude of the sine harmonic correction term to the angle of inclination [radians] - t0e_1 = 0; // Ephemeris reference time [s] - /*Clock correction parameters*/ - t0c_4 = 0; // Clock correction data reference Time of Week [sec] - af0_4 = 0; // SV clock bias correction coefficient [s] - af1_4 = 0; // SV clock drift correction coefficient [s/s] - af2_4 = 0; // SV clock drift rate correction coefficient [s/s^2] - /*GST*/ - WN_5 = 0; - TOW_5 = 0; + M0_1 = 0.0; // Mean anomaly at reference time [semi-circles] + delta_n_3 = 0.0; // Mean motion difference from computed value [semi-circles/sec] + e_1 = 0.0; // Eccentricity + A_1 = 0.0; // Square root of the semi-major axis [meters^1/2] + OMEGA_0_2 = 0.0; // Longitude of ascending node of orbital plane at weekly epoch [semi-circles] + i_0_2 = 0.0; // Inclination angle at reference time [semi-circles] + omega_2 = 0.0; // Argument of perigee [semi-circles] + OMEGA_dot_3 = 0.0; // Rate of right ascension [semi-circles/sec] + iDot_2 = 0.0; // Rate of inclination angle [semi-circles/sec] + C_uc_3 = 0.0; // Amplitude of the cosine harmonic correction term to the argument of latitude [radians] + C_us_3 = 0.0; // Amplitude of the sine harmonic correction term to the argument of latitude [radians] + C_rc_3 = 0.0; // Amplitude of the cosine harmonic correction term to the orbit radius [meters] + C_rs_3 = 0.0; // Amplitude of the sine harmonic correction term to the orbit radius [meters] + C_ic_4 = 0.0; // Amplitude of the cosine harmonic correction term to the angle of inclination [radians] + C_is_4 = 0.0; // Amplitude of the sine harmonic correction term to the angle of inclination [radians] + t0e_1 = 0.0; // Ephemeris reference time [s] + + // Clock correction parameters + t0c_4 = 0.0; // Clock correction data reference Time of Week [sec] + af0_4 = 0.0; // SV clock bias correction coefficient [s] + af1_4 = 0.0; // SV clock drift correction coefficient [s/s] + af2_4 = 0.0; // SV clock drift rate correction coefficient [s/s^2] + + // GST + WN_5 = 0.0; + TOW_5 = 0.0; + // SV status - SISA_3 = 0; - E5a_HS = 0; - E5b_HS_5 = 0; - E1B_HS_5 = 0; + SISA_3 = 0.0; + E5a_HS = 0U; + E5b_HS_5 = 0.0; + E1B_HS_5 = 0.0; E5a_DVS = false; - E5b_DVS_5 = 0; - E1B_DVS_5 = 0; - BGD_E1E5a_5 = 0; // E1-E5a Broadcast Group Delay [s] - BGD_E1E5b_5 = 0; // E1-E5b Broadcast Group Delay [s] + E5b_DVS_5 = 0.0; + E1B_DVS_5 = 0.0; + BGD_E1E5a_5 = 0.0; // E1-E5a Broadcast Group Delay [s] + BGD_E1E5b_5 = 0.0; // E1-E5b Broadcast Group Delay [s] Galileo_satClkDrift = 0.0; Galileo_dtr = 0.0; @@ -81,12 +84,13 @@ Galileo_Ephemeris::Galileo_Ephemeris() d_satpos_X = 0.0; d_satpos_Y = 0.0; d_satpos_Z = 0.0; + // Satellite velocity d_satvel_X = 0.0; d_satvel_Y = 0.0; d_satvel_Z = 0.0; - i_satellite_PRN = 0; + i_satellite_PRN = 0U; } @@ -170,7 +174,7 @@ double Galileo_Ephemeris::sv_clock_relativistic_term(double transmitTime) // Sa E = M; // --- Iteratively compute eccentric anomaly ---------------------------- - for (int ii = 1; ii < 20; ii++) + for (int32_t ii = 1; ii < 20; ii++) { E_old = E; E = M + e_1 * sin(E); @@ -230,7 +234,7 @@ void Galileo_Ephemeris::satellitePosition(double transmitTime) E = M; // --- Iteratively compute eccentric anomaly ---------------------------- - for (int ii = 1; ii < 20; ii++) + for (int32_t ii = 1; ii < 20; ii++) { E_old = E; E = M + e_1 * sin(E); diff --git a/src/core/system_parameters/galileo_ephemeris.h b/src/core/system_parameters/galileo_ephemeris.h index 6704499b5..f057d1c25 100644 --- a/src/core/system_parameters/galileo_ephemeris.h +++ b/src/core/system_parameters/galileo_ephemeris.h @@ -35,6 +35,7 @@ #include #include +#include /*! @@ -48,9 +49,9 @@ public: /* Galileo ephemeris are 16 parameters and here are reported following the ICD order, paragraph 5.1.1. The number in the name after underscore (_1, _2, _3 and so on) refers to the page were we can find that parameter */ bool flag_all_ephemeris; - int IOD_ephemeris; - int IOD_nav_1; - int SV_ID_PRN_4; + int32_t IOD_ephemeris; + int32_t IOD_nav_1; + int32_t SV_ID_PRN_4; double M0_1; //!< Mean anomaly at reference time [semi-circles] double delta_n_3; //!< Mean motion difference from computed value [semi-circles/sec] double e_1; //!< Eccentricity @@ -83,12 +84,12 @@ public: // SV status double SISA_3; - unsigned int E5a_HS; //!< E5a Signal Health Status - double E5b_HS_5; //!< E5b Signal Health Status - double E1B_HS_5; //!< E1B Signal Health Status - bool E5a_DVS; //!< E5a Data Validity Status - double E5b_DVS_5; //!< E5b Data Validity Status - double E1B_DVS_5; //!< E1B Data Validity Status + uint32_t E5a_HS; //!< E5a Signal Health Status + double E5b_HS_5; //!< E5b Signal Health Status + double E1B_HS_5; //!< E1B Signal Health Status + bool E5a_DVS; //!< E5a Data Validity Status + double E5b_DVS_5; //!< E5b Data Validity Status + double E1B_DVS_5; //!< E1B Data Validity Status double BGD_E1E5a_5; //!< E1-E5a Broadcast Group Delay [s] double BGD_E1E5b_5; //!< E1-E5b Broadcast Group Delay [s] @@ -103,7 +104,7 @@ public: double d_satvel_Y; //!< Earth-fixed velocity coordinate y of the satellite [m] double d_satvel_Z; //!< Earth-fixed velocity coordinate z of the satellite [m] - unsigned int i_satellite_PRN; //!< SV PRN NUMBER + uint32_t i_satellite_PRN; //!< SV PRN NUMBER void satellitePosition(double transmitTime); //!< Computes the ECEF SV coordinates and ECEF velocity double Galileo_System_Time(double WN, double TOW); //!< Galileo System Time (GST), ICD paragraph 5.1.2 @@ -116,7 +117,7 @@ public: /*! * \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the ephemeris data on disk file. */ - inline void serialize(Archive& archive, const unsigned int version) + inline void serialize(Archive& archive, const uint32_t version) { using boost::serialization::make_nvp; if (version) diff --git a/src/core/system_parameters/galileo_fnav_message.cc b/src/core/system_parameters/galileo_fnav_message.cc index 644357701..cc1509b4c 100644 --- a/src/core/system_parameters/galileo_fnav_message.cc +++ b/src/core/system_parameters/galileo_fnav_message.cc @@ -66,131 +66,120 @@ void Galileo_Fnav_Message::reset() IOD_ephemeris = 0; page_type = 0; - /* WORD 1 SVID, Clock correction, SISA, Ionospheric correction, BGD, GST, Signal - * health and Data validity status*/ + // WORD 1 SVID, Clock correction, SISA, Ionospheric correction, BGD, GST, Signal + // health and Data validity status FNAV_SV_ID_PRN_1 = 0; FNAV_IODnav_1 = -1; - FNAV_t0c_1 = 0; - FNAV_af0_1 = 0; - FNAV_af1_1 = 0; - FNAV_af2_1 = 0; - FNAV_SISA_1 = 0; - FNAV_ai0_1 = 0; - FNAV_ai1_1 = 0; - FNAV_ai2_1 = 0; - FNAV_region1_1 = 0; - FNAV_region2_1 = 0; - FNAV_region3_1 = 0; - FNAV_region4_1 = 0; - FNAV_region5_1 = 0; - FNAV_BGD_1 = 0; - FNAV_E5ahs_1 = 0; - FNAV_WN_1 = 0; - FNAV_TOW_1 = 0; - FNAV_E5advs_1 = 0; + FNAV_t0c_1 = 0.0; + FNAV_af0_1 = 0.0; + FNAV_af1_1 = 0.0; + FNAV_af2_1 = 0.0; + FNAV_SISA_1 = 0.0; + FNAV_ai0_1 = 0.0; + FNAV_ai1_1 = 0.0; + FNAV_ai2_1 = 0.0; + FNAV_region1_1 = false; + FNAV_region2_1 = false; + FNAV_region3_1 = false; + FNAV_region4_1 = false; + FNAV_region5_1 = false; + FNAV_BGD_1 = 0.0; + FNAV_E5ahs_1 = 0.0; + FNAV_WN_1 = 0.0; + FNAV_TOW_1 = 0.0; + FNAV_E5advs_1 = false; // WORD 2 Ephemeris (1/3) and GST FNAV_IODnav_2 = -2; - FNAV_M0_2 = 0; - FNAV_omegadot_2 = 0; - FNAV_e_2 = 0; - FNAV_a12_2 = 0; - FNAV_omega0_2 = 0; - FNAV_idot_2 = 0; - FNAV_WN_2 = 0; - FNAV_TOW_2 = 0; + FNAV_M0_2 = 0.0; + FNAV_omegadot_2 = 0.0; + FNAV_e_2 = 0.0; + FNAV_a12_2 = 0.0; + FNAV_omega0_2 = 0.0; + FNAV_idot_2 = 0.0; + FNAV_WN_2 = 0.0; + FNAV_TOW_2 = 0.0; // WORD 3 Ephemeris (2/3) and GST FNAV_IODnav_3 = -3; - FNAV_i0_3 = 0; - FNAV_w_3 = 0; - FNAV_deltan_3 = 0; - FNAV_Cuc_3 = 0; - FNAV_Cus_3 = 0; - FNAV_Crc_3 = 0; - FNAV_Crs_3 = 0; - FNAV_t0e_3 = 0; - FNAV_WN_3 = 0; - FNAV_TOW_3 = 0; + FNAV_i0_3 = 0.0; + FNAV_w_3 = 0.0; + FNAV_deltan_3 = 0.0; + FNAV_Cuc_3 = 0.0; + FNAV_Cus_3 = 0.0; + FNAV_Crc_3 = 0.0; + FNAV_Crs_3 = 0.0; + FNAV_t0e_3 = 0.0; + FNAV_WN_3 = 0.0; + FNAV_TOW_3 = 0.0; - /* WORD 4 Ephemeris (3/3), GST-UTC conversion, GST-GPS conversion and TOW. - Note that the clock is repeated in this page type*/ + // WORD 4 Ephemeris (3/3), GST-UTC conversion, GST-GPS conversion and TOW. + // Note that the clock is repeated in this page type FNAV_IODnav_4 = -4; - FNAV_Cic_4 = 0; - FNAV_Cis_4 = 0; - FNAV_A0_4 = 0; - FNAV_A1_4 = 0; - FNAV_deltatls_4 = 0; - FNAV_t0t_4 = 0; - FNAV_WNot_4 = 0; - FNAV_WNlsf_4 = 0; - FNAV_DN_4 = 0; - FNAV_deltatlsf_4 = 0; - FNAV_t0g_4 = 0; - FNAV_A0g_4 = 0; - FNAV_A1g_4 = 0; - FNAV_WN0g_4 = 0; - FNAV_TOW_4 = 0; + FNAV_Cic_4 = 0.0; + FNAV_Cis_4 = 0.0; + FNAV_A0_4 = 0.0; + FNAV_A1_4 = 0.0; + FNAV_deltatls_4 = 0.0; + FNAV_t0t_4 = 0.0; + FNAV_WNot_4 = 0.0; + FNAV_WNlsf_4 = 0.0; + FNAV_DN_4 = 0.0; + FNAV_deltatlsf_4 = 0.0; + FNAV_t0g_4 = 0.0; + FNAV_A0g_4 = 0.0; + FNAV_A1g_4 = 0.0; + FNAV_WN0g_4 = 0.0; + FNAV_TOW_4 = 0.0; // WORD 5 Almanac (SVID1 and SVID2(1/2)), Week Number and almanac reference time FNAV_IODa_5 = 0; - FNAV_WNa_5 = 0; - FNAV_t0a_5 = 0; + FNAV_WNa_5 = 0.0; + FNAV_t0a_5 = 0.0; FNAV_SVID1_5 = 0; - FNAV_Deltaa12_1_5 = 0; - FNAV_e_1_5 = 0; - FNAV_w_1_5 = 0; - FNAV_deltai_1_5 = 0; - FNAV_Omega0_1_5 = 0; - FNAV_Omegadot_1_5 = 0; - FNAV_M0_1_5 = 0; - FNAV_af0_1_5 = 0; - FNAV_af1_1_5 = 0; - FNAV_E5ahs_1_5 = 0; + FNAV_Deltaa12_1_5 = 0.0; + FNAV_e_1_5 = 0.0; + FNAV_w_1_5 = 0.0; + FNAV_deltai_1_5 = 0.0; + FNAV_Omega0_1_5 = 0.0; + FNAV_Omegadot_1_5 = 0.0; + FNAV_M0_1_5 = 0.0; + FNAV_af0_1_5 = 0.0; + FNAV_af1_1_5 = 0.0; + FNAV_E5ahs_1_5 = 0U; FNAV_SVID2_5 = 0; FNAV_Deltaa12_2_5 = 0; - FNAV_e_2_5 = 0; - FNAV_w_2_5 = 0; - FNAV_deltai_2_5 = 0; + FNAV_e_2_5 = 0.0; + FNAV_w_2_5 = 0.0; + FNAV_deltai_2_5 = 0.0; // WORD 6 Almanac (SVID2(2/2) and SVID3) FNAV_IODa_6 = 0; - FNAV_Omega0_2_6 = 0; - FNAV_Omegadot_2_6 = 0; - FNAV_M0_2_6 = 0; - FNAV_af0_2_6 = 0; - FNAV_af1_2_6 = 0; - FNAV_E5ahs_2_6 = 0; + FNAV_Omega0_2_6 = 0.0; + FNAV_Omegadot_2_6 = 0.0; + FNAV_M0_2_6 = 0.0; + FNAV_af0_2_6 = 0.0; + FNAV_af1_2_6 = 0.0; + FNAV_E5ahs_2_6 = 0.0; FNAV_SVID3_6 = 0; - FNAV_Deltaa12_3_6 = 0; - FNAV_e_3_6 = 0; - FNAV_w_3_6 = 0; - FNAV_deltai_3_6 = 0; - FNAV_Omega0_3_6 = 0; - FNAV_Omegadot_3_6 = 0; - FNAV_M0_3_6 = 0; - FNAV_af0_3_6 = 0; - FNAV_af1_3_6 = 0; - FNAV_E5ahs_3_6 = 0; + FNAV_Deltaa12_3_6 = 0.0; + FNAV_e_3_6 = 0.0; + FNAV_w_3_6 = 0.0; + FNAV_deltai_3_6 = 0.0; + FNAV_Omega0_3_6 = 0.0; + FNAV_Omegadot_3_6 = 0.0; + FNAV_M0_3_6 = 0.0; + FNAV_af0_3_6 = 0.0; + FNAV_af1_3_6 = 0.0; + FNAV_E5ahs_3_6 = 0.0; } + Galileo_Fnav_Message::Galileo_Fnav_Message() { reset(); } -//int Galileo_Fnav_Message::toInt(std::string bitString) -//{ -// int tempInt; -// int num=0; -// int sLength = bitString.length(); -// for(int i=0; i bits, boost::uint32_t checksum) +bool Galileo_Fnav_Message::_CRC_test(std::bitset bits, uint32_t checksum) { CRC_Galileo_FNAV_type CRC_Galileo; - boost::uint32_t crc_computed; + uint32_t crc_computed; // Galileo FNAV frame for CRC is not an integer multiple of bytes // it needs to be filled with zeroes at the start of the frame. // This operation is done in the transformation from bits to bytes // using boost::dynamic_bitset. // ToDo: Use boost::dynamic_bitset for all the bitset operations in this class - boost::dynamic_bitset frame_bits(std::string(bits.to_string())); + boost::dynamic_bitset frame_bits(std::string(bits.to_string())); - std::vector bytes; + std::vector bytes; boost::to_block_range(frame_bits, std::back_inserter(bytes)); std::reverse(bytes.begin(), bytes.end()); @@ -249,8 +238,8 @@ void Galileo_Fnav_Message::decode_page(std::string data) switch (page_type) { case 1: // SVID, Clock correction, SISA, Ionospheric correction, BGD, GST, Signal health and Data validity status - FNAV_SV_ID_PRN_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_SV_ID_PRN_1_bit)); - FNAV_IODnav_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_IODnav_1_bit)); + FNAV_SV_ID_PRN_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_SV_ID_PRN_1_bit)); + FNAV_IODnav_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_IODnav_1_bit)); FNAV_t0c_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_t0c_1_bit)); FNAV_t0c_1 *= FNAV_t0c_1_LSB; FNAV_af0_1 = static_cast(read_navigation_signed(data_bits, FNAV_af0_1_bit)); @@ -273,17 +262,16 @@ void Galileo_Fnav_Message::decode_page(std::string data) FNAV_region5_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_region5_1_bit)); FNAV_BGD_1 = static_cast(read_navigation_signed(data_bits, FNAV_BGD_1_bit)); FNAV_BGD_1 *= FNAV_BGD_1_LSB; - FNAV_E5ahs_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_E5ahs_1_bit)); + FNAV_E5ahs_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_E5ahs_1_bit)); FNAV_WN_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_WN_1_bit)); FNAV_TOW_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_TOW_1_bit)); FNAV_E5advs_1 = static_cast(read_navigation_unsigned(data_bits, FNAV_E5advs_1_bit)); - flag_TOW_1 = true; flag_TOW_set = true; - flag_iono_and_GST = true; //set to false externally + flag_iono_and_GST = true; // set to false externally break; case 2: // Ephemeris (1/3) and GST - FNAV_IODnav_2 = static_cast(read_navigation_unsigned(data_bits, FNAV_IODnav_2_bit)); + FNAV_IODnav_2 = static_cast(read_navigation_unsigned(data_bits, FNAV_IODnav_2_bit)); FNAV_M0_2 = static_cast(read_navigation_unsigned(data_bits, FNAV_M0_2_bit)); FNAV_M0_2 *= FNAV_M0_2_LSB; FNAV_omegadot_2 = static_cast(read_navigation_signed(data_bits, FNAV_omegadot_2_bit)); @@ -298,13 +286,12 @@ void Galileo_Fnav_Message::decode_page(std::string data) FNAV_idot_2 *= FNAV_idot_2_LSB; FNAV_WN_2 = static_cast(read_navigation_unsigned(data_bits, FNAV_WN_2_bit)); FNAV_TOW_2 = static_cast(read_navigation_unsigned(data_bits, FNAV_TOW_2_bit)); - flag_TOW_2 = true; flag_TOW_set = true; flag_ephemeris_1 = true; break; case 3: // Ephemeris (2/3) and GST - FNAV_IODnav_3 = static_cast(read_navigation_unsigned(data_bits, FNAV_IODnav_3_bit)); + FNAV_IODnav_3 = static_cast(read_navigation_unsigned(data_bits, FNAV_IODnav_3_bit)); FNAV_i0_3 = static_cast(read_navigation_signed(data_bits, FNAV_i0_3_bit)); FNAV_i0_3 *= FNAV_i0_3_LSB; FNAV_w_3 = static_cast(read_navigation_signed(data_bits, FNAV_w_3_bit)); @@ -323,13 +310,12 @@ void Galileo_Fnav_Message::decode_page(std::string data) FNAV_t0e_3 *= FNAV_t0e_3_LSB; FNAV_WN_3 = static_cast(read_navigation_unsigned(data_bits, FNAV_WN_3_bit)); FNAV_TOW_3 = static_cast(read_navigation_unsigned(data_bits, FNAV_TOW_3_bit)); - flag_TOW_3 = true; flag_TOW_set = true; flag_ephemeris_2 = true; break; case 4: // Ephemeris (3/3), GST-UTC conversion, GST-GPS conversion and TOW - FNAV_IODnav_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_IODnav_4_bit)); + FNAV_IODnav_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_IODnav_4_bit)); FNAV_Cic_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_Cic_4_bit)); FNAV_Cic_4 *= FNAV_Cic_4_LSB; FNAV_Cis_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_Cis_4_bit)); @@ -353,18 +339,17 @@ void Galileo_Fnav_Message::decode_page(std::string data) FNAV_A1g_4 *= FNAV_A1g_4_LSB; FNAV_WN0g_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_WN0g_4_bit)); FNAV_TOW_4 = static_cast(read_navigation_unsigned(data_bits, FNAV_TOW_4_bit)); - flag_TOW_4 = true; flag_TOW_set = true; flag_ephemeris_3 = true; - flag_utc_model = true; //set to false externally + flag_utc_model = true; // set to false externally break; case 5: // Almanac (SVID1 and SVID2(1/2)), Week Number and almanac reference time - FNAV_IODa_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_IODa_5_bit)); + FNAV_IODa_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_IODa_5_bit)); FNAV_WNa_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_WNa_5_bit)); FNAV_t0a_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_t0a_5_bit)); FNAV_t0a_5 *= FNAV_t0a_5_LSB; - FNAV_SVID1_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_SVID1_5_bit)); + FNAV_SVID1_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_SVID1_5_bit)); FNAV_Deltaa12_1_5 = static_cast(read_navigation_signed(data_bits, FNAV_Deltaa12_1_5_bit)); FNAV_Deltaa12_1_5 *= FNAV_Deltaa12_5_LSB; FNAV_e_1_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_e_1_5_bit)); @@ -384,7 +369,7 @@ void Galileo_Fnav_Message::decode_page(std::string data) FNAV_af1_1_5 = static_cast(read_navigation_signed(data_bits, FNAV_af1_1_5_bit)); FNAV_af1_1_5 *= FNAV_af1_5_LSB; FNAV_E5ahs_1_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_E5ahs_1_5_bit)); - FNAV_SVID2_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_SVID2_5_bit)); + FNAV_SVID2_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_SVID2_5_bit)); FNAV_Deltaa12_2_5 = static_cast(read_navigation_signed(data_bits, FNAV_Deltaa12_2_5_bit)); FNAV_Deltaa12_2_5 *= FNAV_Deltaa12_5_LSB; FNAV_e_2_5 = static_cast(read_navigation_unsigned(data_bits, FNAV_e_2_5_bit)); @@ -399,21 +384,18 @@ void Galileo_Fnav_Message::decode_page(std::string data) //omega_flag=true; // //FNAV_Omega012_2_5=static_cast(read_navigation_signed(data_bits, FNAV_Omega012_2_5_bit); - flag_almanac_1 = true; break; case 6: // Almanac (SVID2(2/2) and SVID3) - FNAV_IODa_6 = static_cast(read_navigation_unsigned(data_bits, FNAV_IODa_6_bit)); - - /* Don't worry about omega pieces. If page 5 has not been received, all_ephemeris - * flag will be set to false and the data won't be recorded.*/ + FNAV_IODa_6 = static_cast(read_navigation_unsigned(data_bits, FNAV_IODa_6_bit)); + // Don't worry about omega pieces. If page 5 has not been received, all_ephemeris + // flag will be set to false and the data won't be recorded.*/ std::string omega0_2 = data.substr(10, 12); std::string Omega0 = omega0_1 + omega0_2; std::bitset omega_bits(Omega0); - const std::vector> om_bit({{0, 12}}); + const std::vector> om_bit({{0, 12}}); FNAV_Omega0_2_6 = static_cast(read_navigation_signed(omega_bits, om_bit)); FNAV_Omega0_2_6 *= FNAV_Omega0_5_LSB; - // FNAV_Omegadot_2_6 = static_cast(read_navigation_signed(data_bits, FNAV_Omegadot_2_6_bit)); FNAV_Omegadot_2_6 *= FNAV_Omegadot_5_LSB; FNAV_M0_2_6 = static_cast(read_navigation_signed(data_bits, FNAV_M0_2_6_bit)); @@ -423,7 +405,7 @@ void Galileo_Fnav_Message::decode_page(std::string data) FNAV_af1_2_6 = static_cast(read_navigation_signed(data_bits, FNAV_af1_2_6_bit)); FNAV_af1_2_6 *= FNAV_af1_5_LSB; FNAV_E5ahs_2_6 = static_cast(read_navigation_unsigned(data_bits, FNAV_E5ahs_2_6_bit)); - FNAV_SVID3_6 = static_cast(read_navigation_unsigned(data_bits, FNAV_SVID3_6_bit)); + FNAV_SVID3_6 = static_cast(read_navigation_unsigned(data_bits, FNAV_SVID3_6_bit)); FNAV_Deltaa12_3_6 = static_cast(read_navigation_signed(data_bits, FNAV_Deltaa12_3_6_bit)); FNAV_Deltaa12_3_6 *= FNAV_Deltaa12_5_LSB; FNAV_e_3_6 = static_cast(read_navigation_unsigned(data_bits, FNAV_e_3_6_bit)); @@ -450,15 +432,15 @@ void Galileo_Fnav_Message::decode_page(std::string data) } -uint64_t Galileo_Fnav_Message::read_navigation_unsigned(std::bitset bits, const std::vector> parameter) +uint64_t Galileo_Fnav_Message::read_navigation_unsigned(std::bitset bits, const std::vector> parameter) { - uint64_t value = 0; + uint64_t value = 0ULL; int num_of_slices = parameter.size(); for (int i = 0; i < num_of_slices; i++) { for (int j = 0; j < parameter[i].second; j++) { - value <<= 1; //shift left + value <<= 1; // shift left if (bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[i].first - j] == 1) { value += 1; // insert the bit @@ -469,59 +451,30 @@ uint64_t Galileo_Fnav_Message::read_navigation_unsigned(std::bitset bits, const std::vector> parameter) +int64_t Galileo_Fnav_Message::read_navigation_signed(std::bitset bits, const std::vector> parameter) { - int64_t value = 0; + int64_t value = 0LL; int num_of_slices = parameter.size(); - // Discriminate between 64 bits and 32 bits compiler - int long_int_size_bytes = sizeof(int64_t); - if (long_int_size_bytes == 8) // if a long int takes 8 bytes, we are in a 64 bits system - { - // read the MSB and perform the sign extension - if (bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[0].first] == 1) - { - value ^= 0xFFFFFFFFFFFFFFFF; //64 bits variable - } - else - { - value &= 0; - } - for (int i = 0; i < num_of_slices; i++) - { - for (int j = 0; j < parameter[i].second; j++) - { - value <<= 1; //shift left - value &= 0xFFFFFFFFFFFFFFFE; //reset the corresponding bit (for the 64 bits variable) - if (bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[i].first - j] == 1) - { - value += 1; // insert the bit - } - } - } + // read the MSB and perform the sign extension + if (bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[0].first] == 1) + { + value ^= 0xFFFFFFFFFFFFFFFF; //64 bits variable } - else // we assume we are in a 32 bits system + else { - // read the MSB and perform the sign extension - if (bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[0].first] == 1) - { - value ^= 0xFFFFFFFF; - } - else - { - value &= 0; - } + value &= 0; + } - for (int i = 0; i < num_of_slices; i++) + for (int i = 0; i < num_of_slices; i++) + { + for (int j = 0; j < parameter[i].second; j++) { - for (int j = 0; j < parameter[i].second; j++) + value <<= 1; // shift left + value &= 0xFFFFFFFFFFFFFFFE; // reset the corresponding bit (for the 64 bits variable) + if (bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[i].first - j] == 1) { - value <<= 1; //shift left - value &= 0xFFFFFFFE; //reset the corresponding bit - if (bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[i].first - j] == 1) - { - value += 1; // insert the bit - } + value += 1; // insert the bit } } } @@ -529,11 +482,11 @@ int64_t Galileo_Fnav_Message::read_navigation_signed(std::bitset // for boost::uint16_t #include #include #include @@ -58,17 +57,6 @@ class Galileo_Fnav_Message { public: - // void Galileo_Fnav_Message::split_page(std::string page_string); - // void Galileo_Fnav_Message::reset(); - // bool Galileo_Fnav_Message::have_new_ephemeris(); - // bool Galileo_Fnav_Message::have_new_iono_and_GST(); - // bool Galileo_Fnav_Message::have_new_utc_model(); - // bool Galileo_Fnav_Message::have_new_almanac(); - // Galileo_Ephemeris Galileo_Fnav_Message::get_ephemeris(); - // Galileo_Iono Galileo_Fnav_Message::get_iono(); - // Galileo_Utc_Model Galileo_Fnav_Message::get_utc_model(); - // Galileo_Almanac Galileo_Fnav_Message::get_almanac(); - // void split_page(std::string page_string); void reset(); bool have_new_ephemeris(); @@ -100,13 +88,13 @@ public: bool flag_almanac_1; //!< Flag indicating that almanac 1/2 (word 5) have been received bool flag_almanac_2; //!< Flag indicating that almanac 2/2 (word 6) have been received - int IOD_ephemeris; + int32_t IOD_ephemeris; - int page_type; - /* WORD 1 SVID, Clock correction, SISA, Ionospheric correction, BGD, GST, Signal - * health and Data validity status*/ - int FNAV_SV_ID_PRN_1; - int FNAV_IODnav_1; + int32_t page_type; + // WORD 1 SVID, Clock correction, SISA, Ionospheric correction, BGD, GST, Signal + // health and Data validity status + int32_t FNAV_SV_ID_PRN_1; + int32_t FNAV_IODnav_1; double FNAV_t0c_1; double FNAV_af0_1; double FNAV_af1_1; @@ -127,7 +115,7 @@ public: bool FNAV_E5advs_1; // WORD 2 Ephemeris (1/3) and GST - int FNAV_IODnav_2; + int32_t FNAV_IODnav_2; double FNAV_M0_2; double FNAV_omegadot_2; double FNAV_e_2; @@ -138,7 +126,7 @@ public: double FNAV_TOW_2; // WORD 3 Ephemeris (2/3) and GST - int FNAV_IODnav_3; + int32_t FNAV_IODnav_3; double FNAV_i0_3; double FNAV_w_3; double FNAV_deltan_3; @@ -150,9 +138,9 @@ public: double FNAV_WN_3; double FNAV_TOW_3; - /* WORD 4 Ephemeris (3/3), GST-UTC conversion, GST-GPS conversion and TOW. - Note that the clock is repeated in this page type*/ - int FNAV_IODnav_4; + // WORD 4 Ephemeris (3/3), GST-UTC conversion, GST-GPS conversion and TOW. + // Note that the clock is repeated in this page type + int32_t FNAV_IODnav_4; double FNAV_Cic_4; double FNAV_Cis_4; double FNAV_A0_4; @@ -170,10 +158,10 @@ public: double FNAV_TOW_4; // WORD 5 Almanac (SVID1 and SVID2(1/2)), Week Number and almanac reference time - int FNAV_IODa_5; + int32_t FNAV_IODa_5; double FNAV_WNa_5; double FNAV_t0a_5; - int FNAV_SVID1_5; + int32_t FNAV_SVID1_5; double FNAV_Deltaa12_1_5; double FNAV_e_1_5; double FNAV_w_1_5; @@ -183,22 +171,22 @@ public: double FNAV_M0_1_5; double FNAV_af0_1_5; double FNAV_af1_1_5; - unsigned int FNAV_E5ahs_1_5; - int FNAV_SVID2_5; + uint32_t FNAV_E5ahs_1_5; + int32_t FNAV_SVID2_5; double FNAV_Deltaa12_2_5; double FNAV_e_2_5; double FNAV_w_2_5; double FNAV_deltai_2_5; // WORD 6 Almanac (SVID2(2/2) and SVID3) - int FNAV_IODa_6; + int32_t FNAV_IODa_6; double FNAV_Omega0_2_6; double FNAV_Omegadot_2_6; double FNAV_M0_2_6; double FNAV_af0_2_6; double FNAV_af1_2_6; double FNAV_E5ahs_2_6; - int FNAV_SVID3_6; + int32_t FNAV_SVID3_6; double FNAV_Deltaa12_3_6; double FNAV_e_3_6; double FNAV_w_3_6; @@ -210,12 +198,11 @@ public: double FNAV_af1_3_6; double FNAV_E5ahs_3_6; - private: - bool _CRC_test(std::bitset bits, boost::uint32_t checksum); + bool _CRC_test(std::bitset bits, uint32_t checksum); void decode_page(std::string data); - uint64_t read_navigation_unsigned(std::bitset bits, const std::vector> parameter); - int64_t read_navigation_signed(std::bitset bits, const std::vector> parameter); + uint64_t read_navigation_unsigned(std::bitset bits, const std::vector> parameter); + int64_t read_navigation_signed(std::bitset bits, const std::vector> parameter); std::string omega0_1; //std::string omega0_2; diff --git a/src/core/system_parameters/galileo_iono.cc b/src/core/system_parameters/galileo_iono.cc index 4a8eb35b0..d79b2a319 100644 --- a/src/core/system_parameters/galileo_iono.cc +++ b/src/core/system_parameters/galileo_iono.cc @@ -33,18 +33,18 @@ Galileo_Iono::Galileo_Iono() { - /* Ionospheric correction */ - ai0_5 = 0; // Effective Ionisation Level 1st order parameter [sfu] - ai1_5 = 0; // Effective Ionisation Level 2st order parameter [sfu/degree] - ai2_5 = 0; // Effective Ionisation Level 3st order parameter [sfu/degree] + // Ionospheric correction + ai0_5 = 0.0; // Effective Ionisation Level 1st order parameter [sfu] + ai1_5 = 0.0; // Effective Ionisation Level 2st order parameter [sfu/degree] + ai2_5 = 0.0; // Effective Ionisation Level 3st order parameter [sfu/degree] - /* Ionospheric disturbance flag */ + // Ionospheric disturbance flag Region1_flag_5 = false; // Ionospheric Disturbance Flag for region 1 Region2_flag_5 = false; // Ionospheric Disturbance Flag for region 2 Region3_flag_5 = false; // Ionospheric Disturbance Flag for region 3 Region4_flag_5 = false; // Ionospheric Disturbance Flag for region 4 Region5_flag_5 = false; // Ionospheric Disturbance Flag for region 5 - TOW_5 = 0; - WN_5 = 0; + TOW_5 = 0.0; + WN_5 = 0.0; } diff --git a/src/core/system_parameters/galileo_iono.h b/src/core/system_parameters/galileo_iono.h index 1c3278ed7..cc8af7392 100644 --- a/src/core/system_parameters/galileo_iono.h +++ b/src/core/system_parameters/galileo_iono.h @@ -41,19 +41,19 @@ class Galileo_Iono { public: - /*Ionospheric correction*/ + // Ionospheric correction double ai0_5; //!< Effective Ionisation Level 1st order parameter [sfu] double ai1_5; //!< Effective Ionisation Level 2st order parameter [sfu/degree] double ai2_5; //!< Effective Ionisation Level 3st order parameter [sfu/degree] - /*Ionospheric disturbance flag*/ + // Ionospheric disturbance flag bool Region1_flag_5; //!< Ionospheric Disturbance Flag for region 1 bool Region2_flag_5; //!< Ionospheric Disturbance Flag for region 2 bool Region3_flag_5; //!< Ionospheric Disturbance Flag for region 3 bool Region4_flag_5; //!< Ionospheric Disturbance Flag for region 4 bool Region5_flag_5; //!< Ionospheric Disturbance Flag for region 5 - /*from page 5 (UTC) to have a timestamp*/ + // from page 5 (UTC) to have a timestamp double TOW_5; //!< UTC data reference Time of Week [s] double WN_5; //!< UTC data reference Week number [week] diff --git a/src/core/system_parameters/galileo_navigation_message.cc b/src/core/system_parameters/galileo_navigation_message.cc index 13de3e5f2..cf753292a 100644 --- a/src/core/system_parameters/galileo_navigation_message.cc +++ b/src/core/system_parameters/galileo_navigation_message.cc @@ -61,7 +61,7 @@ void Galileo_Navigation_Message::reset() flag_almanac_3 = false; // flag indicating that almanac 3/4 (word 9) have been received flag_almanac_4 = false; // flag indicating that almanac 4/4 (word 10) have been received - flag_TOW_5 = 0; + flag_TOW_5 = false; flag_TOW_set = false; flag_GGTO = false; @@ -71,139 +71,141 @@ void Galileo_Navigation_Message::reset() flag_GGTO_4 = false; IOD_ephemeris = 0; - /*Word type 1: Ephemeris (1/4)*/ + + // Word type 1: Ephemeris (1/4) IOD_nav_1 = 0; - t0e_1 = 0; - M0_1 = 0; - e_1 = 0; - A_1 = 0; + t0e_1 = 0.0; + M0_1 = 0.0; + e_1 = 0.0; + A_1 = 0.0; - /*Word type 2: Ephemeris (2/4)*/ - IOD_nav_2 = 0; // IOD_nav page 2 - OMEGA_0_2 = 0; // Longitude of ascending node of orbital plane at weekly epoch [semi-circles] - i_0_2 = 0; // Inclination angle at reference time [semi-circles] - omega_2 = 0; // Argument of perigee [semi-circles] - iDot_2 = 0; // Rate of inclination angle [semi-circles/sec] + // Word type 2: Ephemeris (2/4) + IOD_nav_2 = 0; // IOD_nav page 2 + OMEGA_0_2 = 0.0; // Longitude of ascending node of orbital plane at weekly epoch [semi-circles] + i_0_2 = 0.0; // Inclination angle at reference time [semi-circles] + omega_2 = 0.0; // Argument of perigee [semi-circles] + iDot_2 = 0.0; // Rate of inclination angle [semi-circles/sec] + // Word type 3: Ephemeris (3/4) and SISA + IOD_nav_3 = 0; + OMEGA_dot_3 = 0.0; // Rate of right ascension [semi-circles/sec] + delta_n_3 = 0.0; // Mean motion difference from computed value [semi-circles/sec] + C_uc_3 = 0.0; // Amplitude of the cosine harmonic correction term to the argument of latitude [radians] + C_us_3 = 0.0; // Amplitude of the sine harmonic correction term to the argument of latitude [radians] + C_rc_3 = 0.0; // Amplitude of the cosine harmonic correction term to the orbit radius [meters] + C_rs_3 = 0.0; // Amplitude of the sine harmonic correction term to the orbit radius [meters] + SISA_3 = 0.0; // - /*Word type 3: Ephemeris (3/4) and SISA*/ - IOD_nav_3 = 0; // - OMEGA_dot_3 = 0; // Rate of right ascension [semi-circles/sec] - delta_n_3 = 0; // Mean motion difference from computed value [semi-circles/sec] - C_uc_3 = 0; // Amplitude of the cosine harmonic correction term to the argument of latitude [radians] - C_us_3 = 0; // Amplitude of the sine harmonic correction term to the argument of latitude [radians] - C_rc_3 = 0; // Amplitude of the cosine harmonic correction term to the orbit radius [meters] - C_rs_3 = 0; // Amplitude of the sine harmonic correction term to the orbit radius [meters] - SISA_3 = 0; // + // Word type 4: Ephemeris (4/4) and Clock correction parameter/ + IOD_nav_4 = 0; + SV_ID_PRN_4 = 0; + C_ic_4 = 0.0; // Amplitude of the cosine harmonic correction term to the angle of inclination [radians] + C_is_4 = 0.0; // Amplitude of the sine harmonic correction term to the angle of inclination [radians] + // Clock correction parameters + t0c_4 = 0.0; + af0_4 = 0.0; + af1_4 = 0.0; + af2_4 = 0.0; + spare_4 = 0.0; - /*Word type 4: Ephemeris (4/4) and Clock correction parameters*/ - IOD_nav_4 = 0; // - SV_ID_PRN_4 = 0; // - C_ic_4 = 0; // Amplitude of the cosine harmonic correction term to the angle of inclination [radians] - C_is_4 = 0; // Amplitude of the sine harmonic correction term to the angle of inclination [radians] - /*Clock correction parameters*/ - t0c_4 = 0; // - af0_4 = 0; // - af1_4 = 0; // - af2_4 = 0; // - spare_4 = 0; + // Word type 5: Ionospheric correction, BGD, signal health and data validity status and GST + // Ionospheric correction + ai0_5 = 0.0; + ai1_5 = 0.0; + ai2_5 = 0.0; - /*Word type 5: Ionospheric correction, BGD, signal health and data validity status and GST*/ - /*Ionospheric correction*/ - /*Az*/ - ai0_5 = 0; // - ai1_5 = 0; // - ai2_5 = 0; // - /*Ionospheric disturbance flag*/ - Region1_flag_5 = 0; // Region1_flag_5; - Region2_flag_5 = 0; // - Region3_flag_5 = 0; // - Region4_flag_5 = 0; // - Region5_flag_5 = 0; // - BGD_E1E5a_5 = 0; // - BGD_E1E5b_5 = 0; // - E5b_HS_5 = 0; - E1B_HS_5 = 0; - E5b_DVS_5 = 0; // - E1B_DVS_5 = 0; // - /*GST*/ - WN_5 = 0; - TOW_5 = 0; - spare_5 = 0; + // Ionospheric disturbance flag + Region1_flag_5 = false; // Region1_flag_5; + Region2_flag_5 = false; + Region3_flag_5 = false; + Region4_flag_5 = false; + Region5_flag_5 = false; + BGD_E1E5a_5 = 0.0; + BGD_E1E5b_5 = 0.0; + E5b_HS_5 = 0.0; + E1B_HS_5 = 0.0; + E5b_DVS_5 = 0.0; + E1B_DVS_5 = 0.0; - /*Word type 6: GST-UTC conversion parameters*/ - A0_6 = 0; - A1_6 = 0; - Delta_tLS_6 = 0; - t0t_6 = 0; - WNot_6 = 0; - WN_LSF_6 = 0; - DN_6 = 0; - Delta_tLSF_6 = 0; - TOW_6 = 0; + // GST + WN_5 = 0.0; + TOW_5 = 0.0; + spare_5 = 0.0; - /*Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number*/ + // Word type 6: GST-UTC conversion parameters + A0_6 = 0.0; + A1_6 = 0.0; + Delta_tLS_6 = 0.0; + t0t_6 = 0.0; + WNot_6 = 0.0; + WN_LSF_6 = 0.0; + DN_6 = 0.0; + Delta_tLSF_6 = 0.0; + TOW_6 = 0.0; + + // Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number IOD_a_7 = 0; - WN_a_7 = 0; - t0a_7 = 0; + WN_a_7 = 0.0; + t0a_7 = 0.0; SVID1_7 = 0; - DELTA_A_7 = 0; - e_7 = 0; - omega_7 = 0; - delta_i_7 = 0; - Omega0_7 = 0; - Omega_dot_7 = 0; - M0_7 = 0; + DELTA_A_7 = 0.0; + e_7 = 0.0; + omega_7 = 0.0; + delta_i_7 = 0.0; + Omega0_7 = 0.0; + Omega_dot_7 = 0.0; + M0_7 = 0.0; - /*Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2)*/ + // Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2) IOD_a_8 = 0; - af0_8 = 0; - af1_8 = 0; - E5b_HS_8 = 0; - E1B_HS_8 = 0; + af0_8 = 0.0; + af1_8 = 0.0; + E5b_HS_8 = 0.0; + E1B_HS_8 = 0.0; SVID2_8 = 0; - DELTA_A_8 = 0; - e_8 = 0; - omega_8 = 0; - delta_i_8 = 0; - Omega0_8 = 0; - Omega_dot_8 = 0; + DELTA_A_8 = 0.0; + e_8 = 0.0; + omega_8 = 0.0; + delta_i_8 = 0.0; + Omega0_8 = 0.0; + Omega_dot_8 = 0.0; - /*Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2)*/ + // Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2) IOD_a_9 = 0; - WN_a_9 = 0; - t0a_9 = 0; - M0_9 = 0; - af0_9 = 0; - af1_9 = 0; - E5b_HS_9 = 0; - E1B_HS_9 = 0; + WN_a_9 = 0.0; + t0a_9 = 0.0; + M0_9 = 0.0; + af0_9 = 0.0; + af1_9 = 0.0; + E5b_HS_9 = 0.0; + E1B_HS_9 = 0.0; SVID3_9 = 0; - DELTA_A_9 = 0; - e_9 = 0; - omega_9 = 0; - delta_i_9 = 0; + DELTA_A_9 = 0.0; + e_9 = 0.0; + omega_9 = 0.0; + delta_i_9 = 0.0; - /*Word type 10: Almanac for SVID3 (2/2) and GST-GPS conversion parameters*/ + // Word type 10: Almanac for SVID3 (2/2) and GST-GPS conversion parameters IOD_a_10 = 0; - Omega0_10 = 0; - Omega_dot_10 = 0; - M0_10 = 0; - af0_10 = 0; - af1_10 = 0; - E5b_HS_10 = 0; - E1B_HS_10 = 0; - //GST-GPS - A_0G_10 = 0; - A_1G_10 = 0; - t_0G_10 = 0; - WN_0G_10 = 0; + Omega0_10 = 0.0; + Omega_dot_10 = 0.0; + M0_10 = 0.0; + af0_10 = 0.0; + af1_10 = 0.0; + E5b_HS_10 = 0.0; + E1B_HS_10 = 0.0; - /*Word type 0: I/NAV Spare Word*/ - Time_0 = 0; - WN_0 = 0; - TOW_0 = 0; + // GST-GPS + A_0G_10 = 0.0; + A_1G_10 = 0.0; + t_0G_10 = 0.0; + WN_0G_10 = 0.0; + + // Word type 0: I/NAV Spare Word + Time_0 = 0.0; + WN_0 = 0.0; + TOW_0 = 0.0; flag_TOW_6 = false; @@ -258,15 +260,15 @@ bool Galileo_Navigation_Message::CRC_test(std::bitset b } -uint64_t Galileo_Navigation_Message::read_navigation_unsigned(std::bitset bits, const std::vector > parameter) +uint64_t Galileo_Navigation_Message::read_navigation_unsigned(std::bitset bits, const std::vector > parameter) { uint64_t value = 0; - int num_of_slices = parameter.size(); - for (int i = 0; i < num_of_slices; i++) + int32_t num_of_slices = parameter.size(); + for (int32_t i = 0; i < num_of_slices; i++) { - for (int j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < parameter[i].second; j++) { - value <<= 1; //shift left + value <<= 1; // shift left if (bits[GALILEO_DATA_JK_BITS - parameter[i].first - j] == 1) { value += 1; // insert the bit @@ -277,15 +279,15 @@ uint64_t Galileo_Navigation_Message::read_navigation_unsigned(std::bitset bits, const std::vector > parameter) +uint64_t Galileo_Navigation_Message::read_page_type_unsigned(std::bitset bits, const std::vector > parameter) { - uint64_t value = 0; - int num_of_slices = parameter.size(); - for (int i = 0; i < num_of_slices; i++) + uint64_t value = 0ULL; + int32_t num_of_slices = parameter.size(); + for (int32_t i = 0; i < num_of_slices; i++) { - for (int j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < parameter[i].second; j++) { - value <<= 1; //shift left + value <<= 1; // shift left if (bits[GALILEO_PAGE_TYPE_BITS - parameter[i].first - j] == 1) { value += 1; // insert the bit @@ -296,59 +298,30 @@ uint64_t Galileo_Navigation_Message::read_page_type_unsigned(std::bitset bits, const std::vector > parameter) +int64_t Galileo_Navigation_Message::read_navigation_signed(std::bitset bits, const std::vector > parameter) { - int64_t value = 0; - int num_of_slices = parameter.size(); - // Discriminate between 64 bits and 32 bits compiler - int long_int_size_bytes = sizeof(int64_t); - if (long_int_size_bytes == 8) // if a long int takes 8 bytes, we are in a 64 bits system - { - // read the MSB and perform the sign extension - if (bits[GALILEO_DATA_JK_BITS - parameter[0].first] == 1) - { - value ^= 0xFFFFFFFFFFFFFFFF; //64 bits variable - } - else - { - value &= 0; - } + int64_t value = 0LL; + int32_t num_of_slices = parameter.size(); - for (int i = 0; i < num_of_slices; i++) - { - for (int j = 0; j < parameter[i].second; j++) - { - value <<= 1; //shift left - value &= 0xFFFFFFFFFFFFFFFE; //reset the corresponding bit (for the 64 bits variable) - if (bits[GALILEO_DATA_JK_BITS - parameter[i].first - j] == 1) - { - value += 1; // insert the bit - } - } - } + // read the MSB and perform the sign extension + if (bits[GALILEO_DATA_JK_BITS - parameter[0].first] == 1) + { + value ^= 0xFFFFFFFFFFFFFFFF; // 64 bits variable } - else // we assume we are in a 32 bits system + else { - // read the MSB and perform the sign extension - if (bits[GALILEO_DATA_JK_BITS - parameter[0].first] == 1) - { - value ^= 0xFFFFFFFF; - } - else - { - value &= 0; - } + value &= 0; + } - for (int i = 0; i < num_of_slices; i++) + for (int32_t i = 0; i < num_of_slices; i++) + { + for (int32_t j = 0; j < parameter[i].second; j++) { - for (int j = 0; j < parameter[i].second; j++) + value <<= 1; // shift left + value &= 0xFFFFFFFFFFFFFFFE; // reset the corresponding bit (for the 64 bits variable) + if (bits[GALILEO_DATA_JK_BITS - parameter[i].first - j] == 1) { - value <<= 1; //shift left - value &= 0xFFFFFFFE; //reset the corresponding bit - if (bits[GALILEO_DATA_JK_BITS - parameter[i].first - j] == 1) - { - value += 1; // insert the bit - } + value += 1; // insert the bit } } } @@ -356,7 +329,7 @@ int64_t Galileo_Navigation_Message::read_navigation_signed(std::bitset bits, const std::vector > parameter) +bool Galileo_Navigation_Message::read_navigation_bool(std::bitset bits, const std::vector > parameter) { bool value; if (bits[GALILEO_DATA_JK_BITS - parameter[0].first] == 1) @@ -371,20 +344,20 @@ bool Galileo_Navigation_Message::read_navigation_bool(std::bitset page_type_bits(page_number_bits); // from string to bitset - Page_type = static_cast(read_page_type_unsigned(page_type_bits, type)); + Page_type = static_cast(read_page_type_unsigned(page_type_bits, type)); Page_type_time_stamp = Page_type; std::string Data_jk_ephemeris = Data_k + Data_j; page_jk_decoder(Data_jk_ephemeris.c_str()); @@ -452,11 +425,11 @@ void Galileo_Navigation_Message::split_page(std::string page_string, int flag_ev } -bool Galileo_Navigation_Message::have_new_ephemeris() //Check if we have a new ephemeris stored in the galileo navigation class +bool Galileo_Navigation_Message::have_new_ephemeris() // Check if we have a new ephemeris stored in the galileo navigation class { if ((flag_ephemeris_1 == true) and (flag_ephemeris_2 == true) and (flag_ephemeris_3 == true) and (flag_ephemeris_4 == true) and (flag_iono_and_GST == true)) { - //if all ephemeris pages have the same IOD, then they belong to the same block + // if all ephemeris pages have the same IOD, then they belong to the same block if ((IOD_nav_1 == IOD_nav_2) and (IOD_nav_3 == IOD_nav_4) and (IOD_nav_1 == IOD_nav_3)) { std::cout << "Ephemeris (1, 2, 3, 4) have been received and belong to the same batch" << std::endl; @@ -479,9 +452,9 @@ bool Galileo_Navigation_Message::have_new_ephemeris() //Check if we have a new } -bool Galileo_Navigation_Message::have_new_iono_and_GST() //Check if we have a new iono data set stored in the galileo navigation class +bool Galileo_Navigation_Message::have_new_iono_and_GST() // Check if we have a new iono data set stored in the galileo navigation class { - if ((flag_iono_and_GST == true) and (flag_utc_model == true)) //the condition on flag_utc_model is added to have a time stamp for iono + if ((flag_iono_and_GST == true) and (flag_utc_model == true)) // the condition on flag_utc_model is added to have a time stamp for iono { flag_iono_and_GST = false; // clear the flag return true; @@ -503,11 +476,11 @@ bool Galileo_Navigation_Message::have_new_utc_model() // Check if we have a new } -bool Galileo_Navigation_Message::have_new_almanac() //Check if we have a new almanac data set stored in the galileo navigation class +bool Galileo_Navigation_Message::have_new_almanac() // Check if we have a new almanac data set stored in the galileo navigation class { if ((flag_almanac_1 == true) and (flag_almanac_2 == true) and (flag_almanac_3 == true) and (flag_almanac_4 == true)) { - //All almanac have been received + // All almanac have been received flag_almanac_1 = false; flag_almanac_2 = false; flag_almanac_3 = false; @@ -544,13 +517,13 @@ Galileo_Ephemeris Galileo_Navigation_Message::get_ephemeris() ephemeris.C_is_4 = C_is_4; // Amplitude of the sine harmonic correction term to the angle of inclination [radians] ephemeris.t0e_1 = t0e_1; // Ephemeris reference time [s] - /*Clock correction parameters*/ + // Clock correction parameters ephemeris.t0c_4 = t0c_4; // Clock correction data reference Time of Week [sec] ephemeris.af0_4 = af0_4; // SV clock bias correction coefficient [s] ephemeris.af1_4 = af1_4; // SV clock drift correction coefficient [s/s] ephemeris.af2_4 = af2_4; // SV clock drift rate correction coefficient [s/s^2] - /*GST*/ + // GST ephemeris.WN_5 = WN_5; // Week number ephemeris.TOW_5 = TOW_5; // Time of Week @@ -572,20 +545,19 @@ Galileo_Ephemeris Galileo_Navigation_Message::get_ephemeris() Galileo_Iono Galileo_Navigation_Message::get_iono() { Galileo_Iono iono; - /*Ionospheric correction*/ - /*Az*/ + // Ionospheric correction iono.ai0_5 = ai0_5; // Effective Ionisation Level 1st order parameter [sfu] iono.ai1_5 = ai1_5; // Effective Ionisation Level 2st order parameter [sfu/degree] iono.ai2_5 = ai2_5; // Effective Ionisation Level 3st order parameter [sfu/degree] - /*Ionospheric disturbance flag*/ + // Ionospheric disturbance flag iono.Region1_flag_5 = Region1_flag_5; // Ionospheric Disturbance Flag for region 1 iono.Region2_flag_5 = Region2_flag_5; // Ionospheric Disturbance Flag for region 2 iono.Region3_flag_5 = Region3_flag_5; // Ionospheric Disturbance Flag for region 3 iono.Region4_flag_5 = Region4_flag_5; // Ionospheric Disturbance Flag for region 4 iono.Region5_flag_5 = Region5_flag_5; // Ionospheric Disturbance Flag for region 5 - /*GST*/ + // GST // This is the ONLY page containing the Week Number (WN) iono.TOW_5 = TOW_5; iono.WN_5 = WN_5; @@ -596,8 +568,7 @@ Galileo_Iono Galileo_Navigation_Message::get_iono() Galileo_Utc_Model Galileo_Navigation_Message::get_utc_model() { Galileo_Utc_Model utc_model; - //Gal_utc_model.valid = flag_utc_model_valid; - /*Word type 6: GST-UTC conversion parameters*/ + // Word type 6: GST-UTC conversion parameters utc_model.A0_6 = A0_6; utc_model.A1_6 = A1_6; utc_model.Delta_tLS_6 = Delta_tLS_6; @@ -607,9 +578,6 @@ Galileo_Utc_Model Galileo_Navigation_Message::get_utc_model() utc_model.DN_6 = DN_6; utc_model.Delta_tLSF_6 = Delta_tLSF_6; utc_model.flag_utc_model = flag_utc_model; - /*GST*/ - //utc_model.WN_5 = WN_5; //Week number - //utc_model.TOW_5 = WN_5; //Time of Week return utc_model; } @@ -617,7 +585,7 @@ Galileo_Utc_Model Galileo_Navigation_Message::get_utc_model() Galileo_Almanac Galileo_Navigation_Message::get_almanac() { Galileo_Almanac almanac; - /*Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number*/ + // Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number almanac.IOD_a_7 = IOD_a_7; almanac.WN_a_7 = WN_a_7; almanac.t0a_7 = t0a_7; @@ -630,7 +598,7 @@ Galileo_Almanac Galileo_Navigation_Message::get_almanac() almanac.Omega_dot_7 = Omega_dot_7; almanac.M0_7 = M0_7; - /*Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2)*/ + // Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2) almanac.IOD_a_8 = IOD_a_8; almanac.af0_8 = af0_8; almanac.af1_8 = af1_8; @@ -644,7 +612,7 @@ Galileo_Almanac Galileo_Navigation_Message::get_almanac() almanac.Omega0_8 = Omega0_8; almanac.Omega_dot_8 = Omega_dot_8; - /*Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2)*/ + // Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2) almanac.IOD_a_9 = IOD_a_9; almanac.WN_a_9 = WN_a_9; almanac.t0a_9 = t0a_9; @@ -659,7 +627,7 @@ Galileo_Almanac Galileo_Navigation_Message::get_almanac() almanac.omega_9 = omega_9; almanac.delta_i_9 = delta_i_9; - /*Word type 10: Almanac for SVID3 (2/2)*/ + // Word type 10: Almanac for SVID3 (2/2) almanac.IOD_a_10 = IOD_a_10; almanac.Omega0_10 = Omega0_10; almanac.Omega_dot_10 = Omega_dot_10; @@ -669,7 +637,7 @@ Galileo_Almanac Galileo_Navigation_Message::get_almanac() almanac.E5b_HS_10 = E5b_HS_10; almanac.E1B_HS_10 = E1B_HS_10; - /*GPS to Galileo GST conversion parameters*/ + // GPS to Galileo GST conversion parameters almanac.A_0G_10 = A_0G_10; almanac.A_1G_10 = A_1G_10; almanac.t_0G_10 = t_0G_10; @@ -679,21 +647,20 @@ Galileo_Almanac Galileo_Navigation_Message::get_almanac() } -int Galileo_Navigation_Message::page_jk_decoder(const char *data_jk) +int32_t Galileo_Navigation_Message::page_jk_decoder(const char *data_jk) { - int page_number = 0; + int32_t page_number = 0; std::string data_jk_string = data_jk; std::bitset data_jk_bits(data_jk_string); - //DLOG(INFO) << "Data_jk_bits (bitset) "<< endl << data_jk_bits << endl; - page_number = static_cast(read_navigation_unsigned(data_jk_bits, PAGE_TYPE_bit)); + page_number = static_cast(read_navigation_unsigned(data_jk_bits, PAGE_TYPE_bit)); LOG(INFO) << "Page number = " << page_number; switch (page_number) { - case 1: /*Word type 1: Ephemeris (1/4)*/ - IOD_nav_1 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_nav_1_bit)); + case 1: // Word type 1: Ephemeris (1/4) + IOD_nav_1 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_nav_1_bit)); DLOG(INFO) << "IOD_nav_1= " << IOD_nav_1; t0e_1 = static_cast(read_navigation_unsigned(data_jk_bits, T0E_1_bit)); t0e_1 = t0e_1 * t0e_1_LSB; @@ -711,8 +678,8 @@ int Galileo_Navigation_Message::page_jk_decoder(const char *data_jk) DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; - case 2: /*Word type 2: Ephemeris (2/4)*/ - IOD_nav_2 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_nav_2_bit)); + case 2: // Word type 2: Ephemeris (2/4) + IOD_nav_2 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_nav_2_bit)); DLOG(INFO) << "IOD_nav_2= " << IOD_nav_2; OMEGA_0_2 = static_cast(read_navigation_signed(data_jk_bits, OMEGA_0_2_bit)); OMEGA_0_2 = OMEGA_0_2 * OMEGA_0_2_LSB; @@ -730,8 +697,8 @@ int Galileo_Navigation_Message::page_jk_decoder(const char *data_jk) DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; - case 3: /*Word type 3: Ephemeris (3/4) and SISA*/ - IOD_nav_3 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_nav_3_bit)); + case 3: // Word type 3: Ephemeris (3/4) and SISA + IOD_nav_3 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_nav_3_bit)); DLOG(INFO) << "IOD_nav_3= " << IOD_nav_3; OMEGA_dot_3 = static_cast(read_navigation_signed(data_jk_bits, OMEGA_dot_3_bit)); OMEGA_dot_3 = OMEGA_dot_3 * OMEGA_dot_3_LSB; @@ -757,10 +724,10 @@ int Galileo_Navigation_Message::page_jk_decoder(const char *data_jk) DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; - case 4: /* Word type 4: Ephemeris (4/4) and Clock correction parameters*/ - IOD_nav_4 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_nav_4_bit)); + case 4: // Word type 4: Ephemeris (4/4) and Clock correction parameters + IOD_nav_4 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_nav_4_bit)); DLOG(INFO) << "IOD_nav_4= " << IOD_nav_4; - SV_ID_PRN_4 = static_cast(read_navigation_unsigned(data_jk_bits, SV_ID_PRN_4_bit)); + SV_ID_PRN_4 = static_cast(read_navigation_unsigned(data_jk_bits, SV_ID_PRN_4_bit)); DLOG(INFO) << "SV_ID_PRN_4= " << SV_ID_PRN_4; C_ic_4 = static_cast(read_navigation_signed(data_jk_bits, C_ic_4_bit)); C_ic_4 = C_ic_4 * C_ic_4_LSB; @@ -768,7 +735,7 @@ int Galileo_Navigation_Message::page_jk_decoder(const char *data_jk) C_is_4 = static_cast(read_navigation_signed(data_jk_bits, C_is_4_bit)); C_is_4 = C_is_4 * C_is_4_LSB; DLOG(INFO) << "C_is_4= " << C_is_4; - /*Clock correction parameters*/ + // Clock correction parameters t0c_4 = static_cast(read_navigation_unsigned(data_jk_bits, t0c_4_bit)); t0c_4 = t0c_4 * t0c_4_LSB; DLOG(INFO) << "t0c_4= " << t0c_4; @@ -787,9 +754,8 @@ int Galileo_Navigation_Message::page_jk_decoder(const char *data_jk) DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; - case 5: /*Word type 5: Ionospheric correction, BGD, signal health and data validity status and GST*/ - /*Ionospheric correction*/ - /*Az*/ + case 5: // Word type 5: Ionospheric correction, BGD, signal health and data validity status and GST + // Ionospheric correction ai0_5 = static_cast(read_navigation_unsigned(data_jk_bits, ai0_5_bit)); ai0_5 = ai0_5 * ai0_5_LSB; DLOG(INFO) << "ai0_5= " << ai0_5; @@ -799,7 +765,7 @@ int Galileo_Navigation_Message::page_jk_decoder(const char *data_jk) ai2_5 = static_cast(read_navigation_signed(data_jk_bits, ai2_5_bit)); ai2_5 = ai2_5 * ai2_5_LSB; DLOG(INFO) << "ai2_5= " << ai2_5; - /*Ionospheric disturbance flag*/ + // Ionospheric disturbance flag Region1_flag_5 = static_cast(read_navigation_bool(data_jk_bits, Region1_5_bit)); DLOG(INFO) << "Region1_flag_5= " << Region1_flag_5; Region2_flag_5 = static_cast(read_navigation_bool(data_jk_bits, Region2_5_bit)); @@ -824,20 +790,20 @@ int Galileo_Navigation_Message::page_jk_decoder(const char *data_jk) DLOG(INFO) << "E5b_DVS_5= " << E5b_DVS_5; E1B_DVS_5 = static_cast(read_navigation_unsigned(data_jk_bits, E1B_DVS_5_bit)); DLOG(INFO) << "E1B_DVS_5= " << E1B_DVS_5; - /*GST*/ + // GST WN_5 = static_cast(read_navigation_unsigned(data_jk_bits, WN_5_bit)); DLOG(INFO) << "WN_5= " << WN_5; TOW_5 = static_cast(read_navigation_unsigned(data_jk_bits, TOW_5_bit)); DLOG(INFO) << "TOW_5= " << TOW_5; - flag_TOW_5 = true; //set to false externally + flag_TOW_5 = true; // set to false externally spare_5 = static_cast(read_navigation_unsigned(data_jk_bits, spare_5_bit)); DLOG(INFO) << "spare_5= " << spare_5; - flag_iono_and_GST = true; //set to false externally - flag_TOW_set = true; //set to false externally + flag_iono_and_GST = true; // set to false externally + flag_TOW_set = true; // set to false externally DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; - case 6: /*Word type 6: GST-UTC conversion parameters*/ + case 6: // Word type 6: GST-UTC conversion parameters A0_6 = static_cast(read_navigation_signed(data_jk_bits, A0_6_bit)); A0_6 = A0_6 * A0_6_LSB; DLOG(INFO) << "A0_6= " << A0_6; @@ -859,13 +825,13 @@ int Galileo_Navigation_Message::page_jk_decoder(const char *data_jk) DLOG(INFO) << "Delta_tLSF_6= " << Delta_tLSF_6; TOW_6 = static_cast(read_navigation_unsigned(data_jk_bits, TOW_6_bit)); DLOG(INFO) << "TOW_6= " << TOW_6; - flag_TOW_6 = true; //set to false externally - flag_utc_model = true; //set to false externally - flag_TOW_set = true; //set to false externally + flag_TOW_6 = true; // set to false externally + flag_utc_model = true; // set to false externally + flag_TOW_set = true; // set to false externally DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; - case 7: /*Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number*/ + case 7: // Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number IOD_a_7 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_a_7_bit)); DLOG(INFO) << "IOD_a_7= " << IOD_a_7; WN_a_7 = static_cast(read_navigation_unsigned(data_jk_bits, WN_a_7_bit)); @@ -900,7 +866,7 @@ int Galileo_Navigation_Message::page_jk_decoder(const char *data_jk) DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; - case 8: /*Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2)*/ + case 8: // Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2)*/ IOD_a_8 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_a_8_bit)); DLOG(INFO) << "IOD_a_8= " << IOD_a_8; af0_8 = static_cast(read_navigation_signed(data_jk_bits, af0_8_bit)); @@ -937,7 +903,7 @@ int Galileo_Navigation_Message::page_jk_decoder(const char *data_jk) DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; - case 9: /*Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2)*/ + case 9: // Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2) IOD_a_9 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_a_9_bit)); DLOG(INFO) << "IOD_a_9= " << IOD_a_9; WN_a_9 = static_cast(read_navigation_unsigned(data_jk_bits, WN_a_9_bit)); @@ -976,7 +942,7 @@ int Galileo_Navigation_Message::page_jk_decoder(const char *data_jk) DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; - case 10: /*Word type 10: Almanac for SVID3 (2/2) and GST-GPS conversion parameters*/ + case 10: // Word type 10: Almanac for SVID3 (2/2) and GST-GPS conversion parameters IOD_a_10 = static_cast(read_navigation_unsigned(data_jk_bits, IOD_a_10_bit)); DLOG(INFO) << "IOD_a_10= " << IOD_a_10; Omega0_10 = static_cast(read_navigation_signed(data_jk_bits, Omega0_10_bit)); @@ -1017,7 +983,7 @@ int Galileo_Navigation_Message::page_jk_decoder(const char *data_jk) DLOG(INFO) << "flag_tow_set" << flag_TOW_set; break; - case 0: /*Word type 0: I/NAV Spare Word*/ + case 0: // Word type 0: I/NAV Spare Word Time_0 = static_cast(read_navigation_unsigned(data_jk_bits, Time_0_bit)); DLOG(INFO) << "Time_0= " << Time_0; WN_0 = static_cast(read_navigation_unsigned(data_jk_bits, WN_0_bit)); diff --git a/src/core/system_parameters/galileo_navigation_message.h b/src/core/system_parameters/galileo_navigation_message.h index 4eddb5e77..6b41312c4 100644 --- a/src/core/system_parameters/galileo_navigation_message.h +++ b/src/core/system_parameters/galileo_navigation_message.h @@ -38,7 +38,6 @@ #include "galileo_almanac.h" #include "galileo_utc_model.h" #include "Galileo_E1.h" -//#include // for boost::uint32_t #include #include #include @@ -56,15 +55,14 @@ class Galileo_Navigation_Message { private: bool CRC_test(std::bitset bits, uint32_t checksum); - bool read_navigation_bool(std::bitset bits, const std::vector > parameter); - //void print_galileo_word_bytes(unsigned int GPS_word); - uint64_t read_navigation_unsigned(std::bitset bits, const std::vector > parameter); - uint64_t read_page_type_unsigned(std::bitset bits, const std::vector > parameter); - int64_t read_navigation_signed(std::bitset bits, const std::vector > parameter); + bool read_navigation_bool(std::bitset bits, const std::vector > parameter); + uint64_t read_navigation_unsigned(std::bitset bits, const std::vector > parameter); + uint64_t read_page_type_unsigned(std::bitset bits, const std::vector > parameter); + int64_t read_navigation_signed(std::bitset bits, const std::vector > parameter); public: - int Page_type_time_stamp; - int flag_even_word; + int32_t Page_type_time_stamp; + int32_t flag_even_word; std::string page_Even; bool flag_CRC_test; bool flag_all_ephemeris; //!< Flag indicating that all words containing ephemeris have been received @@ -85,7 +83,7 @@ public: bool flag_almanac_3; //!< Flag indicating that almanac 3/4 (word 9) have been received bool flag_almanac_4; //!< Flag indicating that almanac 4/4 (word 10) have been received - int IOD_ephemeris; + int32_t IOD_ephemeris; bool flag_GGTO; bool flag_GGTO_1; @@ -93,22 +91,22 @@ public: bool flag_GGTO_3; bool flag_GGTO_4; - /*Word type 1: Ephemeris (1/4)*/ - int IOD_nav_1; //!< IOD_nav page 1 - double t0e_1; //!< Ephemeris reference time [s] - double M0_1; //!< Mean anomaly at reference time [semi-circles] - double e_1; //!< Eccentricity - double A_1; //!< Square root of the semi-major axis [meters^1/2] + // Word type 1: Ephemeris (1/4) + int32_t IOD_nav_1; //!< IOD_nav page 1 + double t0e_1; //!< Ephemeris reference time [s] + double M0_1; //!< Mean anomaly at reference time [semi-circles] + double e_1; //!< Eccentricity + double A_1; //!< Square root of the semi-major axis [meters^1/2] - /*Word type 2: Ephemeris (2/4)*/ - int IOD_nav_2; //!< IOD_nav page 2 - double OMEGA_0_2; //!< Longitude of ascending node of orbital plane at weekly epoch [semi-circles] - double i_0_2; //!< Inclination angle at reference time [semi-circles] - double omega_2; //!< Argument of perigee [semi-circles] - double iDot_2; //!< Rate of inclination angle [semi-circles/sec] + // Word type 2: Ephemeris (2/4) + int32_t IOD_nav_2; //!< IOD_nav page 2 + double OMEGA_0_2; //!< Longitude of ascending node of orbital plane at weekly epoch [semi-circles] + double i_0_2; //!< Inclination angle at reference time [semi-circles] + double omega_2; //!< Argument of perigee [semi-circles] + double iDot_2; //!< Rate of inclination angle [semi-circles/sec] - /*Word type 3: Ephemeris (3/4) and SISA*/ - int IOD_nav_3; // + // Word type 3: Ephemeris (3/4) and SISA + int32_t IOD_nav_3; // double OMEGA_dot_3; //!< Rate of right ascension [semi-circles/sec] double delta_n_3; //!< Mean motion difference from computed value [semi-circles/sec] double C_uc_3; //!< Amplitude of the cosine harmonic correction term to the argument of latitude [radians] @@ -117,25 +115,26 @@ public: double C_rs_3; //!< Amplitude of the sine harmonic correction term to the orbit radius [meters] double SISA_3; - /*Word type 4: Ephemeris (4/4) and Clock correction parameters*/ - int IOD_nav_4; // - int SV_ID_PRN_4; // - double C_ic_4; //!= 0) // is not in the past { - //Detect if the effectivity time and user's time is within six hours = 6 * 60 *60 = 21600 s + // Detect if the effectivity time and user's time is within six hours = 6 * 60 *60 = 21600 s int secondOfLeapSecondEvent = DN_6 * 24 * 60 * 60; if (std::abs(t_e - secondOfLeapSecondEvent) > 21600) { @@ -74,7 +74,7 @@ double Galileo_Utc_Model::GST_to_UTC_time(double t_e, int WN) { /* 5.1.7b GST->UTC case b * Whenever the user's current time falls within the time span of six hours - * prior to the leap second adjustment to six hours after the adjustment time, , + * prior to the leap second adjustment to six hours after the adjustment time, * the effective time is computed according to the following equations: */ Delta_t_Utc = Delta_tLS_6 + A0_6 + A1_6 * (t_e - t0t_6 + 604800 * static_cast((WN % 256) - WNot_6)); diff --git a/src/core/system_parameters/galileo_utc_model.h b/src/core/system_parameters/galileo_utc_model.h index 00822c44c..cc72d78e2 100644 --- a/src/core/system_parameters/galileo_utc_model.h +++ b/src/core/system_parameters/galileo_utc_model.h @@ -42,7 +42,7 @@ class Galileo_Utc_Model { public: - /*Word type 6: GST-UTC conversion parameters*/ + // Word type 6: GST-UTC conversion parameters double A0_6; double A1_6; double Delta_tLS_6; diff --git a/src/core/system_parameters/glonass_gnav_almanac.cc b/src/core/system_parameters/glonass_gnav_almanac.cc index 0ed27cb6f..e89d31f64 100644 --- a/src/core/system_parameters/glonass_gnav_almanac.cc +++ b/src/core/system_parameters/glonass_gnav_almanac.cc @@ -35,8 +35,8 @@ Glonass_Gnav_Almanac::Glonass_Gnav_Almanac() { i_satellite_freq_channel = 0; - i_satellite_PRN = 0; - i_satellite_slot_number = 0; + i_satellite_PRN = 0U; + i_satellite_slot_number = 0U; d_n_A = 0.0; d_H_n_A = 0.0; diff --git a/src/core/system_parameters/glonass_gnav_almanac.h b/src/core/system_parameters/glonass_gnav_almanac.h index f36fdfbb0..37927bc6b 100644 --- a/src/core/system_parameters/glonass_gnav_almanac.h +++ b/src/core/system_parameters/glonass_gnav_almanac.h @@ -35,6 +35,7 @@ #define GNSS_SDR_GLONASS_ALMANAC_H_ #include +#include /*! * \brief This class is a storage for the GLONASS SV ALMANAC data as described GLONASS ICD (Edition 5.1) @@ -60,15 +61,15 @@ public: bool d_l_n; //!< Health flag for nth satellite; ln = 0 indicates the n-th satellite is helthy, ln = 1 indicates malfunction of this nth satellite [dimensionless] // Satellite Identification Information - int i_satellite_freq_channel; //!< SV Frequency Channel Number - unsigned int i_satellite_PRN; //!< SV PRN Number, equivalent to slot number for compatibility with GPS - unsigned int i_satellite_slot_number; //!< SV Slot Number + int32_t i_satellite_freq_channel; //!< SV Frequency Channel Number + uint32_t i_satellite_PRN; //!< SV PRN Number, equivalent to slot number for compatibility with GPS + uint32_t i_satellite_slot_number; //!< SV Slot Number template /*! * \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the almanac data on disk file. */ - void serialize(Archive& archive, const unsigned int version) + void serialize(Archive& archive, const uint32_t version) { using boost::serialization::make_nvp; if (version) diff --git a/src/core/system_parameters/glonass_gnav_ephemeris.cc b/src/core/system_parameters/glonass_gnav_ephemeris.cc index 2a6ea3eb0..b063d22ba 100644 --- a/src/core/system_parameters/glonass_gnav_ephemeris.cc +++ b/src/core/system_parameters/glonass_gnav_ephemeris.cc @@ -69,8 +69,8 @@ Glonass_Gnav_Ephemeris::Glonass_Gnav_Ephemeris() // Satellite Identification Information i_satellite_freq_channel = 0; //!< SV Frequency Channel Number - i_satellite_PRN = 0; //!< SV PRN Number, equivalent to slot number for compatibility with GPS - i_satellite_slot_number = 0; //!< SV Slot Number + i_satellite_PRN = 0U; //!< SV PRN Number, equivalent to slot number for compatibility with GPS + i_satellite_slot_number = 0U; //!< SV Slot Number d_yr = 1972; //!< Current year, defaults to 1972 (UTC Epoch with leap seconds) d_satClkDrift = 0.0; //!< GLONASS clock error d_dtr = 0.0; //!< relativistic clock correction term diff --git a/src/core/system_parameters/glonass_gnav_ephemeris.h b/src/core/system_parameters/glonass_gnav_ephemeris.h index ef375ab2e..ebea99d58 100644 --- a/src/core/system_parameters/glonass_gnav_ephemeris.h +++ b/src/core/system_parameters/glonass_gnav_ephemeris.h @@ -37,7 +37,7 @@ #include #include - +#include /*! * \brief This class is a storage and orbital model functions for the GLONASS SV ephemeris data as described in GLONASS ICD (Edition 5.1) @@ -86,26 +86,26 @@ public: bool d_l3rd_n; //!< Health flag for nth satellite; ln = 0 indicates the n-th satellite is healthy, ln = 1 indicates malfunction of this nth satellite [dimensionless] bool d_l5th_n; //!< Health flag for nth satellite; ln = 0 indicates the n-th satellite is healthy, ln = 1 indicates malfunction of this nth satellite [dimensionless] - // Inmediate deliverables of ephemeris information + // Immediate deliverables of ephemeris information // Satellite Identification Information - int i_satellite_freq_channel; //!< SV Frequency Channel Number - unsigned int i_satellite_PRN; //!< SV PRN Number, equivalent to slot number for compatibility with GPS - unsigned int i_satellite_slot_number; //!< SV Slot Number - double d_yr; //!< Current year - double d_satClkDrift; //!< GLONASS clock error - double d_dtr; //!< relativistic clock correction term - double d_iode; //!< Issue of data, ephemeris (Bit 0-6 of tb) - double d_tau_c; //!< GLONASST 2 UTC correction (todo) may be eliminated - double d_TOW; //!< GLONASST IN GPST seconds of week - double d_WN; //!< GLONASST IN GPST week number of the start of frame - double d_tod; //!< Time of Day since ephemeris where decoded + int32_t i_satellite_freq_channel; //!< SV Frequency Channel Number + uint32_t i_satellite_PRN; //!< SV PRN Number, equivalent to slot number for compatibility with GPS + uint32_t i_satellite_slot_number; //!< SV Slot Number + double d_yr; //!< Current year + double d_satClkDrift; //!< GLONASS clock error + double d_dtr; //!< relativistic clock correction term + double d_iode; //!< Issue of data, ephemeris (Bit 0-6 of tb) + double d_tau_c; //!< GLONASST 2 UTC correction (todo) may be eliminated + double d_TOW; //!< GLONASST IN GPST seconds of week + double d_WN; //!< GLONASST IN GPST week number of the start of frame + double d_tod; //!< Time of Day since ephemeris where decoded template /*! * \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the ephemeris data on disk file. */ - void serialize(Archive& archive, const unsigned int version) + void serialize(Archive& archive, const uint32_t version) { using boost::serialization::make_nvp; if (version) diff --git a/src/core/system_parameters/glonass_gnav_navigation_message.cc b/src/core/system_parameters/glonass_gnav_navigation_message.cc index 4233632e3..09eea276a 100644 --- a/src/core/system_parameters/glonass_gnav_navigation_message.cc +++ b/src/core/system_parameters/glonass_gnav_navigation_message.cc @@ -38,8 +38,8 @@ void Glonass_Gnav_Navigation_Message::reset() { // Satellite Identification - i_satellite_PRN = 0; - i_alm_satellite_slot_number = 0; //!< SV Orbit Slot Number + i_satellite_PRN = 0U; + i_alm_satellite_slot_number = 0; // SV Orbit Slot Number flag_update_slot_number = false; // Ephmeris Flags @@ -63,17 +63,17 @@ void Glonass_Gnav_Navigation_Message::reset() flag_almanac_str_15 = false; // UTC and System Clocks Flags - flag_utc_model_valid = false; //!< If set, it indicates that the UTC model parameters are filled - flag_utc_model_str_5 = false; //!< Clock info send in string 5 of navigation data - flag_utc_model_str_15 = false; //!< Clock info send in string 15 of frame 5 of navigation data + flag_utc_model_valid = false; // If set, it indicates that the UTC model parameters are filled + flag_utc_model_str_5 = false; // Clock info send in string 5 of navigation data + flag_utc_model_str_15 = false; // Clock info send in string 15 of frame 5 of navigation data // broadcast orbit 1 flag_TOW_set = false; flag_TOW_new = false; flag_CRC_test = false; - d_frame_ID = 0; - d_string_ID = 0; + d_frame_ID = 0U; + d_string_ID = 0U; i_channel_ID = 0; // Clock terms @@ -83,15 +83,15 @@ void Glonass_Gnav_Navigation_Message::reset() // Data update information d_previous_tb = 0.0; - for (unsigned int i = 0; i < GLONASS_CA_NBR_SATS; i++) + for (uint32_t i = 0; i < GLONASS_CA_NBR_SATS; i++) d_previous_Na[i] = 0.0; - std::map satelliteBlock; //!< Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus + std::map satelliteBlock; // Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus auto gnss_sat = Gnss_Satellite(); std::string _system("GLONASS"); //TODO SHould number of channels be hardcoded? - for (unsigned int i = 1; i < 14; i++) + for (uint32_t i = 1; i < 14; i++) { satelliteBlock[i] = gnss_sat.what_block(_system, i); } @@ -106,94 +106,94 @@ Glonass_Gnav_Navigation_Message::Glonass_Gnav_Navigation_Message() bool Glonass_Gnav_Navigation_Message::CRC_test(std::bitset bits) { - int sum_bits = 0; - int sum_hamming = 0; - int C1 = 0; - int C2 = 0; - int C3 = 0; - int C4 = 0; - int C5 = 0; - int C6 = 0; - int C7 = 0; - int C_Sigma = 0; - std::vector string_bits(GLONASS_GNAV_STRING_BITS); + int32_t sum_bits = 0; + int32_t sum_hamming = 0; + int32_t C1 = 0; + int32_t C2 = 0; + int32_t C3 = 0; + int32_t C4 = 0; + int32_t C5 = 0; + int32_t C6 = 0; + int32_t C7 = 0; + int32_t C_Sigma = 0; + std::vector string_bits(GLONASS_GNAV_STRING_BITS); - //!< Populate data and hamming code vectors - for (int i = 0; i < static_cast(GLONASS_GNAV_STRING_BITS); i++) + // Populate data and hamming code vectors + for (int32_t i = 0; i < static_cast(GLONASS_GNAV_STRING_BITS); i++) { - string_bits[i] = static_cast(bits[i]); + string_bits[i] = static_cast(bits[i]); } - //!< Compute C1 term + // Compute C1 term sum_bits = 0; - for (int i = 0; i < static_cast(GLONASS_GNAV_CRC_I_INDEX.size()); i++) + for (int32_t i = 0; i < static_cast(GLONASS_GNAV_CRC_I_INDEX.size()); i++) { sum_bits += string_bits[GLONASS_GNAV_CRC_I_INDEX[i] - 1]; } C1 = string_bits[0] ^ (sum_bits % 2); - //!< Compute C2 term + // Compute C2 term sum_bits = 0; - for (int j = 0; j < static_cast(GLONASS_GNAV_CRC_J_INDEX.size()); j++) + for (int32_t j = 0; j < static_cast(GLONASS_GNAV_CRC_J_INDEX.size()); j++) { sum_bits += string_bits[GLONASS_GNAV_CRC_J_INDEX[j] - 1]; } C2 = (string_bits[1]) ^ (sum_bits % 2); - //!< Compute C3 term + // Compute C3 term sum_bits = 0; - for (int k = 0; k < static_cast(GLONASS_GNAV_CRC_K_INDEX.size()); k++) + for (int32_t k = 0; k < static_cast(GLONASS_GNAV_CRC_K_INDEX.size()); k++) { sum_bits += string_bits[GLONASS_GNAV_CRC_K_INDEX[k] - 1]; } C3 = string_bits[2] ^ (sum_bits % 2); - //!< Compute C4 term + // Compute C4 term sum_bits = 0; - for (int l = 0; l < static_cast(GLONASS_GNAV_CRC_L_INDEX.size()); l++) + for (int32_t l = 0; l < static_cast(GLONASS_GNAV_CRC_L_INDEX.size()); l++) { sum_bits += string_bits[GLONASS_GNAV_CRC_L_INDEX[l] - 1]; } C4 = string_bits[3] ^ (sum_bits % 2); - //!< Compute C5 term + // Compute C5 term sum_bits = 0; - for (int m = 0; m < static_cast(GLONASS_GNAV_CRC_M_INDEX.size()); m++) + for (int32_t m = 0; m < static_cast(GLONASS_GNAV_CRC_M_INDEX.size()); m++) { sum_bits += string_bits[GLONASS_GNAV_CRC_M_INDEX[m] - 1]; } C5 = string_bits[4] ^ (sum_bits % 2); - //!< Compute C6 term + // Compute C6 term sum_bits = 0; - for (int n = 0; n < static_cast(GLONASS_GNAV_CRC_N_INDEX.size()); n++) + for (int32_t n = 0; n < static_cast(GLONASS_GNAV_CRC_N_INDEX.size()); n++) { sum_bits += string_bits[GLONASS_GNAV_CRC_N_INDEX[n] - 1]; } C6 = string_bits[5] ^ (sum_bits % 2); - //!< Compute C7 term + // Compute C7 term sum_bits = 0; - for (int p = 0; p < static_cast(GLONASS_GNAV_CRC_P_INDEX.size()); p++) + for (int32_t p = 0; p < static_cast(GLONASS_GNAV_CRC_P_INDEX.size()); p++) { sum_bits += string_bits[GLONASS_GNAV_CRC_P_INDEX[p] - 1]; } C7 = string_bits[6] ^ (sum_bits % 2); - //!< Compute C_Sigma term + // Compute C_Sigma term sum_bits = 0; sum_hamming = 0; - for (int q = 0; q < static_cast(GLONASS_GNAV_CRC_Q_INDEX.size()); q++) + for (int32_t q = 0; q < static_cast(GLONASS_GNAV_CRC_Q_INDEX.size()); q++) { sum_bits += string_bits[GLONASS_GNAV_CRC_Q_INDEX[q] - 1]; } - for (int q = 0; q < 8; q++) + for (int32_t q = 0; q < 8; q++) { sum_hamming += string_bits[q]; } C_Sigma = (sum_hamming % 2) ^ (sum_bits % 2); - //!< Verification of the data + // Verification of the data // (a-i) All checksums (C1,...,C7 and C_Sigma) are equal to zero if ((C1 + C2 + C3 + C4 + C5 + C6 + C7 + C_Sigma) == 0) { @@ -212,7 +212,7 @@ bool Glonass_Gnav_Navigation_Message::CRC_test(std::bitset bits, const std::vector> parameter) +bool Glonass_Gnav_Navigation_Message::read_navigation_bool(std::bitset bits, const std::vector> parameter) { bool value; @@ -228,13 +228,13 @@ bool Glonass_Gnav_Navigation_Message::read_navigation_bool(std::bitset bits, const std::vector> parameter) +uint64_t Glonass_Gnav_Navigation_Message::read_navigation_unsigned(std::bitset bits, const std::vector> parameter) { uint64_t value = 0; - int num_of_slices = parameter.size(); - for (int i = 0; i < num_of_slices; i++) + int32_t num_of_slices = parameter.size(); + for (int32_t i = 0; i < num_of_slices; i++) { - for (int j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < parameter[i].second; j++) { value <<= 1; //shift left if (bits[GLONASS_GNAV_STRING_BITS - parameter[i].first - j] == 1) @@ -247,11 +247,11 @@ uint64_t Glonass_Gnav_Navigation_Message::read_navigation_unsigned(std::bitset bits, const std::vector> parameter) +int64_t Glonass_Gnav_Navigation_Message::read_navigation_signed(std::bitset bits, const std::vector> parameter) { int64_t value = 0; int64_t sign = 0; - int num_of_slices = parameter.size(); + int32_t num_of_slices = parameter.size(); // read the MSB and perform the sign extension if (bits[GLONASS_GNAV_STRING_BITS - parameter[0].first] == 1) { @@ -261,9 +261,9 @@ int64_t Glonass_Gnav_Navigation_Message::read_navigation_signed(std::bitset= 1 and satellite_slot_number <= 5) { @@ -310,9 +310,9 @@ unsigned int Glonass_Gnav_Navigation_Message::get_frame_number(unsigned int sate } -int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) +int32_t Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) { - int J = 0; + int32_t J = 0; d_string_ID = 0; d_frame_ID = 0; @@ -325,11 +325,11 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) return 0; // Decode all 15 string messages - d_string_ID = static_cast(read_navigation_unsigned(string_bits, STRING_ID)); + d_string_ID = static_cast(read_navigation_unsigned(string_bits, STRING_ID)); switch (d_string_ID) { case 1: - //--- It is string 1 ----------------------------------------------- + // --- It is string 1 ----------------------------------------------- gnav_ephemeris.d_P_1 = (static_cast(read_navigation_unsigned(string_bits, P1)) + 1) * 15; gnav_ephemeris.d_t_k = static_cast(read_navigation_unsigned(string_bits, T_K_HR)) * 3600 + static_cast(read_navigation_unsigned(string_bits, T_K_MIN)) * 60 + @@ -343,7 +343,7 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) break; case 2: - //--- It is string 2 ----------------------------------------------- + // --- It is string 2 ----------------------------------------------- if (flag_ephemeris_str_1 == true) { gnav_ephemeris.d_B_n = static_cast(read_navigation_unsigned(string_bits, B_N)); @@ -391,8 +391,8 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) // Fill in ephemeris deliverables in the code flag_update_slot_number = true; - gnav_ephemeris.i_satellite_slot_number = static_cast(gnav_ephemeris.d_n); - gnav_ephemeris.i_satellite_PRN = static_cast(gnav_ephemeris.d_n); + gnav_ephemeris.i_satellite_slot_number = static_cast(gnav_ephemeris.d_n); + gnav_ephemeris.i_satellite_PRN = static_cast(gnav_ephemeris.d_n); flag_ephemeris_str_4 = true; } @@ -449,7 +449,7 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) case 6: // --- It is string 6 ---------------------------------------------- - i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, n_A)); + i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, n_A)); d_frame_ID = get_frame_number(i_alm_satellite_slot_number); // Make sure a valid frame_ID or satellite slot number is returned if (d_frame_ID == 0) @@ -497,7 +497,7 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) case 8: // --- It is string 8 ---------------------------------------------- - i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, n_A)); + i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, n_A)); d_frame_ID = get_frame_number(i_alm_satellite_slot_number); // Make sure a valid frame_ID or satellite slot number is returned if (d_frame_ID == 0) @@ -540,7 +540,7 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) case 10: // --- It is string 10 --------------------------------------------- - i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, n_A)); + i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, n_A)); d_frame_ID = get_frame_number(i_alm_satellite_slot_number); // Make sure a valid frame_ID or satellite slot number is returned if (d_frame_ID == 0) @@ -583,7 +583,7 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) case 12: // --- It is string 12 --------------------------------------------- - i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, n_A)); + i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, n_A)); d_frame_ID = get_frame_number(i_alm_satellite_slot_number); // Make sure a valid frame_ID or satellite slot number is returned if (d_frame_ID == 0) @@ -632,7 +632,7 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) } else { - i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, n_A)); + i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, n_A)); d_frame_ID = get_frame_number(i_alm_satellite_slot_number); // Make sure a valid frame_ID or satellite slot number is returned if (d_frame_ID == 0) @@ -694,7 +694,7 @@ Glonass_Gnav_Utc_Model Glonass_Gnav_Navigation_Message::get_utc_model() } -Glonass_Gnav_Almanac Glonass_Gnav_Navigation_Message::get_almanac(unsigned int satellite_slot_number) +Glonass_Gnav_Almanac Glonass_Gnav_Navigation_Message::get_almanac(uint32_t satellite_slot_number) { return gnav_almanac[satellite_slot_number - 1]; } @@ -738,14 +738,14 @@ bool Glonass_Gnav_Navigation_Message::have_new_utc_model() // Check if we have } -bool Glonass_Gnav_Navigation_Message::have_new_almanac() //Check if we have a new almanac data set stored in the galileo navigation class +bool Glonass_Gnav_Navigation_Message::have_new_almanac() // Check if we have a new almanac data set stored in the galileo navigation class { bool new_alm = false; if ((flag_almanac_str_6 == true) and (flag_almanac_str_7 == true)) { if (d_previous_Na[i_alm_satellite_slot_number] != gnav_utc_model.d_N_A) { - //All almanac have been received for this satellite + // All almanac have been received for this satellite flag_almanac_str_6 = false; flag_almanac_str_7 = false; new_alm = true; diff --git a/src/core/system_parameters/glonass_gnav_navigation_message.h b/src/core/system_parameters/glonass_gnav_navigation_message.h index cbb42b468..e13f41511 100644 --- a/src/core/system_parameters/glonass_gnav_navigation_message.h +++ b/src/core/system_parameters/glonass_gnav_navigation_message.h @@ -51,18 +51,18 @@ class Glonass_Gnav_Navigation_Message { private: - uint64_t read_navigation_unsigned(std::bitset bits, const std::vector> parameter); - int64_t read_navigation_signed(std::bitset bits, const std::vector> parameter); - bool read_navigation_bool(std::bitset bits, const std::vector> parameter); + uint64_t read_navigation_unsigned(std::bitset bits, const std::vector> parameter); + int64_t read_navigation_signed(std::bitset bits, const std::vector> parameter); + bool read_navigation_bool(std::bitset bits, const std::vector> parameter); public: bool flag_CRC_test; - unsigned int d_frame_ID; - unsigned int d_string_ID; + uint32_t d_frame_ID; + uint32_t d_string_ID; bool flag_update_slot_number; - int i_channel_ID; - unsigned int i_satellite_PRN; + int32_t i_channel_ID; + uint32_t i_satellite_PRN; Glonass_Gnav_Ephemeris gnav_ephemeris; //!< Ephemeris information decoded Glonass_Gnav_Utc_Model gnav_utc_model; //!< UTC model information @@ -76,18 +76,18 @@ public: bool flag_ephemeris_str_4; //!< Flag indicating that ephemeris 4/4 (string 4) have been received // Almanac Flags - bool flag_all_almanac; //!< Flag indicating that all almanac have been received - bool flag_almanac_str_6; //!< Flag indicating that almanac of string 6 have been received - bool flag_almanac_str_7; //!< Flag indicating that almanac of string 7 have been received - bool flag_almanac_str_8; //!< Flag indicating that almanac of string 8 have been received - bool flag_almanac_str_9; //!< Flag indicating that almanac of string 9 have been received - bool flag_almanac_str_10; //!< Flag indicating that almanac of string 10 have been received - bool flag_almanac_str_11; //!< Flag indicating that almanac of string 11 have been received - bool flag_almanac_str_12; //!< Flag indicating that almanac of string 12 have been received - bool flag_almanac_str_13; //!< Flag indicating that almanac of string 13 have been received - bool flag_almanac_str_14; //!< Flag indicating that almanac of string 14 have been received - bool flag_almanac_str_15; //!< Flag indicating that almanac of string 15 have been received - unsigned int i_alm_satellite_slot_number; //!< SV Orbit Slot Number + bool flag_all_almanac; //!< Flag indicating that all almanac have been received + bool flag_almanac_str_6; //!< Flag indicating that almanac of string 6 have been received + bool flag_almanac_str_7; //!< Flag indicating that almanac of string 7 have been received + bool flag_almanac_str_8; //!< Flag indicating that almanac of string 8 have been received + bool flag_almanac_str_9; //!< Flag indicating that almanac of string 9 have been received + bool flag_almanac_str_10; //!< Flag indicating that almanac of string 10 have been received + bool flag_almanac_str_11; //!< Flag indicating that almanac of string 11 have been received + bool flag_almanac_str_12; //!< Flag indicating that almanac of string 12 have been received + bool flag_almanac_str_13; //!< Flag indicating that almanac of string 13 have been received + bool flag_almanac_str_14; //!< Flag indicating that almanac of string 14 have been received + bool flag_almanac_str_15; //!< Flag indicating that almanac of string 15 have been received + uint32_t i_alm_satellite_slot_number; //!< SV Orbit Slot Number // UTC and System Clocks Flags bool flag_utc_model_valid; //!< If set, it indicates that the UTC model parameters are filled @@ -115,7 +115,7 @@ public: * \param satellite_slot_number [in] Satellite slot number identifier * \returns Frame number being decoded, 0 if operation was not successful. */ - unsigned int get_frame_number(unsigned int satellite_slot_number); + uint32_t get_frame_number(uint32_t satellite_slot_number); /*! * \brief Reset GLONASS GNAV Navigation Information @@ -137,7 +137,7 @@ public: * \param satellite_slot_number Slot number identifier for the satellite * \returns Returns the Glonass_Gnav_Almanac object for the input slot number */ - Glonass_Gnav_Almanac get_almanac(unsigned int satellite_slot_number); + Glonass_Gnav_Almanac get_almanac(uint32_t satellite_slot_number); /*! * \brief Returns true if a new Glonass_Gnav_Ephemeris object has arrived. @@ -159,7 +159,7 @@ public: * \param frame_string [in] is the string message within the parsed frame * \returns Returns the ID of the decoded string */ - int string_decoder(std::string frame_string); + int32_t string_decoder(std::string frame_string); /*! * Default constructor diff --git a/src/core/system_parameters/glonass_gnav_utc_model.cc b/src/core/system_parameters/glonass_gnav_utc_model.cc index ceea01529..5450d1581 100644 --- a/src/core/system_parameters/glonass_gnav_utc_model.cc +++ b/src/core/system_parameters/glonass_gnav_utc_model.cc @@ -49,7 +49,7 @@ double Glonass_Gnav_Utc_Model::utc_time(double glonass_time_corrected) double t_utc; // GLONASS Time is relative to UTC Moscow, so we simply add its time difference - t_utc = glonass_time_corrected + 3 * 3600 + d_tau_c; + t_utc = glonass_time_corrected + 3.0 * 3600.0 + d_tau_c; return t_utc; } diff --git a/src/core/system_parameters/glonass_gnav_utc_model.h b/src/core/system_parameters/glonass_gnav_utc_model.h index 8d76d90e2..5a082cb7e 100644 --- a/src/core/system_parameters/glonass_gnav_utc_model.h +++ b/src/core/system_parameters/glonass_gnav_utc_model.h @@ -34,8 +34,8 @@ #ifndef GNSS_SDR_GLONASS_GNAV_UTC_MODEL_H_ #define GNSS_SDR_GLONASS_GNAV_UTC_MODEL_H_ -#include #include +#include /*! * \brief This class is a storage for the GLONASS GNAV UTC MODEL data as described in GLONASS ICD (Edition 5.1) @@ -58,7 +58,7 @@ public: /*! * \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the almanac data on disk file. */ - void serialize(Archive& archive, const unsigned int version) + void serialize(Archive& archive, const uint32_t version) { using boost::serialization::make_nvp; if (version) diff --git a/src/core/system_parameters/gnss_obs_codes.h b/src/core/system_parameters/gnss_obs_codes.h index a28329760..b1e772466 100644 --- a/src/core/system_parameters/gnss_obs_codes.h +++ b/src/core/system_parameters/gnss_obs_codes.h @@ -33,64 +33,65 @@ #ifndef GNSS_SDR_GNSS_OBS_CODES_H_ #define GNSS_SDR_GNSS_OBS_CODES_H_ +#include -const unsigned int CODE_NONE = 0; //!< obs code: none or unknown -const unsigned int CODE_L1C = 1; //!< obs code: L1C/A,G1C/A,E1C (GPS,GLO,GAL,QZS,SBS) -const unsigned int CODE_L1P = 2; //!< obs code: L1P,G1P (GPS,GLO) -const unsigned int CODE_L1W = 3; //!< obs code: L1 Z-track (GPS) -const unsigned int CODE_L1Y = 4; //!< obs code: L1Y (GPS) -const unsigned int CODE_L1M = 5; //!< obs code: L1M (GPS) -const unsigned int CODE_L1N = 6; //!< obs code: L1codeless (GPS) -const unsigned int CODE_L1S = 7; //!< obs code: L1C(D) (GPS,QZS) -const unsigned int CODE_L1L = 8; //!< obs code: L1C(P) (GPS,QZS) -const unsigned int CODE_L1E = 9; //!< (not used) -const unsigned int CODE_L1A = 10; //!< obs code: E1A (GAL) -const unsigned int CODE_L1B = 11; //!< obs code: E1B (GAL) -const unsigned int CODE_L1X = 12; //!< obs code: E1B+C,L1C(D+P) (GAL,QZS) -const unsigned int CODE_L1Z = 13; //!< obs code: E1A+B+C,L1SAIF (GAL,QZS) -const unsigned int CODE_L2C = 14; //!< obs code: L2C/A,G1C/A (GPS,GLO) -const unsigned int CODE_L2D = 15; //!< obs code: L2 L1C/A-(P2-P1) (GPS) -const unsigned int CODE_L2S = 16; //!< obs code: L2C(M) (GPS,QZS) -const unsigned int CODE_L2L = 17; //!< obs code: L2C(L) (GPS,QZS) -const unsigned int CODE_L2X = 18; //!< obs code: L2C(M+L),B1I+Q (GPS,QZS,BDS) -const unsigned int CODE_L2P = 19; //!< obs code: L2P,G2P (GPS,GLO) -const unsigned int CODE_L2W = 20; //!< obs code: L2 Z-track (GPS) -const unsigned int CODE_L2Y = 21; //!< obs code: L2Y (GPS) -const unsigned int CODE_L2M = 22; //!< obs code: L2M (GPS) -const unsigned int CODE_L2N = 23; //!< obs code: L2codeless (GPS) -const unsigned int CODE_L5I = 24; //!< obs code: L5/E5aI (GPS,GAL,QZS,SBS) -const unsigned int CODE_L5Q = 25; //!< obs code: L5/E5aQ (GPS,GAL,QZS,SBS) -const unsigned int CODE_L5X = 26; //!< obs code: L5/E5aI+Q/L5B+C (GPS,GAL,QZS,IRN,SBS) -const unsigned int CODE_L7I = 27; //!< obs code: E5bI,B2I (GAL,BDS) -const unsigned int CODE_L7Q = 28; //!< obs code: E5bQ,B2Q (GAL,BDS) -const unsigned int CODE_L7X = 29; //!< obs code: E5bI+Q,B2I+Q (GAL,BDS) -const unsigned int CODE_L6A = 30; //!< obs code: E6A (GAL) -const unsigned int CODE_L6B = 31; //!< obs code: E6B (GAL) -const unsigned int CODE_L6C = 32; //!< obs code: E6C (GAL) -const unsigned int CODE_L6X = 33; //!< obs code: E6B+C,LEXS+L,B3I+Q (GAL,QZS,BDS) -const unsigned int CODE_L6Z = 34; //!< obs code: E6A+B+C (GAL) -const unsigned int CODE_L6S = 35; //!< obs code: LEXS (QZS) -const unsigned int CODE_L6L = 36; //!< obs code: LEXL (QZS) -const unsigned int CODE_L8I = 37; //!< obs code: E5(a+b)I (GAL) -const unsigned int CODE_L8Q = 38; //!< obs code: E5(a+b)Q (GAL) -const unsigned int CODE_L8X = 39; //!< obs code: E5(a+b)I+Q (GAL) -const unsigned int CODE_L2I = 40; //!< obs code: B1I (BDS) -const unsigned int CODE_L2Q = 41; //!< obs code: B1Q (BDS) -const unsigned int CODE_L6I = 42; //!< obs code: B3I (BDS) -const unsigned int CODE_L6Q = 43; //!< obs code: B3Q (BDS) -const unsigned int CODE_L3I = 44; //!< obs code: G3I (GLO) -const unsigned int CODE_L3Q = 45; //!< obs code: G3Q (GLO) -const unsigned int CODE_L3X = 46; //!< obs code: G3I+Q (GLO) -const unsigned int CODE_L1I = 47; //!< obs code: B1I (BDS) -const unsigned int CODE_L1Q = 48; //!< obs code: B1Q (BDS) -const unsigned int CODE_L5A = 49; //!< obs code: L5A SPS (IRN) -const unsigned int CODE_L5B = 50; //!< obs code: L5B RS(D) (IRN) -const unsigned int CODE_L5C = 51; //!< obs code: L5C RS(P) (IRN) -const unsigned int CODE_L9A = 52; //!< obs code: SA SPS (IRN) -const unsigned int CODE_L9B = 53; //!< obs code: SB RS(D) (IRN) -const unsigned int CODE_L9C = 54; //!< obs code: SC RS(P) (IRN) -const unsigned int CODE_L9X = 55; //!< obs code: SB+C (IRN) -const int MAXCODE = 55; //!< max number of obs code +const uint32_t CODE_NONE = 0; //!< obs code: none or unknown +const uint32_t CODE_L1C = 1; //!< obs code: L1C/A,G1C/A,E1C (GPS,GLO,GAL,QZS,SBS) +const uint32_t CODE_L1P = 2; //!< obs code: L1P,G1P (GPS,GLO) +const uint32_t CODE_L1W = 3; //!< obs code: L1 Z-track (GPS) +const uint32_t CODE_L1Y = 4; //!< obs code: L1Y (GPS) +const uint32_t CODE_L1M = 5; //!< obs code: L1M (GPS) +const uint32_t CODE_L1N = 6; //!< obs code: L1codeless (GPS) +const uint32_t CODE_L1S = 7; //!< obs code: L1C(D) (GPS,QZS) +const uint32_t CODE_L1L = 8; //!< obs code: L1C(P) (GPS,QZS) +const uint32_t CODE_L1E = 9; //!< (not used) +const uint32_t CODE_L1A = 10; //!< obs code: E1A (GAL) +const uint32_t CODE_L1B = 11; //!< obs code: E1B (GAL) +const uint32_t CODE_L1X = 12; //!< obs code: E1B+C,L1C(D+P) (GAL,QZS) +const uint32_t CODE_L1Z = 13; //!< obs code: E1A+B+C,L1SAIF (GAL,QZS) +const uint32_t CODE_L2C = 14; //!< obs code: L2C/A,G1C/A (GPS,GLO) +const uint32_t CODE_L2D = 15; //!< obs code: L2 L1C/A-(P2-P1) (GPS) +const uint32_t CODE_L2S = 16; //!< obs code: L2C(M) (GPS,QZS) +const uint32_t CODE_L2L = 17; //!< obs code: L2C(L) (GPS,QZS) +const uint32_t CODE_L2X = 18; //!< obs code: L2C(M+L),B1I+Q (GPS,QZS,BDS) +const uint32_t CODE_L2P = 19; //!< obs code: L2P,G2P (GPS,GLO) +const uint32_t CODE_L2W = 20; //!< obs code: L2 Z-track (GPS) +const uint32_t CODE_L2Y = 21; //!< obs code: L2Y (GPS) +const uint32_t CODE_L2M = 22; //!< obs code: L2M (GPS) +const uint32_t CODE_L2N = 23; //!< obs code: L2codeless (GPS) +const uint32_t CODE_L5I = 24; //!< obs code: L5/E5aI (GPS,GAL,QZS,SBS) +const uint32_t CODE_L5Q = 25; //!< obs code: L5/E5aQ (GPS,GAL,QZS,SBS) +const uint32_t CODE_L5X = 26; //!< obs code: L5/E5aI+Q/L5B+C (GPS,GAL,QZS,IRN,SBS) +const uint32_t CODE_L7I = 27; //!< obs code: E5bI,B2I (GAL,BDS) +const uint32_t CODE_L7Q = 28; //!< obs code: E5bQ,B2Q (GAL,BDS) +const uint32_t CODE_L7X = 29; //!< obs code: E5bI+Q,B2I+Q (GAL,BDS) +const uint32_t CODE_L6A = 30; //!< obs code: E6A (GAL) +const uint32_t CODE_L6B = 31; //!< obs code: E6B (GAL) +const uint32_t CODE_L6C = 32; //!< obs code: E6C (GAL) +const uint32_t CODE_L6X = 33; //!< obs code: E6B+C,LEXS+L,B3I+Q (GAL,QZS,BDS) +const uint32_t CODE_L6Z = 34; //!< obs code: E6A+B+C (GAL) +const uint32_t CODE_L6S = 35; //!< obs code: LEXS (QZS) +const uint32_t CODE_L6L = 36; //!< obs code: LEXL (QZS) +const uint32_t CODE_L8I = 37; //!< obs code: E5(a+b)I (GAL) +const uint32_t CODE_L8Q = 38; //!< obs code: E5(a+b)Q (GAL) +const uint32_t CODE_L8X = 39; //!< obs code: E5(a+b)I+Q (GAL) +const uint32_t CODE_L2I = 40; //!< obs code: B1I (BDS) +const uint32_t CODE_L2Q = 41; //!< obs code: B1Q (BDS) +const uint32_t CODE_L6I = 42; //!< obs code: B3I (BDS) +const uint32_t CODE_L6Q = 43; //!< obs code: B3Q (BDS) +const uint32_t CODE_L3I = 44; //!< obs code: G3I (GLO) +const uint32_t CODE_L3Q = 45; //!< obs code: G3Q (GLO) +const uint32_t CODE_L3X = 46; //!< obs code: G3I+Q (GLO) +const uint32_t CODE_L1I = 47; //!< obs code: B1I (BDS) +const uint32_t CODE_L1Q = 48; //!< obs code: B1Q (BDS) +const uint32_t CODE_L5A = 49; //!< obs code: L5A SPS (IRN) +const uint32_t CODE_L5B = 50; //!< obs code: L5B RS(D) (IRN) +const uint32_t CODE_L5C = 51; //!< obs code: L5C RS(P) (IRN) +const uint32_t CODE_L9A = 52; //!< obs code: SA SPS (IRN) +const uint32_t CODE_L9B = 53; //!< obs code: SB RS(D) (IRN) +const uint32_t CODE_L9C = 54; //!< obs code: SC RS(P) (IRN) +const uint32_t CODE_L9X = 55; //!< obs code: SB+C (IRN) +const int32_t MAXCODE = 55; //!< max number of obs code #endif diff --git a/src/core/system_parameters/gnss_satellite.cc b/src/core/system_parameters/gnss_satellite.cc index d5ea07402..646aa2b69 100644 --- a/src/core/system_parameters/gnss_satellite.cc +++ b/src/core/system_parameters/gnss_satellite.cc @@ -38,7 +38,7 @@ Gnss_Satellite::Gnss_Satellite() } -Gnss_Satellite::Gnss_Satellite(const std::string& system_, unsigned int PRN_) +Gnss_Satellite::Gnss_Satellite(const std::string& system_, uint32_t PRN_) { Gnss_Satellite::reset(); Gnss_Satellite::set_system(system_); @@ -98,9 +98,9 @@ Gnss_Satellite& Gnss_Satellite::operator=(const Gnss_Satellite &rhs) { if (this != &rhs) { // Deallocate, allocate new space, copy values... const std::string system_ = rhs.get_system(); - const unsigned int PRN_ = rhs.get_PRN(); + const uint32_t PRN_ = rhs.get_PRN(); const std::string block_ = rhs.get_block(); - // const signed int rf_link_ = 0; + // const int32_t rf_link_ = 0; this->set_system(system_); this->set_PRN(PRN_); this->set_block(system_, PRN_); @@ -127,7 +127,7 @@ void Gnss_Satellite::set_system(const std::string& system_) } -void Gnss_Satellite::update_PRN(unsigned int PRN_) +void Gnss_Satellite::update_PRN(uint32_t PRN_) { if (system.compare("Glonass") != 0) { @@ -150,7 +150,7 @@ void Gnss_Satellite::update_PRN(unsigned int PRN_) } -void Gnss_Satellite::set_PRN(unsigned int PRN_) +void Gnss_Satellite::set_PRN(uint32_t PRN_) { // Set satellite's PRN if (system.compare("") == 0) @@ -230,19 +230,19 @@ void Gnss_Satellite::set_PRN(unsigned int PRN_) } -signed int Gnss_Satellite::get_rf_link() const +int32_t Gnss_Satellite::get_rf_link() const { // Get satellite's rf link. Identifies the GLONASS Frequency Channel - signed int rf_link_; + int32_t rf_link_; rf_link_ = rf_link; return rf_link_; } -unsigned int Gnss_Satellite::get_PRN() const +uint32_t Gnss_Satellite::get_PRN() const { // Get satellite's PRN - unsigned int PRN_; + uint32_t PRN_; PRN_ = PRN; return PRN_; } @@ -273,7 +273,7 @@ std::string Gnss_Satellite::get_block() const } -std::string Gnss_Satellite::what_block(const std::string& system_, unsigned int PRN_) +std::string Gnss_Satellite::what_block(const std::string& system_, uint32_t PRN_) { std::string block_ = "Unknown"; if (system_.compare("GPS") == 0) @@ -602,7 +602,7 @@ std::string Gnss_Satellite::what_block(const std::string& system_, unsigned int } -void Gnss_Satellite::set_block(const std::string& system_, unsigned int PRN_) +void Gnss_Satellite::set_block(const std::string& system_, uint32_t PRN_) { block = what_block(system_, PRN_); } diff --git a/src/core/system_parameters/gnss_satellite.h b/src/core/system_parameters/gnss_satellite.h index 65e261ab6..58a3b1165 100644 --- a/src/core/system_parameters/gnss_satellite.h +++ b/src/core/system_parameters/gnss_satellite.h @@ -32,9 +32,10 @@ #ifndef GNSS_SDR_GNSS_SATELLITE_H_ #define GNSS_SDR_GNSS_SATELLITE_H_ +#include +#include #include #include -#include /*! @@ -47,27 +48,27 @@ class Gnss_Satellite { public: Gnss_Satellite(); //!< Default Constructor. - Gnss_Satellite(const std::string& system_, unsigned int PRN_); //!< Concrete GNSS satellite Constructor. + Gnss_Satellite(const std::string& system_, uint32_t PRN_); //!< Concrete GNSS satellite Constructor. ~Gnss_Satellite(); //!< Default Destructor. - void update_PRN(unsigned int PRN); //!< Updates the PRN Number when information is decoded, only applies to GLONASS GNAV messages - unsigned int get_PRN() const; //!< Gets satellite's PRN - signed int get_rf_link() const; //!< Gets the satellite's rf link + void update_PRN(uint32_t PRN); //!< Updates the PRN Number when information is decoded, only applies to GLONASS GNAV messages + uint32_t get_PRN() const; //!< Gets satellite's PRN + int32_t get_rf_link() const; //!< Gets the satellite's rf link std::string get_system() const; //!< Gets the satellite system {"GPS", "GLONASS", "SBAS", "Galileo", "Beidou"} std::string get_system_short() const; //!< Gets the satellite system {"G", "R", "SBAS", "E", "C"} std::string get_block() const; //!< Gets the satellite block. If GPS, returns {"IIA", "IIR", "IIR-M", "IIF"} - std::string what_block(const std::string& system_, unsigned int PRN_); //!< Gets the block of a given satellite + std::string what_block(const std::string& system_, uint32_t PRN_); //!< Gets the block of a given satellite friend bool operator==(const Gnss_Satellite&, const Gnss_Satellite&); //!< operator== for comparison friend std::ostream& operator<<(std::ostream&, const Gnss_Satellite&); //!< operator<< for pretty printing //Gnss_Satellite& operator=(const Gnss_Satellite &); private: - unsigned int PRN; + uint32_t PRN; std::string system; std::map satelliteSystem; std::string block; - signed int rf_link; + int32_t rf_link; void set_system(const std::string& system); // Sets the satellite system {"GPS", "GLONASS", "SBAS", "Galileo", "Beidou"}. - void set_PRN(unsigned int PRN); // Sets satellite's PRN - void set_block(const std::string& system_, unsigned int PRN_); + void set_PRN(uint32_t PRN); // Sets satellite's PRN + void set_block(const std::string& system_, uint32_t PRN_); std::set system_set; // = {"GPS", "GLONASS", "SBAS", "Galileo", "Compass"}; void reset(); }; diff --git a/src/core/system_parameters/gnss_signal.cc b/src/core/system_parameters/gnss_signal.cc index 882b5d231..cc2e8effd 100644 --- a/src/core/system_parameters/gnss_signal.cc +++ b/src/core/system_parameters/gnss_signal.cc @@ -36,11 +36,13 @@ Gnss_Signal::Gnss_Signal() this->signal = ""; } + Gnss_Signal::Gnss_Signal(const std::string& signal_) { this->signal = signal_; } + Gnss_Signal::Gnss_Signal(const Gnss_Satellite& satellite_, const std::string& signal_) { this->satellite = satellite_; diff --git a/src/core/system_parameters/gnss_signal.h b/src/core/system_parameters/gnss_signal.h index f857042e8..2b739c633 100644 --- a/src/core/system_parameters/gnss_signal.h +++ b/src/core/system_parameters/gnss_signal.h @@ -52,7 +52,7 @@ public: Gnss_Signal(const std::string& signal_); Gnss_Signal(const Gnss_Satellite& satellite_, const std::string& signal_); ~Gnss_Signal(); - std::string get_signal_str() const; //!< Get the satellite signal {"1C" for GPS L1 C/A, "2S" for GPS L2C (M), "L5" for GPS L5, "1G" for GLONASS L1 C/A, "1B" for Galileo E1B, "5X" for Galileo E5a. + std::string get_signal_str() const; //!< Get the satellite signal {"1C" for GPS L1 C/A, "2S" for GPS L2C (M), "L5" for GPS L5, "1G" for GLONASS L1 C/A, "1B" for Galileo E1B, "5X" for Galileo E5a. Gnss_Satellite get_satellite() const; //!< Get the Gnss_Satellite associated to the signal friend bool operator==(const Gnss_Signal&, const Gnss_Signal&); //!< operator== for comparison friend std::ostream& operator<<(std::ostream&, const Gnss_Signal&); //!< operator<< for pretty printing diff --git a/src/core/system_parameters/gps_acq_assist.cc b/src/core/system_parameters/gps_acq_assist.cc index 5b4510560..128772316 100644 --- a/src/core/system_parameters/gps_acq_assist.cc +++ b/src/core/system_parameters/gps_acq_assist.cc @@ -34,7 +34,7 @@ Gps_Acq_Assist::Gps_Acq_Assist() { - i_satellite_PRN = 0; + i_satellite_PRN = 0U; d_TOW = 0.0; d_Doppler0 = 0.0; d_Doppler1 = 0.0; diff --git a/src/core/system_parameters/gps_acq_assist.h b/src/core/system_parameters/gps_acq_assist.h index c84d0b730..5083aca44 100644 --- a/src/core/system_parameters/gps_acq_assist.h +++ b/src/core/system_parameters/gps_acq_assist.h @@ -32,6 +32,7 @@ #ifndef GNSS_SDR_GPS_ACQ_ASSIST_H_ #define GNSS_SDR_GPS_ACQ_ASSIST_H_ +#include /*! * \brief This class is a storage for the GPS GSM RRLL acquisition assistance data as described in @@ -44,17 +45,17 @@ class Gps_Acq_Assist { public: - unsigned int i_satellite_PRN; //!< SV PRN NUMBER - double d_TOW; //!< Time Of Week assigned to the acquisition data - double d_Doppler0; //!< Doppler (0 order term) [Hz] - double d_Doppler1; //!< Doppler (1 order term) [Hz] - double dopplerUncertainty; //!< Doppler Uncertainty [Hz] - double Code_Phase; //!< Code phase [chips] - double Code_Phase_int; //!< Integer Code Phase [1 C/A code period] - double GPS_Bit_Number; //!< GPS Bit Number - double Code_Phase_window; //!< Code Phase search window [chips] - double Azimuth; //!< Satellite Azimuth [deg] - double Elevation; //!< Satellite Elevation [deg] + uint32_t i_satellite_PRN; //!< SV PRN NUMBER + double d_TOW; //!< Time Of Week assigned to the acquisition data + double d_Doppler0; //!< Doppler (0 order term) [Hz] + double d_Doppler1; //!< Doppler (1 order term) [Hz] + double dopplerUncertainty; //!< Doppler Uncertainty [Hz] + double Code_Phase; //!< Code phase [chips] + double Code_Phase_int; //!< Integer Code Phase [1 C/A code period] + double GPS_Bit_Number; //!< GPS Bit Number + double Code_Phase_window; //!< Code Phase search window [chips] + double Azimuth; //!< Satellite Azimuth [deg] + double Elevation; //!< Satellite Elevation [deg] /*! * Default constructor diff --git a/src/core/system_parameters/gps_almanac.cc b/src/core/system_parameters/gps_almanac.cc index 5c7747d0a..acf7068b0 100644 --- a/src/core/system_parameters/gps_almanac.cc +++ b/src/core/system_parameters/gps_almanac.cc @@ -34,7 +34,7 @@ Gps_Almanac::Gps_Almanac() { - i_satellite_PRN = 0; + i_satellite_PRN = 0U; d_Delta_i = 0.0; d_Toa = 0.0; d_M_0 = 0.0; diff --git a/src/core/system_parameters/gps_almanac.h b/src/core/system_parameters/gps_almanac.h index d3e31db80..22bb79c4c 100644 --- a/src/core/system_parameters/gps_almanac.h +++ b/src/core/system_parameters/gps_almanac.h @@ -32,6 +32,7 @@ #ifndef GNSS_SDR_GPS_ALMANAC_H_ #define GNSS_SDR_GPS_ALMANAC_H_ +#include /*! * \brief This class is a storage for the GPS SV ALMANAC data as described in IS-GPS-200E @@ -41,7 +42,7 @@ class Gps_Almanac { public: - unsigned int i_satellite_PRN; //!< SV PRN NUMBER + uint32_t i_satellite_PRN; //!< SV PRN NUMBER double d_Delta_i; double d_Toa; //!< Almanac data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200E) [s] double d_M_0; //!< Mean Anomaly at Reference Time [semi-circles] @@ -50,7 +51,7 @@ public: double d_OMEGA0; //!< Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles] double d_OMEGA; //!< Argument of Perigee [semi-cicles] double d_OMEGA_DOT; //!< Rate of Right Ascension [semi-circles/s] - int i_SV_health; // SV Health + int32_t i_SV_health; // SV Health double d_A_f0; //!< Coefficient 0 of code phase offset model [s] double d_A_f1; //!< Coefficient 1 of code phase offset model [s/s] diff --git a/src/core/system_parameters/gps_cnav_ephemeris.cc b/src/core/system_parameters/gps_cnav_ephemeris.cc index 574196813..41b3dd655 100644 --- a/src/core/system_parameters/gps_cnav_ephemeris.cc +++ b/src/core/system_parameters/gps_cnav_ephemeris.cc @@ -35,34 +35,34 @@ Gps_CNAV_Ephemeris::Gps_CNAV_Ephemeris() { - i_satellite_PRN = 0; + i_satellite_PRN = 0U; - d_Toe1 = -1; - d_Toe2 = -1; + d_Toe1 = -1.0; + d_Toe2 = -1.0; - d_TOW = 0; - d_Crs = 0; - d_M_0 = 0; - d_Cuc = 0; - d_e_eccentricity = 0; - d_Cus = 0; + d_TOW = 0.0; + d_Crs = 0.0; + d_M_0 = 0.0; + d_Cuc = 0.0; + d_e_eccentricity = 0.0; + d_Cus = 0.0; - d_Toc = 0; - d_Cic = 0; - d_OMEGA0 = 0; - d_Cis = 0; - d_i_0 = 0; - d_Crc = 0; - d_OMEGA = 0; - d_IDOT = 0; + d_Toc = 0.0; + d_Cic = 0.0; + d_OMEGA0 = 0.0; + d_Cis = 0.0; + d_i_0 = 0.0; + d_Crc = 0.0; + d_OMEGA = 0.0; + d_IDOT = 0.0; i_GPS_week = 0; - d_TGD = 0; // Estimated Group Delay Differential: L1-L2 correction term only for the benefit of "L1 P(Y)" or "L2 P(Y)" s users [s] + d_TGD = 0.0; // Estimated Group Delay Differential: L1-L2 correction term only for the benefit of "L1 P(Y)" or "L2 P(Y)" s users [s] - d_A_f0 = 0; // Coefficient 0 of code phase offset model [s] - d_A_f1 = 0; // Coefficient 1 of code phase offset model [s/s] - d_A_f2 = 0; // Coefficient 2 of code phase offset model [s/s^2] + d_A_f0 = 0.0; // Coefficient 0 of code phase offset model [s] + d_A_f1 = 0.0; // Coefficient 1 of code phase offset model [s/s] + d_A_f2 = 0.0; // Coefficient 2 of code phase offset model [s/s^2] b_integrity_status_flag = false; b_alert_flag = false; // If true, indicates that the SV URA may be worse than indicated in d_SV_accuracy, use that SV at our own risk. @@ -95,6 +95,7 @@ Gps_CNAV_Ephemeris::Gps_CNAV_Ephemeris() b_l2c_phasing_flag = false; } + double Gps_CNAV_Ephemeris::check_t(double time) { double corrTime; @@ -162,7 +163,7 @@ double Gps_CNAV_Ephemeris::sv_clock_relativistic_term(double transmitTime) E = M; // --- Iteratively compute eccentric anomaly ---------------------------- - for (int ii = 1; ii < 20; ii++) + for (int32_t ii = 1; ii < 20; ii++) { E_old = E; E = M + d_e_eccentricity * sin(E); @@ -232,7 +233,7 @@ double Gps_CNAV_Ephemeris::satellitePosition(double transmitTime) E = M; // --- Iteratively compute eccentric anomaly ---------------------------- - for (int ii = 1; ii < 20; ii++) + for (int32_t ii = 1; ii < 20; ii++) { E_old = E; E = M + d_e_eccentricity * sin(E); diff --git a/src/core/system_parameters/gps_cnav_ephemeris.h b/src/core/system_parameters/gps_cnav_ephemeris.h index 97c90a272..158206994 100644 --- a/src/core/system_parameters/gps_cnav_ephemeris.h +++ b/src/core/system_parameters/gps_cnav_ephemeris.h @@ -48,12 +48,12 @@ private: double check_t(double time); public: - unsigned int i_satellite_PRN; // SV PRN NUMBER + uint32_t i_satellite_PRN; // SV PRN NUMBER - //Message Types 10 and 11 Parameters (1 of 2) - int i_GPS_week; //!< GPS week number, aka WN [week] - int i_URA; //!< ED Accuracy Index - int i_signal_health; //!< Signal health (L1/L2/L5) + // Message Types 10 and 11 Parameters (1 of 2) + int32_t i_GPS_week; //!< GPS week number, aka WN [week] + int32_t i_URA; //!< ED Accuracy Index + int32_t i_signal_health; //!< Signal health (L1/L2/L5) double d_Top; //!< Data predict time of week double d_DELTA_A; //!< Semi-major axis difference at reference time double d_A_DOT; //!< Change rate in semi-major axis @@ -75,7 +75,7 @@ public: double d_Cus; //!< Amplitude of the Sine Harmonic Correction Term to the Argument of Latitude [rad] double d_Cuc; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] - //Clock Correction and Accuracy Parameters + // Clock Correction and Accuracy Parameters double d_Toc; //!< clock data reference time (Ref. 20.3.3.3.3.1 IS-GPS-200E) [s] double d_A_f0; //!< Coefficient 0 of code phase offset model [s] double d_A_f1; //!< Coefficient 1 of code phase offset model [s/s] @@ -85,8 +85,7 @@ public: double d_URA1; //! bits, const std::vector> parameter) +bool Gps_CNAV_Navigation_Message::read_navigation_bool(std::bitset bits, const std::vector> parameter) { bool value; @@ -88,15 +88,15 @@ bool Gps_CNAV_Navigation_Message::read_navigation_bool(std::bitset bits, const std::vector> parameter) +uint64_t Gps_CNAV_Navigation_Message::read_navigation_unsigned(std::bitset bits, const std::vector> parameter) { - uint64_t value = 0; - int num_of_slices = parameter.size(); - for (int i = 0; i < num_of_slices; i++) + uint64_t value = 0ULL; + int32_t num_of_slices = parameter.size(); + for (int32_t i = 0; i < num_of_slices; i++) { - for (int j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < parameter[i].second; j++) { - value <<= 1; //shift left + value <<= 1; // shift left if (bits[GPS_CNAV_DATA_PAGE_BITS - parameter[i].first - j] == 1) { value += 1; // insert the bit @@ -107,59 +107,30 @@ uint64_t Gps_CNAV_Navigation_Message::read_navigation_unsigned(std::bitset bits, const std::vector> parameter) +int64_t Gps_CNAV_Navigation_Message::read_navigation_signed(std::bitset bits, const std::vector> parameter) { - int64_t value = 0; - int num_of_slices = parameter.size(); - // Discriminate between 64 bits and 32 bits compiler - int long_int_size_bytes = sizeof(int64_t); - if (long_int_size_bytes == 8) // if a long int takes 8 bytes, we are in a 64 bits system - { - // read the MSB and perform the sign extension - if (bits[GPS_CNAV_DATA_PAGE_BITS - parameter[0].first] == 1) - { - value ^= 0xFFFFFFFFFFFFFFFF; //64 bits variable - } - else - { - value &= 0; - } + int64_t value = 0LL; + int32_t num_of_slices = parameter.size(); - for (int i = 0; i < num_of_slices; i++) - { - for (int j = 0; j < parameter[i].second; j++) - { - value <<= 1; //shift left - value &= 0xFFFFFFFFFFFFFFFE; //reset the corresponding bit (for the 64 bits variable) - if (bits[GPS_CNAV_DATA_PAGE_BITS - parameter[i].first - j] == 1) - { - value += 1; // insert the bit - } - } - } + // read the MSB and perform the sign extension + if (bits[GPS_CNAV_DATA_PAGE_BITS - parameter[0].first] == 1) + { + value ^= 0xFFFFFFFFFFFFFFFF; // 64 bits variable } - else // we assume we are in a 32 bits system + else { - // read the MSB and perform the sign extension - if (bits[GPS_CNAV_DATA_PAGE_BITS - parameter[0].first] == 1) - { - value ^= 0xFFFFFFFF; - } - else - { - value &= 0; - } + value &= 0; + } - for (int i = 0; i < num_of_slices; i++) + for (int32_t i = 0; i < num_of_slices; i++) + { + for (int32_t j = 0; j < parameter[i].second; j++) { - for (int j = 0; j < parameter[i].second; j++) + value <<= 1; // shift left + value &= 0xFFFFFFFFFFFFFFFE; // reset the corresponding bit (for the 64 bits variable) + if (bits[GPS_CNAV_DATA_PAGE_BITS - parameter[i].first - j] == 1) { - value <<= 1; //shift left - value &= 0xFFFFFFFE; //reset the corresponding bit - if (bits[GPS_CNAV_DATA_PAGE_BITS - parameter[i].first - j] == 1) - { - value += 1; // insert the bit - } + value += 1; // insert the bit } } } @@ -169,13 +140,12 @@ int64_t Gps_CNAV_Navigation_Message::read_navigation_signed(std::bitset data_bits) { - int PRN; - int page_type; - + int32_t PRN; + int32_t page_type; bool alert_flag; // common to all messages - PRN = static_cast(read_navigation_unsigned(data_bits, CNAV_PRN)); + PRN = static_cast(read_navigation_unsigned(data_bits, CNAV_PRN)); ephemeris_record.i_satellite_PRN = PRN; d_TOW = static_cast(read_navigation_unsigned(data_bits, CNAV_TOW)); @@ -185,13 +155,13 @@ void Gps_CNAV_Navigation_Message::decode_page(std::bitset(read_navigation_bool(data_bits, CNAV_ALERT_FLAG)); ephemeris_record.b_alert_flag = alert_flag; - page_type = static_cast(read_navigation_unsigned(data_bits, CNAV_MSG_TYPE)); + page_type = static_cast(read_navigation_unsigned(data_bits, CNAV_MSG_TYPE)); switch (page_type) { case 10: // Ephemeris 1/2 - ephemeris_record.i_GPS_week = static_cast(read_navigation_unsigned(data_bits, CNAV_WN)); - ephemeris_record.i_signal_health = static_cast(read_navigation_unsigned(data_bits, CNAV_HEALTH)); + ephemeris_record.i_GPS_week = static_cast(read_navigation_unsigned(data_bits, CNAV_WN)); + ephemeris_record.i_signal_health = static_cast(read_navigation_unsigned(data_bits, CNAV_HEALTH)); ephemeris_record.d_Top = static_cast(read_navigation_unsigned(data_bits, CNAV_TOP1)); ephemeris_record.d_Top *= CNAV_TOP1_LSB; ephemeris_record.d_URA0 = static_cast(read_navigation_signed(data_bits, CNAV_URA)); @@ -256,7 +226,7 @@ void Gps_CNAV_Navigation_Message::decode_page(std::bitset(read_navigation_signed(data_bits, CNAV_AF2)); ephemeris_record.d_A_f2 *= CNAV_AF2_LSB; //group delays - //Check if the grup delay values are not available. See IS-GPS-200, Table 30-IV. + // Check if the grup delay values are not available. See IS-GPS-200, Table 30-IV. //Bit string "1000000000000" is -4096 in 2 complement ephemeris_record.d_TGD = static_cast(read_navigation_signed(data_bits, CNAV_TGD)); if (ephemeris_record.d_TGD < -4095.9) @@ -330,7 +300,6 @@ void Gps_CNAV_Navigation_Message::decode_page(std::bitset(read_navigation_signed(data_bits, CNAV_A2)); utc_model_record.d_A2 = utc_model_record.d_A2 * CNAV_A2_LSB; - utc_model_record.d_DeltaT_LS = static_cast(read_navigation_signed(data_bits, CNAV_DELTA_TLS)); utc_model_record.d_DeltaT_LS = utc_model_record.d_DeltaT_LS * CNAV_DELTA_TLS_LSB; @@ -356,13 +325,13 @@ void Gps_CNAV_Navigation_Message::decode_page(std::bitset bits, const std::vector> parameter); - int64_t read_navigation_signed(std::bitset bits, const std::vector> parameter); - bool read_navigation_bool(std::bitset bits, const std::vector> parameter); + uint64_t read_navigation_unsigned(std::bitset bits, const std::vector> parameter); + int64_t read_navigation_signed(std::bitset bits, const std::vector> parameter); + bool read_navigation_bool(std::bitset bits, const std::vector> parameter); Gps_CNAV_Ephemeris ephemeris_record; Gps_CNAV_Iono iono_record; @@ -71,7 +71,7 @@ public: bool b_flag_iono_valid; //!< If set, it indicates that the ionospheric parameters are filled and are not yet read by the get_iono bool b_flag_utc_valid; //!< If set, it indicates that the utc parameters are filled and are not yet read by the get_utc_model - std::map satelliteBlock; //!< Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus + std::map satelliteBlock; //!< Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus // satellite positions double d_satpos_X; //!< Earth-fixed coordinate x of the satellite [m]. Intersection of the IERS Reference Meridian (IRM) and the plane passing through the origin and normal to the Z-axis. @@ -79,8 +79,8 @@ public: double d_satpos_Z; //!< Earth-fixed coordinate z of the satellite [m]. The direction of the IERS (International Earth Rotation and Reference Systems Service) Reference Pole (IRP). // satellite identification info - int i_channel_ID; - unsigned int i_satellite_PRN; + int32_t i_channel_ID; + uint32_t i_satellite_PRN; // Satellite velocity double d_satvel_X; //!< Earth-fixed velocity coordinate x of the satellite [m] @@ -91,14 +91,17 @@ public: void reset(); void decode_page(std::bitset data_bits); + /*! * \brief Obtain a GPS SV Ephemeris class filled with current SV data */ Gps_CNAV_Ephemeris get_ephemeris(); + /*! * \brief Check if we have a new iono record stored in the GPS ephemeris class */ bool have_new_iono(); + /*! * \brief Obtain a GPS ionospheric correction parameters class filled with current SV data */ diff --git a/src/core/system_parameters/gps_cnav_utc_model.cc b/src/core/system_parameters/gps_cnav_utc_model.cc index a705566da..90e1a4af2 100644 --- a/src/core/system_parameters/gps_cnav_utc_model.cc +++ b/src/core/system_parameters/gps_cnav_utc_model.cc @@ -34,35 +34,36 @@ Gps_CNAV_Utc_Model::Gps_CNAV_Utc_Model() { valid = false; - d_A2 = 0; - d_A1 = 0; - d_A0 = 0; - d_t_OT = 0; + d_A2 = 0.0; + d_A1 = 0.0; + d_A0 = 0.0; + d_t_OT = 0.0; i_WN_T = 0; - d_DeltaT_LS = 0; + d_DeltaT_LS = 0.0; i_WN_LSF = 0; i_DN = 0; - d_DeltaT_LSF = 0; + d_DeltaT_LSF = 0.0; } -double Gps_CNAV_Utc_Model::utc_time(double gpstime_corrected, int i_GPS_week) + +double Gps_CNAV_Utc_Model::utc_time(double gpstime_corrected, int32_t i_GPS_week) { double t_utc; double t_utc_daytime; double Delta_t_UTC = d_DeltaT_LS + d_A0 + d_A1 * (gpstime_corrected - d_t_OT + 604800 * static_cast(i_GPS_week - i_WN_T)); // Determine if the effectivity time of the leap second event is in the past - int weeksToLeapSecondEvent = i_WN_LSF - i_GPS_week; + int32_t weeksToLeapSecondEvent = i_WN_LSF - i_GPS_week; if (weeksToLeapSecondEvent >= 0) // is not in the past { - //Detect if the effectivity time and user's time is within six hours = 6 * 60 *60 = 21600 s - int secondOfLeapSecondEvent = i_DN * 24 * 60 * 60; + // Detect if the effectivity time and user's time is within six hours = 6 * 60 *60 = 21600 s + int32_t secondOfLeapSecondEvent = i_DN * 24 * 60 * 60; if (weeksToLeapSecondEvent > 0) { t_utc_daytime = fmod(gpstime_corrected - Delta_t_UTC, 86400); } - else //we are in the same week than the leap second event + else // we are in the same week than the leap second event { if (std::abs(gpstime_corrected - secondOfLeapSecondEvent) > 21600) { @@ -83,9 +84,9 @@ double Gps_CNAV_Utc_Model::utc_time(double gpstime_corrected, int i_GPS_week) * proper accommodation of the leap second event with a possible week number * transition is provided by the following expression for UTC: */ - int W = fmod(gpstime_corrected - Delta_t_UTC - 43200, 86400) + 43200; + int32_t W = fmod(gpstime_corrected - Delta_t_UTC - 43200, 86400) + 43200; t_utc_daytime = fmod(W, 86400 + d_DeltaT_LSF - d_DeltaT_LS); - //implement something to handle a leap second event! + // implement something to handle a leap second event! } if ((gpstime_corrected - secondOfLeapSecondEvent) > 21600) { diff --git a/src/core/system_parameters/gps_cnav_utc_model.h b/src/core/system_parameters/gps_cnav_utc_model.h index 42a26839a..b9dba4936 100644 --- a/src/core/system_parameters/gps_cnav_utc_model.h +++ b/src/core/system_parameters/gps_cnav_utc_model.h @@ -34,7 +34,7 @@ #include #include - +#include /*! * \brief This class is a storage for the GPS UTC MODEL data as described in in IS-GPS-200H @@ -50,10 +50,10 @@ public: double d_A1; //!< 1st order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200H) [s/s] double d_A0; //!< Constant of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200H) [s] double d_t_OT; //!< Reference time for UTC data (reference 20.3.4.5 and 20.3.3.5.2.4 IS-GPS-200H) [s] - int i_WN_T; //!< UTC reference week number [weeks] + int32_t i_WN_T; //!< UTC reference week number [weeks] double d_DeltaT_LS; //!< delta time due to leap seconds [s]. Number of leap seconds since 6-Jan-1980 as transmitted by the GPS almanac. - int i_WN_LSF; //!< Week number at the end of which the leap second becomes effective [weeks] - int i_DN; //!< Day number (DN) at the end of which the leap second becomes effective [days] + int32_t i_WN_LSF; //!< Week number at the end of which the leap second becomes effective [weeks] + int32_t i_DN; //!< Day number (DN) at the end of which the leap second becomes effective [days] double d_DeltaT_LSF; //!< Scheduled future or recent past (relative to NAV message upload) value of the delta time due to leap seconds [s] /*! @@ -65,13 +65,13 @@ public: * \brief Computes the Coordinated Universal Time (UTC) and * returns it in [s] (IS-GPS-200E, 20.3.3.5.2.4 + 30.3.3.6.2) */ - double utc_time(double gpstime_corrected, int i_GPS_week); + double utc_time(double gpstime_corrected, int32_t i_GPS_week); template /* * \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the ephemeris data on disk file. */ - inline void serialize(Archive& archive, const unsigned int version) + inline void serialize(Archive& archive, const uint32_t version) { using boost::serialization::make_nvp; if (version) diff --git a/src/core/system_parameters/gps_ephemeris.cc b/src/core/system_parameters/gps_ephemeris.cc index 3ee9ed42a..c7f394efc 100644 --- a/src/core/system_parameters/gps_ephemeris.cc +++ b/src/core/system_parameters/gps_ephemeris.cc @@ -37,43 +37,43 @@ Gps_Ephemeris::Gps_Ephemeris() { - i_satellite_PRN = 0; - d_TOW = 0; - d_Crs = 0; - d_Delta_n = 0; - d_M_0 = 0; - d_Cuc = 0; - d_e_eccentricity = 0; - d_Cus = 0; - d_sqrt_A = 0; - d_Toe = 0; - d_Toc = 0; - d_Cic = 0; - d_OMEGA0 = 0; - d_Cis = 0; - d_i_0 = 0; - d_Crc = 0; - d_OMEGA = 0; - d_OMEGA_DOT = 0; - d_IDOT = 0; + i_satellite_PRN = 0U; + d_TOW = 0.0; + d_Crs = 0.0; + d_Delta_n = 0.0; + d_M_0 = 0.0; + d_Cuc = 0.0; + d_e_eccentricity = 0.0; + d_Cus = 0.0; + d_sqrt_A = 0.0; + d_Toe = 0.0; + d_Toc = 0.0; + d_Cic = 0.0; + d_OMEGA0 = 0.0; + d_Cis = 0.0; + d_i_0 = 0.0; + d_Crc = 0.0; + d_OMEGA = 0.0; + d_OMEGA_DOT = 0.0; + d_IDOT = 0.0; i_code_on_L2 = 0; i_GPS_week = 0; b_L2_P_data_flag = false; i_SV_accuracy = 0; i_SV_health = 0; - d_IODE_SF2 = 0; - d_IODE_SF3 = 0; - d_TGD = 0; // Estimated Group Delay Differential: L1-L2 correction term only for the benefit of "L1 P(Y)" or "L2 P(Y)" s users [s] - d_IODC = 0; // Issue of Data, Clock - i_AODO = 0; // Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subframe 4 (reference paragraph 20.3.3.5.1.9) [s] + d_IODE_SF2 = 0.0; + d_IODE_SF3 = 0.0; + d_TGD = 0.0; // Estimated Group Delay Differential: L1-L2 correction term only for the benefit of "L1 P(Y)" or "L2 P(Y)" s users [s] + d_IODC = 0.0; // Issue of Data, Clock + i_AODO = 0; // Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subframe 4 (reference paragraph 20.3.3.5.1.9) [s] b_fit_interval_flag = false; // indicates the curve-fit interval used by the CS (Block II/IIA/IIR/IIR-M/IIF) and SS (Block IIIA) in determining the ephemeris parameters, as follows: 0 = 4 hours, 1 = greater than 4 hours. - d_spare1 = 0; - d_spare2 = 0; + d_spare1 = 0.0; + d_spare2 = 0.0; - d_A_f0 = 0; // Coefficient 0 of code phase offset model [s] - d_A_f1 = 0; // Coefficient 1 of code phase offset model [s/s] - d_A_f2 = 0; // Coefficient 2 of code phase offset model [s/s^2] + d_A_f0 = 0.0; // Coefficient 0 of code phase offset model [s] + d_A_f1 = 0.0; // Coefficient 1 of code phase offset model [s/s] + d_A_f2 = 0.0; // Coefficient 2 of code phase offset model [s/s^2] b_integrity_status_flag = false; b_alert_flag = false; // If true, indicates that the SV URA may be worse than indicated in d_SV_accuracy, use that SV at our own risk. @@ -81,7 +81,7 @@ Gps_Ephemeris::Gps_Ephemeris() auto gnss_sat = Gnss_Satellite(); std::string _system("GPS"); - for (unsigned int i = 1; i < 33; i++) + for (uint32_t i = 1; i < 33; i++) { satelliteBlock[i] = gnss_sat.what_block(_system, i); } @@ -120,7 +120,7 @@ double Gps_Ephemeris::sv_clock_drift(double transmitTime) // double dt; // dt = check_t(transmitTime - d_Toc); // - // for (int i = 0; i < 2; i++) + // for (int32_t i = 0; i < 2; i++) // { // dt -= d_A_f0 + d_A_f1 * dt + d_A_f2 * (dt * dt); // } @@ -169,7 +169,7 @@ double Gps_Ephemeris::sv_clock_relativistic_term(double transmitTime) E = M; // --- Iteratively compute eccentric anomaly ---------------------------- - for (int ii = 1; ii < 20; ii++) + for (int32_t ii = 1; ii < 20; ii++) { E_old = E; E = M + d_e_eccentricity * sin(E); @@ -228,7 +228,7 @@ double Gps_Ephemeris::satellitePosition(double transmitTime) E = M; // --- Iteratively compute eccentric anomaly ---------------------------- - for (int ii = 1; ii < 20; ii++) + for (int32_t ii = 1; ii < 20; ii++) { E_old = E; E = M + d_e_eccentricity * sin(E); diff --git a/src/core/system_parameters/gps_ephemeris.h b/src/core/system_parameters/gps_ephemeris.h index d13ad4893..e7870fdc8 100644 --- a/src/core/system_parameters/gps_ephemeris.h +++ b/src/core/system_parameters/gps_ephemeris.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -58,35 +59,35 @@ private: double check_t(double time); public: - unsigned int i_satellite_PRN; // SV PRN NUMBER - double d_TOW; //!< Time of GPS Week of the ephemeris set (taken from subframes TOW) [s] - double d_Crs; //!< Amplitude of the Sine Harmonic Correction Term to the Orbit Radius [m] - double d_Delta_n; //!< Mean Motion Difference From Computed Value [semi-circles/s] - double d_M_0; //!< Mean Anomaly at Reference Time [semi-circles] - double d_Cuc; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] - double d_e_eccentricity; //!< Eccentricity [dimensionless] - double d_Cus; //!< Amplitude of the Sine Harmonic Correction Term to the Argument of Latitude [rad] - double d_sqrt_A; //!< Square Root of the Semi-Major Axis [sqrt(m)] - double d_Toe; //!< Ephemeris data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200E) [s] - double d_Toc; //!< clock data reference time (Ref. 20.3.3.3.3.1 IS-GPS-200E) [s] - double d_Cic; //!< Amplitude of the Cosine Harmonic Correction Term to the Angle of Inclination [rad] - double d_OMEGA0; //!< Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles] - double d_Cis; //!< Amplitude of the Sine Harmonic Correction Term to the Angle of Inclination [rad] - double d_i_0; //!< Inclination Angle at Reference Time [semi-circles] - double d_Crc; //!< Amplitude of the Cosine Harmonic Correction Term to the Orbit Radius [m] - double d_OMEGA; //!< Argument of Perigee [semi-cicles] - double d_OMEGA_DOT; //!< Rate of Right Ascension [semi-circles/s] - double d_IDOT; //!< Rate of Inclination Angle [semi-circles/s] - int i_code_on_L2; //!< If 1, P code ON in L2; if 2, C/A code ON in L2; - int i_GPS_week; //!< GPS week number, aka WN [week] - bool b_L2_P_data_flag; //!< When true, indicates that the NAV data stream was commanded OFF on the P-code of the L2 channel - int i_SV_accuracy; //!< User Range Accuracy (URA) index of the SV (reference paragraph 6.2.1) for the standard positioning service user (Ref 20.3.3.3.1.3 IS-GPS-200E) - int i_SV_health; + uint32_t i_satellite_PRN; // SV PRN NUMBER + double d_TOW; //!< Time of GPS Week of the ephemeris set (taken from subframes TOW) [s] + double d_Crs; //!< Amplitude of the Sine Harmonic Correction Term to the Orbit Radius [m] + double d_Delta_n; //!< Mean Motion Difference From Computed Value [semi-circles/s] + double d_M_0; //!< Mean Anomaly at Reference Time [semi-circles] + double d_Cuc; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] + double d_e_eccentricity; //!< Eccentricity [dimensionless] + double d_Cus; //!< Amplitude of the Sine Harmonic Correction Term to the Argument of Latitude [rad] + double d_sqrt_A; //!< Square Root of the Semi-Major Axis [sqrt(m)] + double d_Toe; //!< Ephemeris data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200E) [s] + double d_Toc; //!< clock data reference time (Ref. 20.3.3.3.3.1 IS-GPS-200E) [s] + double d_Cic; //!< Amplitude of the Cosine Harmonic Correction Term to the Angle of Inclination [rad] + double d_OMEGA0; //!< Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles] + double d_Cis; //!< Amplitude of the Sine Harmonic Correction Term to the Angle of Inclination [rad] + double d_i_0; //!< Inclination Angle at Reference Time [semi-circles] + double d_Crc; //!< Amplitude of the Cosine Harmonic Correction Term to the Orbit Radius [m] + double d_OMEGA; //!< Argument of Perigee [semi-cicles] + double d_OMEGA_DOT; //!< Rate of Right Ascension [semi-circles/s] + double d_IDOT; //!< Rate of Inclination Angle [semi-circles/s] + int32_t i_code_on_L2; //!< If 1, P code ON in L2; if 2, C/A code ON in L2; + int32_t i_GPS_week; //!< GPS week number, aka WN [week] + bool b_L2_P_data_flag; //!< When true, indicates that the NAV data stream was commanded OFF on the P-code of the L2 channel + int32_t i_SV_accuracy; //!< User Range Accuracy (URA) index of the SV (reference paragraph 6.2.1) for the standard positioning service user (Ref 20.3.3.3.1.3 IS-GPS-200E) + int32_t i_SV_health; double d_TGD; //!< Estimated Group Delay Differential: L1-L2 correction term only for the benefit of "L1 P(Y)" or "L2 P(Y)" s users [s] double d_IODC; //!< Issue of Data, Clock double d_IODE_SF2; //!< Issue of Data, Ephemeris (IODE), subframe 2 double d_IODE_SF3; //!< Issue of Data, Ephemeris(IODE), subframe 3 - int i_AODO; //!< Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subframe 4 (reference paragraph 20.3.3.5.1.9) [s] + int32_t i_AODO; //!< Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subframe 4 (reference paragraph 20.3.3.5.1.9) [s] bool b_fit_interval_flag; //!< indicates the curve-fit interval used by the CS (Block II/IIA/IIR/IIR-M/IIF) and SS (Block IIIA) in determining the ephemeris parameters, as follows: 0 = 4 hours, 1 = greater than 4 hours. double d_spare1; @@ -133,7 +134,7 @@ public: /*! * \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the ephemeris data on disk file. */ - inline void serialize(Archive& archive, const unsigned int version) + inline void serialize(Archive& archive, const uint32_t version) { using boost::serialization::make_nvp; if (version) diff --git a/src/core/system_parameters/gps_navigation_message.cc b/src/core/system_parameters/gps_navigation_message.cc index 2a5955b1f..71d59a75c 100644 --- a/src/core/system_parameters/gps_navigation_message.cc +++ b/src/core/system_parameters/gps_navigation_message.cc @@ -40,64 +40,64 @@ void Gps_Navigation_Message::reset() { b_valid_ephemeris_set_flag = false; d_TOW = 0.0; - d_TOW_SF1 = 0; - d_TOW_SF2 = 0; - d_TOW_SF3 = 0; - d_TOW_SF4 = 0; - d_TOW_SF5 = 0; - d_IODE_SF2 = 0; - d_IODE_SF3 = 0; - d_Crs = 0; - d_Delta_n = 0; - d_M_0 = 0; - d_Cuc = 0; - d_e_eccentricity = 0; - d_Cus = 0; - d_sqrt_A = 0; - d_Toe = 0; - d_Toc = 0; - d_Cic = 0; - d_OMEGA0 = 0; - d_Cis = 0; - d_i_0 = 0; - d_Crc = 0; - d_OMEGA = 0; - d_OMEGA_DOT = 0; - d_IDOT = 0; + d_TOW_SF1 = 0.0; + d_TOW_SF2 = 0.0; + d_TOW_SF3 = 0.0; + d_TOW_SF4 = 0.0; + d_TOW_SF5 = 0.0; + d_IODE_SF2 = 0.0; + d_IODE_SF3 = 0.0; + d_Crs = 0.0; + d_Delta_n = 0.0; + d_M_0 = 0.0; + d_Cuc = 0.0; + d_e_eccentricity = 0.0; + d_Cus = 0.0; + d_sqrt_A = 0.0; + d_Toe = 0.0; + d_Toc = 0.0; + d_Cic = 0.0; + d_OMEGA0 = 0.0; + d_Cis = 0.0; + d_i_0 = 0.0; + d_Crc = 0.0; + d_OMEGA = 0.0; + d_OMEGA_DOT = 0.0; + d_IDOT = 0.0; i_code_on_L2 = 0; i_GPS_week = 0; b_L2_P_data_flag = false; i_SV_accuracy = 0; i_SV_health = 0; - d_TGD = 0; + d_TGD = 0.0; d_IODC = -1.0; i_AODO = 0; b_fit_interval_flag = false; - d_spare1 = 0; - d_spare2 = 0; + d_spare1 = 0.0; + d_spare2 = 0.0; - d_A_f0 = 0; - d_A_f1 = 0; - d_A_f2 = 0; + d_A_f0 = 0.0; + d_A_f1 = 0.0; + d_A_f2 = 0.0; //clock terms //d_master_clock=0; - d_dtr = 0; - d_satClkCorr = 0; - d_satClkDrift = 0; + d_dtr = 0.0; + d_satClkCorr = 0.0; + d_satClkDrift = 0.0; // satellite positions - d_satpos_X = 0; - d_satpos_Y = 0; - d_satpos_Z = 0; + d_satpos_X = 0.0; + d_satpos_Y = 0.0; + d_satpos_Z = 0.0; // info i_channel_ID = 0; - i_satellite_PRN = 0; + i_satellite_PRN = 0U; // time synchro - d_subframe_timestamp_ms = 0; + d_subframe_timestamp_ms = 0.0; // flags b_alert_flag = false; @@ -107,39 +107,39 @@ void Gps_Navigation_Message::reset() // Ionosphere and UTC flag_iono_valid = false; flag_utc_model_valid = false; - d_alpha0 = 0; - d_alpha1 = 0; - d_alpha2 = 0; - d_alpha3 = 0; - d_beta0 = 0; - d_beta1 = 0; - d_beta2 = 0; - d_beta3 = 0; - d_A1 = 0; - d_A0 = 0; - d_t_OT = 0; + d_alpha0 = 0.0; + d_alpha1 = 0.0; + d_alpha2 = 0.0; + d_alpha3 = 0.0; + d_beta0 = 0.0; + d_beta1 = 0.0; + d_beta2 = 0.0; + d_beta3 = 0.0; + d_A1 = 0.0; + d_A0 = 0.0; + d_t_OT = 0.0; i_WN_T = 0; - d_DeltaT_LS = 0; + d_DeltaT_LS = 0.0; i_WN_LSF = 0; i_DN = 0; - d_DeltaT_LSF = 0; + d_DeltaT_LSF = 0.0; - //Almanac - d_Toa = 0; + // Almanac + d_Toa = 0.0; i_WN_A = 0; - for (int i = 1; i < 32; i++) + for (int32_t i = 1; i < 32; i++) { almanacHealth[i] = 0; } // Satellite velocity - d_satvel_X = 0; - d_satvel_Y = 0; - d_satvel_Z = 0; + d_satvel_X = 0.0; + d_satvel_Y = 0.0; + d_satvel_Z = 0.0; auto gnss_sat = Gnss_Satellite(); std::string _system("GPS"); - for (unsigned int i = 1; i < 33; i++) + for (uint32_t i = 1; i < 33; i++) { satelliteBlock[i] = gnss_sat.what_block(_system, i); } @@ -152,7 +152,7 @@ Gps_Navigation_Message::Gps_Navigation_Message() } -void Gps_Navigation_Message::print_gps_word_bytes(unsigned int GPS_word) +void Gps_Navigation_Message::print_gps_word_bytes(uint32_t GPS_word) { std::cout << " Word ="; std::cout << std::bitset<32>(GPS_word); @@ -160,7 +160,7 @@ void Gps_Navigation_Message::print_gps_word_bytes(unsigned int GPS_word) } -bool Gps_Navigation_Message::read_navigation_bool(std::bitset bits, const std::vector> parameter) +bool Gps_Navigation_Message::read_navigation_bool(std::bitset bits, const std::vector> parameter) { bool value; @@ -176,13 +176,13 @@ bool Gps_Navigation_Message::read_navigation_bool(std::bitset } -uint64_t Gps_Navigation_Message::read_navigation_unsigned(std::bitset bits, const std::vector> parameter) +uint64_t Gps_Navigation_Message::read_navigation_unsigned(std::bitset bits, const std::vector> parameter) { - uint64_t value = 0; - int num_of_slices = parameter.size(); - for (int i = 0; i < num_of_slices; i++) + uint64_t value = 0ULL; + int32_t num_of_slices = parameter.size(); + for (int32_t i = 0; i < num_of_slices; i++) { - for (int j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < parameter[i].second; j++) { value <<= 1; //shift left if (bits[GPS_SUBFRAME_BITS - parameter[i].first - j] == 1) @@ -195,87 +195,55 @@ uint64_t Gps_Navigation_Message::read_navigation_unsigned(std::bitset bits, const std::vector> parameter) +int64_t Gps_Navigation_Message::read_navigation_signed(std::bitset bits, const std::vector> parameter) { - int64_t value = 0; - int num_of_slices = parameter.size(); - // Discriminate between 64 bits and 32 bits compiler - int long_int_size_bytes = sizeof(int64_t); - if (long_int_size_bytes == 8) // if a long int takes 8 bytes, we are in a 64 bits system - { - // read the MSB and perform the sign extension - if (bits[GPS_SUBFRAME_BITS - parameter[0].first] == 1) - { - value ^= 0xFFFFFFFFFFFFFFFF; //64 bits variable - } - else - { - value &= 0; - } + int64_t value = 0LL; + int32_t num_of_slices = parameter.size(); - for (int i = 0; i < num_of_slices; i++) - { - for (int j = 0; j < parameter[i].second; j++) - { - value <<= 1; //shift left - value &= 0xFFFFFFFFFFFFFFFE; //reset the corresponding bit (for the 64 bits variable) - if (bits[GPS_SUBFRAME_BITS - parameter[i].first - j] == 1) - { - value += 1; // insert the bit - } - } - } + // read the MSB and perform the sign extension + if (bits[GPS_SUBFRAME_BITS - parameter[0].first] == 1) + { + value ^= 0xFFFFFFFFFFFFFFFF; // 64 bits variable } - else // we assume we are in a 32 bits system + else { - // read the MSB and perform the sign extension - if (bits[GPS_SUBFRAME_BITS - parameter[0].first] == 1) - { - value ^= 0xFFFFFFFF; - } - else - { - value &= 0; - } + value &= 0; + } - for (int i = 0; i < num_of_slices; i++) + for (int32_t i = 0; i < num_of_slices; i++) + { + for (int32_t j = 0; j < parameter[i].second; j++) { - for (int j = 0; j < parameter[i].second; j++) + value <<= 1; // shift left + value &= 0xFFFFFFFFFFFFFFFE; // reset the corresponding bit (for the 64 bits variable) + if (bits[GPS_SUBFRAME_BITS - parameter[i].first - j] == 1) { - value <<= 1; //shift left - value &= 0xFFFFFFFE; //reset the corresponding bit - if (bits[GPS_SUBFRAME_BITS - parameter[i].first - j] == 1) - { - value += 1; // insert the bit - } + value += 1; // insert the bit } } } return value; } -int Gps_Navigation_Message::subframe_decoder(char *subframe) +int32_t Gps_Navigation_Message::subframe_decoder(char *subframe) { - int subframe_ID = 0; - - //double tmp_TOW; - - unsigned int gps_word; + int32_t subframe_ID = 0; + uint32_t gps_word; // UNPACK BYTES TO BITS AND REMOVE THE CRC REDUNDANCE std::bitset subframe_bits; std::bitset word_bits; - for (int i = 0; i < 10; i++) + for (int32_t i = 0; i < 10; i++) { memcpy(&gps_word, &subframe[i * 4], sizeof(char) * 4); word_bits = std::bitset<(GPS_WORD_BITS + 2)>(gps_word); - for (int j = 0; j < GPS_WORD_BITS; j++) + for (int32_t j = 0; j < GPS_WORD_BITS; j++) { subframe_bits[GPS_WORD_BITS * (9 - i) + j] = word_bits[j]; } } - subframe_ID = static_cast(read_navigation_unsigned(subframe_bits, SUBFRAME_ID)); + subframe_ID = static_cast(read_navigation_unsigned(subframe_bits, SUBFRAME_ID)); // Decode all 5 sub-frames switch (subframe_ID) @@ -295,11 +263,11 @@ int Gps_Navigation_Message::subframe_decoder(char *subframe) b_integrity_status_flag = read_navigation_bool(subframe_bits, INTEGRITY_STATUS_FLAG); b_alert_flag = read_navigation_bool(subframe_bits, ALERT_FLAG); b_antispoofing_flag = read_navigation_bool(subframe_bits, ANTI_SPOOFING_FLAG); - i_GPS_week = static_cast(read_navigation_unsigned(subframe_bits, GPS_WEEK)); - i_SV_accuracy = static_cast(read_navigation_unsigned(subframe_bits, SV_ACCURACY)); // (20.3.3.3.1.3) - i_SV_health = static_cast(read_navigation_unsigned(subframe_bits, SV_HEALTH)); + i_GPS_week = static_cast(read_navigation_unsigned(subframe_bits, GPS_WEEK)); + i_SV_accuracy = static_cast(read_navigation_unsigned(subframe_bits, SV_ACCURACY)); // (20.3.3.3.1.3) + i_SV_health = static_cast(read_navigation_unsigned(subframe_bits, SV_HEALTH)); b_L2_P_data_flag = read_navigation_bool(subframe_bits, L2_P_DATA_FLAG); // - i_code_on_L2 = static_cast(read_navigation_unsigned(subframe_bits, CA_OR_P_ON_L2)); + i_code_on_L2 = static_cast(read_navigation_unsigned(subframe_bits, CA_OR_P_ON_L2)); d_TGD = static_cast(read_navigation_signed(subframe_bits, T_GD)); d_TGD = d_TGD * T_GD_LSB; d_IODC = static_cast(read_navigation_unsigned(subframe_bits, IODC)); @@ -311,7 +279,6 @@ int Gps_Navigation_Message::subframe_decoder(char *subframe) d_A_f1 = d_A_f1 * A_F1_LSB; d_A_f2 = static_cast(read_navigation_signed(subframe_bits, A_F2)); d_A_f2 = d_A_f2 * A_F2_LSB; - break; case 2: //--- It is subframe 2 ------------------- @@ -339,9 +306,8 @@ int Gps_Navigation_Message::subframe_decoder(char *subframe) d_Toe = static_cast(read_navigation_unsigned(subframe_bits, T_OE)); d_Toe = d_Toe * T_OE_LSB; b_fit_interval_flag = read_navigation_bool(subframe_bits, FIT_INTERVAL_FLAG); - i_AODO = static_cast(read_navigation_unsigned(subframe_bits, AODO)); + i_AODO = static_cast(read_navigation_unsigned(subframe_bits, AODO)); i_AODO = i_AODO * AODO_LSB; - break; case 3: // --- It is subframe 3 ------------------------------------- @@ -368,20 +334,19 @@ int Gps_Navigation_Message::subframe_decoder(char *subframe) d_IODE_SF3 = static_cast(read_navigation_unsigned(subframe_bits, IODE_SF3)); d_IDOT = static_cast(read_navigation_signed(subframe_bits, I_DOT)); d_IDOT = d_IDOT * I_DOT_LSB; - break; case 4: // --- It is subframe 4 ---------- Almanac, ionospheric model, UTC parameters, SV health (PRN: 25-32) - int SV_data_ID; - int SV_page; + int32_t SV_data_ID; + int32_t SV_page; d_TOW_SF4 = static_cast(read_navigation_unsigned(subframe_bits, TOW)); d_TOW_SF4 = d_TOW_SF4 * 6.0; d_TOW = d_TOW_SF4; // Set transmission time b_integrity_status_flag = read_navigation_bool(subframe_bits, INTEGRITY_STATUS_FLAG); b_alert_flag = read_navigation_bool(subframe_bits, ALERT_FLAG); b_antispoofing_flag = read_navigation_bool(subframe_bits, ANTI_SPOOFING_FLAG); - SV_data_ID = static_cast(read_navigation_unsigned(subframe_bits, SV_DATA_ID)); - SV_page = static_cast(read_navigation_unsigned(subframe_bits, SV_PAGE)); + SV_data_ID = static_cast(read_navigation_unsigned(subframe_bits, SV_DATA_ID)); + SV_page = static_cast(read_navigation_unsigned(subframe_bits, SV_PAGE)); if (SV_page > 24 && SV_page < 33) // Page 4 (from Table 20-V. Data IDs and SV IDs in Subframes 4 and 5, IS-GPS-200H, page 110) { //! \TODO read almanac @@ -420,10 +385,10 @@ int Gps_Navigation_Message::subframe_decoder(char *subframe) d_A0 = d_A0 * A_0_LSB; d_t_OT = static_cast(read_navigation_unsigned(subframe_bits, T_OT)); d_t_OT = d_t_OT * T_OT_LSB; - i_WN_T = static_cast(read_navigation_unsigned(subframe_bits, WN_T)); + i_WN_T = static_cast(read_navigation_unsigned(subframe_bits, WN_T)); d_DeltaT_LS = static_cast(read_navigation_signed(subframe_bits, DELTAT_LS)); - i_WN_LSF = static_cast(read_navigation_unsigned(subframe_bits, WN_LSF)); - i_DN = static_cast(read_navigation_unsigned(subframe_bits, DN)); // Right-justified ? + i_WN_LSF = static_cast(read_navigation_unsigned(subframe_bits, WN_LSF)); + i_DN = static_cast(read_navigation_unsigned(subframe_bits, DN)); // Right-justified ? d_DeltaT_LSF = static_cast(read_navigation_signed(subframe_bits, DELTAT_LSF)); flag_iono_valid = true; flag_utc_model_valid = true; @@ -437,29 +402,28 @@ int Gps_Navigation_Message::subframe_decoder(char *subframe) { // Page 25 Anti-Spoofing, SV config and almanac health (PRN: 25-32) //! \TODO Read Anti-Spoofing, SV config - almanacHealth[25] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV25)); - almanacHealth[26] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV26)); - almanacHealth[27] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV27)); - almanacHealth[28] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV28)); - almanacHealth[29] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV29)); - almanacHealth[30] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV30)); - almanacHealth[31] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV31)); - almanacHealth[32] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV32)); + almanacHealth[25] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV25)); + almanacHealth[26] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV26)); + almanacHealth[27] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV27)); + almanacHealth[28] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV28)); + almanacHealth[29] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV29)); + almanacHealth[30] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV30)); + almanacHealth[31] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV31)); + almanacHealth[32] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV32)); } - break; case 5: //--- It is subframe 5 -----------------almanac health (PRN: 1-24) and Almanac reference week number and time. - int SV_data_ID_5; - int SV_page_5; + int32_t SV_data_ID_5; + int32_t SV_page_5; d_TOW_SF5 = static_cast(read_navigation_unsigned(subframe_bits, TOW)); d_TOW_SF5 = d_TOW_SF5 * 6.0; d_TOW = d_TOW_SF5; // Set transmission time b_integrity_status_flag = read_navigation_bool(subframe_bits, INTEGRITY_STATUS_FLAG); b_alert_flag = read_navigation_bool(subframe_bits, ALERT_FLAG); b_antispoofing_flag = read_navigation_bool(subframe_bits, ANTI_SPOOFING_FLAG); - SV_data_ID_5 = static_cast(read_navigation_unsigned(subframe_bits, SV_DATA_ID)); - SV_page_5 = static_cast(read_navigation_unsigned(subframe_bits, SV_PAGE)); + SV_data_ID_5 = static_cast(read_navigation_unsigned(subframe_bits, SV_DATA_ID)); + SV_page_5 = static_cast(read_navigation_unsigned(subframe_bits, SV_PAGE)); if (SV_page_5 < 25) { //! \TODO read almanac @@ -471,31 +435,31 @@ int Gps_Navigation_Message::subframe_decoder(char *subframe) { d_Toa = static_cast(read_navigation_unsigned(subframe_bits, T_OA)); d_Toa = d_Toa * T_OA_LSB; - i_WN_A = static_cast(read_navigation_unsigned(subframe_bits, WN_A)); - almanacHealth[1] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV1)); - almanacHealth[2] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV2)); - almanacHealth[3] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV3)); - almanacHealth[4] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV4)); - almanacHealth[5] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV5)); - almanacHealth[6] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV6)); - almanacHealth[7] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV7)); - almanacHealth[8] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV8)); - almanacHealth[9] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV9)); - almanacHealth[10] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV10)); - almanacHealth[11] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV11)); - almanacHealth[12] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV12)); - almanacHealth[13] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV13)); - almanacHealth[14] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV14)); - almanacHealth[15] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV15)); - almanacHealth[16] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV16)); - almanacHealth[17] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV17)); - almanacHealth[18] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV18)); - almanacHealth[19] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV19)); - almanacHealth[20] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV20)); - almanacHealth[21] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV21)); - almanacHealth[22] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV22)); - almanacHealth[23] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV23)); - almanacHealth[24] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV24)); + i_WN_A = static_cast(read_navigation_unsigned(subframe_bits, WN_A)); + almanacHealth[1] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV1)); + almanacHealth[2] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV2)); + almanacHealth[3] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV3)); + almanacHealth[4] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV4)); + almanacHealth[5] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV5)); + almanacHealth[6] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV6)); + almanacHealth[7] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV7)); + almanacHealth[8] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV8)); + almanacHealth[9] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV9)); + almanacHealth[10] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV10)); + almanacHealth[11] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV11)); + almanacHealth[12] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV12)); + almanacHealth[13] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV13)); + almanacHealth[14] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV14)); + almanacHealth[15] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV15)); + almanacHealth[16] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV16)); + almanacHealth[17] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV17)); + almanacHealth[18] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV18)); + almanacHealth[19] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV19)); + almanacHealth[20] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV20)); + almanacHealth[21] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV21)); + almanacHealth[22] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV22)); + almanacHealth[23] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV23)); + almanacHealth[24] = static_cast(read_navigation_unsigned(subframe_bits, HEALTH_SV24)); } break; @@ -514,12 +478,12 @@ double Gps_Navigation_Message::utc_time(const double gpstime_corrected) const double Delta_t_UTC = d_DeltaT_LS + d_A0 + d_A1 * (gpstime_corrected - d_t_OT + 604800 * static_cast((i_GPS_week - i_WN_T))); // Determine if the effectivity time of the leap second event is in the past - int weeksToLeapSecondEvent = i_WN_LSF - i_GPS_week; + int32_t weeksToLeapSecondEvent = i_WN_LSF - i_GPS_week; if ((weeksToLeapSecondEvent) >= 0) // is not in the past { //Detect if the effectivity time and user's time is within six hours = 6 * 60 *60 = 21600 s - int secondOfLeapSecondEvent = i_DN * 24 * 60 * 60; + int32_t secondOfLeapSecondEvent = i_DN * 24 * 60 * 60; if (weeksToLeapSecondEvent > 0) { t_utc_daytime = fmod(gpstime_corrected - Delta_t_UTC, 86400); @@ -545,7 +509,7 @@ double Gps_Navigation_Message::utc_time(const double gpstime_corrected) const * proper accommodation of the leap second event with a possible week number * transition is provided by the following expression for UTC: */ - int W = fmod(gpstime_corrected - Delta_t_UTC - 43200, 86400) + 43200; + int32_t W = fmod(gpstime_corrected - Delta_t_UTC - 43200, 86400) + 43200; t_utc_daytime = fmod(W, 86400 + d_DeltaT_LSF - d_DeltaT_LS); //implement something to handle a leap second event! } @@ -639,7 +603,7 @@ Gps_Iono Gps_Navigation_Message::get_iono() iono.d_beta2 = d_beta2; iono.d_beta3 = d_beta3; iono.valid = flag_iono_valid; - //WARNING: We clear flag_utc_model_valid in order to not re-send the same information to the ionospheric parameters queue + // WARNING: We clear flag_utc_model_valid in order to not re-send the same information to the ionospheric parameters queue flag_iono_valid = false; return iono; } diff --git a/src/core/system_parameters/gps_navigation_message.h b/src/core/system_parameters/gps_navigation_message.h index 12c3836c9..b54c0dba7 100644 --- a/src/core/system_parameters/gps_navigation_message.h +++ b/src/core/system_parameters/gps_navigation_message.h @@ -54,10 +54,10 @@ class Gps_Navigation_Message { private: - uint64_t read_navigation_unsigned(std::bitset bits, const std::vector> parameter); - int64_t read_navigation_signed(std::bitset bits, const std::vector> parameter); - bool read_navigation_bool(std::bitset bits, const std::vector> parameter); - void print_gps_word_bytes(unsigned int GPS_word); + uint64_t read_navigation_unsigned(std::bitset bits, const std::vector> parameter); + int64_t read_navigation_signed(std::bitset bits, const std::vector> parameter); + bool read_navigation_bool(std::bitset bits, const std::vector> parameter); + void print_gps_word_bytes(uint32_t GPS_word); public: bool b_valid_ephemeris_set_flag; // flag indicating that this ephemeris set have passed the validation check @@ -92,16 +92,16 @@ public: double d_OMEGA_DOT; //!< Rate of Right Ascension [semi-circles/s] //broadcast orbit 5 double d_IDOT; //!< Rate of Inclination Angle [semi-circles/s] - int i_code_on_L2; //!< If 1, P code ON in L2; if 2, C/A code ON in L2; - int i_GPS_week; //!< GPS week number, aka WN [week] + int32_t i_code_on_L2; //!< If 1, P code ON in L2; if 2, C/A code ON in L2; + int32_t i_GPS_week; //!< GPS week number, aka WN [week] bool b_L2_P_data_flag; //!< When true, indicates that the NAV data stream was commanded OFF on the P-code of the L2 channel //broadcast orbit 6 - int i_SV_accuracy; //!< User Range Accuracy (URA) index of the SV (reference paragraph 6.2.1) for the standard positioning service user (Ref 20.3.3.3.1.3 IS-GPS-200E) - int i_SV_health; + int32_t i_SV_accuracy; //!< User Range Accuracy (URA) index of the SV (reference paragraph 6.2.1) for the standard positioning service user (Ref 20.3.3.3.1.3 IS-GPS-200E) + int32_t i_SV_health; double d_TGD; //!< Estimated Group Delay Differential: L1-L2 correction term only for the benefit of "L1 P(Y)" or "L2 P(Y)" s users [s] double d_IODC; //!< Issue of Data, Clock //broadcast orbit 7 - int i_AODO; //!< Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subframe 4 (reference paragraph 20.3.3.5.1.9) [s] + int32_t i_AODO; //!< Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subframe 4 (reference paragraph 20.3.3.5.1.9) [s] bool b_fit_interval_flag; //!< indicates the curve-fit interval used by the CS (Block II/IIA/IIR/IIR-M/IIF) and SS (Block IIIA) in determining the ephemeris parameters, as follows: 0 = 4 hours, 1 = greater than 4 hours. double d_spare1; @@ -113,11 +113,11 @@ public: // Almanac - double d_Toa; //!< Almanac reference time [s] - int i_WN_A; //!< Modulo 256 of the GPS week number to which the almanac reference time (d_Toa) is referenced - std::map almanacHealth; //!< Map that stores the health information stored in the almanac + double d_Toa; //!< Almanac reference time [s] + int32_t i_WN_A; //!< Modulo 256 of the GPS week number to which the almanac reference time (d_Toa) is referenced + std::map almanacHealth; //!< Map that stores the health information stored in the almanac - std::map satelliteBlock; //!< Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus + std::map satelliteBlock; //!< Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus // Flags @@ -147,8 +147,8 @@ public: double d_satpos_Z; //!< Earth-fixed coordinate z of the satellite [m]. The direction of the IERS (International Earth Rotation and Reference Systems Service) Reference Pole (IRP). // satellite identification info - int i_channel_ID; - unsigned int i_satellite_PRN; + int32_t i_channel_ID; + uint32_t i_satellite_PRN; // time synchro double d_subframe_timestamp_ms; //[ms] @@ -169,10 +169,10 @@ public: double d_A1; //!< 1st order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s/s] double d_A0; //!< Constant of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s] double d_t_OT; //!< Reference time for UTC data (reference 20.3.4.5 and 20.3.3.5.2.4 IS-GPS-200E) [s] - int i_WN_T; //!< UTC reference week number [weeks] + int32_t i_WN_T; //!< UTC reference week number [weeks] double d_DeltaT_LS; //!< delta time due to leap seconds [s]. Number of leap seconds since 6-Jan-1980 as transmitted by the GPS almanac. - int i_WN_LSF; //!< Week number at the end of which the leap second becomes effective [weeks] - int i_DN; //!< Day number (DN) at the end of which the leap second becomes effective [days] + int32_t i_WN_LSF; //!< Week number at the end of which the leap second becomes effective [weeks] + int32_t i_DN; //!< Day number (DN) at the end of which the leap second becomes effective [days] double d_DeltaT_LSF; //!< Scheduled future or recent past (relative to NAV message upload) value of the delta time due to leap seconds [s] // Satellite velocity @@ -202,7 +202,7 @@ public: /*! * \brief Decodes the GPS NAV message */ - int subframe_decoder(char *subframe); + int32_t subframe_decoder(char *subframe); /*! * \brief Computes the Coordinated Universal Time (UTC) and diff --git a/src/core/system_parameters/gps_utc_model.cc b/src/core/system_parameters/gps_utc_model.cc index ffe1af6f5..0f9a5744e 100644 --- a/src/core/system_parameters/gps_utc_model.cc +++ b/src/core/system_parameters/gps_utc_model.cc @@ -35,34 +35,35 @@ Gps_Utc_Model::Gps_Utc_Model() { valid = false; - d_A1 = 0; - d_A0 = 0; - d_t_OT = 0; + d_A1 = 0.0; + d_A0 = 0.0; + d_t_OT = 0.0; i_WN_T = 0; - d_DeltaT_LS = 0; + d_DeltaT_LS = 0.0; i_WN_LSF = 0; i_DN = 0; - d_DeltaT_LSF = 0; + d_DeltaT_LSF = 0.0; } -double Gps_Utc_Model::utc_time(double gpstime_corrected, int i_GPS_week) + +double Gps_Utc_Model::utc_time(double gpstime_corrected, int32_t i_GPS_week) { double t_utc; double t_utc_daytime; double Delta_t_UTC = d_DeltaT_LS + d_A0 + d_A1 * (gpstime_corrected - d_t_OT + 604800 * static_cast(i_GPS_week - i_WN_T)); // Determine if the effectivity time of the leap second event is in the past - int weeksToLeapSecondEvent = i_WN_LSF - i_GPS_week; + int32_t weeksToLeapSecondEvent = i_WN_LSF - i_GPS_week; if (weeksToLeapSecondEvent >= 0) // is not in the past { - //Detect if the effectivity time and user's time is within six hours = 6 * 60 *60 = 21600 s - int secondOfLeapSecondEvent = i_DN * 24 * 60 * 60; + // Detect if the effectivity time and user's time is within six hours = 6 * 60 *60 = 21600 s + int32_t secondOfLeapSecondEvent = i_DN * 24 * 60 * 60; if (weeksToLeapSecondEvent > 0) { t_utc_daytime = fmod(gpstime_corrected - Delta_t_UTC, 86400); } - else //we are in the same week than the leap second event + else // we are in the same week than the leap second event { if (std::abs(gpstime_corrected - secondOfLeapSecondEvent) > 21600) { @@ -83,9 +84,9 @@ double Gps_Utc_Model::utc_time(double gpstime_corrected, int i_GPS_week) * proper accommodation of the leap second event with a possible week number * transition is provided by the following expression for UTC: */ - int W = fmod(gpstime_corrected - Delta_t_UTC - 43200, 86400) + 43200; + int32_t W = fmod(gpstime_corrected - Delta_t_UTC - 43200, 86400) + 43200; t_utc_daytime = fmod(W, 86400 + d_DeltaT_LSF - d_DeltaT_LS); - //implement something to handle a leap second event! + // implement something to handle a leap second event! } if ((gpstime_corrected - secondOfLeapSecondEvent) > 21600) { diff --git a/src/core/system_parameters/gps_utc_model.h b/src/core/system_parameters/gps_utc_model.h index ede2c1e67..e037aff99 100644 --- a/src/core/system_parameters/gps_utc_model.h +++ b/src/core/system_parameters/gps_utc_model.h @@ -32,9 +32,8 @@ #ifndef GNSS_SDR_GPS_UTC_MODEL_H_ #define GNSS_SDR_GPS_UTC_MODEL_H_ -#include #include - +#include /*! * \brief This class is a storage for the GPS UTC MODEL data as described in IS-GPS-200E @@ -49,10 +48,10 @@ public: double d_A1; //!< 1st order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s/s] double d_A0; //!< Constant of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s] double d_t_OT; //!< Reference time for UTC data (reference 20.3.4.5 and 20.3.3.5.2.4 IS-GPS-200E) [s] - int i_WN_T; //!< UTC reference week number [weeks] + int32_t i_WN_T; //!< UTC reference week number [weeks] double d_DeltaT_LS; //!< delta time due to leap seconds [s]. Number of leap seconds since 6-Jan-1980 as transmitted by the GPS almanac. - int i_WN_LSF; //!< Week number at the end of which the leap second becomes effective [weeks] - int i_DN; //!< Day number (DN) at the end of which the leap second becomes effective [days] + int32_t i_WN_LSF; //!< Week number at the end of which the leap second becomes effective [weeks] + int32_t i_DN; //!< Day number (DN) at the end of which the leap second becomes effective [days] double d_DeltaT_LSF; //!< Scheduled future or recent past (relative to NAV message upload) value of the delta time due to leap seconds [s] /*! @@ -64,7 +63,7 @@ public: /* * \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the ephemeris data on disk file. */ - inline void serialize(Archive& archive, const unsigned int version) + inline void serialize(Archive& archive, const uint32_t version) { using boost::serialization::make_nvp; if (version) @@ -85,7 +84,7 @@ public: * \brief Computes the Coordinated Universal Time (UTC) and * returns it in [s] (IS-GPS-200E, 20.3.3.5.2.4) */ - double utc_time(double gpstime_corrected, int i_GPS_week); + double utc_time(double gpstime_corrected, int32_t i_GPS_week); }; #endif