Fix TOW week crossover in PVT time prints and rinex obs prints

This commit is contained in:
Javier Arribas 2019-05-09 18:05:46 +02:00
parent 6a6ec19b63
commit 87e30c2fcb
3 changed files with 25 additions and 4 deletions

View File

@ -11116,6 +11116,10 @@ boost::posix_time::ptime Rinex_Printer::compute_GPS_time(const Gps_Ephemeris& ep
// --??? No time correction here, since it will be done in the RINEX processor
const double gps_t = obs_time;
boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast<int64_t>((gps_t + 604800 * static_cast<double>(eph.i_GPS_week % 1024)) * 1000));
if (obs_time < 18)
{
t += boost::posix_time::seconds(604800);
}
if (eph.i_GPS_week < 512)
{
boost::posix_time::ptime p_time(boost::gregorian::date(2019, 4, 7), t);

View File

@ -991,9 +991,6 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
this->set_course_over_ground(new_cog);
}
//observable fix:
//double offset_s = this->get_time_offset_s();
//this->set_time_offset_s(offset_s + (rx_position_and_time(3) / GPS_C_m_s)); // accumulate the rx time error for the next iteration [meters]->[seconds]
this->set_time_offset_s(rx_position_and_time(3));
DLOG(INFO) << "RTKLIB Position at RX TOW = " << gnss_observables_map.begin()->second.RX_time
@ -1002,10 +999,17 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
boost::posix_time::ptime p_time;
// gtime_t rtklib_utc_time = gpst2utc(pvt_sol.time); //Corrected RX Time (Non integer multiply of 1 ms of granularity)
// Uncorrected RX Time (integer multiply of 1 ms and the same observables time reported in RTCM and RINEX)
gtime_t rtklib_time = gpst2time(adjgpsweek(nav_data.eph[0].week), gnss_observables_map.begin()->second.RX_time);
gtime_t rtklib_time = timeadd(pvt_sol.time, rx_position_and_time(3)); //uncorrected rx time
if (gnss_observables_map.begin()->second.RX_time < 18000.0)
{
//p_time += boost::posix_time::seconds(604800);
rtklib_time = timeadd(rtklib_time, 604800);
}
gtime_t rtklib_utc_time = gpst2utc(rtklib_time);
p_time = boost::posix_time::from_time_t(rtklib_utc_time.time);
p_time += boost::posix_time::microseconds(static_cast<long>(round(rtklib_utc_time.sec * 1e6))); // NOLINT(google-runtime-int)
this->set_position_UTC_time(p_time);
cart2geo(static_cast<double>(rx_position_and_time(0)), static_cast<double>(rx_position_and_time(1)), static_cast<double>(rx_position_and_time(2)), 4);
@ -1014,6 +1018,7 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
<< " [deg], Height= " << this->get_height() << " [m]"
<< " RX time offset= " << this->get_time_offset_s() << " [s]";
// PVT MONITOR
// TOW

View File

@ -2044,6 +2044,17 @@ double time2doy(gtime_t t)
*-----------------------------------------------------------------------------*/
int adjgpsweek(int week)
{
// 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
// }
// else
// {
// //assume receiver date < 7 april 2019
// w = week + 1024; //add weeks from 6-january-1980 to week rollover in 22 august 2019
// }
int w;
(void)time2gpst(utc2gpst(timeget()), &w);
if (w < 1560)
@ -2051,6 +2062,7 @@ int adjgpsweek(int week)
w = 1560; /* use 2009/12/1 if time is earlier than 2009/12/1 */
}
return week + (w - week + 512) / 1024 * 1024;
// return w;
}