mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-11-04 09:13:05 +00:00 
			
		
		
		
	Adding global configuration option to specify a custom year in order to postprocess old GNSS captures and avoid wrong week rollover
This commit is contained in:
		@@ -68,6 +68,9 @@ 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);
 | 
			
		||||
 | 
			
		||||
    // output rate
 | 
			
		||||
    pvt_output_parameters.output_rate_ms = bc::lcm(20, configuration->property(role + ".output_rate_ms", 500));
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -467,18 +467,21 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels,
 | 
			
		||||
            // user PVT solver
 | 
			
		||||
            d_user_pvt_solver = std::make_shared<Rtklib_Solver>(static_cast<int32_t>(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);
 | 
			
		||||
 | 
			
		||||
            // 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<Rtklib_Solver>(static_cast<int32_t>(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);
 | 
			
		||||
        }
 | 
			
		||||
    else
 | 
			
		||||
        {
 | 
			
		||||
            // only one solver, customized by the user options
 | 
			
		||||
            d_internal_pvt_solver = std::make_shared<Rtklib_Solver>(static_cast<int32_t>(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_user_pvt_solver = d_internal_pvt_solver;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -76,6 +76,6 @@ Pvt_Conf::Pvt_Conf()
 | 
			
		||||
    monitor_enabled = false;
 | 
			
		||||
    protobuf_enabled = true;
 | 
			
		||||
    udp_port = 0;
 | 
			
		||||
 | 
			
		||||
    custom_year = 0;
 | 
			
		||||
    show_local_time_zone = false;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -91,6 +91,7 @@ public:
 | 
			
		||||
 | 
			
		||||
    bool enable_rx_clock_correction;
 | 
			
		||||
    bool show_local_time_zone;
 | 
			
		||||
    int custom_year;
 | 
			
		||||
 | 
			
		||||
    Pvt_Conf();
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -53,6 +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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -431,3 +432,8 @@ void Pvt_Solution::set_num_valid_observations(int num)
 | 
			
		||||
{
 | 
			
		||||
    d_valid_observations = num;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Pvt_Solution::set_custom_year(int custom_year)
 | 
			
		||||
{
 | 
			
		||||
    d_custom_year = custom_year;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -49,7 +49,7 @@ 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]
 | 
			
		||||
 | 
			
		||||
@@ -129,6 +129,8 @@ 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
 | 
			
		||||
private:
 | 
			
		||||
    double d_rx_dt_s;  // RX time offset [s]
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -496,13 +496,14 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &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);
 | 
			
		||||
                                        eph_data[valid_obs] = eph_to_rtklib(galileo_ephemeris_iter->second, d_custom_year);
 | 
			
		||||
                                        // 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);
 | 
			
		||||
                                            0,
 | 
			
		||||
                                            d_custom_year);
 | 
			
		||||
                                        valid_obs++;
 | 
			
		||||
                                    }
 | 
			
		||||
                                else  // the ephemeris are not available for this SV
 | 
			
		||||
@@ -526,7 +527,8 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &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)
 | 
			
		||||
                                                            2,  // Band 3 (L5/E5)
 | 
			
		||||
                                                            d_custom_year);
 | 
			
		||||
                                                        found_E1_obs = true;
 | 
			
		||||
                                                        break;
 | 
			
		||||
                                                    }
 | 
			
		||||
@@ -535,7 +537,7 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &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);
 | 
			
		||||
                                                eph_data[valid_obs] = eph_to_rtklib(galileo_ephemeris_iter->second, d_custom_year);
 | 
			
		||||
                                                // convert observation from GNSS-SDR class to RTKLIB structure
 | 
			
		||||
                                                auto default_code_ = static_cast<unsigned char>(CODE_NONE);
 | 
			
		||||
                                                obsd_t newobs = {{0, 0}, '0', '0', {}, {},
 | 
			
		||||
@@ -544,7 +546,8 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &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)
 | 
			
		||||
                                                    2,  // Band 3 (L5/E5)
 | 
			
		||||
                                                    d_custom_year);
 | 
			
		||||
                                                valid_obs++;
 | 
			
		||||
                                            }
 | 
			
		||||
                                    }
 | 
			
		||||
@@ -566,13 +569,14 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &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);
 | 
			
		||||
                                        eph_data[valid_obs] = eph_to_rtklib(gps_ephemeris_iter->second, d_custom_year);
 | 
			
		||||
                                        // 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);
 | 
			
		||||
                                            0,
 | 
			
		||||
                                            d_custom_year);
 | 
			
		||||
                                        valid_obs++;
 | 
			
		||||
                                    }
 | 
			
		||||
                                else  // the ephemeris are not available for this SV
 | 
			
		||||
@@ -611,7 +615,7 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &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);
 | 
			
		||||
                                                eph_data[valid_obs] = eph_to_rtklib(gps_cnav_ephemeris_iter->second, d_custom_year);
 | 
			
		||||
                                                // convert observation from GNSS-SDR class to RTKLIB structure
 | 
			
		||||
                                                auto default_code_ = static_cast<unsigned char>(CODE_NONE);
 | 
			
		||||
                                                obsd_t newobs = {{0, 0}, '0', '0', {}, {},
 | 
			
		||||
@@ -620,7 +624,8 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &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)
 | 
			
		||||
                                                    1,  // Band 2 (L2)
 | 
			
		||||
                                                    d_custom_year);
 | 
			
		||||
                                                valid_obs++;
 | 
			
		||||
                                            }
 | 
			
		||||
                                    }
 | 
			
		||||
@@ -645,11 +650,12 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
 | 
			
		||||
                                                    {
 | 
			
		||||
                                                        if (eph_data[i].sat == static_cast<int>(gnss_observables_iter->second.PRN))
 | 
			
		||||
                                                            {
 | 
			
		||||
                                                                eph_data[i] = eph_to_rtklib(gps_cnav_ephemeris_iter->second);
 | 
			
		||||
                                                                eph_data[i] = eph_to_rtklib(gps_cnav_ephemeris_iter->second, d_custom_year);
 | 
			
		||||
                                                                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)
 | 
			
		||||
                                                                    2,  // Band 3 (L5)
 | 
			
		||||
                                                                    d_custom_year);
 | 
			
		||||
                                                                break;
 | 
			
		||||
                                                            }
 | 
			
		||||
                                                    }
 | 
			
		||||
@@ -658,7 +664,7 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &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);
 | 
			
		||||
                                                eph_data[valid_obs] = eph_to_rtklib(gps_cnav_ephemeris_iter->second, d_custom_year);
 | 
			
		||||
                                                // convert observation from GNSS-SDR class to RTKLIB structure
 | 
			
		||||
                                                auto default_code_ = static_cast<unsigned char>(CODE_NONE);
 | 
			
		||||
                                                obsd_t newobs = {{0, 0}, '0', '0', {}, {},
 | 
			
		||||
@@ -667,7 +673,8 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &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)
 | 
			
		||||
                                                    2,  // Band 3 (L5)
 | 
			
		||||
                                                    d_custom_year);
 | 
			
		||||
                                                valid_obs++;
 | 
			
		||||
                                            }
 | 
			
		||||
                                    }
 | 
			
		||||
@@ -695,7 +702,8 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &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)
 | 
			
		||||
                                            0,  // Band 0 (L1)
 | 
			
		||||
                                            d_custom_year);
 | 
			
		||||
                                        glo_valid_obs++;
 | 
			
		||||
                                    }
 | 
			
		||||
                                else  // the ephemeris are not available for this SV
 | 
			
		||||
@@ -718,7 +726,8 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &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)
 | 
			
		||||
                                                            1,  // Band 1 (L2)
 | 
			
		||||
                                                            d_custom_year);
 | 
			
		||||
                                                        found_L1_obs = true;
 | 
			
		||||
                                                        break;
 | 
			
		||||
                                                    }
 | 
			
		||||
@@ -733,7 +742,8 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &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)
 | 
			
		||||
                                                    1,  // Band 1 (L2)
 | 
			
		||||
                                                    d_custom_year);
 | 
			
		||||
                                                glo_valid_obs++;
 | 
			
		||||
                                            }
 | 
			
		||||
                                    }
 | 
			
		||||
@@ -761,7 +771,8 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &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);
 | 
			
		||||
                                            0,
 | 
			
		||||
                                            d_custom_year);
 | 
			
		||||
                                        valid_obs++;
 | 
			
		||||
                                    }
 | 
			
		||||
                                else  // the ephemeris are not available for this SV
 | 
			
		||||
@@ -783,7 +794,8 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &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)
 | 
			
		||||
                                                            2,  // Band 3 (L2/G2/B3)
 | 
			
		||||
                                                            d_custom_year);
 | 
			
		||||
                                                        found_B1I_obs = true;
 | 
			
		||||
                                                        break;
 | 
			
		||||
                                                    }
 | 
			
		||||
@@ -801,7 +813,8 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &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)
 | 
			
		||||
                                                    2,  // Band 2 (L2/G2)
 | 
			
		||||
                                                    d_custom_year);
 | 
			
		||||
                                                valid_obs++;
 | 
			
		||||
                                            }
 | 
			
		||||
                                    }
 | 
			
		||||
@@ -1025,7 +1038,7 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &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);
 | 
			
		||||
                    monitor_pvt.week = adjgpsweek(nav_data.eph[0].week, d_custom_year);
 | 
			
		||||
                    // PVT GPS time
 | 
			
		||||
                    monitor_pvt.RX_time = gnss_observables_map.begin()->second.RX_time;
 | 
			
		||||
                    // User clock offset [s]
 | 
			
		||||
@@ -1083,7 +1096,7 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
 | 
			
		||||
                                    tmp_uint32 = gnss_observables_map.begin()->second.TOW_at_current_symbol_ms;
 | 
			
		||||
                                    d_dump_file.write(reinterpret_cast<char *>(&tmp_uint32), sizeof(uint32_t));
 | 
			
		||||
                                    // WEEK
 | 
			
		||||
                                    tmp_uint32 = adjgpsweek(nav_data.eph[0].week);
 | 
			
		||||
                                    tmp_uint32 = adjgpsweek(nav_data.eph[0].week, d_custom_year);
 | 
			
		||||
                                    d_dump_file.write(reinterpret_cast<char *>(&tmp_uint32), sizeof(uint32_t));
 | 
			
		||||
                                    // PVT GPS time
 | 
			
		||||
                                    tmp_double = gnss_observables_map.begin()->second.RX_time;
 | 
			
		||||
 
 | 
			
		||||
@@ -45,7 +45,7 @@
 | 
			
		||||
#include <cstdint>
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
obsd_t insert_obs_to_rtklib(obsd_t& rtklib_obs, const Gnss_Synchro& gnss_synchro, int week, int band)
 | 
			
		||||
obsd_t insert_obs_to_rtklib(obsd_t& rtklib_obs, const Gnss_Synchro& gnss_synchro, int week, int band, int custom_year)
 | 
			
		||||
{
 | 
			
		||||
    // 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), gnss_synchro.RX_time);
 | 
			
		||||
    rtklib_obs.time = gpst2time(adjgpsweek(week, custom_year), 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)
 | 
			
		||||
        {
 | 
			
		||||
@@ -158,19 +158,19 @@ geph_t eph_to_rtklib(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, const Glona
 | 
			
		||||
 | 
			
		||||
    // Time expressed in GPS Time but using RTKLib format
 | 
			
		||||
    glonass_gnav_eph.glot_to_gpst(glonass_gnav_eph.d_t_b, gnav_clock_model.d_tau_c, gnav_clock_model.d_tau_gps, &week, &sec);
 | 
			
		||||
    adj_week = adjgpsweek(static_cast<int>(week));
 | 
			
		||||
    adj_week = adjgpsweek(static_cast<int>(week), 0);
 | 
			
		||||
    rtklib_sat.toe = gpst2time(adj_week, sec);
 | 
			
		||||
 | 
			
		||||
    // Time expressed in GPS Time but using RTKLib format
 | 
			
		||||
    glonass_gnav_eph.glot_to_gpst(glonass_gnav_eph.d_t_k, gnav_clock_model.d_tau_c, gnav_clock_model.d_tau_gps, &week, &sec);
 | 
			
		||||
    adj_week = adjgpsweek(static_cast<int>(week));
 | 
			
		||||
    adj_week = adjgpsweek(static_cast<int>(week), 0);
 | 
			
		||||
    rtklib_sat.tof = gpst2time(adj_week, sec);
 | 
			
		||||
 | 
			
		||||
    return rtklib_sat;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
eph_t eph_to_rtklib(const Galileo_Ephemeris& gal_eph)
 | 
			
		||||
eph_t eph_to_rtklib(const Galileo_Ephemeris& gal_eph, int custom_year)
 | 
			
		||||
{
 | 
			
		||||
    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)
 | 
			
		||||
    rtklib_sat.Adot = 0;  // only in CNAV;
 | 
			
		||||
    rtklib_sat.ndot = 0;  // only in CNAV;
 | 
			
		||||
 | 
			
		||||
    rtklib_sat.week = adjgpsweek(gal_eph.WN_5); /* week of tow */
 | 
			
		||||
    rtklib_sat.week = adjgpsweek(gal_eph.WN_5, custom_year); /* 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)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
eph_t eph_to_rtklib(const Gps_Ephemeris& gps_eph)
 | 
			
		||||
eph_t eph_to_rtklib(const Gps_Ephemeris& gps_eph, int custom_year)
 | 
			
		||||
{
 | 
			
		||||
    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)
 | 
			
		||||
    rtklib_sat.Adot = 0;  // only in CNAV;
 | 
			
		||||
    rtklib_sat.ndot = 0;  // only in CNAV;
 | 
			
		||||
 | 
			
		||||
    rtklib_sat.week = adjgpsweek(gps_eph.i_GPS_week); /* week of tow */
 | 
			
		||||
    rtklib_sat.week = adjgpsweek(gps_eph.i_GPS_week, custom_year); /* 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)
 | 
			
		||||
eph_t eph_to_rtklib(const Gps_CNAV_Ephemeris& gps_cnav_eph, int custom_year)
 | 
			
		||||
{
 | 
			
		||||
    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)
 | 
			
		||||
    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); /* week of tow */
 | 
			
		||||
    rtklib_sat.week = adjgpsweek(gps_cnav_eph.i_GPS_week, custom_year); /* 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;
 | 
			
		||||
 
 | 
			
		||||
@@ -43,9 +43,9 @@ class Gps_Almanac;
 | 
			
		||||
class Gps_CNAV_Ephemeris;
 | 
			
		||||
class Gps_Ephemeris;
 | 
			
		||||
 | 
			
		||||
eph_t eph_to_rtklib(const Galileo_Ephemeris& gal_eph);
 | 
			
		||||
eph_t eph_to_rtklib(const Gps_Ephemeris& gps_eph);
 | 
			
		||||
eph_t eph_to_rtklib(const Gps_CNAV_Ephemeris& gps_cnav_eph);
 | 
			
		||||
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 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);
 | 
			
		||||
obsd_t insert_obs_to_rtklib(obsd_t& rtklib_obs, const Gnss_Synchro& gnss_synchro, int week, int band, int custom_year);
 | 
			
		||||
 | 
			
		||||
#endif /* GNSS_SDR_RTKLIB_CONVERSIONS_H_ */
 | 
			
		||||
 
 | 
			
		||||
@@ -192,7 +192,7 @@ int decode_type3(rtcm_t *rtcm)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* decode type 14: gps time of week ------------------------------------------*/
 | 
			
		||||
int decode_type14(rtcm_t *rtcm)
 | 
			
		||||
int decode_type14(rtcm_t *rtcm, int custom_year)
 | 
			
		||||
{
 | 
			
		||||
    double zcnt;
 | 
			
		||||
    int i = 48;
 | 
			
		||||
@@ -216,7 +216,7 @@ int decode_type14(rtcm_t *rtcm)
 | 
			
		||||
            trace(2, "rtcm2 14 length error: len=%d\n", rtcm->len);
 | 
			
		||||
            return -1;
 | 
			
		||||
        }
 | 
			
		||||
    week = adjgpsweek(week);
 | 
			
		||||
    week = adjgpsweek(week, custom_year);
 | 
			
		||||
    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 decode_type17(rtcm_t *rtcm, int custom_year)
 | 
			
		||||
{
 | 
			
		||||
    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)
 | 
			
		||||
        }
 | 
			
		||||
    sat = satno(SYS_GPS, prn);
 | 
			
		||||
    eph.sat = sat;
 | 
			
		||||
    eph.week = adjgpsweek(week);
 | 
			
		||||
    eph.week = adjgpsweek(week, custom_year);
 | 
			
		||||
    eph.toe = gpst2time(eph.week, eph.toes);
 | 
			
		||||
    eph.toc = gpst2time(eph.week, toc);
 | 
			
		||||
    eph.ttr = rtcm->time;
 | 
			
		||||
 
 | 
			
		||||
@@ -1036,7 +1036,7 @@ int decode_type1013(rtcm_t *rtcm __attribute__((unused)))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* decode type 1019: gps ephemerides -----------------------------------------*/
 | 
			
		||||
int decode_type1019(rtcm_t *rtcm)
 | 
			
		||||
int decode_type1019(rtcm_t *rtcm, int custom_year)
 | 
			
		||||
{
 | 
			
		||||
    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)
 | 
			
		||||
            return -1;
 | 
			
		||||
        }
 | 
			
		||||
    eph.sat = sat;
 | 
			
		||||
    eph.week = adjgpsweek(week);
 | 
			
		||||
    eph.week = adjgpsweek(week, custom_year);
 | 
			
		||||
    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 decode_type1044(rtcm_t *rtcm, int custom_year)
 | 
			
		||||
{
 | 
			
		||||
    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)
 | 
			
		||||
            return -1;
 | 
			
		||||
        }
 | 
			
		||||
    eph.sat = sat;
 | 
			
		||||
    eph.week = adjgpsweek(week);
 | 
			
		||||
    eph.week = adjgpsweek(week, custom_year);
 | 
			
		||||
    eph.toe = gpst2time(eph.week, eph.toes);
 | 
			
		||||
    eph.toc = gpst2time(eph.week, toc);
 | 
			
		||||
    eph.ttr = rtcm->time;
 | 
			
		||||
 
 | 
			
		||||
@@ -2114,27 +2114,45 @@ double time2doy(gtime_t t)
 | 
			
		||||
 * args   : int   week       I   not-adjusted gps week number
 | 
			
		||||
 * return : adjusted gps week number
 | 
			
		||||
 *-----------------------------------------------------------------------------*/
 | 
			
		||||
int adjgpsweek(int week)
 | 
			
		||||
int adjgpsweek(int week, int custom_year)
 | 
			
		||||
{
 | 
			
		||||
    //    int w;
 | 
			
		||||
    //    if (week < 512)
 | 
			
		||||
    //        {
 | 
			
		||||
    //            //assume receiver date > 7 april 2019
 | 
			
		||||
    //            w = week + 2048;  //add weeks from 6-january-1980 to week rollover in 7 april 2019
 | 
			
		||||
    //            w = week + 2048;  //add weeks from 6-january-1980 to week rollover in 6 april 2019
 | 
			
		||||
    //        }
 | 
			
		||||
    //    else
 | 
			
		||||
    //        {
 | 
			
		||||
    //            //assume receiver date < 7 april 2019
 | 
			
		||||
    //            w = week + 1024;  //add weeks from 6-january-1980 to week rollover in 22 august 2019
 | 
			
		||||
    //            w = week + 1024;  //add weeks from 6-january-1980 to week rollover in 21 august 1999
 | 
			
		||||
    //        }
 | 
			
		||||
    int w;
 | 
			
		||||
    if (custom_year == 0)
 | 
			
		||||
        {
 | 
			
		||||
            (void)time2gpst(utc2gpst(timeget()), &w);
 | 
			
		||||
            if (w < 1560)
 | 
			
		||||
                {
 | 
			
		||||
                    w = 1560; /* use 2009/12/1 if time is earlier than 2009/12/1 */
 | 
			
		||||
                }
 | 
			
		||||
            return week + (w - week + 512) / 1024 * 1024;
 | 
			
		||||
    //    return w;
 | 
			
		||||
        }
 | 
			
		||||
    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
 | 
			
		||||
                }
 | 
			
		||||
            return w;
 | 
			
		||||
        }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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 adjgpsweek(int week, int custom_year);
 | 
			
		||||
unsigned int tickget();
 | 
			
		||||
void sleepms(int ms);
 | 
			
		||||
void deg2dms(double deg, double *dms, int ndec);
 | 
			
		||||
 
 | 
			
		||||
@@ -116,6 +116,8 @@ ControlThread::ControlThread(const std::shared_ptr<ConfigurationInterface> &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);
 | 
			
		||||
    // Instantiates a control queue, a GNSS flowgraph, and a control message factory
 | 
			
		||||
    control_queue_ = std::make_shared<Concurrent_Queue<pmt::pmt_t>>();
 | 
			
		||||
    cmd_interface_.set_msg_queue(control_queue_);  // set also the queue pointer for the telecommand thread
 | 
			
		||||
@@ -942,7 +944,7 @@ std::vector<std::pair<int, Gnss_Satellite>> ControlThread::get_visible_sats(time
 | 
			
		||||
    std::map<int, Gps_Ephemeris> gps_eph_map = pvt_ptr->get_gps_ephemeris();
 | 
			
		||||
    for (auto &it : gps_eph_map)
 | 
			
		||||
        {
 | 
			
		||||
            eph_t rtklib_eph = eph_to_rtklib(it.second);
 | 
			
		||||
            eph_t rtklib_eph = eph_to_rtklib(it.second, custom_year_);
 | 
			
		||||
            std::array<double, 3> r_sat{};
 | 
			
		||||
            double clock_bias_s;
 | 
			
		||||
            double sat_pos_variance_m2;
 | 
			
		||||
@@ -967,7 +969,7 @@ std::vector<std::pair<int, Gnss_Satellite>> ControlThread::get_visible_sats(time
 | 
			
		||||
    std::map<int, Galileo_Ephemeris> gal_eph_map = pvt_ptr->get_galileo_ephemeris();
 | 
			
		||||
    for (auto &it : gal_eph_map)
 | 
			
		||||
        {
 | 
			
		||||
            eph_t rtklib_eph = eph_to_rtklib(it.second);
 | 
			
		||||
            eph_t rtklib_eph = eph_to_rtklib(it.second, custom_year_);
 | 
			
		||||
            std::array<double, 3> r_sat{};
 | 
			
		||||
            double clock_bias_s;
 | 
			
		||||
            double sat_pos_variance_m2;
 | 
			
		||||
 
 | 
			
		||||
@@ -171,6 +171,7 @@ private:
 | 
			
		||||
    std::shared_ptr<GNSSFlowgraph> flowgraph_;
 | 
			
		||||
    std::shared_ptr<ConfigurationInterface> configuration_;
 | 
			
		||||
    std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> control_queue_;
 | 
			
		||||
    int custom_year_;  //to override the system time to postprocess old gnss records and avoid wrong week rollover
 | 
			
		||||
    bool stop_;
 | 
			
		||||
    bool restart_;
 | 
			
		||||
    bool delete_configuration_;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user