diff --git a/src/algorithms/PVT/adapters/rtklib_pvt.cc b/src/algorithms/PVT/adapters/rtklib_pvt.cc index 2f5b53c46..58d9b6a09 100644 --- a/src/algorithms/PVT/adapters/rtklib_pvt.cc +++ b/src/algorithms/PVT/adapters/rtklib_pvt.cc @@ -68,8 +68,8 @@ Rtklib_Pvt::Rtklib_Pvt(ConfigurationInterface* configuration, pvt_output_parameters.dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); pvt_output_parameters.dump_mat = configuration->property(role + ".dump_mat", true); - // OPTIONAL: specify a custom year to override the system time in order to postprocess old gnss records and avoid wrong week rollover - pvt_output_parameters.custom_year = configuration->property("GNSS-SDR.custom_year", 0); + // Flag to postprocess old gnss records (older than 2009) and avoid wrong week rollover + pvt_output_parameters.pre_2009_file = configuration->property("GNSS-SDR.pre_2009_file", false); // output rate pvt_output_parameters.output_rate_ms = bc::lcm(20, configuration->property(role + ".output_rate_ms", 500)); diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index 0ec015b24..fdc135c48 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -347,7 +347,7 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, if (b_rinex_output_enabled) { rp = std::make_shared(d_rinex_version, conf_.rinex_output_path); - rp->set_custom_year(conf_.custom_year); + rp->set_pre_2009_file(conf_.pre_2009_file); } else { @@ -468,21 +468,21 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, // user PVT solver d_user_pvt_solver = std::make_shared(static_cast(nchannels), dump_ls_pvt_filename, d_dump, d_dump_mat, rtk); d_user_pvt_solver->set_averaging_depth(1); - d_user_pvt_solver->set_custom_year(conf_.custom_year); + d_user_pvt_solver->set_pre_2009_file(conf_.pre_2009_file); // internal PVT solver, mainly used to estimate the receiver clock rtk_t internal_rtk = rtk; internal_rtk.opt.mode = PMODE_SINGLE; // use single positioning mode in internal PVT solver d_internal_pvt_solver = std::make_shared(static_cast(nchannels), dump_ls_pvt_filename, false, false, internal_rtk); d_internal_pvt_solver->set_averaging_depth(1); - d_internal_pvt_solver->set_custom_year(conf_.custom_year); + d_internal_pvt_solver->set_pre_2009_file(conf_.pre_2009_file); } else { // only one solver, customized by the user options d_internal_pvt_solver = std::make_shared(static_cast(nchannels), dump_ls_pvt_filename, d_dump, d_dump_mat, rtk); d_internal_pvt_solver->set_averaging_depth(1); - d_internal_pvt_solver->set_custom_year(conf_.custom_year); + d_internal_pvt_solver->set_pre_2009_file(conf_.pre_2009_file); d_user_pvt_solver = d_internal_pvt_solver; } diff --git a/src/algorithms/PVT/libs/pvt_conf.cc b/src/algorithms/PVT/libs/pvt_conf.cc index 42c596bba..31ad685ab 100644 --- a/src/algorithms/PVT/libs/pvt_conf.cc +++ b/src/algorithms/PVT/libs/pvt_conf.cc @@ -76,6 +76,6 @@ Pvt_Conf::Pvt_Conf() monitor_enabled = false; protobuf_enabled = true; udp_port = 0; - custom_year = 0; + pre_2009_file = false; show_local_time_zone = false; } diff --git a/src/algorithms/PVT/libs/pvt_conf.h b/src/algorithms/PVT/libs/pvt_conf.h index ad79fd2e6..8584e73b1 100644 --- a/src/algorithms/PVT/libs/pvt_conf.h +++ b/src/algorithms/PVT/libs/pvt_conf.h @@ -91,7 +91,7 @@ public: bool enable_rx_clock_correction; bool show_local_time_zone; - int custom_year; + bool pre_2009_file; Pvt_Conf(); }; diff --git a/src/algorithms/PVT/libs/pvt_solution.cc b/src/algorithms/PVT/libs/pvt_solution.cc index 1e06b7aed..7dd0000c2 100644 --- a/src/algorithms/PVT/libs/pvt_solution.cc +++ b/src/algorithms/PVT/libs/pvt_solution.cc @@ -53,7 +53,7 @@ Pvt_Solution::Pvt_Solution() d_valid_observations = 0; d_rx_pos = arma::zeros(3, 1); d_rx_dt_s = 0.0; - d_custom_year = 0; // disabled by default + d_pre_2009_file = false; // disabled by default } @@ -433,7 +433,8 @@ void Pvt_Solution::set_num_valid_observations(int num) d_valid_observations = num; } -void Pvt_Solution::set_custom_year(int custom_year) + +void Pvt_Solution::set_pre_2009_file(bool pre_2009_file) { - d_custom_year = custom_year; + d_pre_2009_file = pre_2009_file; } diff --git a/src/algorithms/PVT/libs/pvt_solution.h b/src/algorithms/PVT/libs/pvt_solution.h index 6f4d0ede8..f1f94f04d 100644 --- a/src/algorithms/PVT/libs/pvt_solution.h +++ b/src/algorithms/PVT/libs/pvt_solution.h @@ -49,9 +49,9 @@ class Pvt_Solution { public: Pvt_Solution(); - void set_custom_year(int custom_year); //!< Set a custom year for the week rollover computation instead of using the system clock, useful in post processing mode - double get_time_offset_s() const; //!< Get RX time offset [s] - void set_time_offset_s(double offset); //!< Set RX time offset [s] + void set_pre_2009_file(bool pre_2009_file); //!< Flag for the week rollover computation in post processing mode for signals older than 2009 + double get_time_offset_s() const; //!< Get RX time offset [s] + void set_time_offset_s(double offset); //!< Set RX time offset [s] double get_latitude() const; //!< Get RX position Latitude WGS84 [deg] double get_longitude() const; //!< Get RX position Longitude WGS84 [deg] @@ -130,7 +130,7 @@ public: int tropo(double *ddr_m, double sinel, double hsta_km, double p_mb, double t_kel, double hum, double hp_km, double htkel_km, double hhum_km); protected: - int d_custom_year; // custom year to guess the correct week rollover in post processing mode + bool d_pre_2009_file; // Flag to correct week rollover in post processing mode for signals older than 2009 private: double d_rx_dt_s; // RX time offset [s] diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 524202ae1..520358f56 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -88,7 +88,7 @@ namespace errorlib = boost::system; Rinex_Printer::Rinex_Printer(int32_t conf_version, const std::string& base_path) { - custom_year_ = 0; + pre_2009_file_ = false; std::string base_rinex_path = base_path; fs::path full_path(fs::current_path()); const fs::path p(base_rinex_path); @@ -728,7 +728,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A1, 15, 2), 16); line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_t_OT), 7); - if (custom_year_ == 0 or custom_year_ >= 2009) + if (pre_2009_file_ == false) { if (eph.i_GPS_week < 512) { @@ -1503,7 +1503,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& iono, co line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A0, 18, 2), 19); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A1, 18, 2), 19); line += Rinex_Printer::rightJustify(std::to_string(utc_model.d_t_OT), 9); - if (custom_year_ == 0 or custom_year_ >= 2009) + if (pre_2009_file_ == false) { if (eph.i_GPS_week < 512) { @@ -1549,7 +1549,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& iono, co line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A0, 16, 2), 18); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A1, 15, 2), 16); line += Rinex_Printer::rightJustify(std::to_string(utc_model.d_t_OT), 7); - if (custom_year_ == 0 or custom_year_ >= 2009) + if (pre_2009_file_ == false) { if (eph.i_GPS_week < 512) { @@ -1733,7 +1733,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A0, 16, 2), 18); line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A1, 15, 2), 16); line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_t_OT), 7); - if (custom_year_ == 0 or custom_year_ >= 2009) + if (pre_2009_file_ == false) { if (eph.i_GPS_week < 512) { @@ -2775,7 +2775,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Utc_Model& ut line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A0, 18, 2), 19); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A1, 18, 2), 19); line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_t_OT), 9); - if (custom_year_ == 0 or custom_year_ >= 2009) + if (pre_2009_file_ == false) { if (eph.i_GPS_week < 512) { @@ -2844,7 +2844,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Utc_Model& ut line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A0, 16, 2), 18); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A1, 15, 2), 16); line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.d_t_OT), 7); - if (custom_year_ == 0 or custom_year_ >= 2009) + if (pre_2009_file_ == false) { if (eph.i_GPS_week < 512) { @@ -3191,7 +3191,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_ion line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A0, 16, 2), 18); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A1, 15, 2), 16); line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_t_OT), 7); - if (custom_year_ == 0 or custom_year_ >= 2009) + if (pre_2009_file_ == false) { if (eph.i_GPS_week < 512) { @@ -3313,7 +3313,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_ion line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A0, 16, 2), 18); line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A1, 15, 2), 16); line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_t_OT), 7); - if (custom_year_ == 0 or custom_year_ >= 2009) + if (pre_2009_file_ == false) { if (eph.i_GPS_week < 512) { @@ -3936,7 +3936,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map(gps_ephemeris_iter->second.i_code_on_L2), 18, 2); line += std::string(1, ' '); double GPS_week_continuous_number; - if (custom_year_ == 0 or custom_year_ >= 2009) + if (pre_2009_file_ == false) { if (gps_ephemeris_iter->second.i_GPS_week < 512) { @@ -11896,7 +11896,7 @@ boost::posix_time::ptime Rinex_Printer::compute_UTC_time(const Gps_Navigation_Me const double utc_t = nav_msg.utc_time(nav_msg.d_TOW); boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((utc_t + 604800 * static_cast(nav_msg.i_GPS_week)) * 1000)); // Handle week rollover - if (custom_year_ == 0 or custom_year_ >= 2009) + if (pre_2009_file_ == false) { // Handle week rollover (valid from 2009 to 2029) if (nav_msg.i_GPS_week < 512) @@ -11943,7 +11943,7 @@ boost::posix_time::ptime Rinex_Printer::compute_GPS_time(const Gps_Ephemeris& ep } // Handle week rollover - if (custom_year_ == 0 or custom_year_ >= 2009) + if (pre_2009_file_ == false) { // Handle week rollover (valid from 2009 to 2029) if (eph.i_GPS_week < 512) @@ -12069,9 +12069,9 @@ double Rinex_Printer::get_leap_second(const Glonass_Gnav_Ephemeris& eph, const d return leap_second; } -void Rinex_Printer::set_custom_year(int custom_year) +void Rinex_Printer::set_pre_2009_file(bool pre_2009_file) { - custom_year_ = custom_year; + pre_2009_file_ = pre_2009_file; } diff --git a/src/algorithms/PVT/libs/rinex_printer.h b/src/algorithms/PVT/libs/rinex_printer.h index c84a977c9..9e4e11470 100644 --- a/src/algorithms/PVT/libs/rinex_printer.h +++ b/src/algorithms/PVT/libs/rinex_printer.h @@ -448,12 +448,13 @@ public: std::string navBdsfilename; std::string navMixfilename; - void set_custom_year(int custom_year); + void set_pre_2009_file(bool pre_2009_file); private: int version; // RINEX version (2 for 2.10/2.11 and 3 for 3.01) int numberTypesObservations; // Number of available types of observable in the system. Should be public? - int custom_year_; + bool pre_2009_file_; + /* * Generation of RINEX signal strength indicators */ diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index 61085af33..75aa0f6ea 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -496,14 +496,13 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ if (galileo_ephemeris_iter != galileo_ephemeris_map.cend()) { // convert ephemeris from GNSS-SDR class to RTKLIB structure - eph_data[valid_obs] = eph_to_rtklib(galileo_ephemeris_iter->second, d_custom_year); + eph_data[valid_obs] = eph_to_rtklib(galileo_ephemeris_iter->second); // convert observation from GNSS-SDR class to RTKLIB structure obsd_t newobs = {{0, 0}, '0', '0', {}, {}, {}, {}, {}, {}}; obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, galileo_ephemeris_iter->second.WN_5, - 0, - d_custom_year); + 0); valid_obs++; } else // the ephemeris are not available for this SV @@ -527,8 +526,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, galileo_ephemeris_iter->second.WN_5, - 2, // Band 3 (L5/E5) - d_custom_year); + 2); // Band 3 (L5/E5) found_E1_obs = true; break; } @@ -537,7 +535,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ { // insert Galileo E5 obs as new obs and also insert its ephemeris // convert ephemeris from GNSS-SDR class to RTKLIB structure - eph_data[valid_obs] = eph_to_rtklib(galileo_ephemeris_iter->second, d_custom_year); + eph_data[valid_obs] = eph_to_rtklib(galileo_ephemeris_iter->second); // convert observation from GNSS-SDR class to RTKLIB structure auto default_code_ = static_cast(CODE_NONE); obsd_t newobs = {{0, 0}, '0', '0', {}, {}, @@ -546,8 +544,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, galileo_ephemeris_iter->second.WN_5, - 2, // Band 3 (L5/E5) - d_custom_year); + 2); // Band 3 (L5/E5) valid_obs++; } } @@ -569,14 +566,14 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ if (gps_ephemeris_iter != gps_ephemeris_map.cend()) { // convert ephemeris from GNSS-SDR class to RTKLIB structure - eph_data[valid_obs] = eph_to_rtklib(gps_ephemeris_iter->second, d_custom_year); + eph_data[valid_obs] = eph_to_rtklib(gps_ephemeris_iter->second, d_pre_2009_file); // convert observation from GNSS-SDR class to RTKLIB structure obsd_t newobs = {{0, 0}, '0', '0', {}, {}, {}, {}, {}, {}}; obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, gps_ephemeris_iter->second.i_GPS_week, 0, - d_custom_year); + d_pre_2009_file); valid_obs++; } else // the ephemeris are not available for this SV @@ -615,7 +612,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ { // 3. If not found, insert the GPS L2 ephemeris and the observation // convert ephemeris from GNSS-SDR class to RTKLIB structure - eph_data[valid_obs] = eph_to_rtklib(gps_cnav_ephemeris_iter->second, d_custom_year); + eph_data[valid_obs] = eph_to_rtklib(gps_cnav_ephemeris_iter->second); // convert observation from GNSS-SDR class to RTKLIB structure auto default_code_ = static_cast(CODE_NONE); obsd_t newobs = {{0, 0}, '0', '0', {}, {}, @@ -624,8 +621,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, gps_cnav_ephemeris_iter->second.i_GPS_week, - 1, // Band 2 (L2) - d_custom_year); + 1); // Band 2 (L2) valid_obs++; } } @@ -650,12 +646,11 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ { if (eph_data[i].sat == static_cast(gnss_observables_iter->second.PRN)) { - eph_data[i] = eph_to_rtklib(gps_cnav_ephemeris_iter->second, d_custom_year); + eph_data[i] = eph_to_rtklib(gps_cnav_ephemeris_iter->second); obs_data[i + glo_valid_obs] = insert_obs_to_rtklib(obs_data[i], gnss_observables_iter->second, gps_cnav_ephemeris_iter->second.i_GPS_week, - 2, // Band 3 (L5) - d_custom_year); + 2); // Band 3 (L5) break; } } @@ -664,7 +659,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ { // 3. If not found, insert the GPS L5 ephemeris and the observation // convert ephemeris from GNSS-SDR class to RTKLIB structure - eph_data[valid_obs] = eph_to_rtklib(gps_cnav_ephemeris_iter->second, d_custom_year); + eph_data[valid_obs] = eph_to_rtklib(gps_cnav_ephemeris_iter->second); // convert observation from GNSS-SDR class to RTKLIB structure auto default_code_ = static_cast(CODE_NONE); obsd_t newobs = {{0, 0}, '0', '0', {}, {}, @@ -673,8 +668,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, gps_cnav_ephemeris_iter->second.i_GPS_week, - 2, // Band 3 (L5) - d_custom_year); + 2); // Band 3 (L5) valid_obs++; } } @@ -702,8 +696,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, glonass_gnav_ephemeris_iter->second.d_WN, - 0, // Band 0 (L1) - d_custom_year); + 0); // Band 0 (L1) glo_valid_obs++; } else // the ephemeris are not available for this SV @@ -726,8 +719,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ obs_data[i + valid_obs] = insert_obs_to_rtklib(obs_data[i + valid_obs], gnss_observables_iter->second, glonass_gnav_ephemeris_iter->second.d_WN, - 1, // Band 1 (L2) - d_custom_year); + 1); // Band 1 (L2) found_L1_obs = true; break; } @@ -742,8 +734,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, glonass_gnav_ephemeris_iter->second.d_WN, - 1, // Band 1 (L2) - d_custom_year); + 1); // Band 1 (L2) glo_valid_obs++; } } @@ -771,8 +762,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, beidou_ephemeris_iter->second.i_BEIDOU_week + BEIDOU_DNAV_BDT2GPST_WEEK_NUM_OFFSET, - 0, - d_custom_year); + 0); valid_obs++; } else // the ephemeris are not available for this SV @@ -794,8 +784,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 + BEIDOU_DNAV_BDT2GPST_WEEK_NUM_OFFSET, - 2, // Band 3 (L2/G2/B3) - d_custom_year); + 2); // Band 3 (L2/G2/B3) found_B1I_obs = true; break; } @@ -813,8 +802,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs, gnss_observables_iter->second, beidou_ephemeris_iter->second.i_BEIDOU_week + BEIDOU_DNAV_BDT2GPST_WEEK_NUM_OFFSET, - 2, // Band 2 (L2/G2) - d_custom_year); + 2); // Band 2 (L2/G2) valid_obs++; } } @@ -1038,7 +1026,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ // TOW monitor_pvt.TOW_at_current_symbol_ms = gnss_observables_map.begin()->second.TOW_at_current_symbol_ms; // WEEK - monitor_pvt.week = adjgpsweek(nav_data.eph[0].week, d_custom_year); + monitor_pvt.week = adjgpsweek(nav_data.eph[0].week, d_pre_2009_file); // PVT GPS time monitor_pvt.RX_time = gnss_observables_map.begin()->second.RX_time; // User clock offset [s] @@ -1096,7 +1084,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ tmp_uint32 = gnss_observables_map.begin()->second.TOW_at_current_symbol_ms; d_dump_file.write(reinterpret_cast(&tmp_uint32), sizeof(uint32_t)); // WEEK - tmp_uint32 = adjgpsweek(nav_data.eph[0].week, d_custom_year); + tmp_uint32 = adjgpsweek(nav_data.eph[0].week, d_pre_2009_file); d_dump_file.write(reinterpret_cast(&tmp_uint32), sizeof(uint32_t)); // PVT GPS time tmp_double = gnss_observables_map.begin()->second.RX_time; diff --git a/src/algorithms/libs/rtklib/rtklib_conversions.cc b/src/algorithms/libs/rtklib/rtklib_conversions.cc index e58c70db7..69b642e3a 100644 --- a/src/algorithms/libs/rtklib/rtklib_conversions.cc +++ b/src/algorithms/libs/rtklib/rtklib_conversions.cc @@ -45,7 +45,7 @@ #include #include -obsd_t insert_obs_to_rtklib(obsd_t& rtklib_obs, const Gnss_Synchro& gnss_synchro, int week, int band, int custom_year) +obsd_t insert_obs_to_rtklib(obsd_t& rtklib_obs, const Gnss_Synchro& gnss_synchro, int week, int band, bool pre_2009_file) { // Get signal type info to adjust code type based on constellation std::string sig_ = gnss_synchro.Signal; @@ -118,7 +118,7 @@ obsd_t insert_obs_to_rtklib(obsd_t& rtklib_obs, const Gnss_Synchro& gnss_synchro // rtklib_obs.time = gpst2time(adjgpsweek(week), gnss_synchro.RX_time); // } // - rtklib_obs.time = gpst2time(adjgpsweek(week, custom_year), gnss_synchro.RX_time); + rtklib_obs.time = gpst2time(adjgpsweek(week, pre_2009_file), gnss_synchro.RX_time); // account for the TOW crossover transitory in the first 18 seconds where the week is not yet updated! if (gnss_synchro.RX_time < 18.0) { @@ -170,7 +170,7 @@ geph_t eph_to_rtklib(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, const Glona } -eph_t eph_to_rtklib(const Galileo_Ephemeris& gal_eph, int custom_year) +eph_t eph_to_rtklib(const Galileo_Ephemeris& gal_eph) { eph_t rtklib_sat = {0, 0, 0, 0, 0, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, {}, 0.0, 0.0}; @@ -188,7 +188,7 @@ eph_t eph_to_rtklib(const Galileo_Ephemeris& gal_eph, int custom_year) rtklib_sat.Adot = 0; // only in CNAV; rtklib_sat.ndot = 0; // only in CNAV; - rtklib_sat.week = adjgpsweek(gal_eph.WN_5, custom_year); /* week of tow */ + rtklib_sat.week = adjgpsweek(gal_eph.WN_5); /* week of tow */ rtklib_sat.cic = gal_eph.C_ic_4; rtklib_sat.cis = gal_eph.C_is_4; rtklib_sat.cuc = gal_eph.C_uc_3; @@ -229,7 +229,7 @@ eph_t eph_to_rtklib(const Galileo_Ephemeris& gal_eph, int custom_year) } -eph_t eph_to_rtklib(const Gps_Ephemeris& gps_eph, int custom_year) +eph_t eph_to_rtklib(const Gps_Ephemeris& gps_eph, bool pre_2009_file) { eph_t rtklib_sat = {0, 0, 0, 0, 0, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, {}, 0.0, 0.0}; @@ -246,7 +246,7 @@ eph_t eph_to_rtklib(const Gps_Ephemeris& gps_eph, int custom_year) rtklib_sat.Adot = 0; // only in CNAV; rtklib_sat.ndot = 0; // only in CNAV; - rtklib_sat.week = adjgpsweek(gps_eph.i_GPS_week, custom_year); /* week of tow */ + rtklib_sat.week = adjgpsweek(gps_eph.i_GPS_week, pre_2009_file); /* week of tow */ rtklib_sat.cic = gps_eph.d_Cic; rtklib_sat.cis = gps_eph.d_Cis; rtklib_sat.cuc = gps_eph.d_Cuc; @@ -356,7 +356,7 @@ eph_t eph_to_rtklib(const Beidou_Dnav_Ephemeris& bei_eph) } -eph_t eph_to_rtklib(const Gps_CNAV_Ephemeris& gps_cnav_eph, int custom_year) +eph_t eph_to_rtklib(const Gps_CNAV_Ephemeris& gps_cnav_eph) { eph_t rtklib_sat = {0, 0, 0, 0, 0, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, {}, 0.0, 0.0}; @@ -377,7 +377,7 @@ eph_t eph_to_rtklib(const Gps_CNAV_Ephemeris& gps_cnav_eph, int custom_year) rtklib_sat.Adot = gps_cnav_eph.d_A_DOT; // only in CNAV; rtklib_sat.ndot = gps_cnav_eph.d_DELTA_DOT_N; // only in CNAV; - rtklib_sat.week = adjgpsweek(gps_cnav_eph.i_GPS_week, custom_year); /* week of tow */ + rtklib_sat.week = adjgpsweek(gps_cnav_eph.i_GPS_week); /* week of tow */ rtklib_sat.cic = gps_cnav_eph.d_Cic; rtklib_sat.cis = gps_cnav_eph.d_Cis; rtklib_sat.cuc = gps_cnav_eph.d_Cuc; diff --git a/src/algorithms/libs/rtklib/rtklib_conversions.h b/src/algorithms/libs/rtklib/rtklib_conversions.h index 6621b6ae9..68f2b33bc 100644 --- a/src/algorithms/libs/rtklib/rtklib_conversions.h +++ b/src/algorithms/libs/rtklib/rtklib_conversions.h @@ -43,9 +43,9 @@ class Gps_Almanac; class Gps_CNAV_Ephemeris; class Gps_Ephemeris; -eph_t eph_to_rtklib(const Galileo_Ephemeris& gal_eph, int custom_year); -eph_t eph_to_rtklib(const Gps_Ephemeris& gps_eph, int custom_year); -eph_t eph_to_rtklib(const Gps_CNAV_Ephemeris& gps_cnav_eph, int custom_year); +eph_t eph_to_rtklib(const Galileo_Ephemeris& gal_eph); +eph_t eph_to_rtklib(const Gps_Ephemeris& gps_eph, bool pre_2009_file); +eph_t eph_to_rtklib(const Gps_CNAV_Ephemeris& gps_cnav_eph); eph_t eph_to_rtklib(const Beidou_Dnav_Ephemeris& bei_eph); alm_t alm_to_rtklib(const Gps_Almanac& gps_alm); @@ -58,6 +58,6 @@ alm_t alm_to_rtklib(const Galileo_Almanac& gal_alm); */ geph_t eph_to_rtklib(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, const Glonass_Gnav_Utc_Model& gnav_clock_model); -obsd_t insert_obs_to_rtklib(obsd_t& rtklib_obs, const Gnss_Synchro& gnss_synchro, int week, int band, int custom_year); +obsd_t insert_obs_to_rtklib(obsd_t& rtklib_obs, const Gnss_Synchro& gnss_synchro, int week, int band, bool pre_2009_file = false); #endif /* GNSS_SDR_RTKLIB_CONVERSIONS_H_ */ diff --git a/src/algorithms/libs/rtklib/rtklib_rtcm2.cc b/src/algorithms/libs/rtklib/rtklib_rtcm2.cc index 4eefac11e..e171cff45 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtcm2.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtcm2.cc @@ -192,7 +192,7 @@ int decode_type3(rtcm_t *rtcm) /* decode type 14: gps time of week ------------------------------------------*/ -int decode_type14(rtcm_t *rtcm, int custom_year) +int decode_type14(rtcm_t *rtcm, bool pre_2009_file) { double zcnt; int i = 48; @@ -216,7 +216,7 @@ int decode_type14(rtcm_t *rtcm, int custom_year) trace(2, "rtcm2 14 length error: len=%d\n", rtcm->len); return -1; } - week = adjgpsweek(week, custom_year); + week = adjgpsweek(week, pre_2009_file); rtcm->time = gpst2time(week, hour * 3600.0 + zcnt * 0.6); rtcm->nav.leaps = leaps; return 6; @@ -244,7 +244,7 @@ int decode_type16(rtcm_t *rtcm) /* decode type 17: gps ephemerides -------------------------------------------*/ -int decode_type17(rtcm_t *rtcm, int custom_year) +int decode_type17(rtcm_t *rtcm, bool pre_2009_file) { eph_t eph = {0, -1, -1, 0, 0, 0, 0, 0, {0, 0.0}, {0, 0.0}, {0, 0.0}, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, @@ -329,7 +329,7 @@ int decode_type17(rtcm_t *rtcm, int custom_year) } sat = satno(SYS_GPS, prn); eph.sat = sat; - eph.week = adjgpsweek(week, custom_year); + eph.week = adjgpsweek(week, pre_2009_file); eph.toe = gpst2time(eph.week, eph.toes); eph.toc = gpst2time(eph.week, toc); eph.ttr = rtcm->time; diff --git a/src/algorithms/libs/rtklib/rtklib_rtcm2.h b/src/algorithms/libs/rtklib/rtklib_rtcm2.h index 56fbe948f..4a849e141 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtcm2.h +++ b/src/algorithms/libs/rtklib/rtklib_rtcm2.h @@ -61,9 +61,9 @@ void adjhour(rtcm_t *rtcm, double zcnt); int obsindex(obs_t *obs, gtime_t time, int sat); int decode_type1(rtcm_t *rtcm); int decode_type3(rtcm_t *rtcm); -int decode_type14(rtcm_t *rtcm); +int decode_type14(rtcm_t *rtcm, bool pre_2009_file = false); int decode_type16(rtcm_t *rtcm); -int decode_type17(rtcm_t *rtcm); +int decode_type17(rtcm_t *rtcm, bool pre_2009_file = false); int decode_type18(rtcm_t *rtcm); int decode_type19(rtcm_t *rtcm); int decode_type22(rtcm_t *rtcm); diff --git a/src/algorithms/libs/rtklib/rtklib_rtcm3.cc b/src/algorithms/libs/rtklib/rtklib_rtcm3.cc index 623e0d618..a35fdfc2d 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtcm3.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtcm3.cc @@ -1036,7 +1036,7 @@ int decode_type1013(rtcm_t *rtcm __attribute__((unused))) /* decode type 1019: gps ephemerides -----------------------------------------*/ -int decode_type1019(rtcm_t *rtcm, int custom_year) +int decode_type1019(rtcm_t *rtcm, bool pre_2009_file) { eph_t eph = {0, -1, -1, 0, 0, 0, 0, 0, {0, 0.0}, {0, 0.0}, {0, 0.0}, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, @@ -1136,7 +1136,7 @@ int decode_type1019(rtcm_t *rtcm, int custom_year) return -1; } eph.sat = sat; - eph.week = adjgpsweek(week, custom_year); + eph.week = adjgpsweek(week, pre_2009_file); eph.toe = gpst2time(eph.week, eph.toes); eph.toc = gpst2time(eph.week, toc); eph.ttr = rtcm->time; @@ -1535,7 +1535,7 @@ int decode_type1039(rtcm_t *rtcm __attribute__((unused))) /* decode type 1044: qzss ephemerides (ref [15]) -----------------------------*/ -int decode_type1044(rtcm_t *rtcm, int custom_year) +int decode_type1044(rtcm_t *rtcm, bool pre_2009_file) { eph_t eph = {0, -1, -1, 0, 0, 0, 0, 0, {0, 0.0}, {0, 0.0}, {0, 0.0}, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, @@ -1628,7 +1628,7 @@ int decode_type1044(rtcm_t *rtcm, int custom_year) return -1; } eph.sat = sat; - eph.week = adjgpsweek(week, custom_year); + eph.week = adjgpsweek(week, pre_2009_file); eph.toe = gpst2time(eph.week, eph.toes); eph.toc = gpst2time(eph.week, toc); eph.ttr = rtcm->time; diff --git a/src/algorithms/libs/rtklib/rtklib_rtcm3.h b/src/algorithms/libs/rtklib/rtklib_rtcm3.h index 847bae424..0e229e6ba 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtcm3.h +++ b/src/algorithms/libs/rtklib/rtklib_rtcm3.h @@ -149,7 +149,7 @@ int decode_type1012(rtcm_t *rtcm); int decode_type1013(rtcm_t *rtcm); -int decode_type1019(rtcm_t *rtcm); +int decode_type1019(rtcm_t *rtcm, bool pre_2009_file = false); int decode_type1020(rtcm_t *rtcm); @@ -187,7 +187,7 @@ int decode_type1038(rtcm_t *rtcm); int decode_type1039(rtcm_t *rtcm); -int decode_type1044(rtcm_t *rtcm); +int decode_type1044(rtcm_t *rtcm, bool pre_2009_file = false); int decode_type1045(rtcm_t *rtcm); diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index d262022a1..6856f399c 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -2114,7 +2114,7 @@ double time2doy(gtime_t t) * args : int week I not-adjusted gps week number * return : adjusted gps week number *-----------------------------------------------------------------------------*/ -int adjgpsweek(int week, int custom_year) +int adjgpsweek(int week, bool pre_2009_file) { // int w; // if (week < 512) @@ -2133,7 +2133,7 @@ int adjgpsweek(int week, int custom_year) return week; } - if (custom_year == 0) + if (pre_2009_file == false) { (void)time2gpst(utc2gpst(timeget()), &w); if (w < 1560) @@ -2144,18 +2144,7 @@ int adjgpsweek(int week, int custom_year) } else { - if (custom_year >= 2019) - { - w = week + 2048; // add weeks from 6-january-1980 to week rollover in 6 april 2019 - } - else if (custom_year < 2019 and custom_year >= 1999) - { - w = week + 1024; // add weeks from 6-january-1980 to week rollover in 21 august 1999 - } - else - { - w = week; // no rollover - } + w = week + 1024; // add weeks from 6-january-1980 to week rollover in 21 august 1999 return w; } } diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.h b/src/algorithms/libs/rtklib/rtklib_rtkcmn.h index 9eb64207a..d118a5bb6 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.h +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.h @@ -189,7 +189,7 @@ double utc2gmst(gtime_t t, double ut1_utc); void time2str(gtime_t t, char *s, int n); char *time_str(gtime_t t, int n); double time2doy(gtime_t t); -int adjgpsweek(int week, int custom_year); +int adjgpsweek(int week, bool pre_2009_file = false); unsigned int tickget(); void sleepms(int ms); void deg2dms(double deg, double *dms, int ndec); diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 6d9cd055d..0966f5441 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -117,7 +117,7 @@ ControlThread::ControlThread(const std::shared_ptr &conf void ControlThread::init() { // OPTIONAL: specify a custom year to override the system time in order to postprocess old gnss records and avoid wrong week rollover - custom_year_ = configuration_->property("GNSS-SDR.custom_year", 0); + pre_2009_file_ = configuration_->property("GNSS-SDR.pre_2009_file", false); // Instantiates a control queue, a GNSS flowgraph, and a control message factory control_queue_ = std::make_shared>(); cmd_interface_.set_msg_queue(control_queue_); // set also the queue pointer for the telecommand thread @@ -944,7 +944,7 @@ std::vector> ControlThread::get_visible_sats(time std::map gps_eph_map = pvt_ptr->get_gps_ephemeris(); for (auto &it : gps_eph_map) { - eph_t rtklib_eph = eph_to_rtklib(it.second, custom_year_); + eph_t rtklib_eph = eph_to_rtklib(it.second, pre_2009_file_); std::array r_sat{}; double clock_bias_s; double sat_pos_variance_m2; @@ -969,7 +969,7 @@ std::vector> ControlThread::get_visible_sats(time std::map gal_eph_map = pvt_ptr->get_galileo_ephemeris(); for (auto &it : gal_eph_map) { - eph_t rtklib_eph = eph_to_rtklib(it.second, custom_year_); + eph_t rtklib_eph = eph_to_rtklib(it.second); std::array r_sat{}; double clock_bias_s; double sat_pos_variance_m2; diff --git a/src/core/receiver/control_thread.h b/src/core/receiver/control_thread.h index b993f6d03..2e6c4239e 100644 --- a/src/core/receiver/control_thread.h +++ b/src/core/receiver/control_thread.h @@ -171,7 +171,7 @@ private: std::shared_ptr flowgraph_; std::shared_ptr configuration_; std::shared_ptr> control_queue_; - int custom_year_; // to override the system time to postprocess old gnss records and avoid wrong week rollover + bool pre_2009_file_; // to override the system time to postprocess old gnss records and avoid wrong week rollover bool stop_; bool restart_; bool delete_configuration_;