diff --git a/conf/gnss-sdr_BDS_B1I_byte.conf b/conf/gnss-sdr_BDS_B1I_byte.conf index 0e7bd9ef6..2eff13a45 100644 --- a/conf/gnss-sdr_BDS_B1I_byte.conf +++ b/conf/gnss-sdr_BDS_B1I_byte.conf @@ -58,16 +58,16 @@ Channels_B1.count=10 Channels.in_acquisition=1 Channel.signal=B1 -Channel0.satellite = 1; -Channel1.satellite = 2; -Channel2.satellite = 3; -Channel3.satellite = 4; -Channel4.satellite = 5; -Channel5.satellite = 6; -Channel6.satellite = 8; -Channel7.satellite = 9; -Channel8.satellite = 13; -Channel9.satellite = 17; +Channel0.satellite = 6; +Channel1.satellite = 8; +Channel2.satellite = 9; +Channel3.satellite = 13; +Channel4.satellite = 17; +Channel5.satellite = 1; +Channel6.satellite = 2; +Channel7.satellite = 3; +Channel8.satellite = 4; +Channel9.satellite = 5; ;######### ACQUISITION GLOBAL CONFIG ############ Acquisition_B1.implementation=BEIDOU_B1I_PCPS_Acquisition diff --git a/src/algorithms/PVT/libs/rtklib_solver.h b/src/algorithms/PVT/libs/rtklib_solver.h index 1b8697436..08b49e8fd 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.h +++ b/src/algorithms/PVT/libs/rtklib_solver.h @@ -60,13 +60,14 @@ #include "gps_navigation_message.h" #include "gps_cnav_navigation_message.h" #include "glonass_gnav_navigation_message.h" +#include "beidou_dnav_navigation_message.h" #include "galileo_almanac.h" #include "gnss_synchro.h" #include "pvt_solution.h" #include #include #include -#include "../../../core/system_parameters/beidou_dnav_navigation_message.h" + /*! diff --git a/src/algorithms/libs/rtklib/rtklib_conversions.cc b/src/algorithms/libs/rtklib/rtklib_conversions.cc index 22659e6ec..9e0e86818 100644 --- a/src/algorithms/libs/rtklib/rtklib_conversions.cc +++ b/src/algorithms/libs/rtklib/rtklib_conversions.cc @@ -66,13 +66,23 @@ obsd_t insert_obs_to_rtklib(obsd_t& rtklib_obs, const Gnss_Synchro& gnss_synchro rtklib_obs.sat = gnss_synchro.PRN + NSATGPS; break; case 'C': - rtklib_obs.sat = gnss_synchro.PRN + NSATGPS + NSATGLO + NSATGAL; + rtklib_obs.sat = gnss_synchro.PRN + NSATGPS + NSATGLO + NSATGAL + NSATQZS; break; default: rtklib_obs.sat = gnss_synchro.PRN; } - rtklib_obs.time = gpst2time(adjgpsweek(week), gnss_synchro.RX_time); + + // Mote that BeiDou week numbers do not need adjustment for foreseeable future. Consider change + // to more elegant solution + if(gnss_synchro.System == 'C') + { + rtklib_obs.time = bdt2time(week, gnss_synchro.RX_time); + } + else + { + rtklib_obs.time = gpst2time(adjgpsweek(week), gnss_synchro.RX_time); + } rtklib_obs.rcv = 1; return rtklib_obs; } @@ -247,7 +257,7 @@ eph_t eph_to_rtklib(const Beidou_Dnav_Ephemeris& bei_eph) rtklib_sat.Adot = 0; //only in CNAV; rtklib_sat.ndot = 0; //only in CNAV; - rtklib_sat.week = adjgpsweek(bei_eph.i_BEIDOU_week); /* week of tow */ + rtklib_sat.week = bei_eph.i_BEIDOU_week; /* week of tow */ rtklib_sat.cic = bei_eph.d_Cic; rtklib_sat.cis = bei_eph.d_Cis; rtklib_sat.cuc = bei_eph.d_Cuc; @@ -258,7 +268,7 @@ eph_t eph_to_rtklib(const Beidou_Dnav_Ephemeris& bei_eph) rtklib_sat.f1 = bei_eph.d_A_f1; rtklib_sat.f2 = bei_eph.d_A_f2; rtklib_sat.tgd[0] = bei_eph.d_TGD1; - rtklib_sat.tgd[1] = 0.0; + rtklib_sat.tgd[1] = bei_eph.d_TGD2; rtklib_sat.tgd[2] = 0.0; rtklib_sat.tgd[3] = 0.0; rtklib_sat.toes = bei_eph.d_Toe; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.cc index 72f10a231..ea1a7db3b 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.cc @@ -58,7 +58,7 @@ beidou_b1i_telemetry_decoder_cc::beidou_b1i_telemetry_decoder_cc( d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); // set the preamble - unsigned short int preambles_bits[BEIDOU_B1I_PREAMBLE_LENGTH_BITS] = BEIDOU_PREAMBLE; + unsigned short int preambles_bits[BEIDOU_B1I_PREAMBLE_LENGTH_BITS] = BEIDOU_DNAV_PREAMBLE; // preamble bits to sampled symbols d_preambles_symbols = static_cast(volk_gnsssdr_malloc(BEIDOU_B1I_PREAMBLE_LENGTH_SYMBOLS * sizeof(int), volk_gnsssdr_get_alignment())); @@ -94,16 +94,16 @@ beidou_b1i_telemetry_decoder_cc::beidou_b1i_telemetry_decoder_cc( d_preamble_time_samples = 0; d_TOW_at_current_symbol_ms = 0; d_symbol_history.resize(BEIDOU_B1I_PREAMBLE_LENGTH_BITS); // Change fixed buffer size - d_symbol_nh_history.resize(BEIDOU_B1I_NH_CODE_LENGTH); // Change fixed buffer size + d_symbol_nh_history.resize(BEIDOU_B1I_SECONDARY_CODE_LENGTH); // Change fixed buffer size d_bit_buffer.resize(30); // Change fixed buffer size d_symbol_history.clear(); // Clear all the elements in the buffer d_symbol_nh_history.clear(); d_bit_buffer.clear(); d_make_correlation = true; d_symbol_counter_corr = 0; - for (int aux = 0; aux < BEIDOU_B1I_NH_CODE_LENGTH; aux++) + for (int aux = 0; aux < BEIDOU_B1I_SECONDARY_CODE_LENGTH; aux++) { - if (BEIDOU_B1I_NH_CODE[aux] == 0) + if (BEIDOU_B1I_SECONDARY_CODE[aux] == 0) { bits_NH[aux] = -1.0; } @@ -270,9 +270,9 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_ d_symbol_nh_history.push_back(current_symbol.Prompt_I); //add new symbol to the symbol queue consume_each(1); - if (d_symbol_nh_history.size() == BEIDOU_B1I_NH_CODE_LENGTH) + if (d_symbol_nh_history.size() == BEIDOU_B1I_SECONDARY_CODE_LENGTH) { - for (int i = 0; i < BEIDOU_B1I_NH_CODE_LENGTH; i++) + for (int i = 0; i < BEIDOU_B1I_SECONDARY_CODE_LENGTH; i++) { if ((bits_NH[i] * d_symbol_nh_history.at(i)) > 0.0) { @@ -283,7 +283,7 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_ corr_NH -= 1; } } - if (abs(corr_NH) == BEIDOU_B1I_NH_CODE_LENGTH) + if (abs(corr_NH) == BEIDOU_B1I_SECONDARY_CODE_LENGTH) { sync_NH = true; if (corr_NH > 0) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.h index fe8e08904..c6e8ae3ef 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.h @@ -96,7 +96,7 @@ private: //bits and frame unsigned short int d_frame_bit_index; - double bits_NH[BEIDOU_B1I_NH_CODE_LENGTH]; + double bits_NH[BEIDOU_B1I_SECONDARY_CODE_LENGTH]; unsigned int d_BEIDOU_frame_4bytes; unsigned int d_prev_BEIDOU_frame_4bytes; bool d_flag_parity; 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 2eb83605c..0a15c7a39 100755 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc @@ -49,6 +49,8 @@ #include "gps_l2c_signal.h" #include "GPS_L5.h" #include "gps_l5_signal.h" +#include "Beidou_B1I.h" +#include "beidou_b1i_signal_processing.h" #include "gnss_sdr_create_directory.h" #include #include @@ -60,8 +62,7 @@ #include #include #include -#include "../../../core/system_parameters/Beidou_B1I.h" -#include "../../libs/beidou_b1i_signal_processing.h" + using google::LogMessage; @@ -288,8 +289,8 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl d_secondary = true; trk_parameters.track_pilot = false; interchange_iq = false; - d_secondary_code_length = static_cast(BEIDOU_B1I_NH_CODE_LENGTH); - d_secondary_code_string = const_cast(&BEIDOU_B1I_NH_CODE_STR); + d_secondary_code_length = static_cast(BEIDOU_B1I_SECONDARY_CODE_LENGTH); + d_secondary_code_string = const_cast(&BEIDOU_B1I_SECONDARY_CODE_STR); } else diff --git a/src/core/system_parameters/Beidou_B1I.h b/src/core/system_parameters/Beidou_B1I.h index 848649511..2dbe6e8c8 100644 --- a/src/core/system_parameters/Beidou_B1I.h +++ b/src/core/system_parameters/Beidou_B1I.h @@ -53,6 +53,9 @@ const double BEIDOU_B1I_CODE_LENGTH_CHIPS = 2046.0; //!< beidou b1I code l const double BEIDOU_B1I_CODE_PERIOD = 0.001; //!< beidou b1I code period [seconds] const unsigned int BEIDOU_B1I_CODE_PERIOD_MS = 1; //!< GPS L1 C/A code period [ms] const double BEIDOU_B1I_CHIP_PERIOD = 4.8875e-07; //!< beidou b1I chip period [seconds] +const int BEIDOU_B1I_SECONDARY_CODE_LENGTH = 20; +const int BEIDOU_B1I_SECONDARY_CODE[20] = {0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0}; +const std::string BEIDOU_B1I_SECONDARY_CODE_STR = "00000100110101001110"; /*! * \brief Maximum Time-Of-Arrival (TOA) difference between satellites for a receiver operated on Earth surface is 20 ms @@ -72,8 +75,7 @@ const double BEIDOU_STARTOFFSET_ms = 68.802; //**************[ms] Initial sign. const int BEIDOU_B1I_HISTORY_DEEP = 100; // **************** // NAVIGATION MESSAGE DEMODULATION AND DECODING - -#define BEIDOU_PREAMBLE {1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0} +#define BEIDOU_DNAV_PREAMBLE {1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0} const int BEIDOU_B1I_PREAMBLE_LENGTH_BITS = 11; const int BEIDOU_B1I_PREAMBLE_LENGTH_SYMBOLS = 220; // ************** const double BEIDOU_B1I_PREAMBLE_DURATION_S = 0.220; @@ -87,9 +89,7 @@ const int BEIDOU_SUBFRAME_BITS = 300; //!< Number of bits per s 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_NH_CODE_LENGTH = 20; -const int BEIDOU_B1I_NH_CODE[20] = {0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0}; -const std::string BEIDOU_B1I_NH_CODE_STR = "00000100110101001110"; + // BEIDOU D1 NAVIGATION MESSAGE STRUCTURE @@ -151,11 +151,11 @@ const std::vector > D1_CRS( { {225,8},{241,10} } ); const double D1_CRS_LSB = TWO_N6; const std::vector > D1_SQRT_A( { {251,12},{271,20} } ); const double D1_SQRT_A_LSB = TWO_N19; -const std::vector > D1_TOE( { {291,2} } ); +const std::vector > D1_TOE_SF2( { {291,2} } ); const double D1_TOE_LSB = TWO_P3; //SUBFRAME 3 -const std::vector > D1_TOE_MSB2( { {43,10},{61,5} } ); +const std::vector > D1_TOE_SF3( { {43,10},{61,5} } ); const std::vector > D1_I0( { {66,17},{91,15} } ); const double D1_I0_LSB = PI_TWO_N31; const std::vector > D1_CIC( { {106,7},{121,11} } ); diff --git a/src/core/system_parameters/beidou_dnav_navigation_message.cc b/src/core/system_parameters/beidou_dnav_navigation_message.cc index d5d47be88..9f179cfab 100644 --- a/src/core/system_parameters/beidou_dnav_navigation_message.cc +++ b/src/core/system_parameters/beidou_dnav_navigation_message.cc @@ -53,7 +53,7 @@ void Beidou_Dnav_Navigation_Message::reset() d_e_eccentricity = 0; d_Cus = 0; d_sqrt_A = 0; - d_Toe = 0; + d_Toe_sf2 = 0; d_Toc = 0; d_Cic = 0; d_OMEGA0 = 0; @@ -317,7 +317,7 @@ void Beidou_Dnav_Navigation_Message::satellitePosition(double transmitTime) a = d_sqrt_A * d_sqrt_A; // Time from ephemeris reference epoch - tk = check_t(transmitTime - d_Toe); + tk = check_t(transmitTime - d_Toe_sf2); // Computed mean motion n0 = sqrt(BEIDOU_GM / (a * a * a)); @@ -371,7 +371,7 @@ void Beidou_Dnav_Navigation_Message::satellitePosition(double transmitTime) i = d_i_0 + d_IDOT * tk + d_Cic * cos(2 * phi) + d_Cis * sin(2 * phi); // Compute the angle between the ascending node and the Greenwich meridian - Omega = d_OMEGA0 + (d_OMEGA_DOT - BEIDOU_OMEGA_EARTH_DOT) * tk - BEIDOU_OMEGA_EARTH_DOT * d_Toe; + Omega = d_OMEGA0 + (d_OMEGA_DOT - BEIDOU_OMEGA_EARTH_DOT) * tk - BEIDOU_OMEGA_EARTH_DOT * d_Toe_sf2; // Reduce to between 0 and 2*pi rad Omega = fmod((Omega + 2 * BEIDOU_PI), (2 * BEIDOU_PI)); @@ -452,7 +452,7 @@ int Beidou_Dnav_Navigation_Message::subframe_decoder(char *subframe) d_alpha0 = static_cast(read_navigation_signed(subframe_bits, D1_ALPHA0)); d_alpha0 = d_alpha0 * D1_ALPHA0_LSB; - d_alpha1 = static_cast(read_navigation_signed(subframe_bits, D1_ALPHA1)); + d_alpha1 = static_cast(read_navigation_signed(subframe_bits, D1_ALPHA1)); d_alpha1 = d_alpha1 * D1_ALPHA1_LSB; d_alpha2 = static_cast(read_navigation_signed(subframe_bits, D1_ALPHA2)); d_alpha2 = d_alpha2 * D1_ALPHA2_LSB; @@ -514,8 +514,8 @@ int Beidou_Dnav_Navigation_Message::subframe_decoder(char *subframe) d_sqrt_A = static_cast(read_navigation_unsigned(subframe_bits, D1_SQRT_A)); d_sqrt_A = d_sqrt_A * D1_SQRT_A_LSB; - d_Toe = static_cast(read_navigation_unsigned(subframe_bits, D1_TOE)); - d_Toe = d_Toe * D1_TOE_LSB; + d_Toe_sf2 = static_cast(read_navigation_unsigned(subframe_bits, D1_TOE_SF2)); + d_Toe_sf2 = static_cast((static_cast(d_Toe_sf2) << 15)); // d_SOW = d_SOW_SF2; // Set transmission time // b_integrity_status_flag = read_navigation_bool(subframe_bits, INTEGRITY_STATUS_FLAG); @@ -532,7 +532,7 @@ int Beidou_Dnav_Navigation_Message::subframe_decoder(char *subframe) d_SOW_SF3 = static_cast(read_navigation_unsigned(subframe_bits, D1_SOW)); d_SOW = d_SOW_SF3; // Set transmission time - d_Toe = d_Toe * D1_TOE_LSB; + d_Toe_sf3 = static_cast(read_navigation_unsigned(subframe_bits, D1_TOE_SF3)); d_i_0 = static_cast(read_navigation_signed(subframe_bits, D1_I0)); d_i_0 = d_i_0 * D1_I0_LSB; @@ -833,7 +833,7 @@ Beidou_Dnav_Ephemeris Beidou_Dnav_Navigation_Message::get_ephemeris() ephemeris.d_e_eccentricity = d_e_eccentricity; ephemeris.d_Cus = d_Cus; ephemeris.d_sqrt_A = d_sqrt_A; - ephemeris.d_Toe =static_cast( (static_cast(d_Toe) << 15) | static_cast(d_Toe2)) ; + ephemeris.d_Toe = ((d_Toe_sf2 + d_Toe_sf3) * D1_TOE_LSB) ; ephemeris.d_Toc = d_Toc; ephemeris.d_Cic = d_Cic; ephemeris.d_OMEGA0 = d_OMEGA0; diff --git a/src/core/system_parameters/beidou_dnav_navigation_message.h b/src/core/system_parameters/beidou_dnav_navigation_message.h index 0b098cb65..d2b8d2fab 100644 --- a/src/core/system_parameters/beidou_dnav_navigation_message.h +++ b/src/core/system_parameters/beidou_dnav_navigation_message.h @@ -87,7 +87,8 @@ public: double d_Cus; //!< Amplitude of the Sine Harmonic Correction Term to the Argument of Latitude [rad] double d_sqrt_A; //!< Square Root of the Semi-Major Axis [sqrt(m)] //broadcast orbit 3 - double d_Toe; //!< Ephemeris data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200E) [s] + double d_Toe_sf2; //!< Ephemeris data reference time of week in subframe 2 + double d_Toe_sf3; //!< Ephemeris data reference time of week in subframe 3 double d_Toe2; double d_Toc; //!< clock data reference time (Ref. 20.3.3.3.3.1 IS-GPS-200E) [s] double d_Cic; //!< Amplitude of the Cosine Harmonic Correction Term to the Angle of Inclination [rad] diff --git a/src/utils/matlab/dll_pll_veml_plot_sample.m b/src/utils/matlab/dll_pll_veml_plot_sample.m index a78ff99a7..084ad56b6 100644 --- a/src/utils/matlab/dll_pll_veml_plot_sample.m +++ b/src/utils/matlab/dll_pll_veml_plot_sample.m @@ -34,9 +34,9 @@ if ~exist('dll_pll_veml_read_tracking_dump.m', 'file') addpath('./libs') end -samplingFreq = 99375000; %[Hz] +samplingFreq = 25000000; %[Hz] coherent_integration_time_ms = 1; %[ms] -channels = 8; % Number of channels +channels = 10; % Number of channels first_channel = 0; % Number of the first channel path = '/home/dmiralles/Documents/gnss-sdr/';%#'; %% CHANGE THIS PATH diff --git a/src/utils/matlab/hybrid_observables_plot_sample.m b/src/utils/matlab/hybrid_observables_plot_sample.m index 9105c5bbd..2a8a784e5 100644 --- a/src/utils/matlab/hybrid_observables_plot_sample.m +++ b/src/utils/matlab/hybrid_observables_plot_sample.m @@ -29,10 +29,10 @@ clearvars; close all; addpath('./libs'); -samplingFreq = 6625000; %[Hz] -channels=5; -path='/archive/'; -observables_log_path=[path 'glo_observables.dat']; +samplingFreq = 25000000; %[Hz] +channels=10; +path='/home/dmiralles/Documents/gnss-sdr/'; +observables_log_path=[path 'observables.dat']; GNSS_observables= read_hybrid_observables_dump(channels,observables_log_path); %%