From ed9aaf86cecdcd0d5975efeede8590d1b8638d91 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 18 Mar 2019 08:43:38 +0100 Subject: [PATCH] Fix building, apply formatting --- src/algorithms/PVT/adapters/rtklib_pvt.cc | 40 +- src/algorithms/PVT/libs/rtklib_solver.cc | 6 +- .../adapters/beidou_b3i_pcps_acquisition.cc | 32 +- .../adapters/beidou_b3i_pcps_acquisition.h | 7 +- .../libs/beidou_b3i_signal_processing.cc | 58 +- .../libs/beidou_b3i_signal_processing.h | 14 +- .../adapters/beidou_b3i_telemetry_decoder.cc | 82 +- .../adapters/beidou_b3i_telemetry_decoder.h | 66 +- .../beidou_b3i_telemetry_decoder_gs.cc | 1044 +++++++++-------- .../beidou_b3i_telemetry_decoder_gs.h | 109 +- .../adapters/beidou_b3i_dll_pll_tracking.cc | 15 +- .../adapters/beidou_b3i_dll_pll_tracking.h | 4 +- .../gnuradio_blocks/dll_pll_veml_tracking.cc | 103 +- src/core/receiver/gnss_flowgraph.cc | 78 +- src/core/system_parameters/Beidou_B3I.h | 40 +- src/core/system_parameters/Beidou_DNAV.h | 348 +++--- 16 files changed, 1080 insertions(+), 966 deletions(-) diff --git a/src/algorithms/PVT/adapters/rtklib_pvt.cc b/src/algorithms/PVT/adapters/rtklib_pvt.cc index 16cd60ec0..bbb4cdc2d 100644 --- a/src/algorithms/PVT/adapters/rtklib_pvt.cc +++ b/src/algorithms/PVT/adapters/rtklib_pvt.cc @@ -340,27 +340,27 @@ Rtklib_Pvt::Rtklib_Pvt(ConfigurationInterface* configuration, { pvt_output_parameters.type_of_receiver = 55; } - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count != 0) && (bds_B3_count != 0)) - { - pvt_output_parameters.type_of_receiver = 56; - } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count != 0) && (bds_B3_count != 0)) + { + pvt_output_parameters.type_of_receiver = 56; + } // BeiDou B3I Receiver - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0) && (bds_B3_count != 0)) - { - pvt_output_parameters.type_of_receiver = 60; - } - if ((gps_1C_count != 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0) && (bds_B3_count != 0)) - { - pvt_output_parameters.type_of_receiver = 61; - } - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count != 0) && (bds_B1_count == 0) && (bds_B3_count != 0)) - { - pvt_output_parameters.type_of_receiver = 62; - } - if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count != 0) && (bds_B1_count == 0) && (bds_B3_count != 0)) - { - pvt_output_parameters.type_of_receiver = 63; - } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0) && (bds_B3_count != 0)) + { + pvt_output_parameters.type_of_receiver = 60; + } + if ((gps_1C_count != 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0) && (bds_B3_count != 0)) + { + pvt_output_parameters.type_of_receiver = 61; + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count != 0) && (bds_B1_count == 0) && (bds_B3_count != 0)) + { + pvt_output_parameters.type_of_receiver = 62; + } + if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count != 0) && (bds_B1_count == 0) && (bds_B3_count != 0)) + { + pvt_output_parameters.type_of_receiver = 63; + } // RTKLIB PVT solver options // Settings 1 diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index 1a81af22d..792fe004a 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -837,7 +837,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ // BeiDou B3 if (sig_ == "B3") { - beidou_ephemeris_iter = beidou_dnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + beidou_ephemeris_iter = beidou_dnav_ephemeris_map.find(gnss_observables_iter->second.PRN); if (beidou_ephemeris_iter != beidou_dnav_ephemeris_map.cend()) { bool found_B1I_obs = false; @@ -847,7 +847,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ { obs_data[i + glo_valid_obs] = insert_obs_to_rtklib(obs_data[i + glo_valid_obs], gnss_observables_iter->second, - beidou_ephemeris_iter->second.i_BEIDOU_week + 1356, + beidou_ephemeris_iter->second.i_BEIDOU_week + 1356, 1); // Band 3 (L2/G2/B3) found_B1I_obs = true; break; @@ -865,7 +865,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ {}, {0.0, 0.0, 0.0}, {}}; obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, - beidou_ephemeris_iter->second.i_BEIDOU_week + 1356, + beidou_ephemeris_iter->second.i_BEIDOU_week + 1356, 1); // Band 2 (L2/G2) valid_obs++; } diff --git a/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.cc index b44c25613..d8eec0412 100644 --- a/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.cc @@ -30,27 +30,26 @@ */ #include "beidou_b3i_pcps_acquisition.h" +#include "Beidou_B3I.h" +#include "acq_conf.h" +#include "beidou_b3i_signal_processing.h" #include "configuration_interface.h" #include "gnss_sdr_flags.h" -#include "acq_conf.h" #include #include -#include "beidou_b3i_signal_processing.h" -#include "Beidou_B3I.h" - using google::LogMessage; BeidouB3iPcpsAcquisition::BeidouB3iPcpsAcquisition( ConfigurationInterface* configuration, - std::string role, - unsigned int in_streams, - unsigned int out_streams) : role_(role), - in_streams_(in_streams), - out_streams_(out_streams) + std::string role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) { - Acq_Conf acq_parameters = Acq_Conf(); + Acq_Conf acq_parameters = Acq_Conf(); configuration_ = configuration; std::string default_item_type = "gr_complex"; std::string default_dump_filename = "./data/acquisition.dat"; @@ -59,7 +58,7 @@ BeidouB3iPcpsAcquisition::BeidouB3iPcpsAcquisition( item_type_ = configuration_->property(role + ".item_type", default_item_type); - long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); acq_parameters.fs_in = fs_in_; dump_ = configuration_->property(role + ".dump", false); @@ -80,7 +79,7 @@ BeidouB3iPcpsAcquisition::BeidouB3iPcpsAcquisition( dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename); acq_parameters.dump_filename = dump_filename_; //--- Find number of samples per spreading code ------------------------- - code_length_ = static_cast(std::round(static_cast(fs_in_) / ( BEIDOU_B3I_CODE_RATE_HZ / BEIDOU_B3I_CODE_LENGTH_CHIPS))); + code_length_ = static_cast(std::round(static_cast(fs_in_) / (BEIDOU_B3I_CODE_RATE_HZ / BEIDOU_B3I_CODE_LENGTH_CHIPS))); vector_length_ = code_length_ * sampled_ms_; @@ -264,11 +263,11 @@ void BeidouB3iPcpsAcquisition::connect(gr::top_block_sptr top_block) { if (item_type_.compare("gr_complex") == 0) { - // nothing to connect + // nothing to connect } else if (item_type_.compare("cshort") == 0) { - // nothing to connect + // nothing to connect } else if (item_type_.compare("cbyte") == 0) { @@ -287,11 +286,11 @@ void BeidouB3iPcpsAcquisition::disconnect(gr::top_block_sptr top_block) { if (item_type_.compare("gr_complex") == 0) { - // nothing to disconnect + // nothing to disconnect } else if (item_type_.compare("cshort") == 0) { - // nothing to disconnect + // nothing to disconnect } else if (item_type_.compare("cbyte") == 0) { @@ -335,6 +334,7 @@ gr::basic_block_sptr BeidouB3iPcpsAcquisition::get_right_block() return acquisition_; } + void BeidouB3iPcpsAcquisition::set_resampler_latency(uint32_t latency_samples) { acquisition_->set_resampler_latency(latency_samples); diff --git a/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h b/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h index 9c1484816..cc76c671d 100644 --- a/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h @@ -34,12 +34,13 @@ #include "acq_conf.h" #include "acquisition_interface.h" +#include "complex_byte_to_float_x2.h" #include "gnss_synchro.h" #include "pcps_acquisition.h" -#include "complex_byte_to_float_x2.h" -#include #include +#include #include +#include #include @@ -162,7 +163,7 @@ private: unsigned int doppler_step_; unsigned int sampled_ms_; unsigned int max_dwells_; - long fs_in_; + int64_t fs_in_; bool dump_; bool blocking_; std::string dump_filename_; diff --git a/src/algorithms/libs/beidou_b3i_signal_processing.cc b/src/algorithms/libs/beidou_b3i_signal_processing.cc index d5077174b..d0e6de608 100644 --- a/src/algorithms/libs/beidou_b3i_signal_processing.cc +++ b/src/algorithms/libs/beidou_b3i_signal_processing.cc @@ -39,13 +39,13 @@ void beidou_b3i_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shi const unsigned int _code_length = 10230; bool G1[_code_length]; bool G2[_code_length]; - std::array G1_register = {{1,1,1,1,1,1,1,1,1,1,1,1,1}}; - std::array G2_register = {{1,1,1,1,1,1,1,1,1,1,1,1,1}}; - std::array G1_register_reset = {{0,0,1,1,1,1,1,1,1,1,1,1,1}}; + std::array G1_register = {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}; + std::array G2_register = {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}; + std::array G1_register_reset = {{0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}; bool feedback1, feedback2, aux; uint32_t lcv, lcv2, delay; int32_t prn_idx = _prn - 1; - + // clang-format off std::array, 63> G2_register_shifted = {{ {{1,0,1,0,1,1,1,1,1,1,1,1,1,}}, {{1,1,1,1,0,0,0,1,0,1,0,1,1,}}, {{1,0,1,1,1,1,0,0,0,1,0,1,0,}}, {{1,1,1,1,1,1,1,1,1,1,0,1,1,}}, {{1,1,0,0,1,0,0,0,1,1,1,1,1,}}, {{1,0,0,1,0,0,1,1,0,0,1,0,0,}}, {{1,1,1,1,1,1,1,0,1,0,0,1,0,}}, {{1,1,1,0,1,1,1,1,1,1,1,0,1,}}, @@ -63,41 +63,42 @@ void beidou_b3i_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shi {{0,0,0,0,0,0,0,0,1,1,0,0,0,}}, {{1,0,0,0,0,0,0,0,0,0,1,0,0,}}, {{0,0,1,1,0,1,0,1,0,0,1,1,0,}}, {{1,0,1,1,0,0,1,0,0,0,1,1,0,}}, {{0,1,1,1,0,0,1,1,1,1,0,0,0,}}, {{0,0,1,0,1,1,1,0,0,1,0,1,0,}}, {{1,1,0,0,1,1,1,1,1,0,1,1,0,}}, {{1,0,0,1,0,0,1,0,0,0,1,0,1,}}, {{0,1,1,1,0,0,0,1,0,0,0,0,0,}}, {{0,0,1,1,0,0,1,0,0,0,0,1,0,}}, {{0,0,1,0,0,0,1,0,0,1,1,1,0,}}}}; - + // clang-format on // A simple error check if ((prn_idx < 0) || (prn_idx > 63)) return; // Assign shifted G2 register based on prn number G2_register = G2_register_shifted[prn_idx]; - std::reverse(G2_register.begin(), G2_register.end()) ; + std::reverse(G2_register.begin(), G2_register.end()); // Generate G1 and G2 Register for (lcv = 0; lcv < _code_length; lcv++) - { - G1[lcv] = G1_register[0]; - G2[lcv] = G2_register[0]; + { + G1[lcv] = G1_register[0]; + G2[lcv] = G2_register[0]; - //feedback1 = (test_G1_register[0]+test_G1_register[2]+test_G1_register[3]+test_G1_register[12]) & 0x1; - feedback1 = (G1_register[0]+G1_register[9]+G1_register[10]+G1_register[12]) & 0x01; - feedback2 = (G2_register[0]+G2_register[1]+G2_register[3]+G2_register[4]+ - G2_register[6]+G2_register[7]+G2_register[8]+G2_register[12]) & 0x01; + //feedback1 = (test_G1_register[0]+test_G1_register[2]+test_G1_register[3]+test_G1_register[12]) & 0x1; + feedback1 = (G1_register[0] + G1_register[9] + G1_register[10] + G1_register[12]) & 0x01; + feedback2 = (G2_register[0] + G2_register[1] + G2_register[3] + G2_register[4] + + G2_register[6] + G2_register[7] + G2_register[8] + G2_register[12]) & + 0x01; - for (lcv2 = 0; lcv2 < 12; lcv2++) - { - G1_register[lcv2] = G1_register[lcv2 + 1]; - G2_register[lcv2] = G2_register[lcv2 + 1]; - } + for (lcv2 = 0; lcv2 < 12; lcv2++) + { + G1_register[lcv2] = G1_register[lcv2 + 1]; + G2_register[lcv2] = G2_register[lcv2 + 1]; + } - G1_register[12] = feedback1; - G2_register[12] = feedback2; + G1_register[12] = feedback1; + G2_register[12] = feedback2; - // Reset G1 register if sequence found - if(G1_register == G1_register_reset) - { - G1_register = {{1,1,1,1,1,1,1,1,1,1,1,1,1}}; - } - } + // Reset G1 register if sequence found + if (G1_register == G1_register_reset) + { + G1_register = {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}; + } + } delay = _code_length; delay += _chip_shift; @@ -119,7 +120,6 @@ void beidou_b3i_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shi delay++; delay %= _code_length; } - } @@ -166,8 +166,8 @@ void beidou_b3i_code_gen_complex_sampled(std::complex* _dest, unsigned in _samplesPerCode = static_cast(static_cast(_fs) / static_cast(_codeFreqBasis / _codeLength)); //--- Find time constants -------------------------------------------------- - _ts = 1.0 / static_cast(_fs); // Sampling period in sec - _tc = 1.0 / static_cast(_codeFreqBasis); // C/A chip period in sec + _ts = 1.0 / static_cast(_fs); // Sampling period in sec + _tc = 1.0 / static_cast(_codeFreqBasis); // C/A chip period in sec beidou_b3i_code_gen_complex(_code, _prn, _chip_shift); //generate C/A code 1 sample per chip for (signed int i = 0; i < _samplesPerCode; i++) diff --git a/src/algorithms/libs/beidou_b3i_signal_processing.h b/src/algorithms/libs/beidou_b3i_signal_processing.h index 1c7e7a368..1bfab5519 100644 --- a/src/algorithms/libs/beidou_b3i_signal_processing.h +++ b/src/algorithms/libs/beidou_b3i_signal_processing.h @@ -7,7 +7,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -30,8 +30,8 @@ * ------------------------------------------------------------------------- */ -#ifndef BEIDOU_B3I_SDR_SIGNAL_PROCESSING_H_ -#define BEIDOU_B3I_SDR_SIGNAL_PROCESSING_H_ +#ifndef GNSS_SDR_BEIDOU_B3I_SIGNAL_PROCESSING_H_ +#define GNSS_SDR_BEIDOU_B3I_SIGNAL_PROCESSING_H_ #include #include @@ -39,13 +39,13 @@ #include #include -//!Generates int BeiDou B3I code for the desired SV ID and code shift +//! Generates int BeiDou B3I code for the desired SV ID and code shift void beidou_b3i_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shift); -//!Generates float BeiDou B3I code for the desired SV ID and code shift +//! Generates float BeiDou B3I code for the desired SV ID and code shift void beidou_b3i_code_gen_float(float* _dest, signed int _prn, unsigned int _chip_shift); -//!Generates complex BeiDou B3I code for the desired SV ID and code shift, and sampled to specific sampling frequency +//! Generates complex BeiDou B3I code for the desired SV ID and code shift, and sampled to specific sampling frequency void beidou_b3i_code_gen_complex(std::complex* _dest, signed int _prn, unsigned int _chip_shift); //! Generates N complex BeiDou B3I codes for the desired SV ID and code shift @@ -54,4 +54,4 @@ void beidou_b3i_code_gen_complex_sampled(std::complex* _dest, unsigned in //! Generates complex BeiDou B3I code for the desired SV ID and code shift void beidou_b3i_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, int _fs, unsigned int _chip_shift); -#endif /* BEIDOU_B3I_SDR_SIGNAL_PROCESSING_H_ */ +#endif /* GNSS_SDR_BEIDOU_B3I_SIGNAL_PROCESSING_H_ */ diff --git a/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.cc index 7b4f9cfb8..d334bb72a 100644 --- a/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.cc @@ -36,49 +36,65 @@ BeidouB3iTelemetryDecoder::BeidouB3iTelemetryDecoder( ConfigurationInterface *configuration, std::string role, unsigned int in_streams, unsigned int out_streams) - : role_(role), in_streams_(in_streams), out_streams_(out_streams) { - std::string default_dump_filename = "./navigation.dat"; - DLOG(INFO) << "role " << role; - dump_ = configuration->property(role + ".dump", false); - dump_filename_ = - configuration->property(role + ".dump_filename", default_dump_filename); - // make telemetry decoder object - telemetry_decoder_ = beidou_b3i_make_telemetry_decoder_gs(satellite_, dump_); - DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; - channel_ = 0; - if (in_streams_ > 1) { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) { - LOG(ERROR) << "This implementation only supports one output stream"; - } + : role_(role), in_streams_(in_streams), out_streams_(out_streams) +{ + std::string default_dump_filename = "./navigation.dat"; + DLOG(INFO) << "role " << role; + dump_ = configuration->property(role + ".dump", false); + dump_filename_ = + configuration->property(role + ".dump_filename", default_dump_filename); + // make telemetry decoder object + telemetry_decoder_ = beidou_b3i_make_telemetry_decoder_gs(satellite_, dump_); + DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; + channel_ = 0; + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } } + BeidouB3iTelemetryDecoder::~BeidouB3iTelemetryDecoder() = default; -void BeidouB3iTelemetryDecoder::set_satellite(const Gnss_Satellite &satellite) { - satellite_ = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - telemetry_decoder_->set_satellite(satellite_); - DLOG(INFO) << "TELEMETRY DECODER: satellite set to " << satellite_; + +void BeidouB3iTelemetryDecoder::set_satellite(const Gnss_Satellite &satellite) +{ + satellite_ = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); + telemetry_decoder_->set_satellite(satellite_); + DLOG(INFO) << "TELEMETRY DECODER: satellite set to " << satellite_; } -void BeidouB3iTelemetryDecoder::connect(gr::top_block_sptr top_block) { - if (top_block) { /* top_block is not null */ - }; - // Nothing to connect internally - DLOG(INFO) << "nothing to connect internally"; + +void BeidouB3iTelemetryDecoder::connect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + // Nothing to connect internally + DLOG(INFO) << "nothing to connect internally"; } -void BeidouB3iTelemetryDecoder::disconnect(gr::top_block_sptr top_block) { - if (top_block) { /* top_block is not null */ - }; - // Nothing to disconnect + +void BeidouB3iTelemetryDecoder::disconnect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + // Nothing to disconnect } -gr::basic_block_sptr BeidouB3iTelemetryDecoder::get_left_block() { - return telemetry_decoder_; + +gr::basic_block_sptr BeidouB3iTelemetryDecoder::get_left_block() +{ + return telemetry_decoder_; } -gr::basic_block_sptr BeidouB3iTelemetryDecoder::get_right_block() { - return telemetry_decoder_; + +gr::basic_block_sptr BeidouB3iTelemetryDecoder::get_right_block() +{ + return telemetry_decoder_; } diff --git a/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.h index 81f1e1ab3..a0b4996f9 100644 --- a/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.h @@ -33,54 +33,58 @@ #define GNSS_SDR_BEIDOU_B3I_TELEMETRY_DECODER_H_ #include "beidou_b3i_telemetry_decoder_gs.h" -#include "gnss_satellite.h" // for Gnss_Satellite +#include "gnss_satellite.h" // for Gnss_Satellite #include "telemetry_decoder_interface.h" -#include // for size_t -#include // for basic_block_sptr, top_block_sptr +#include // for basic_block_sptr, top_block_sptr +#include // for size_t #include + class ConfigurationInterface; /*! * \brief This class implements a NAV data decoder for BEIDOU B1I */ -class BeidouB3iTelemetryDecoder : public TelemetryDecoderInterface { +class BeidouB3iTelemetryDecoder : public TelemetryDecoderInterface +{ public: - BeidouB3iTelemetryDecoder(ConfigurationInterface *configuration, - std::string role, unsigned int in_streams, - unsigned int out_streams); + BeidouB3iTelemetryDecoder(ConfigurationInterface *configuration, + std::string role, unsigned int in_streams, + unsigned int out_streams); - virtual ~BeidouB3iTelemetryDecoder(); + virtual ~BeidouB3iTelemetryDecoder(); - inline std::string role() override { return role_; } + inline std::string role() override { return role_; } - //! Returns "BEIDOU_B3I_Telemetry_Decoder" - inline std::string implementation() override { - return "BEIDOU_B3I_Telemetry_Decoder"; - } + //! Returns "BEIDOU_B3I_Telemetry_Decoder" + inline std::string implementation() override + { + return "BEIDOU_B3I_Telemetry_Decoder"; + } - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; + void connect(gr::top_block_sptr top_block) override; + void disconnect(gr::top_block_sptr top_block) override; + gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block() override; - void set_satellite(const Gnss_Satellite &satellite) override; - inline void set_channel(int channel) override { - telemetry_decoder_->set_channel(channel); - } + void set_satellite(const Gnss_Satellite &satellite) override; + inline void set_channel(int channel) override + { + telemetry_decoder_->set_channel(channel); + } - inline void reset() override { return; } + inline void reset() override { return; } - inline size_t item_size() override { return 0; } + inline size_t item_size() override { return 0; } private: - beidou_b3i_telemetry_decoder_gs_sptr telemetry_decoder_; - Gnss_Satellite satellite_; - int channel_; - bool dump_; - std::string dump_filename_; - std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; + beidou_b3i_telemetry_decoder_gs_sptr telemetry_decoder_; + Gnss_Satellite satellite_; + int channel_; + bool dump_; + std::string dump_filename_; + std::string role_; + unsigned int in_streams_; + unsigned int out_streams_; }; #endif diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc index c54d355c9..e1920e2d1 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc @@ -36,528 +36,622 @@ #include "beidou_dnav_iono.h" #include "beidou_dnav_utc_model.h" #include "gnss_synchro.h" -#include // for abs -#include // for exception #include #include -#include // for cout -#include // for shared_ptr, make_shared -#include // for make_any -#include // for mp +#include // for make_any +#include // for mp #include +#include // for abs +#include // for exception +#include // for cout +#include // for shared_ptr, make_shared #define CRC_ERROR_LIMIT 8 beidou_b3i_telemetry_decoder_gs_sptr beidou_b3i_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, - bool dump) { - return beidou_b3i_telemetry_decoder_gs_sptr( - new beidou_b3i_telemetry_decoder_gs(satellite, dump)); + bool dump) +{ + return beidou_b3i_telemetry_decoder_gs_sptr( + new beidou_b3i_telemetry_decoder_gs(satellite, dump)); } beidou_b3i_telemetry_decoder_gs::beidou_b3i_telemetry_decoder_gs( const Gnss_Satellite &satellite, bool dump) : gr::block("beidou_b3i_telemetry_decoder_gs", - gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), - gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { - // Ephemeris data port out - this->message_port_register_out(pmt::mp("telemetry")); - // initialize internal vars - d_dump = dump; - d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - LOG(INFO) << "Initializing BeiDou B3I Telemetry Decoding for satellite " - << this->d_satellite; + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) +{ + // Ephemeris data port out + this->message_port_register_out(pmt::mp("telemetry")); + // initialize internal vars + d_dump = dump; + d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); + LOG(INFO) << "Initializing BeiDou B3I Telemetry Decoding for satellite " + << this->d_satellite; - d_samples_per_symbol = - (BEIDOU_B3I_CODE_RATE_HZ / BEIDOU_B3I_CODE_LENGTH_CHIPS) / - BEIDOU_D1NAV_SYMBOL_RATE_SPS; - d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS; - d_samples_per_preamble = - BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS * d_samples_per_symbol; - d_secondary_code_symbols = static_cast( - volk_gnsssdr_malloc(BEIDOU_B3I_SECONDARY_CODE_LENGTH * sizeof(int32_t), - volk_gnsssdr_get_alignment())); - d_preamble_samples = static_cast(volk_gnsssdr_malloc( - d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment())); - d_preamble_period_samples = - BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * d_samples_per_symbol; + d_samples_per_symbol = + (BEIDOU_B3I_CODE_RATE_HZ / BEIDOU_B3I_CODE_LENGTH_CHIPS) / + BEIDOU_D1NAV_SYMBOL_RATE_SPS; + d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS; + d_samples_per_preamble = + BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS * d_samples_per_symbol; + d_secondary_code_symbols = static_cast( + volk_gnsssdr_malloc(BEIDOU_B3I_SECONDARY_CODE_LENGTH * sizeof(int32_t), + volk_gnsssdr_get_alignment())); + d_preamble_samples = static_cast(volk_gnsssdr_malloc( + d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment())); + d_preamble_period_samples = + BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * d_samples_per_symbol; - // Setting samples of secondary code - for (int32_t i = 0; i < BEIDOU_B3I_SECONDARY_CODE_LENGTH; i++) { - if (BEIDOU_B3I_SECONDARY_CODE.at(i) == '1') { - d_secondary_code_symbols[i] = 1; - } else { - d_secondary_code_symbols[i] = -1; - } - } + // Setting samples of secondary code + for (int32_t i = 0; i < BEIDOU_B3I_SECONDARY_CODE_LENGTH; i++) + { + if (BEIDOU_B3I_SECONDARY_CODE.at(i) == '1') + { + d_secondary_code_symbols[i] = 1; + } + else + { + d_secondary_code_symbols[i] = -1; + } + } - // Setting samples of preamble code - int32_t n = 0; - for (int32_t i = 0; i < d_symbols_per_preamble; i++) { - int32_t m = 0; - if (BEIDOU_DNAV_PREAMBLE.at(i) == '1') { - for (uint32_t j = 0; j < d_samples_per_symbol; j++) { - d_preamble_samples[n] = d_secondary_code_symbols[m]; - n++; - m++; - m = m % BEIDOU_B3I_SECONDARY_CODE_LENGTH; - } - } else { - for (uint32_t j = 0; j < d_samples_per_symbol; j++) { - d_preamble_samples[n] = -d_secondary_code_symbols[m]; - n++; - m++; - m = m % BEIDOU_B3I_SECONDARY_CODE_LENGTH; - } - } - } + // Setting samples of preamble code + int32_t n = 0; + for (int32_t i = 0; i < d_symbols_per_preamble; i++) + { + int32_t m = 0; + if (BEIDOU_DNAV_PREAMBLE.at(i) == '1') + { + for (uint32_t j = 0; j < d_samples_per_symbol; j++) + { + d_preamble_samples[n] = d_secondary_code_symbols[m]; + n++; + m++; + m = m % BEIDOU_B3I_SECONDARY_CODE_LENGTH; + } + } + else + { + for (uint32_t j = 0; j < d_samples_per_symbol; j++) + { + d_preamble_samples[n] = -d_secondary_code_symbols[m]; + n++; + m++; + m = m % BEIDOU_B3I_SECONDARY_CODE_LENGTH; + } + } + } - d_subframe_symbols = static_cast( - volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(double), - volk_gnsssdr_get_alignment())); - d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS * d_samples_per_symbol + - d_samples_per_preamble; - d_symbol_history.set_capacity(d_required_symbols + 1); + d_subframe_symbols = static_cast( + volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(double), + volk_gnsssdr_get_alignment())); + d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS * d_samples_per_symbol + + d_samples_per_preamble; + d_symbol_history.set_capacity(d_required_symbols + 1); - // Generic settings - d_sample_counter = 0; - d_stat = 0; - d_preamble_index = 0; - d_flag_frame_sync = false; - d_TOW_at_current_symbol_ms = 0; - Flag_valid_word = false; - d_CRC_error_counter = 0; - d_flag_preamble = false; - d_channel = 0; - flag_SOW_set = false; + // Generic settings + d_sample_counter = 0; + d_stat = 0; + d_preamble_index = 0; + d_flag_frame_sync = false; + d_TOW_at_current_symbol_ms = 0; + Flag_valid_word = false; + d_CRC_error_counter = 0; + d_flag_preamble = false; + d_channel = 0; + flag_SOW_set = false; } -beidou_b3i_telemetry_decoder_gs::~beidou_b3i_telemetry_decoder_gs() { - volk_gnsssdr_free(d_preamble_samples); - volk_gnsssdr_free(d_secondary_code_symbols); - volk_gnsssdr_free(d_subframe_symbols); - if (d_dump_file.is_open() == true) { - try { - d_dump_file.close(); - } catch (const std::exception &ex) { - LOG(WARNING) << "Exception in destructor closing the dump file " - << ex.what(); - } - } -} - -void beidou_b3i_telemetry_decoder_gs::decode_bch15_11_01(const int32_t *bits, - int32_t *decbits) { - int32_t bit, err, reg[4] = {1, 1, 1, 1}; - int32_t errind[15] = {14, 13, 10, 12, 6, 9, 4, 11, 0, 5, 7, 8, 1, 3, 2}; - - for (uint32_t i = 0; i < 15; i++) { - decbits[i] = bits[i]; - } - - for (uint32_t i = 0; i < 15; i++) { - bit = reg[3]; - reg[3] = reg[2]; - reg[2] = reg[1]; - reg[1] = reg[0]; - reg[0] = bits[i] * bit; - reg[1] *= bit; - } - - err = errind[reg[0] + reg[1] * 2 + reg[2] * 4 + reg[3] * 8]; - - if (err > 0) { - decbits[err - 1] *= -1; - } -} - -void beidou_b3i_telemetry_decoder_gs::decode_word( - int32_t word_counter, const double *enc_word_symbols, - int32_t *dec_word_symbols) { - int32_t bitsbch[30], first_branch[15], second_branch[15]; - - if (word_counter == 1) { - for (uint32_t j = 0; j < 30; j++) { - dec_word_symbols[j] = - static_cast(enc_word_symbols[j] > 0) ? (1) : (-1); - } - } else { - for (uint32_t r = 0; r < 2; r++) { - for (uint32_t c = 0; c < 15; c++) { - bitsbch[r * 15 + c] = - static_cast(enc_word_symbols[c * 2 + r] > 0) ? (1) : (-1); - } - } - - decode_bch15_11_01(&bitsbch[0], first_branch); - decode_bch15_11_01(&bitsbch[15], second_branch); - - for (uint32_t j = 0; j < 11; j++) { - dec_word_symbols[j] = first_branch[j]; - dec_word_symbols[j + 11] = second_branch[j]; - } - - for (uint32_t j = 0; j < 4; j++) { - dec_word_symbols[j + 22] = first_branch[11 + j]; - dec_word_symbols[j + 26] = second_branch[11 + j]; - } - } -} - -void beidou_b3i_telemetry_decoder_gs::decode_subframe(double *frame_symbols) { - // 1. Transform from symbols to bits - std::string data_bits; - int32_t dec_word_bits[30]; - - // Decode each word in subframe - for (uint32_t ii = 0; ii < BEIDOU_DNAV_WORDS_SUBFRAME; ii++) { - // decode the word - decode_word((ii + 1), &frame_symbols[ii * 30], dec_word_bits); - - // Save word to string format - for (uint32_t jj = 0; jj < (BEIDOU_DNAV_WORD_LENGTH_BITS); jj++) { - data_bits.push_back((dec_word_bits[jj] > 0) ? ('1') : ('0')); - } - } - - if (d_satellite.get_PRN() > 0 and d_satellite.get_PRN() < 6) { - d_nav.d2_subframe_decoder(data_bits); - } else { - d_nav.d1_subframe_decoder(data_bits); - } - - // 3. Check operation executed correctly - if (d_nav.flag_crc_test == true) { - LOG(INFO) << "BeiDou DNAV CRC correct in channel " << d_channel - << " from satellite " << d_satellite; - } else { - LOG(INFO) << "BeiDou DNAV CRC error in channel " << d_channel - << " from satellite " << d_satellite; - } - // 4. Push the new navigation data to the queues - if (d_nav.have_new_ephemeris() == true) { - // get object for this SV (mandatory) - std::shared_ptr tmp_obj = - std::make_shared(d_nav.get_ephemeris()); - this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - LOG(INFO) << "BEIDOU DNAV Ephemeris have been received in channel" - << d_channel << " from satellite " << d_satellite; - std::cout << "New BEIDOU B3I DNAV message received in channel " << d_channel - << ": ephemeris from satellite " << d_satellite << std::endl; - } - if (d_nav.have_new_utc_model() == true) { - // get object for this SV (mandatory) - std::shared_ptr tmp_obj = - std::make_shared(d_nav.get_utc_model()); - this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - LOG(INFO) << "BEIDOU DNAV UTC Model have been received in channel" - << d_channel << " from satellite " << d_satellite; - std::cout << "New BEIDOU B3I DNAV utc model message received in channel " - << d_channel << ": UTC model parameters from satellite " - << d_satellite << std::endl; - } - if (d_nav.have_new_iono() == true) { - // get object for this SV (mandatory) - std::shared_ptr tmp_obj = - std::make_shared(d_nav.get_iono()); - this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); - LOG(INFO) << "BEIDOU DNAV Iono have been received in channel" << d_channel - << " from satellite " << d_satellite; - std::cout << "New BEIDOU B3I DNAV Iono message received in channel " - << d_channel << ": Iono model parameters from satellite " - << d_satellite << std::endl; - } - if (d_nav.have_new_almanac() == true) { - // unsigned int slot_nbr = d_nav.i_alm_satellite_PRN; - // 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) << "BEIDOU DNAV Almanac have been received in channel" - << d_channel << " from satellite " << d_satellite << std::endl; - std::cout << "New BEIDOU B3I DNAV almanac received in channel " << d_channel - << " from satellite " << d_satellite << std::endl; - } -} - -void beidou_b3i_telemetry_decoder_gs::set_satellite( - const Gnss_Satellite &satellite) { - uint32_t sat_prn = 0; - d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - DLOG(INFO) << "Setting decoder Finite State Machine to satellite " - << d_satellite; - DLOG(INFO) << "Navigation Satellite set to " << d_satellite; - - // Update satellite information for DNAV decoder - sat_prn = d_satellite.get_PRN(); - d_nav.i_satellite_PRN = sat_prn; - d_nav.i_signal_type = - 5; //!< BDS: data source (0:unknown,1:B1I,2:B1Q,3:B2I,4:B2Q,5:B3I,6:B3Q) - - // Update tel dec parameters for D2 NAV Messages - if (sat_prn > 0 and sat_prn < 6) { - // Clear values from previous declaration +beidou_b3i_telemetry_decoder_gs::~beidou_b3i_telemetry_decoder_gs() +{ volk_gnsssdr_free(d_preamble_samples); volk_gnsssdr_free(d_secondary_code_symbols); volk_gnsssdr_free(d_subframe_symbols); - d_samples_per_symbol = - (BEIDOU_B3I_CODE_RATE_HZ / BEIDOU_B3I_CODE_LENGTH_CHIPS) / - BEIDOU_D2NAV_SYMBOL_RATE_SPS; - d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS; - d_samples_per_preamble = - BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS * d_samples_per_symbol; - d_secondary_code_symbols = nullptr; - d_preamble_samples = static_cast( - volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), - volk_gnsssdr_get_alignment())); - d_preamble_period_samples = - BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * d_samples_per_symbol; - - // Setting samples of preamble code - int32_t n = 0; - for (int32_t i = 0; i < d_symbols_per_preamble; i++) { - if (BEIDOU_DNAV_PREAMBLE.at(i) == '1') { - for (uint32_t j = 0; j < d_samples_per_symbol; j++) { - d_preamble_samples[n] = 1; - n++; + if (d_dump_file.is_open() == true) + { + try + { + d_dump_file.close(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Exception in destructor closing the dump file " + << ex.what(); + } } - } else { - for (uint32_t j = 0; j < d_samples_per_symbol; j++) { - d_preamble_samples[n] = -1; - n++; - } - } - } - - d_subframe_symbols = static_cast(volk_gnsssdr_malloc( - BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(double), - volk_gnsssdr_get_alignment())); - d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS * d_samples_per_symbol + - d_samples_per_preamble; - d_symbol_history.set_capacity(d_required_symbols + 1); - } } -void beidou_b3i_telemetry_decoder_gs::set_channel(int32_t channel) { - d_channel = channel; - LOG(INFO) << "Navigation channel set to " << channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) { - if (d_dump_file.is_open() == false) { - try { - d_dump_filename = "telemetry"; - d_dump_filename.append(std::to_string(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), - std::ios::out | std::ios::binary); - LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel - << " Log file: " << d_dump_filename.c_str(); - } catch (const std::ifstream::failure &e) { - LOG(WARNING) << "channel " << d_channel - << ": exception opening Beidou TLM dump file. " - << e.what(); - } - } - } + +void beidou_b3i_telemetry_decoder_gs::decode_bch15_11_01(const int32_t *bits, + int32_t *decbits) +{ + int32_t bit, err, reg[4] = {1, 1, 1, 1}; + int32_t errind[15] = {14, 13, 10, 12, 6, 9, 4, 11, 0, 5, 7, 8, 1, 3, 2}; + + for (uint32_t i = 0; i < 15; i++) + { + decbits[i] = bits[i]; + } + + for (uint32_t i = 0; i < 15; i++) + { + bit = reg[3]; + reg[3] = reg[2]; + reg[2] = reg[1]; + reg[1] = reg[0]; + reg[0] = bits[i] * bit; + reg[1] *= bit; + } + + err = errind[reg[0] + reg[1] * 2 + reg[2] * 4 + reg[3] * 8]; + + if (err > 0) + { + decbits[err - 1] *= -1; + } } + +void beidou_b3i_telemetry_decoder_gs::decode_word( + int32_t word_counter, const double *enc_word_symbols, + int32_t *dec_word_symbols) +{ + int32_t bitsbch[30], first_branch[15], second_branch[15]; + + if (word_counter == 1) + { + for (uint32_t j = 0; j < 30; j++) + { + dec_word_symbols[j] = + static_cast(enc_word_symbols[j] > 0) ? (1) : (-1); + } + } + else + { + for (uint32_t r = 0; r < 2; r++) + { + for (uint32_t c = 0; c < 15; c++) + { + bitsbch[r * 15 + c] = + static_cast(enc_word_symbols[c * 2 + r] > 0) ? (1) : (-1); + } + } + + decode_bch15_11_01(&bitsbch[0], first_branch); + decode_bch15_11_01(&bitsbch[15], second_branch); + + for (uint32_t j = 0; j < 11; j++) + { + dec_word_symbols[j] = first_branch[j]; + dec_word_symbols[j + 11] = second_branch[j]; + } + + for (uint32_t j = 0; j < 4; j++) + { + dec_word_symbols[j + 22] = first_branch[11 + j]; + dec_word_symbols[j + 26] = second_branch[11 + j]; + } + } +} + + +void beidou_b3i_telemetry_decoder_gs::decode_subframe(double *frame_symbols) +{ + // 1. Transform from symbols to bits + std::string data_bits; + int32_t dec_word_bits[30]; + + // Decode each word in subframe + for (uint32_t ii = 0; ii < BEIDOU_DNAV_WORDS_SUBFRAME; ii++) + { + // decode the word + decode_word((ii + 1), &frame_symbols[ii * 30], dec_word_bits); + + // Save word to string format + for (uint32_t jj = 0; jj < (BEIDOU_DNAV_WORD_LENGTH_BITS); jj++) + { + data_bits.push_back((dec_word_bits[jj] > 0) ? ('1') : ('0')); + } + } + + if (d_satellite.get_PRN() > 0 and d_satellite.get_PRN() < 6) + { + d_nav.d2_subframe_decoder(data_bits); + } + else + { + d_nav.d1_subframe_decoder(data_bits); + } + + // 3. Check operation executed correctly + if (d_nav.flag_crc_test == true) + { + LOG(INFO) << "BeiDou DNAV CRC correct in channel " << d_channel + << " from satellite " << d_satellite; + } + else + { + LOG(INFO) << "BeiDou DNAV CRC error in channel " << d_channel + << " from satellite " << d_satellite; + } + // 4. Push the new navigation data to the queues + if (d_nav.have_new_ephemeris() == true) + { + // get object for this SV (mandatory) + std::shared_ptr tmp_obj = + std::make_shared(d_nav.get_ephemeris()); + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + LOG(INFO) << "BEIDOU DNAV Ephemeris have been received in channel" + << d_channel << " from satellite " << d_satellite; + std::cout << "New BEIDOU B3I DNAV message received in channel " << d_channel + << ": ephemeris from satellite " << d_satellite << std::endl; + } + if (d_nav.have_new_utc_model() == true) + { + // get object for this SV (mandatory) + std::shared_ptr tmp_obj = + std::make_shared(d_nav.get_utc_model()); + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + LOG(INFO) << "BEIDOU DNAV UTC Model have been received in channel" + << d_channel << " from satellite " << d_satellite; + std::cout << "New BEIDOU B3I DNAV utc model message received in channel " + << d_channel << ": UTC model parameters from satellite " + << d_satellite << std::endl; + } + if (d_nav.have_new_iono() == true) + { + // get object for this SV (mandatory) + std::shared_ptr tmp_obj = + std::make_shared(d_nav.get_iono()); + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + LOG(INFO) << "BEIDOU DNAV Iono have been received in channel" << d_channel + << " from satellite " << d_satellite; + std::cout << "New BEIDOU B3I DNAV Iono message received in channel " + << d_channel << ": Iono model parameters from satellite " + << d_satellite << std::endl; + } + if (d_nav.have_new_almanac() == true) + { + // unsigned int slot_nbr = d_nav.i_alm_satellite_PRN; + // 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) << "BEIDOU DNAV Almanac have been received in channel" + << d_channel << " from satellite " << d_satellite << std::endl; + std::cout << "New BEIDOU B3I DNAV almanac received in channel " << d_channel + << " from satellite " << d_satellite << std::endl; + } +} + + +void beidou_b3i_telemetry_decoder_gs::set_satellite( + const Gnss_Satellite &satellite) +{ + uint32_t sat_prn = 0; + d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); + DLOG(INFO) << "Setting decoder Finite State Machine to satellite " + << d_satellite; + DLOG(INFO) << "Navigation Satellite set to " << d_satellite; + + // Update satellite information for DNAV decoder + sat_prn = d_satellite.get_PRN(); + d_nav.i_satellite_PRN = sat_prn; + d_nav.i_signal_type = 5; // BDS: data source (0:unknown,1:B1I,2:B1Q,3:B2I,4:B2Q,5:B3I,6:B3Q) + + // Update tel dec parameters for D2 NAV Messages + if (sat_prn > 0 and sat_prn < 6) + { + // Clear values from previous declaration + volk_gnsssdr_free(d_preamble_samples); + volk_gnsssdr_free(d_secondary_code_symbols); + volk_gnsssdr_free(d_subframe_symbols); + + d_samples_per_symbol = + (BEIDOU_B3I_CODE_RATE_HZ / BEIDOU_B3I_CODE_LENGTH_CHIPS) / + BEIDOU_D2NAV_SYMBOL_RATE_SPS; + d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS; + d_samples_per_preamble = + BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS * d_samples_per_symbol; + d_secondary_code_symbols = nullptr; + d_preamble_samples = static_cast( + volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), + volk_gnsssdr_get_alignment())); + d_preamble_period_samples = + BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * d_samples_per_symbol; + + // Setting samples of preamble code + int32_t n = 0; + for (int32_t i = 0; i < d_symbols_per_preamble; i++) + { + if (BEIDOU_DNAV_PREAMBLE.at(i) == '1') + { + for (uint32_t j = 0; j < d_samples_per_symbol; j++) + { + d_preamble_samples[n] = 1; + n++; + } + } + else + { + for (uint32_t j = 0; j < d_samples_per_symbol; j++) + { + d_preamble_samples[n] = -1; + n++; + } + } + } + + d_subframe_symbols = static_cast(volk_gnsssdr_malloc( + BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(double), + volk_gnsssdr_get_alignment())); + d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS * d_samples_per_symbol + + d_samples_per_preamble; + d_symbol_history.set_capacity(d_required_symbols + 1); + } +} + +void beidou_b3i_telemetry_decoder_gs::set_channel(int32_t channel) +{ + d_channel = channel; + LOG(INFO) << "Navigation channel set to " << channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename = "telemetry"; + d_dump_filename.append(std::to_string(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), + std::ios::out | std::ios::binary); + LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel + << " Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "channel " << d_channel + << ": exception opening Beidou TLM dump file. " + << e.what(); + } + } + } +} + + int beidou_b3i_telemetry_decoder_gs::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) { - int32_t corr_value = 0; - int32_t preamble_diff = 0; + gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) +{ + int32_t corr_value = 0; + int32_t preamble_diff = 0; - auto **out = reinterpret_cast( - &output_items[0]); // Get the output buffer pointer - const auto **in = reinterpret_cast( - &input_items[0]); // Get the input buffer pointer + auto **out = reinterpret_cast(&output_items[0]); // Get the output buffer pointer + const auto **in = reinterpret_cast(&input_items[0]); // Get the input buffer pointer - Gnss_Synchro current_symbol; // structure to save the synchronization - // information and send the output object to the - // next block - // 1. Copy the current tracking output - current_symbol = in[0][0]; - d_symbol_history.push_back( - current_symbol.Prompt_I); // add new symbol to the symbol queue - d_sample_counter++; // count for the processed samples - consume_each(1); + 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]; + d_symbol_history.push_back(current_symbol.Prompt_I); // add new symbol to the symbol queue + d_sample_counter++; // count for the processed samples + consume_each(1); - d_flag_preamble = false; + d_flag_preamble = false; - if (d_symbol_history.size() > d_required_symbols) { - //******* preamble correlation ******** - for (int32_t i = 0; i < d_samples_per_preamble; i++) { - if (d_symbol_history[i] < 0) // symbols clipping - { - corr_value -= d_preamble_samples[i]; - } else { - corr_value += d_preamble_samples[i]; - } - } - } - - //******* frame sync ****************** - if (d_stat == 0) // no preamble information - { - if (abs(corr_value) >= d_samples_per_preamble) { - // Record the preamble sample stamp - d_preamble_index = d_sample_counter; - LOG(INFO) << "Preamble detection for BEIDOU B3I SAT " - << this->d_satellite; - // Enter into frame pre-detection status - d_stat = 1; - } - } else if (d_stat == 1) // possible preamble lock - { - if (abs(corr_value) >= d_samples_per_preamble) { - // check preamble separation - preamble_diff = static_cast(d_sample_counter - d_preamble_index); - if (abs(preamble_diff - d_preamble_period_samples) == 0) { - // try to decode frame - LOG(INFO) << "Starting BeiDou DNAV frame decoding for BeiDou B3I SAT " - << this->d_satellite; - d_preamble_index = d_sample_counter; // record the preamble sample stamp - d_stat = 2; - } else { - if (preamble_diff > d_preamble_period_samples) { - d_stat = 0; // start again + if (d_symbol_history.size() > d_required_symbols) + { + //******* preamble correlation ******** + for (int32_t i = 0; i < d_samples_per_preamble; i++) + { + if (d_symbol_history[i] < 0) // symbols clipping + { + corr_value -= d_preamble_samples[i]; + } + else + { + corr_value += d_preamble_samples[i]; + } + } } - DLOG(INFO) << "Failed BeiDou DNAV frame decoding for BeiDou B3I SAT " - << this->d_satellite; - } - } - } else if (d_stat == 2) // preamble acquired - { - if (d_sample_counter == - d_preamble_index + static_cast(d_preamble_period_samples)) { - //******* SAMPLES TO SYMBOLS ******* - if (corr_value > 0) // normal PLL lock - { - int32_t k = 0; - for (uint32_t i = 0; i < BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; i++) { - d_subframe_symbols[i] = 0; - // integrate samples into symbols - for (uint32_t m = 0; m < d_samples_per_symbol; m++) { - if (d_satellite.get_PRN() > 0 and d_satellite.get_PRN() < 6) { - // because last symbol of the preamble is just received now! - d_subframe_symbols[i] += - d_symbol_history.at(i * d_samples_per_symbol + m); - } else { - // because last symbol of the preamble is just received now! - d_subframe_symbols[i] += - static_cast(d_secondary_code_symbols[k]) * - d_symbol_history.at(i * d_samples_per_symbol + m); - k++; - k = k % BEIDOU_B3I_SECONDARY_CODE_LENGTH; - } - } + + //******* frame sync ****************** + if (d_stat == 0) // no preamble information + { + if (abs(corr_value) >= d_samples_per_preamble) + { + // Record the preamble sample stamp + d_preamble_index = d_sample_counter; + LOG(INFO) << "Preamble detection for BEIDOU B3I SAT " + << this->d_satellite; + // Enter into frame pre-detection status + d_stat = 1; + } } - } else // 180 deg. inverted carrier phase PLL lock - { - int32_t k = 0; - for (uint32_t i = 0; i < BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; i++) { - d_subframe_symbols[i] = 0; - // integrate samples into symbols - for (uint32_t m = 0; m < d_samples_per_symbol; m++) { - if (d_satellite.get_PRN() > 0 and d_satellite.get_PRN() < 6) { - // because last symbol of the preamble is just received now! - d_subframe_symbols[i] -= - d_symbol_history.at(i * d_samples_per_symbol + m); - } else { - // because last symbol of the preamble is just received now! - d_subframe_symbols[i] -= - static_cast(d_secondary_code_symbols[k]) * - d_symbol_history.at(i * d_samples_per_symbol + m); - k++; - k = k % BEIDOU_B3I_SECONDARY_CODE_LENGTH; - } - } + else if (d_stat == 1) // possible preamble lock + { + if (abs(corr_value) >= d_samples_per_preamble) + { + // check preamble separation + preamble_diff = static_cast(d_sample_counter - d_preamble_index); + if (abs(preamble_diff - d_preamble_period_samples) == 0) + { + // try to decode frame + LOG(INFO) << "Starting BeiDou DNAV frame decoding for BeiDou B3I SAT " + << this->d_satellite; + d_preamble_index = d_sample_counter; // record the preamble sample stamp + d_stat = 2; + } + else + { + if (preamble_diff > d_preamble_period_samples) + { + d_stat = 0; // start again + } + DLOG(INFO) << "Failed BeiDou DNAV frame decoding for BeiDou B3I SAT " + << this->d_satellite; + } + } } - } + else if (d_stat == 2) // preamble acquired + { + if (d_sample_counter == + d_preamble_index + static_cast(d_preamble_period_samples)) + { + //******* SAMPLES TO SYMBOLS ******* + if (corr_value > 0) // normal PLL lock + { + int32_t k = 0; + for (uint32_t i = 0; i < BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; i++) + { + d_subframe_symbols[i] = 0; + // integrate samples into symbols + for (uint32_t m = 0; m < d_samples_per_symbol; m++) + { + if (d_satellite.get_PRN() > 0 and d_satellite.get_PRN() < 6) + { + // because last symbol of the preamble is just received now! + d_subframe_symbols[i] += + d_symbol_history.at(i * d_samples_per_symbol + m); + } + else + { + // because last symbol of the preamble is just received now! + d_subframe_symbols[i] += + static_cast(d_secondary_code_symbols[k]) * + d_symbol_history.at(i * d_samples_per_symbol + m); + k++; + k = k % BEIDOU_B3I_SECONDARY_CODE_LENGTH; + } + } + } + } + else // 180 deg. inverted carrier phase PLL lock + { + int32_t k = 0; + for (uint32_t i = 0; i < BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; i++) + { + d_subframe_symbols[i] = 0; + // integrate samples into symbols + for (uint32_t m = 0; m < d_samples_per_symbol; m++) + { + if (d_satellite.get_PRN() > 0 and d_satellite.get_PRN() < 6) + { + // because last symbol of the preamble is just received now! + d_subframe_symbols[i] -= + d_symbol_history.at(i * d_samples_per_symbol + m); + } + else + { + // because last symbol of the preamble is just received now! + d_subframe_symbols[i] -= + static_cast(d_secondary_code_symbols[k]) * + d_symbol_history.at(i * d_samples_per_symbol + m); + k++; + k = k % BEIDOU_B3I_SECONDARY_CODE_LENGTH; + } + } + } + } - // call the decoder - decode_subframe(d_subframe_symbols); + // call the decoder + decode_subframe(d_subframe_symbols); - if (d_nav.flag_crc_test == true) { - d_CRC_error_counter = 0; - d_flag_preamble = true; // valid preamble indicator (initialized to - // false every work()) - d_preamble_index = - d_sample_counter; // record the preamble sample stamp (t_P) - if (!d_flag_frame_sync) { - d_flag_frame_sync = true; - DLOG(INFO) << "BeiDou DNAV frame sync found for SAT " - << this->d_satellite; + if (d_nav.flag_crc_test == true) + { + d_CRC_error_counter = 0; + d_flag_preamble = true; // valid preamble indicator (initialized to + // false every work()) + d_preamble_index = + d_sample_counter; // record the preamble sample stamp (t_P) + if (!d_flag_frame_sync) + { + d_flag_frame_sync = true; + DLOG(INFO) << "BeiDou DNAV frame sync found for SAT " + << this->d_satellite; + } + } + else + { + d_CRC_error_counter++; + d_preamble_index = d_sample_counter; // record the preamble sample stamp + if (d_CRC_error_counter > CRC_ERROR_LIMIT) + { + LOG(INFO) << "BeiDou DNAV frame sync lost for SAT " + << this->d_satellite; + d_flag_frame_sync = false; + d_stat = 0; + flag_SOW_set = false; + } + } + } } - } else { - d_CRC_error_counter++; - d_preamble_index = d_sample_counter; // record the preamble sample stamp - if (d_CRC_error_counter > CRC_ERROR_LIMIT) { - LOG(INFO) << "BeiDou DNAV frame sync lost for SAT " - << this->d_satellite; - d_flag_frame_sync = false; - d_stat = 0; - flag_SOW_set = false; + + // UPDATE GNSS SYNCHRO DATA + // 2. Add the telemetry decoder information + if (this->d_flag_preamble == true and d_nav.flag_new_SOW_available == true) + // update TOW at the preamble instant + { + // Reporting sow as gps time of week + d_TOW_at_Preamble_ms = static_cast((d_nav.d_SOW + 14) * 1000.0); + d_TOW_at_current_symbol_ms = + d_TOW_at_Preamble_ms + static_cast((d_required_symbols + 1) * + BEIDOU_B3I_CODE_PERIOD_MS); + flag_SOW_set = true; + d_nav.flag_new_SOW_available = false; + } + else // if there is not a new preamble, we define the TOW of the current + // symbol + { + d_TOW_at_current_symbol_ms += + static_cast(BEIDOU_B3I_CODE_PERIOD_MS); } - } - } - } - // UPDATE GNSS SYNCHRO DATA - // 2. Add the telemetry decoder information - if (this->d_flag_preamble == true and d_nav.flag_new_SOW_available == true) - // update TOW at the preamble instant - { - // Reporting sow as gps time of week - d_TOW_at_Preamble_ms = static_cast((d_nav.d_SOW + 14) * 1000.0); - d_TOW_at_current_symbol_ms = - d_TOW_at_Preamble_ms + static_cast((d_required_symbols + 1) * - BEIDOU_B3I_CODE_PERIOD_MS); - flag_SOW_set = true; - d_nav.flag_new_SOW_available = false; - } else // if there is not a new preamble, we define the TOW of the current - // symbol - { - d_TOW_at_current_symbol_ms += - static_cast(BEIDOU_B3I_CODE_PERIOD_MS); - } + if (d_flag_frame_sync == true and flag_SOW_set == true) + { + current_symbol.Flag_valid_word = true; + } + else + { + current_symbol.Flag_valid_word = false; + } - if (d_flag_frame_sync == true and flag_SOW_set == true) { - current_symbol.Flag_valid_word = true; - } else { - current_symbol.Flag_valid_word = false; - } + current_symbol.PRN = this->d_satellite.get_PRN(); + current_symbol.TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; - current_symbol.PRN = this->d_satellite.get_PRN(); - current_symbol.TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; + if (d_dump == true) + { + // MULTIPLEXED FILE RECORDING - Record results to file + try + { + double tmp_double; + uint64_t tmp_ulong_int; + tmp_double = static_cast(d_TOW_at_current_symbol_ms); + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_ulong_int = current_symbol.Tracking_sample_counter; + d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(uint64_t)); + tmp_double = d_nav.d_SOW; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_ulong_int = static_cast(d_required_symbols); + d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(uint64_t)); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "Exception writing observables dump file " << e.what(); + } + } - if (d_dump == true) { - // MULTIPLEXED FILE RECORDING - Record results to file - try { - double tmp_double; - uint64_t tmp_ulong_int; - tmp_double = static_cast(d_TOW_at_current_symbol_ms); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_ulong_int = current_symbol.Tracking_sample_counter; - d_dump_file.write(reinterpret_cast(&tmp_ulong_int), - sizeof(uint64_t)); - tmp_double = d_nav.d_SOW; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_ulong_int = static_cast(d_required_symbols); - d_dump_file.write(reinterpret_cast(&tmp_ulong_int), - sizeof(uint64_t)); - } catch (const std::ifstream::failure &e) { - LOG(WARNING) << "Exception writing observables dump file " << e.what(); - } - } + // 3. Make the output (copy the object contents to the GNURadio reserved memory) + *out[0] = current_symbol; - // 3. Make the output (copy the object contents to the GNURadio reserved - // memory) - *out[0] = current_symbol; - - return 1; + return 1; } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.h index 5f05b213d..746e68895 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.h @@ -34,11 +34,11 @@ #include "beidou_dnav_navigation_message.h" #include "gnss_satellite.h" #include -#include // for boost::shared_ptr +#include // for boost::shared_ptr +#include // for block +#include // for gr_vector_const_void_star #include #include -#include // for block -#include // for gr_vector_const_void_star #include class beidou_b3i_telemetry_decoder_gs; @@ -48,73 +48,74 @@ using beidou_b3i_telemetry_decoder_gs_sptr = beidou_b3i_telemetry_decoder_gs_sptr beidou_b3i_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, - bool dump); + bool dump); /*! * \brief This class implements a block that decodes the BeiDou DNAV data. * */ -class beidou_b3i_telemetry_decoder_gs : public gr::block { +class beidou_b3i_telemetry_decoder_gs : public gr::block +{ public: - ~beidou_b3i_telemetry_decoder_gs(); //!< Class destructor - void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int channel); //!< Set receiver's channel + ~beidou_b3i_telemetry_decoder_gs(); //!< Class destructor + void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN + void set_channel(int channel); //!< Set receiver's channel - /*! - * \brief This is where all signal processing takes place - */ - int general_work(int noutput_items, gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); + /*! + * \brief This is where all signal processing takes place + */ + 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 beidou_b3i_telemetry_decoder_gs_sptr - beidou_b3i_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, - bool dump); - beidou_b3i_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump); + friend beidou_b3i_telemetry_decoder_gs_sptr + beidou_b3i_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, + bool dump); + beidou_b3i_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump); - void decode_subframe(double *symbols); - void decode_word(int32_t word_counter, const double *enc_word_symbols, - int32_t *dec_word_symbols); - void decode_bch15_11_01(const int32_t *bits, int32_t *decbits); + void decode_subframe(double *symbols); + void decode_word(int32_t word_counter, const double *enc_word_symbols, + int32_t *dec_word_symbols); + void decode_bch15_11_01(const int32_t *bits, int32_t *decbits); - // Preamble decoding - int32_t *d_preamble_samples; - int32_t *d_secondary_code_symbols; - uint32_t d_samples_per_symbol; - int32_t d_symbols_per_preamble; - int32_t d_samples_per_preamble; - int32_t d_preamble_period_samples; - double *d_subframe_symbols; - uint32_t d_required_symbols; + // Preamble decoding + int32_t *d_preamble_samples; + int32_t *d_secondary_code_symbols; + uint32_t d_samples_per_symbol; + int32_t d_symbols_per_preamble; + int32_t d_samples_per_preamble; + int32_t d_preamble_period_samples; + double *d_subframe_symbols; + uint32_t d_required_symbols; - // Storage for incoming data - boost::circular_buffer d_symbol_history; + // Storage for incoming data + boost::circular_buffer 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 - uint32_t d_stat; // Status of decoder - bool d_flag_frame_sync; // Indicate when a frame sync is achieved - bool d_flag_preamble; // Flag indicating when preamble was found - int32_t d_CRC_error_counter; // Number of failed CRC operations - bool flag_SOW_set; // Indicates when time of week is set + // 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 + uint32_t d_stat; // Status of decoder + bool d_flag_frame_sync; // Indicate when a frame sync is achieved + bool d_flag_preamble; // Flag indicating when preamble was found + int32_t d_CRC_error_counter; // Number of failed CRC operations + bool flag_SOW_set; // Indicates when time of week is set - //!< Navigation Message variable - Beidou_Dnav_Navigation_Message d_nav; + // Navigation Message variable + Beidou_Dnav_Navigation_Message d_nav; - //!< Values to populate gnss synchronization structure - uint32_t d_TOW_at_Preamble_ms; - uint32_t d_TOW_at_current_symbol_ms; - bool Flag_valid_word; + // Values to populate gnss synchronization structure + uint32_t d_TOW_at_Preamble_ms; + uint32_t d_TOW_at_current_symbol_ms; + bool Flag_valid_word; - //!< Satellite Information and logging capacity - Gnss_Satellite d_satellite; - int32_t d_channel; - bool d_dump; - std::string d_dump_filename; - std::ofstream d_dump_file; + // Satellite Information and logging capacity + Gnss_Satellite d_satellite; + int32_t d_channel; + bool d_dump; + std::string d_dump_filename; + std::ofstream d_dump_file; }; #endif diff --git a/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.cc index 18c7b8e4e..2deaefce1 100644 --- a/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.cc @@ -11,7 +11,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -34,13 +34,13 @@ * ------------------------------------------------------------------------- */ -#include "dll_pll_conf.h" #include "beidou_b3i_dll_pll_tracking.h" -#include "configuration_interface.h" -#include "gnss_sdr_flags.h" -#include "display.h" -#include #include "Beidou_B3I.h" +#include "configuration_interface.h" +#include "display.h" +#include "dll_pll_conf.h" +#include "gnss_sdr_flags.h" +#include using google::LogMessage; @@ -48,7 +48,7 @@ BeidouB3iDllPllTracking::BeidouB3iDllPllTracking( ConfigurationInterface* configuration, std::string role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { - Dll_Pll_Conf trk_param = Dll_Pll_Conf(); + Dll_Pll_Conf trk_param = Dll_Pll_Conf(); DLOG(INFO) << "role " << role; //################# CONFIGURATION PARAMETERS ######################## std::string default_item_type = "gr_complex"; @@ -151,6 +151,7 @@ void BeidouB3iDllPllTracking::start_tracking() tracking_->start_tracking(); } + void BeidouB3iDllPllTracking::stop_tracking() { tracking_->stop_tracking(); diff --git a/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.h b/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.h index 746b8d0dd..c3dda0777 100644 --- a/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.h +++ b/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.h @@ -11,7 +11,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -37,8 +37,8 @@ #ifndef GNSS_SDR_BEIDOU_B3I_DLL_PLL_TRACKING_H_ #define GNSS_SDR_BEIDOU_B3I_DLL_PLL_TRACKING_H_ -#include "tracking_interface.h" #include "dll_pll_veml_tracking.h" +#include "tracking_interface.h" #include class ConfigurationInterface; diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc index bc8b5f9ec..e5c85a5ba 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc @@ -43,8 +43,8 @@ #include "Galileo_E1.h" #include "Galileo_E5a.h" #include "MATH_CONSTANTS.h" -#include "beidou_b3i_signal_processing.h" #include "beidou_b1i_signal_processing.h" +#include "beidou_b3i_signal_processing.h" #include "galileo_e1_signal_processing.h" #include "galileo_e5_signal_processing.h" #include "gnss_satellite.h" @@ -302,20 +302,20 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl d_secondary_code_string = const_cast(&BEIDOU_B1I_SECONDARY_CODE_STR); } else if (signal_type == "B3") - { - // GEO Satellites use different secondary code - d_signal_carrier_freq = BEIDOU_B3I_FREQ_HZ; - d_code_period = BEIDOU_B3I_CODE_PERIOD; - d_code_chip_rate = BEIDOU_B3I_CODE_RATE_HZ; - d_code_length_chips = static_cast(BEIDOU_B3I_CODE_LENGTH_CHIPS); - d_symbols_per_bit = BEIDOU_B3I_TELEMETRY_SYMBOLS_PER_BIT; - d_correlation_length_ms = 1; - d_code_samples_per_chip = 1; - d_secondary = true; - trk_parameters.track_pilot = false; - interchange_iq = false; - d_secondary_code_length = static_cast(BEIDOU_B3I_SECONDARY_CODE_LENGTH); - d_secondary_code_string = const_cast(&BEIDOU_B3I_SECONDARY_CODE_STR); + { + // GEO Satellites use different secondary code + d_signal_carrier_freq = BEIDOU_B3I_FREQ_HZ; + d_code_period = BEIDOU_B3I_CODE_PERIOD; + d_code_chip_rate = BEIDOU_B3I_CODE_RATE_HZ; + d_code_length_chips = static_cast(BEIDOU_B3I_CODE_LENGTH_CHIPS); + d_symbols_per_bit = BEIDOU_B3I_TELEMETRY_SYMBOLS_PER_BIT; + d_correlation_length_ms = 1; + d_code_samples_per_chip = 1; + d_secondary = true; + trk_parameters.track_pilot = false; + interchange_iq = false; + d_secondary_code_length = static_cast(BEIDOU_B3I_SECONDARY_CODE_LENGTH); + d_secondary_code_string = const_cast(&BEIDOU_B3I_SECONDARY_CODE_STR); } else { @@ -616,47 +616,46 @@ void dll_pll_veml_tracking::start_tracking() d_preambles_symbols = static_cast(volk_gnsssdr_malloc(22 * sizeof(int32_t), volk_gnsssdr_get_alignment())); int32_t n = 0; uint32_t preambles_bits[BEIDOU_B1I_PREAMBLE_LENGTH_BITS] = {1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0}; - for (uint32_t preambles_bit : preambles_bits) - { - for (uint32_t j = 0; j < d_symbols_per_bit; j++) - { - if (preambles_bit == 1) - { - d_preambles_symbols[n] = 1; - } - else - { - d_preambles_symbols[n] = -1; - } - n++; - } - } - d_symbol_history.resize(22); // Change fixed buffer size - d_symbol_history.clear(); + for (uint32_t preambles_bit : preambles_bits) + { + for (uint32_t j = 0; j < d_symbols_per_bit; j++) + { + if (preambles_bit == 1) + { + d_preambles_symbols[n] = 1; + } + else + { + d_preambles_symbols[n] = -1; + } + n++; + } + } + d_symbol_history.resize(22); // Change fixed buffer size + d_symbol_history.clear(); } - } else if (systemName == "Beidou" and signal_type == "B3") { beidou_b3i_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN, 0); // Update secondary code settings for geo satellites - if(d_acquisition_gnss_synchro->PRN > 0 and d_acquisition_gnss_synchro->PRN < 6) + if (d_acquisition_gnss_synchro->PRN > 0 and d_acquisition_gnss_synchro->PRN < 6) { - d_symbols_per_bit = 2; - d_correlation_length_ms = 1; - d_code_samples_per_chip = 1; - d_secondary = false; - trk_parameters.track_pilot = false; - interchange_iq = false; - d_secondary_code_length = 0; - d_secondary_code_string = const_cast(&BEIDOU_B3I_D2_SECONDARY_CODE_STR); + d_symbols_per_bit = 2; + d_correlation_length_ms = 1; + d_code_samples_per_chip = 1; + d_secondary = false; + trk_parameters.track_pilot = false; + interchange_iq = false; + d_secondary_code_length = 0; + d_secondary_code_string = const_cast(&BEIDOU_B3I_D2_SECONDARY_CODE_STR); - // preamble bits to sampled symbols - d_preamble_length_symbols = 22; - d_preambles_symbols = static_cast(volk_gnsssdr_malloc(22 * sizeof(int32_t), volk_gnsssdr_get_alignment())); - int32_t n = 0; - uint32_t preambles_bits[BEIDOU_B3I_PREAMBLE_LENGTH_BITS] = {1,1,1,0,0,0,1,0,0,1,0}; + // preamble bits to sampled symbols + d_preamble_length_symbols = 22; + d_preambles_symbols = static_cast(volk_gnsssdr_malloc(22 * sizeof(int32_t), volk_gnsssdr_get_alignment())); + int32_t n = 0; + uint32_t preambles_bits[BEIDOU_B3I_PREAMBLE_LENGTH_BITS] = {1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0}; for (uint32_t preambles_bit : preambles_bits) { for (int32_t j = 0; j < d_symbols_per_bit; j++) @@ -740,9 +739,9 @@ dll_pll_veml_tracking::~dll_pll_veml_tracking() if (d_dump_mat) { try - { - save_matfile(); - } + { + save_matfile(); + } catch (const std::exception &ex) { LOG(WARNING) << "Error saving the .mat file: " << ex.what(); @@ -1061,11 +1060,11 @@ void dll_pll_veml_tracking::save_correlation_results() // If tracking pilot, disable Costas loop if (trk_parameters.track_pilot) { - d_cloop = false; + d_cloop = false; } else { - d_cloop = true; + d_cloop = true; } } diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index edcb8759b..a5c051c3a 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -1117,19 +1117,19 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) break; case evBDS_B1: - available_BDS_B1_signals_.remove(gs); - available_BDS_B1_signals_.push_back(gs); - break; + available_BDS_B1_signals_.remove(gs); + available_BDS_B1_signals_.push_back(gs); + break; case evBDS_B3: - available_BDS_B3_signals_.remove(gs); - available_BDS_B3_signals_.push_back(gs); + available_BDS_B3_signals_.remove(gs); + available_BDS_B3_signals_.push_back(gs); break; default: LOG(ERROR) << "This should not happen :-("; break; - } + } } channels_state_[who] = 0; acq_channels_count_--; @@ -1728,8 +1728,8 @@ void GNSSFlowgraph::set_signals_list() std::set available_beidou_prn = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 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}; + 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}; std::string sv_list = configuration_->property("Galileo.prns", std::string("")); @@ -1796,7 +1796,7 @@ void GNSSFlowgraph::set_signals_list() } sv_list = configuration_->property("Beidou.prns", std::string("")); - + if (sv_list.length() > 0) { // Reset the available prns: @@ -1928,7 +1928,6 @@ void GNSSFlowgraph::set_signals_list() available_BDS_B1_signals_.push_back(Gnss_Signal( Gnss_Satellite(std::string("Beidou"), *available_gnss_prn_iter), std::string("B1"))); - } } @@ -1944,7 +1943,6 @@ void GNSSFlowgraph::set_signals_list() available_BDS_B3_signals_.push_back(Gnss_Signal( Gnss_Satellite(std::string("Beidou"), *available_gnss_prn_iter), std::string("B3"))); - } } } @@ -1989,7 +1987,7 @@ Gnss_Signal GNSSFlowgraph::search_next_signal(const std::string& searched_signal if (!pop) { available_GPS_1C_signals_.push_back(result); - } + } if (tracked) { if ((configuration_->property("Channels_2S.count", 0) > 0) or (configuration_->property("Channels_L5.count", 0) > 0)) @@ -2206,19 +2204,19 @@ Gnss_Signal GNSSFlowgraph::search_next_signal(const std::string& searched_signal } if (tracked) { - if (configuration_->property("Channels_B3.count", 0) > 0) - { - for (unsigned int ch = 0; ch < channels_count_; ch++) - { - if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "2G")) untracked_satellite = false; - } - if (untracked_satellite) - { - Gnss_Signal gs = Gnss_Signal(result.get_satellite(), "B3"); - available_BDS_B3_signals_.remove(gs); - available_BDS_B3_signals_.push_front(gs); - } - } + if (configuration_->property("Channels_B3.count", 0) > 0) + { + for (unsigned int ch = 0; ch < channels_count_; ch++) + { + if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "2G")) untracked_satellite = false; + } + if (untracked_satellite) + { + Gnss_Signal gs = Gnss_Signal(result.get_satellite(), "B3"); + available_BDS_B3_signals_.remove(gs); + available_BDS_B3_signals_.push_front(gs); + } + } } break; @@ -2231,27 +2229,27 @@ Gnss_Signal GNSSFlowgraph::search_next_signal(const std::string& searched_signal } if (tracked) { - if (configuration_->property("Channels_B1.count", 0) > 0) - { - for (unsigned int ch = 0; ch < channels_count_; ch++) - { - if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "2G")) untracked_satellite = false; - } - if (untracked_satellite) - { - Gnss_Signal gs = Gnss_Signal(result.get_satellite(), "B1"); - available_BDS_B1_signals_.remove(gs); - available_BDS_B1_signals_.push_front(gs); - } - } + if (configuration_->property("Channels_B1.count", 0) > 0) + { + for (unsigned int ch = 0; ch < channels_count_; ch++) + { + if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "2G")) untracked_satellite = false; + } + if (untracked_satellite) + { + Gnss_Signal gs = Gnss_Signal(result.get_satellite(), "B1"); + available_BDS_B1_signals_.remove(gs); + available_BDS_B1_signals_.push_front(gs); + } + } } break; default: LOG(ERROR) << "This should not happen :-("; result = available_GPS_1C_signals_.front(); - if (pop) - { + if (pop) + { available_GPS_1C_signals_.pop_front(); } break; diff --git a/src/core/system_parameters/Beidou_B3I.h b/src/core/system_parameters/Beidou_B3I.h index 76f208997..13e4aa2ba 100644 --- a/src/core/system_parameters/Beidou_B3I.h +++ b/src/core/system_parameters/Beidou_B3I.h @@ -4,7 +4,7 @@ * \author Damian Miralles, 2019. dmiralles2009@gmail.com * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -31,27 +31,27 @@ #ifndef GNSS_SDR_BEIDOU_B3I_H_ #define GNSS_SDR_BEIDOU_B3I_H_ -#include -#include -#include // std::pair #include "MATH_CONSTANTS.h" +#include +#include // std::pair +#include // carrier and code frequencies -const double BEIDOU_B3I_FREQ_HZ = 1.268520e9; //!< BeiDou B3I [Hz] -const double BEIDOU_B3I_CODE_RATE_HZ = 10.23e6; //!< BeiDou B3I code rate [chips/s] -const double BEIDOU_B3I_CODE_LENGTH_CHIPS = 10230.0; //!< BeiDou B3I code length [chips] -const double BEIDOU_B3I_CODE_PERIOD = 0.001; //!< BeiDou B3I code period [seconds] -const uint32_t BEIDOU_B3I_CODE_PERIOD_MS = 1; //!< GPS L1 C/A code period [ms] -const int32_t BEIDOU_B3I_SECONDARY_CODE_LENGTH = 20; -const std::string BEIDOU_B3I_SECONDARY_CODE = "00000100110101001110"; -const std::string BEIDOU_B3I_SECONDARY_CODE_STR = "00000100110101001110"; -const std::string BEIDOU_B3I_D2_SECONDARY_CODE_STR = "00"; -const uint32_t BEIDOU_B3I_PREAMBLE_LENGTH_BITS = 11; -const uint32_t BEIDOU_B3I_PREAMBLE_LENGTH_SYMBOLS = 220; // ************** -const double BEIDOU_B3I_PREAMBLE_DURATION_S = 0.220; -const int32_t BEIDOU_B3I_PREAMBLE_DURATION_MS = 220; -const int32_t BEIDOU_B3I_TELEMETRY_RATE_BITS_SECOND = 50; //!< D1 NAV message bit rate [bits/s] -const int32_t BEIDOU_B3I_TELEMETRY_SYMBOLS_PER_BIT = 20; // ************* -const int32_t BEIDOU_B3I_TELEMETRY_RATE_SYMBOLS_SECOND = BEIDOU_B3I_TELEMETRY_RATE_BITS_SECOND*BEIDOU_B3I_TELEMETRY_SYMBOLS_PER_BIT; //************!< NAV message bit rate [symbols/s] +const double BEIDOU_B3I_FREQ_HZ = 1.268520e9; //!< BeiDou B3I [Hz] +const double BEIDOU_B3I_CODE_RATE_HZ = 10.23e6; //!< BeiDou B3I code rate [chips/s] +const double BEIDOU_B3I_CODE_LENGTH_CHIPS = 10230.0; //!< BeiDou B3I code length [chips] +const double BEIDOU_B3I_CODE_PERIOD = 0.001; //!< BeiDou B3I code period [seconds] +const uint32_t BEIDOU_B3I_CODE_PERIOD_MS = 1; //!< GPS L1 C/A code period [ms] +const int32_t BEIDOU_B3I_SECONDARY_CODE_LENGTH = 20; +const std::string BEIDOU_B3I_SECONDARY_CODE = "00000100110101001110"; +const std::string BEIDOU_B3I_SECONDARY_CODE_STR = "00000100110101001110"; +const std::string BEIDOU_B3I_D2_SECONDARY_CODE_STR = "00"; +const uint32_t BEIDOU_B3I_PREAMBLE_LENGTH_BITS = 11; +const uint32_t BEIDOU_B3I_PREAMBLE_LENGTH_SYMBOLS = 220; // ************** +const double BEIDOU_B3I_PREAMBLE_DURATION_S = 0.220; +const int32_t BEIDOU_B3I_PREAMBLE_DURATION_MS = 220; +const int32_t BEIDOU_B3I_TELEMETRY_RATE_BITS_SECOND = 50; //!< D1 NAV message bit rate [bits/s] +const int32_t BEIDOU_B3I_TELEMETRY_SYMBOLS_PER_BIT = 20; // ************* +const int32_t BEIDOU_B3I_TELEMETRY_RATE_SYMBOLS_SECOND = BEIDOU_B3I_TELEMETRY_RATE_BITS_SECOND * BEIDOU_B3I_TELEMETRY_SYMBOLS_PER_BIT; //************!< NAV message bit rate [symbols/s] #endif /* GNSS_SDR_BEIDOU_B3I_H_ */ diff --git a/src/core/system_parameters/Beidou_DNAV.h b/src/core/system_parameters/Beidou_DNAV.h index e62acbc26..fdb496709 100644 --- a/src/core/system_parameters/Beidou_DNAV.h +++ b/src/core/system_parameters/Beidou_DNAV.h @@ -31,17 +31,17 @@ #ifndef GNSS_SDR_BEIDOU_DNAV_H_ #define GNSS_SDR_BEIDOU_DNAV_H_ -#include +#include "MATH_CONSTANTS.h" #include #include -#include "MATH_CONSTANTS.h" +#include -const double BEIDOU_DNAV_C_m_s = 299792458.0; //!< The speed of light, [m/s] -const double BEIDOU_DNAV_C_m_ms = 299792.4580; //!< The speed of light, [m/ms] -const double BEIDOU_DNAV_PI = 3.1415926535898; //!< Pi -const double BEIDOU_DNAV_TWO_PI = 6.283185307179586;//!< 2Pi -const int32_t BEIDOU_DNAV_PREAMBLE_LENGTH_BITS = 11; -const int32_t BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS = 11; // ************** +const double BEIDOU_DNAV_C_m_s = 299792458.0; //!< The speed of light, [m/s] +const double BEIDOU_DNAV_C_m_ms = 299792.4580; //!< The speed of light, [m/ms] +const double BEIDOU_DNAV_PI = 3.1415926535898; //!< Pi +const double BEIDOU_DNAV_TWO_PI = 6.283185307179586; //!< 2Pi +const int32_t BEIDOU_DNAV_PREAMBLE_LENGTH_BITS = 11; +const int32_t BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS = 11; // ************** const double BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS = 300; const double BEIDOU_DNAV_SUBFRAME_SYMBOLS = 300; const double BEIDOU_DNAV_DATA_BITS = 300; @@ -53,10 +53,10 @@ const std::string BEIDOU_DNAV_PREAMBLE = "11100010010"; // BEIDOU D1 NAVIGATION MESSAGE STRUCTURE // GENERAL -const std::vector > D1_PRE( { {1,11} } ); -const std::vector > D1_FRAID( { {16,3} } ); -const std::vector > D1_SOW( { {19,8},{31,12} } ); -const std::vector > D1_PNUM( { {44,7} } ); +const std::vector > D1_PRE({{1, 11}}); +const std::vector > D1_FRAID({{16, 3}}); +const std::vector > D1_SOW({{19, 8}, {31, 12}}); +const std::vector > D1_PNUM({{44, 7}}); // DNAV SCALE FACTORS // EPH @@ -74,220 +74,220 @@ const double D1_BETA3_LSB = TWO_P16; const double D1_A2_LSB = TWO_N66; const double D1_A0_LSB = TWO_N33; const double D1_A1_LSB = TWO_N50; -const double D1_DELTA_N_LSB = PI_TWO_N43; +const double D1_DELTA_N_LSB = PI_TWO_N43; const double D1_CUC_LSB = TWO_N31; -const double D1_M0_LSB = PI_TWO_N31; +const double D1_M0_LSB = PI_TWO_N31; const double D1_E_LSB = TWO_N33; const double D1_CUS_LSB = TWO_N31; const double D1_CRC_LSB = TWO_N6; const double D1_CRS_LSB = TWO_N6; const double D1_SQRT_A_LSB = TWO_N19; const double D1_TOE_LSB = TWO_P3; -const double D1_I0_LSB = PI_TWO_N31; +const double D1_I0_LSB = PI_TWO_N31; const double D1_CIC_LSB = TWO_N31; -const double D1_OMEGA_DOT_LSB = PI_TWO_N43; +const double D1_OMEGA_DOT_LSB = PI_TWO_N43; const double D1_CIS_LSB = TWO_N31; -const double D1_IDOT_LSB = PI_TWO_N43; -const double D1_OMEGA0_LSB = PI_TWO_N31; -const double D1_OMEGA_LSB = PI_TWO_N31; +const double D1_IDOT_LSB = PI_TWO_N43; +const double D1_OMEGA0_LSB = PI_TWO_N31; +const double D1_OMEGA_LSB = PI_TWO_N31; //ALM const double D1_SQRT_A_ALMANAC_LSB = TWO_N11; const double D1_A1_ALMANAC_LSB = TWO_N38; const double D1_A0_ALMANAC_LSB = TWO_N20; -const double D1_OMEGA0_ALMANAC_LSB = PI_TWO_N23; +const double D1_OMEGA0_ALMANAC_LSB = PI_TWO_N23; const double D1_E_ALMANAC_LSB = TWO_N21; -const double D1_DELTA_I_LSB = PI_TWO_N19; +const double D1_DELTA_I_LSB = PI_TWO_N19; const double D1_TOA_LSB = TWO_P12; -const double D1_OMEGA_DOT_ALMANAC_LSB = PI_TWO_N38; -const double D1_OMEGA_ALMANAC_LSB = PI_TWO_N23; -const double D1_M0_ALMANAC_LSB = PI_TWO_N23; -const double D1_A0GPS_LSB = 0.1e-9; -const double D1_A1GPS_LSB = 0.1e-9; -const double D1_A0GAL_LSB = 0.1e-9; -const double D1_A1GAL_LSB = 0.1e-9; -const double D1_A0GLO_LSB = 0.1e-9; -const double D1_A1GLO_LSB = 0.1e-9; -const double D1_A0UTC_LSB = TWO_N30; -const double D1_A1UTC_LSB = TWO_N50; +const double D1_OMEGA_DOT_ALMANAC_LSB = PI_TWO_N38; +const double D1_OMEGA_ALMANAC_LSB = PI_TWO_N23; +const double D1_M0_ALMANAC_LSB = PI_TWO_N23; +const double D1_A0GPS_LSB = 0.1e-9; +const double D1_A1GPS_LSB = 0.1e-9; +const double D1_A0GAL_LSB = 0.1e-9; +const double D1_A1GAL_LSB = 0.1e-9; +const double D1_A0GLO_LSB = 0.1e-9; +const double D1_A1GLO_LSB = 0.1e-9; +const double D1_A0UTC_LSB = TWO_N30; +const double D1_A1UTC_LSB = TWO_N50; // SUBFRAME 1 -const std::vector > D1_SAT_H1( { {43,1} } ); -const std::vector > D1_AODC( { {44,5} } ); -const std::vector > D1_URAI( { {49,4} } ); -const std::vector > D1_WN( { {61,13} } ); -const std::vector > D1_TOC( { {74,9},{91,8} } ); -const std::vector > D1_TGD1( { {99,10} } ); -const std::vector > D1_TGD2( { {121,6} } ); -const std::vector > D1_ALPHA0( { {127,8} } ); -const std::vector > D1_ALPHA1( { {135,8} } ); -const std::vector > D1_ALPHA2( { {151,8} } ); -const std::vector > D1_ALPHA3( { {159,8} } ); -const std::vector > D1_BETA0( { {167,6}, {181,2} } ); -const std::vector > D1_BETA1( { {183,8} } ); -const std::vector > D1_BETA2( { {191,8} } ); -const std::vector > D1_BETA3( { {199,4},{211,4} } ); -const std::vector > D1_A2( { {215,11} } ); -const std::vector > D1_A0( { {226,7},{241,17} } ); -const std::vector > D1_A1( { {258,5},{271,17} } ); -const std::vector > D1_AODE( { {288,5} } ); +const std::vector > D1_SAT_H1({{43, 1}}); +const std::vector > D1_AODC({{44, 5}}); +const std::vector > D1_URAI({{49, 4}}); +const std::vector > D1_WN({{61, 13}}); +const std::vector > D1_TOC({{74, 9}, {91, 8}}); +const std::vector > D1_TGD1({{99, 10}}); +const std::vector > D1_TGD2({{121, 6}}); +const std::vector > D1_ALPHA0({{127, 8}}); +const std::vector > D1_ALPHA1({{135, 8}}); +const std::vector > D1_ALPHA2({{151, 8}}); +const std::vector > D1_ALPHA3({{159, 8}}); +const std::vector > D1_BETA0({{167, 6}, {181, 2}}); +const std::vector > D1_BETA1({{183, 8}}); +const std::vector > D1_BETA2({{191, 8}}); +const std::vector > D1_BETA3({{199, 4}, {211, 4}}); +const std::vector > D1_A2({{215, 11}}); +const std::vector > D1_A0({{226, 7}, {241, 17}}); +const std::vector > D1_A1({{258, 5}, {271, 17}}); +const std::vector > D1_AODE({{288, 5}}); //SUBFRAME 2 -const std::vector > D1_DELTA_N( { {43,10},{61,6} } ); -const std::vector > D1_CUC( { {67,16},{91,2} } ); -const std::vector > D1_M0( { {93,20}, {121,12} } ); -const std::vector > D1_E( { {133,10},{151,22} } ); -const std::vector > D1_CUS( { {181,18} } ); -const std::vector > D1_CRC( { {199,4},{211,14} } ); -const std::vector > D1_CRS( { {225,8},{241,10} } ); -const std::vector > D1_SQRT_A( { {251,12},{271,20} } ); -const std::vector > D1_TOE_SF2( { {291,2} } ); +const std::vector > D1_DELTA_N({{43, 10}, {61, 6}}); +const std::vector > D1_CUC({{67, 16}, {91, 2}}); +const std::vector > D1_M0({{93, 20}, {121, 12}}); +const std::vector > D1_E({{133, 10}, {151, 22}}); +const std::vector > D1_CUS({{181, 18}}); +const std::vector > D1_CRC({{199, 4}, {211, 14}}); +const std::vector > D1_CRS({{225, 8}, {241, 10}}); +const std::vector > D1_SQRT_A({{251, 12}, {271, 20}}); +const std::vector > D1_TOE_SF2({{291, 2}}); //SUBFRAME 3 -const std::vector > D1_TOE_SF3( { {43,10},{61,5} } ); -const std::vector > D1_I0( { {66,17},{91,15} } ); -const std::vector > D1_CIC( { {106,7},{121,11} } ); -const std::vector > D1_OMEGA_DOT( { {132,11},{151,13} } ); -const std::vector > D1_CIS( { {164,9},{181,9} } ); -const std::vector > D1_IDOT( { {190,13},{211,1} } ); -const std::vector > D1_OMEGA0( { {212,21},{241,11} } ); -const std::vector > D1_OMEGA( { {252,11},{271,21} } ); +const std::vector > D1_TOE_SF3({{43, 10}, {61, 5}}); +const std::vector > D1_I0({{66, 17}, {91, 15}}); +const std::vector > D1_CIC({{106, 7}, {121, 11}}); +const std::vector > D1_OMEGA_DOT({{132, 11}, {151, 13}}); +const std::vector > D1_CIS({{164, 9}, {181, 9}}); +const std::vector > D1_IDOT({{190, 13}, {211, 1}}); +const std::vector > D1_OMEGA0({{212, 21}, {241, 11}}); +const std::vector > D1_OMEGA({{252, 11}, {271, 21}}); //SUBFRAME 4 AND PAGES 1 THROUGH 6 IN SUBFRAME 5 -const std::vector > D1_SQRT_A_ALMANAC( { {51,2},{61,22} } ); -const std::vector > D1_A1_ALMANAC( { {91,11} } ); -const std::vector > D1_A0_ALMANAC( { {102,11} } ); -const std::vector > D1_OMEGA0_ALMANAC( { {121,22},{151,2} } ); -const std::vector > D1_E_ALMANAC( { {153,17} } ); -const std::vector > D1_DELTA_I( { {170,3},{181,13} } ); -const std::vector > D1_TOA( { {194,8} } ); -const std::vector > D1_OMEGA_DOT_ALMANAC( { {202,1}, {211,16} } ); -const std::vector > D1_OMEGA_ALMANAC( { {227,6},{241,18} } ); -const std::vector > D1_M0_ALMANAC( { {259,4},{271,20} } ); +const std::vector > D1_SQRT_A_ALMANAC({{51, 2}, {61, 22}}); +const std::vector > D1_A1_ALMANAC({{91, 11}}); +const std::vector > D1_A0_ALMANAC({{102, 11}}); +const std::vector > D1_OMEGA0_ALMANAC({{121, 22}, {151, 2}}); +const std::vector > D1_E_ALMANAC({{153, 17}}); +const std::vector > D1_DELTA_I({{170, 3}, {181, 13}}); +const std::vector > D1_TOA({{194, 8}}); +const std::vector > D1_OMEGA_DOT_ALMANAC({{202, 1}, {211, 16}}); +const std::vector > D1_OMEGA_ALMANAC({{227, 6}, {241, 18}}); +const std::vector > D1_M0_ALMANAC({{259, 4}, {271, 20}}); //SUBFRAME 5 PAGE 7 -const std::vector > D1_HEA1( { {51,2},{61,7} } ); -const std::vector > D1_HEA2( { {68,9} } ); -const std::vector > D1_HEA3( { {77,6},{91,3} } ); -const std::vector > D1_HEA4( { {94,9} } ); -const std::vector > D1_HEA5( { {103,9} } ); -const std::vector > D1_HEA6( { {112,1},{121,8} } ); -const std::vector > D1_HEA7( { {129,9} } ); -const std::vector > D1_HEA8( { {138,5},{151,4} } ); -const std::vector > D1_HEA9( { {155,9} } ); -const std::vector > D1_HEA10( { {164,9} } ); -const std::vector > D1_HEA11( { {181,9} } ); -const std::vector > D1_HEA12( { {190,9} } ); -const std::vector > D1_HEA13( { {199,4},{211,5} } ); -const std::vector > D1_HEA14( { {216,9} } ); -const std::vector > D1_HEA15( { {225,8},{241,1} } ); -const std::vector > D1_HEA16( { {242,9} } ); -const std::vector > D1_HEA17( { {251,9} } ); -const std::vector > D1_HEA18( { {260,3},{271,6} } ); -const std::vector > D1_HEA19( { {277,9} } ); +const std::vector > D1_HEA1({{51, 2}, {61, 7}}); +const std::vector > D1_HEA2({{68, 9}}); +const std::vector > D1_HEA3({{77, 6}, {91, 3}}); +const std::vector > D1_HEA4({{94, 9}}); +const std::vector > D1_HEA5({{103, 9}}); +const std::vector > D1_HEA6({{112, 1}, {121, 8}}); +const std::vector > D1_HEA7({{129, 9}}); +const std::vector > D1_HEA8({{138, 5}, {151, 4}}); +const std::vector > D1_HEA9({{155, 9}}); +const std::vector > D1_HEA10({{164, 9}}); +const std::vector > D1_HEA11({{181, 9}}); +const std::vector > D1_HEA12({{190, 9}}); +const std::vector > D1_HEA13({{199, 4}, {211, 5}}); +const std::vector > D1_HEA14({{216, 9}}); +const std::vector > D1_HEA15({{225, 8}, {241, 1}}); +const std::vector > D1_HEA16({{242, 9}}); +const std::vector > D1_HEA17({{251, 9}}); +const std::vector > D1_HEA18({{260, 3}, {271, 6}}); +const std::vector > D1_HEA19({{277, 9}}); //SUBFRAME 5 PAGE 8 -const std::vector > D1_HEA20( { {51,2},{61,7} } ); -const std::vector > D1_HEA21( { {68,9} } ); -const std::vector > D1_HEA22( { {77,6},{91,3} } ); -const std::vector > D1_HEA23( { {94,9} } ); -const std::vector > D1_HEA24( { {103,9} } ); -const std::vector > D1_HEA25( { {112,1},{121,8} } ); -const std::vector > D1_HEA26( { {129,9} } ); -const std::vector > D1_HEA27( { {138,5},{151,4} } ); -const std::vector > D1_HEA28( { {155,9} } ); -const std::vector > D1_HEA29( { {164,9} } ); -const std::vector > D1_HEA30( { {181,9} } ); -const std::vector > D1_WNA( { {190,8} } ); -const std::vector > D1_TOA2( { {198,5},{211,3} } ); +const std::vector > D1_HEA20({{51, 2}, {61, 7}}); +const std::vector > D1_HEA21({{68, 9}}); +const std::vector > D1_HEA22({{77, 6}, {91, 3}}); +const std::vector > D1_HEA23({{94, 9}}); +const std::vector > D1_HEA24({{103, 9}}); +const std::vector > D1_HEA25({{112, 1}, {121, 8}}); +const std::vector > D1_HEA26({{129, 9}}); +const std::vector > D1_HEA27({{138, 5}, {151, 4}}); +const std::vector > D1_HEA28({{155, 9}}); +const std::vector > D1_HEA29({{164, 9}}); +const std::vector > D1_HEA30({{181, 9}}); +const std::vector > D1_WNA({{190, 8}}); +const std::vector > D1_TOA2({{198, 5}, {211, 3}}); //SUBFRAME 5 PAGE 9 -const std::vector > D1_A0GPS( { {97,14} } ); -const std::vector > D1_A1GPS( { {111,2},{121,14} } ); -const std::vector > D1_A0GAL( { {135,8},{151,6} } ); -const std::vector > D1_A1GAL( { {157,16} } ); -const std::vector > D1_A0GLO( { {181,14} } ); -const std::vector > D1_A1GLO( { {195,8},{211,8} } ); +const std::vector > D1_A0GPS({{97, 14}}); +const std::vector > D1_A1GPS({{111, 2}, {121, 14}}); +const std::vector > D1_A0GAL({{135, 8}, {151, 6}}); +const std::vector > D1_A1GAL({{157, 16}}); +const std::vector > D1_A0GLO({{181, 14}}); +const std::vector > D1_A1GLO({{195, 8}, {211, 8}}); //SUBFRAME 5 PAGE 10 -const std::vector > D1_DELTA_T_LS( { {51,2},{61,6} } ); -const std::vector > D1_DELTA_T_LSF( { {67,8} } ); -const std::vector > D1_WN_LSF( { {75,8} } ); -const std::vector > D1_A0UTC( { {91,22},{121,10} } ); -const std::vector > D1_A1UTC( { {131,12},{151,12} } ); -const std::vector > D1_DN( { {163,8} } ); +const std::vector > D1_DELTA_T_LS({{51, 2}, {61, 6}}); +const std::vector > D1_DELTA_T_LSF({{67, 8}}); +const std::vector > D1_WN_LSF({{75, 8}}); +const std::vector > D1_A0UTC({{91, 22}, {121, 10}}); +const std::vector > D1_A1UTC({{131, 12}, {151, 12}}); +const std::vector > D1_DN({{163, 8}}); // D2 NAV Message Decoding Information -const std::vector > D2_PRE( { {1,11} } ); -const std::vector > D2_FRAID( { {16,3} } ); -const std::vector > D2_SOW( { {19,8},{31,12} } ); -const std::vector > D2_PNUM( { {43,4} } ); +const std::vector > D2_PRE({{1, 11}}); +const std::vector > D2_FRAID({{16, 3}}); +const std::vector > D2_SOW({{19, 8}, {31, 12}}); +const std::vector > D2_PNUM({{43, 4}}); // D2 NAV, SUBFRAME 1, PAGE 1 -const std::vector > D2_SAT_H1( { {47,1} } ); -const std::vector > D2_AODC( { {48,5} } ); -const std::vector > D2_URAI( { {61,4} } ); -const std::vector > D2_WN( { {65,13} } ); -const std::vector > D2_TOC( { {78,5},{91,12} } ); -const std::vector > D2_TGD1( { {103,10} } ); -const std::vector > D2_TGD2( { {121,10} } ); +const std::vector > D2_SAT_H1({{47, 1}}); +const std::vector > D2_AODC({{48, 5}}); +const std::vector > D2_URAI({{61, 4}}); +const std::vector > D2_WN({{65, 13}}); +const std::vector > D2_TOC({{78, 5}, {91, 12}}); +const std::vector > D2_TGD1({{103, 10}}); +const std::vector > D2_TGD2({{121, 10}}); // D2 NAV, SUBFRAME 1, PAGE 2 -const std::vector > D2_ALPHA0( { {47,6}, {61,2} } ); -const std::vector > D2_ALPHA1( { {63,8} } ); -const std::vector > D2_ALPHA2( { {71,8} } ); -const std::vector > D2_ALPHA3( { {79,4}, {91,4} } ); -const std::vector > D2_BETA0( { {95,8} } ); -const std::vector > D2_BETA1( { {103,8} } ); -const std::vector > D2_BETA2( { {111,2}, {121,6} } ); -const std::vector > D2_BETA3( { {127,8} } ); +const std::vector > D2_ALPHA0({{47, 6}, {61, 2}}); +const std::vector > D2_ALPHA1({{63, 8}}); +const std::vector > D2_ALPHA2({{71, 8}}); +const std::vector > D2_ALPHA3({{79, 4}, {91, 4}}); +const std::vector > D2_BETA0({{95, 8}}); +const std::vector > D2_BETA1({{103, 8}}); +const std::vector > D2_BETA2({{111, 2}, {121, 6}}); +const std::vector > D2_BETA3({{127, 8}}); // D2 NAV, SUBFRAME 1, PAGE 3 -const std::vector > D2_A0( { {101,12},{121,12} } ); -const std::vector > D2_A1_MSB( { {133,4} } ); -const std::vector > D2_A1_LSB( { {47,6}, {61, 12} } ); -const std::vector > D2_A1( { {279,22} } ); +const std::vector > D2_A0({{101, 12}, {121, 12}}); +const std::vector > D2_A1_MSB({{133, 4}}); +const std::vector > D2_A1_LSB({{47, 6}, {61, 12}}); +const std::vector > D2_A1({{279, 22}}); // D2 NAV, SUBFRAME 1, PAGE 4 -const std::vector > D2_A2( { {73,10}, {91,1} } ); -const std::vector > D2_AODE( { {92,5} } ); -const std::vector > D2_DELTA_N( { {97,16} } ); -const std::vector > D2_CUC_MSB( { {121,14} } ); -const std::vector > D2_CUC_LSB( { {47,4} } ); -const std::vector > D2_CUC( { {283,18} } ); +const std::vector > D2_A2({{73, 10}, {91, 1}}); +const std::vector > D2_AODE({{92, 5}}); +const std::vector > D2_DELTA_N({{97, 16}}); +const std::vector > D2_CUC_MSB({{121, 14}}); +const std::vector > D2_CUC_LSB({{47, 4}}); +const std::vector > D2_CUC({{283, 18}}); // D2 NAV, SUBFRAME 1, PAGE 5 -const std::vector > D2_M0( { {51,2}, {61,22}, {91,8} } ); -const std::vector > D2_CUS( { {99,14}, {121, 4} } ); -const std::vector > D2_E_MSB( { {125,10} } ); +const std::vector > D2_M0({{51, 2}, {61, 22}, {91, 8}}); +const std::vector > D2_CUS({{99, 14}, {121, 4}}); +const std::vector > D2_E_MSB({{125, 10}}); // D2 NAV, SUBFRAME 1, PAGE 6 -const std::vector > D2_E_LSB( { {47,6}, {61, 16} } ); -const std::vector > D2_SQRT_A( { {77,6},{91,22}, {121,4} } ); -const std::vector > D2_CIC_MSB( { {125,10} } ); -const std::vector > D2_CIC_LSB( { {47,6}, {61,2} } ); -const std::vector > D2_CIC( { {283,18} } ); +const std::vector > D2_E_LSB({{47, 6}, {61, 16}}); +const std::vector > D2_SQRT_A({{77, 6}, {91, 22}, {121, 4}}); +const std::vector > D2_CIC_MSB({{125, 10}}); +const std::vector > D2_CIC_LSB({{47, 6}, {61, 2}}); +const std::vector > D2_CIC({{283, 18}}); // D2 NAV, SUBFRAME 1, PAGE 7 -const std::vector > D2_CIS( { {63,18} } ); -const std::vector > D2_TOE( { {81,2},{91,15} } ); -const std::vector > D2_I0_MSB( { {106,7},{121,14} } ); -const std::vector > D2_I0_LSB( { {47,6},{61,5} } ); -const std::vector > D2_I0( { {269,32} } ); +const std::vector > D2_CIS({{63, 18}}); +const std::vector > D2_TOE({{81, 2}, {91, 15}}); +const std::vector > D2_I0_MSB({{106, 7}, {121, 14}}); +const std::vector > D2_I0_LSB({{47, 6}, {61, 5}}); +const std::vector > D2_I0({{269, 32}}); // D2 NAV, SUBFRAME 1, PAGE 8 -const std::vector > D2_CRC( { {66,17},{91,1} } ); -const std::vector > D2_CRS( { {92,18} } ); -const std::vector > D2_OMEGA_DOT_MSB( { {110,3},{121,16} } ); -const std::vector > D2_OMEGA_DOT_LSB( { {47,5} } ); -const std::vector > D2_OMEGA_DOT( { {277,24} } ); +const std::vector > D2_CRC({{66, 17}, {91, 1}}); +const std::vector > D2_CRS({{92, 18}}); +const std::vector > D2_OMEGA_DOT_MSB({{110, 3}, {121, 16}}); +const std::vector > D2_OMEGA_DOT_LSB({{47, 5}}); +const std::vector > D2_OMEGA_DOT({{277, 24}}); // D2 NAV, SUBFRAME 1, PAGE 9 -const std::vector > D2_OMEGA0( { {52,1},{61,22},{91,9} } ); -const std::vector > D2_OMEGA_MSB( { {100,13},{121,14} } ); -const std::vector > D2_OMEGA_LSB( { {47,5} } ); -const std::vector > D2_OMEGA( { {269,32} } ); +const std::vector > D2_OMEGA0({{52, 1}, {61, 22}, {91, 9}}); +const std::vector > D2_OMEGA_MSB({{100, 13}, {121, 14}}); +const std::vector > D2_OMEGA_LSB({{47, 5}}); +const std::vector > D2_OMEGA({{269, 32}}); // D2 NAV, SUBFRAME 1, PAGE 10 -const std::vector > D2_IDOT( { {52,1},{61,13} } ); +const std::vector > D2_IDOT({{52, 1}, {61, 13}}); #endif /* GNSS_SDR_BEIDOU_DNAV_H_ */