diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index 0f6e84b06..e9cf5f942 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -54,6 +54,7 @@ #include "rtklib_solver.h" #include "Beidou_B1I.h" #include "Beidou_B3I.h" +#include "Beidou_DNAV.h" #include "GLONASS_L1_L2_CA.h" #include "GPS_L1_CA.h" #include "Galileo_E1.h" @@ -730,7 +731,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ obsd_t newobs = {{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 + BEIDOU_DNAV_BDT2GPST_WEEK_NUM_OFFSET, 0); valid_obs++; } @@ -752,7 +753,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 + BEIDOU_DNAV_BDT2GPST_WEEK_NUM_OFFSET, 1); // Band 3 (L2/G2/B3) found_B1I_obs = true; break; @@ -770,7 +771,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 + BEIDOU_DNAV_BDT2GPST_WEEK_NUM_OFFSET, 1); // Band 2 (L2/G2) valid_obs++; } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc index 57f8d5e7b..1dbd91c6f 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc @@ -33,6 +33,7 @@ #include "beidou_b1i_telemetry_decoder_gs.h" #include "Beidou_B1I.h" +#include "Beidou_DNAV.h" #include "beidou_dnav_ephemeris.h" #include "beidou_dnav_iono.h" #include "beidou_dnav_utc_model.h" @@ -546,7 +547,7 @@ int beidou_b1i_telemetry_decoder_gs::general_work(int noutput_items __attribute_ // 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_Preamble_ms = static_cast((d_nav.d_SOW + BEIDOU_DNAV_BDT2GPST_LEAP_SEC_OFFSET) * 1000.0); d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast((d_required_symbols + 1) * BEIDOU_B1I_CODE_PERIOD_MS); flag_SOW_set = true; d_nav.flag_new_SOW_available = false; 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 01530cd32..8b7758b92 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 @@ -611,7 +611,7 @@ int beidou_b3i_telemetry_decoder_gs::general_work( // 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_Preamble_ms = static_cast((d_nav.d_SOW + BEIDOU_DNAV_BDT2GPST_LEAP_SEC_OFFSET) * 1000.0); d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast((d_required_symbols + 1) * BEIDOU_B3I_CODE_PERIOD_MS); diff --git a/src/core/system_parameters/Beidou_B1I.h b/src/core/system_parameters/Beidou_B1I.h index a341d9a2c..b726ffe49 100644 --- a/src/core/system_parameters/Beidou_B1I.h +++ b/src/core/system_parameters/Beidou_B1I.h @@ -36,16 +36,6 @@ #include #include -// Physical constants -const double BEIDOU_C_M_S = 299792458.0; //!< The speed of light, [m/s] -const double BEIDOU_C_M_MS = 299792.4580; //!< The speed of light, [m/ms] -const double BEIDOU_PI = 3.1415926535898; //!< Pi -const double BEIDOU_TWO_PI = 6.283185307179586; //!< 2Pi -const double BEIDOU_OMEGA_EARTH_DOT = 7.2921150e-5; //!< Earth rotation rate, [rad/s] as defined in CGCS2000 -const double BEIDOU_GM = 3.986004418e14; //!< Universal gravitational constant times the mass of the Earth, [m^3/s^2] as defined in CGCS2000 -const double BEIDOU_F = -4.442807309e-10; //!< Constant, [s/(m)^(1/2)] F=-2(GM)^.5/C^2 - - // carrier and code frequencies const double BEIDOU_B1I_FREQ_HZ = 1.561098e9; //!< B1I [Hz] const double BEIDOU_B1I_CODE_RATE_HZ = 2.046e6; //!< Beidou B1I code rate [chips/s] @@ -54,27 +44,20 @@ const double BEIDOU_B1I_CODE_PERIOD = 0.001; //!< Beidou B1I code period const uint32_t BEIDOU_B1I_CODE_PERIOD_MS = 1; //!< Beidou B1I code period [ms] const double BEIDOU_B1I_CHIP_PERIOD = 4.8875e-07; //!< Beidou B1I chip period [seconds] const int32_t BEIDOU_B1I_SECONDARY_CODE_LENGTH = 20; -const std::string BEIDOU_B1I_SECONDARY_CODE = "00000100110101001110"; const std::string BEIDOU_B1I_SECONDARY_CODE_STR = "00000100110101001110"; const std::string BEIDOU_B1I_GEO_PREAMBLE_SYMBOLS_STR = {"1111110000001100001100"}; const int32_t BEIDOU_B1I_GEO_PREAMBLE_LENGTH_SYMBOLS = 22; const std::string BEIDOU_B1I_D2_SECONDARY_CODE_STR = "00"; const int BEIDOU_B1I_PREAMBLE_LENGTH_BITS = 11; -const int BEIDOU_B1I_PREAMBLE_LENGTH_SYMBOLS = 220; // ************** +const int BEIDOU_B1I_PREAMBLE_LENGTH_SYMBOLS = 220; const double BEIDOU_B1I_PREAMBLE_DURATION_S = 0.220; const int BEIDOU_B1I_PREAMBLE_DURATION_MS = 220; -const int BEIDOU_B1I_TELEMETRY_RATE_BITS_SECOND = 50; //!< D1 NAV message bit rate [bits/s] +const int BEIDOU_B1I_TELEMETRY_RATE_BITS_SECOND = 50; const int BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT = 20; const int BEIDOU_B1I_GEO_TELEMETRY_SYMBOLS_PER_BIT = 2; const int BEIDOU_B1I_TELEMETRY_SYMBOL_PERIOD_MS = BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT * BEIDOU_B1I_CODE_PERIOD_MS; -const int BEIDOU_B1I_TELEMETRY_RATE_SYMBOLS_SECOND = BEIDOU_B1I_TELEMETRY_RATE_BITS_SECOND * BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT; //************!< NAV message bit rate [symbols/s] -const int BEIDOU_WORD_LENGTH = 4; //**************!< CRC + BEIDOU WORD (-2 -1 0 ... 29) Bits = 4 bytes -const int BEIDOU_SUBFRAME_LENGTH = 40; //**************!< BEIDOU_WORD_LENGTH x 10 = 40 bytes -const int BEIDOU_DNAV_SUBFRAME_DATA_BITS = 300; //!< Number of bits per subframe in the NAV message [bits] -const int BEIDOU_SUBFRAME_SECONDS = 6; //!< Subframe duration [seconds] -const int BEIDOU_SUBFRAME_MS = 6000; //!< Subframe duration [miliseconds] -const int BEIDOU_WORD_BITS = 30; //!< Number of bits per word in the NAV message [bits] +const int BEIDOU_B1I_TELEMETRY_RATE_SYMBOLS_SECOND = BEIDOU_B1I_TELEMETRY_RATE_BITS_SECOND * BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT; #endif /* GNSS_SDR_BEIDOU_B1I_H_ */ diff --git a/src/core/system_parameters/Beidou_B3I.h b/src/core/system_parameters/Beidou_B3I.h index bf77457f5..f7bac9ac5 100644 --- a/src/core/system_parameters/Beidou_B3I.h +++ b/src/core/system_parameters/Beidou_B3I.h @@ -42,7 +42,6 @@ const double BEIDOU_B3I_CODE_LENGTH_CHIPS = 10230.0; //!< BeiDou B3I code lengt const double BEIDOU_B3I_CODE_PERIOD = 0.001; //!< BeiDou B3I code period [seconds] const uint32_t BEIDOU_B3I_CODE_PERIOD_MS = 1; //!< BeiDou B3I 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_GEO_PREAMBLE_SYMBOLS_STR = {"1111110000001100001100"}; const int32_t BEIDOU_B3I_GEO_PREAMBLE_LENGTH_SYMBOLS = 22; diff --git a/src/core/system_parameters/Beidou_DNAV.h b/src/core/system_parameters/Beidou_DNAV.h index fd2792493..8ab7a80e5 100644 --- a/src/core/system_parameters/Beidou_DNAV.h +++ b/src/core/system_parameters/Beidou_DNAV.h @@ -51,6 +51,11 @@ const double BEIDOU_D1NAV_SYMBOL_RATE_SPS = 50; const double BEIDOU_D2NAV_SYMBOL_RATE_SPS = 500; const std::string BEIDOU_DNAV_PREAMBLE = "11100010010"; +// Number of leap seconds passed from the start of the GPS epoch up to the start of BeiDou epoch +const int32_t BEIDOU_DNAV_BDT2GPST_LEAP_SEC_OFFSET = 14; +// Number of weeks passed from the start of the GPS epoch up to the start of BeiDou epoch +const int32_t BEIDOU_DNAV_BDT2GPST_WEEK_NUM_OFFSET = 1356; + // BEIDOU D1 NAVIGATION MESSAGE STRUCTURE // GENERAL const std::vector > D1_PRE({{1, 11}});