mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-18 05:03:01 +00:00
bugfix: Adjusting time of week (TOW) computation for GLONASS
Fixing the time of week computation for GLONASS by treating N_T as a day offset from January 1. It also adds more units test for TOW checks
This commit is contained in:
parent
c9fba22307
commit
791dfbd6d3
@ -118,7 +118,6 @@ void Glonass_Gnav_Ephemeris::glot_to_gpst(double tod_offset, double glot2utc_cor
|
||||
double days = 0.0;
|
||||
double total_sec = 0.0, sec_of_day = 0.0;
|
||||
int i = 0;
|
||||
boost::gregorian::days d3(0);
|
||||
|
||||
boost::gregorian::date gps_epoch { 1980, 1, 6 };
|
||||
|
||||
@ -129,14 +128,8 @@ void Glonass_Gnav_Ephemeris::glot_to_gpst(double tod_offset, double glot2utc_cor
|
||||
|
||||
boost::posix_time::time_duration t(0, 0, tod);
|
||||
boost::gregorian::date d1(d_yr, 1, 1);
|
||||
boost::gregorian::days d2(d_N_T);
|
||||
|
||||
if(tod < 0)
|
||||
{
|
||||
d3 = boost::gregorian::days(-1);
|
||||
}
|
||||
|
||||
boost::posix_time::ptime glonass_time(d1+d2+d3, t);
|
||||
boost::gregorian::days d2(d_N_T-1);
|
||||
boost::posix_time::ptime glonass_time(d1+d2, t);
|
||||
boost::gregorian::date utc_date = glonass_time.date();
|
||||
|
||||
// Total number of days
|
||||
|
@ -64,11 +64,12 @@ TEST(GlonassGnavEphemerisTest, ComputeGlonassTime)
|
||||
ASSERT_TRUE(expected_gtime.seconds() - t.seconds() < FLT_EPSILON );
|
||||
}
|
||||
|
||||
TEST(GlonassGnavEphemerisTest, ConvertGlonassT2GpsT)
|
||||
// testing case where calendar
|
||||
TEST(GlonassGnavEphemerisTest, ConvertGlonassT2GpsT1)
|
||||
{
|
||||
Glonass_Gnav_Ephemeris gnav_eph;
|
||||
gnav_eph.d_yr = 2005;
|
||||
gnav_eph.d_N_T = 32;
|
||||
gnav_eph.d_yr = 2004;
|
||||
gnav_eph.d_N_T = 366+28;
|
||||
|
||||
double tod = 70200;
|
||||
double week = 0.0;
|
||||
@ -83,3 +84,43 @@ TEST(GlonassGnavEphemerisTest, ConvertGlonassT2GpsT)
|
||||
ASSERT_TRUE(week - true_week < FLT_EPSILON );
|
||||
ASSERT_TRUE(tow - true_week < FLT_EPSILON );
|
||||
}
|
||||
|
||||
TEST(GlonassGnavEphemerisTest, ConvertGlonassT2GpsT2)
|
||||
{
|
||||
Glonass_Gnav_Ephemeris gnav_eph;
|
||||
gnav_eph.d_yr = 2016;
|
||||
gnav_eph.d_N_T = 268;
|
||||
|
||||
double tod = 7560;
|
||||
double week = 0.0;
|
||||
double tow = 0.0;
|
||||
double true_leap_sec = 13;
|
||||
double true_week = 1915;
|
||||
double true_tow = 480600+true_leap_sec;
|
||||
|
||||
gnav_eph.glot_to_gpst(tod, 0.0, 0.0, &week, &tow);
|
||||
|
||||
// Perform assertions of decoded fields
|
||||
ASSERT_TRUE(week - true_week < FLT_EPSILON );
|
||||
ASSERT_TRUE(tow - true_week < FLT_EPSILON );
|
||||
}
|
||||
|
||||
TEST(GlonassGnavEphemerisTest, ConvertGlonassT2GpsT3)
|
||||
{
|
||||
Glonass_Gnav_Ephemeris gnav_eph;
|
||||
gnav_eph.d_yr = 2016;
|
||||
gnav_eph.d_N_T = 62;
|
||||
|
||||
double tod = 7560 + 6*3600;
|
||||
double week = 0.0;
|
||||
double tow = 0.0;
|
||||
double true_leap_sec = 13;
|
||||
double true_week = 1307;
|
||||
double true_tow = 480600+true_leap_sec;
|
||||
|
||||
gnav_eph.glot_to_gpst(tod, 0.0, 0.0, &week, &tow);
|
||||
|
||||
// Perform assertions of decoded fields
|
||||
ASSERT_TRUE(week - true_week < FLT_EPSILON );
|
||||
ASSERT_TRUE(tow - true_week < FLT_EPSILON );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user