1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-11-07 18:54:06 +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:
Javier
2019-09-13 16:36:41 +02:00
parent e80122f4ff
commit ad51654fbf
15 changed files with 105 additions and 56 deletions

View File

@@ -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;

View File

@@ -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_ */

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
(void)time2gpst(utc2gpst(timeget()), &w);
if (w < 1560)
if (custom_year == 0)
{
w = 1560; /* use 2009/12/1 if time is earlier than 2009/12/1 */
(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;
}
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;
}
return week + (w - week + 512) / 1024 * 1024;
// return w;
}

View File

@@ -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);