2017-06-21 04:44:44 +00:00
|
|
|
/*!
|
2018-01-26 13:52:57 +00:00
|
|
|
* \file glonass_gnav_ephemeris_test.cc.cc
|
2017-08-19 21:04:14 +00:00
|
|
|
* \note Code added as part of GSoC 2017 program
|
|
|
|
* \author Damian Miralles, 2017. dmiralles2009(at)gmail.com
|
|
|
|
* \see <a href="http://russianspacesystems.ru/wp-content/uploads/2016/08/ICD_GLONASS_eng_v5.1.pdf">GLONASS ICD</a>
|
2017-06-21 04:44:44 +00:00
|
|
|
*
|
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2017-06-21 04:44:44 +00:00
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
2017-06-21 04:44:44 +00:00
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2017-06-21 04:44:44 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2017-06-21 04:44:44 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "glonass_gnav_ephemeris.h"
|
2020-11-07 21:43:19 +00:00
|
|
|
#include "gnss_signal_replica.h"
|
2017-06-21 04:44:44 +00:00
|
|
|
|
|
|
|
|
2017-08-19 21:04:14 +00:00
|
|
|
TEST(GlonassGnavEphemerisTest, ComputeGlonassTime)
|
2017-06-21 04:44:44 +00:00
|
|
|
{
|
|
|
|
Glonass_Gnav_Ephemeris gnav_eph;
|
2017-08-19 21:04:14 +00:00
|
|
|
gnav_eph.d_yr = 2016;
|
|
|
|
gnav_eph.d_N_T = 367;
|
|
|
|
boost::posix_time::time_duration t(0, 0, 7560);
|
|
|
|
boost::gregorian::date d(gnav_eph.d_yr, 1, 1);
|
|
|
|
boost::gregorian::days d2(gnav_eph.d_N_T);
|
|
|
|
d = d + d2;
|
2017-06-21 04:44:44 +00:00
|
|
|
|
2017-08-19 21:04:14 +00:00
|
|
|
boost::gregorian::date expected_gdate;
|
2018-01-26 13:52:57 +00:00
|
|
|
boost::posix_time::time_duration expected_gtime;
|
2017-06-21 04:44:44 +00:00
|
|
|
|
2018-01-26 13:52:57 +00:00
|
|
|
boost::posix_time::ptime gtime = gnav_eph.compute_GLONASS_time(7560);
|
|
|
|
expected_gdate = gtime.date();
|
|
|
|
expected_gtime = gtime.time_of_day();
|
2017-08-19 21:04:14 +00:00
|
|
|
|
|
|
|
// Perform assertions of decoded fields
|
2018-03-03 01:03:39 +00:00
|
|
|
ASSERT_TRUE(expected_gdate.year() - d.year() < FLT_EPSILON);
|
|
|
|
ASSERT_TRUE(expected_gdate.month() - d.month() < FLT_EPSILON);
|
|
|
|
ASSERT_TRUE(expected_gdate.day() - d.day() < FLT_EPSILON);
|
|
|
|
ASSERT_TRUE(expected_gtime.hours() - t.hours() < FLT_EPSILON);
|
|
|
|
ASSERT_TRUE(expected_gtime.minutes() - t.minutes() < FLT_EPSILON);
|
|
|
|
ASSERT_TRUE(expected_gtime.seconds() - t.seconds() < FLT_EPSILON);
|
2017-06-21 04:44:44 +00:00
|
|
|
}
|
2017-10-24 14:51:38 +00:00
|
|
|
|
2018-01-26 14:12:55 +00:00
|
|
|
|
2020-07-19 12:44:18 +00:00
|
|
|
TEST(GlonassGnavEphemerisTest, ComputeGlonassTime2019)
|
|
|
|
{
|
|
|
|
Glonass_Gnav_Ephemeris gnav_eph;
|
|
|
|
gnav_eph.d_yr = 2019;
|
|
|
|
gnav_eph.d_N_T = 1366;
|
|
|
|
boost::posix_time::time_duration t(0, 0, 7560);
|
|
|
|
boost::gregorian::date d(gnav_eph.d_yr, 1, 1);
|
|
|
|
boost::gregorian::days d2(gnav_eph.d_N_T);
|
|
|
|
d = d + d2;
|
|
|
|
|
|
|
|
boost::gregorian::date expected_gdate;
|
|
|
|
boost::posix_time::time_duration expected_gtime;
|
|
|
|
|
|
|
|
boost::posix_time::ptime gtime = gnav_eph.compute_GLONASS_time(7560);
|
|
|
|
expected_gdate = gtime.date();
|
|
|
|
expected_gtime = gtime.time_of_day();
|
|
|
|
|
|
|
|
// Perform assertions of decoded fields
|
|
|
|
ASSERT_TRUE(expected_gdate.year() - d.year() < FLT_EPSILON);
|
|
|
|
ASSERT_TRUE(expected_gdate.month() - d.month() < FLT_EPSILON);
|
|
|
|
ASSERT_TRUE(expected_gdate.day() - d.day() < FLT_EPSILON);
|
|
|
|
ASSERT_TRUE(expected_gtime.hours() - t.hours() < FLT_EPSILON);
|
|
|
|
ASSERT_TRUE(expected_gtime.minutes() - t.minutes() < FLT_EPSILON);
|
|
|
|
ASSERT_TRUE(expected_gtime.seconds() - t.seconds() < FLT_EPSILON);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(GlonassGnavEphemerisTest, ComputeGlonassTime2020)
|
|
|
|
{
|
|
|
|
Glonass_Gnav_Ephemeris gnav_eph;
|
|
|
|
gnav_eph.d_yr = 2020;
|
|
|
|
gnav_eph.d_N_T = 62;
|
|
|
|
boost::posix_time::time_duration t(0, 0, 7560);
|
|
|
|
boost::gregorian::date d(gnav_eph.d_yr, 1, 1);
|
|
|
|
boost::gregorian::days d2(gnav_eph.d_N_T);
|
|
|
|
d = d + d2;
|
|
|
|
|
|
|
|
boost::gregorian::date expected_gdate;
|
|
|
|
boost::posix_time::time_duration expected_gtime;
|
|
|
|
|
|
|
|
boost::posix_time::ptime gtime = gnav_eph.compute_GLONASS_time(7560);
|
|
|
|
expected_gdate = gtime.date();
|
|
|
|
expected_gtime = gtime.time_of_day();
|
|
|
|
|
|
|
|
// Perform assertions of decoded fields
|
|
|
|
ASSERT_TRUE(expected_gdate.year() - d.year() < FLT_EPSILON);
|
|
|
|
ASSERT_TRUE(expected_gdate.month() - d.month() < FLT_EPSILON);
|
|
|
|
ASSERT_TRUE(expected_gdate.day() - d.day() < FLT_EPSILON);
|
|
|
|
ASSERT_TRUE(expected_gtime.hours() - t.hours() < FLT_EPSILON);
|
|
|
|
ASSERT_TRUE(expected_gtime.minutes() - t.minutes() < FLT_EPSILON);
|
|
|
|
ASSERT_TRUE(expected_gtime.seconds() - t.seconds() < FLT_EPSILON);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-27 02:46:16 +00:00
|
|
|
/*!
|
|
|
|
* \brief Testing conversion from GLONASST to GPST
|
|
|
|
* \test Tests scenario for N_T when greater than 365 days. Possible values here from 1 to 365*4
|
|
|
|
*/
|
2017-10-27 00:43:18 +00:00
|
|
|
TEST(GlonassGnavEphemerisTest, ConvertGlonassT2GpsT1)
|
2017-10-24 14:51:38 +00:00
|
|
|
{
|
|
|
|
Glonass_Gnav_Ephemeris gnav_eph;
|
2017-10-27 00:43:18 +00:00
|
|
|
gnav_eph.d_yr = 2004;
|
2018-03-03 01:03:39 +00:00
|
|
|
gnav_eph.d_N_T = 366 + 28;
|
2017-10-24 14:51:38 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
double glo2utc = 3600 * 3;
|
2017-11-14 05:41:12 +00:00
|
|
|
double tod = 48600;
|
2020-07-09 22:37:55 +00:00
|
|
|
int week = 0.0;
|
2017-10-24 14:51:38 +00:00
|
|
|
double tow = 0.0;
|
|
|
|
double true_leap_sec = 13;
|
|
|
|
double true_week = 1307;
|
2018-03-03 01:03:39 +00:00
|
|
|
double true_tow = 480600 + true_leap_sec;
|
2017-10-24 14:51:38 +00:00
|
|
|
|
2018-01-26 13:52:57 +00:00
|
|
|
gnav_eph.glot_to_gpst(tod + glo2utc, 0.0, 0.0, &week, &tow);
|
2017-10-24 14:51:38 +00:00
|
|
|
|
|
|
|
// Perform assertions of decoded fields
|
2018-03-03 01:03:39 +00:00
|
|
|
ASSERT_TRUE(week - true_week < FLT_EPSILON);
|
|
|
|
ASSERT_TRUE(tow - true_tow < FLT_EPSILON);
|
2017-10-24 14:51:38 +00:00
|
|
|
}
|
2017-10-27 00:43:18 +00:00
|
|
|
|
2018-01-26 14:12:55 +00:00
|
|
|
|
2017-10-27 02:46:16 +00:00
|
|
|
/*!
|
|
|
|
* \brief Testing conversion from GLONASST to GPST
|
|
|
|
* \test This version tests the conversion for offsets greater than 30 in a leap year
|
|
|
|
*/
|
2017-10-27 00:43:18 +00:00
|
|
|
TEST(GlonassGnavEphemerisTest, ConvertGlonassT2GpsT2)
|
|
|
|
{
|
|
|
|
Glonass_Gnav_Ephemeris gnav_eph;
|
|
|
|
gnav_eph.d_yr = 2016;
|
|
|
|
gnav_eph.d_N_T = 268;
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
double glo2utc = 3600 * 3;
|
2017-10-27 00:43:18 +00:00
|
|
|
double tod = 7560;
|
2020-07-09 22:37:55 +00:00
|
|
|
int week = 0.0;
|
2017-10-27 00:43:18 +00:00
|
|
|
double tow = 0.0;
|
2017-11-14 05:41:12 +00:00
|
|
|
double true_leap_sec = 17;
|
2017-10-27 00:43:18 +00:00
|
|
|
double true_week = 1915;
|
2018-03-03 01:03:39 +00:00
|
|
|
double true_tow = 518400 + true_leap_sec + tod;
|
2017-10-27 00:43:18 +00:00
|
|
|
|
2018-01-26 13:52:57 +00:00
|
|
|
gnav_eph.glot_to_gpst(tod + glo2utc, 0.0, 0.0, &week, &tow);
|
2017-10-27 00:43:18 +00:00
|
|
|
|
|
|
|
// Perform assertions of decoded fields
|
2018-03-03 01:03:39 +00:00
|
|
|
ASSERT_TRUE(week - true_week < FLT_EPSILON);
|
|
|
|
ASSERT_TRUE(tow - true_tow < FLT_EPSILON);
|
2017-10-27 00:43:18 +00:00
|
|
|
}
|
|
|
|
|
2018-01-26 14:12:55 +00:00
|
|
|
|
2017-10-27 02:46:16 +00:00
|
|
|
/*!
|
|
|
|
* \brief Testing conversion from GLONASST to GPST
|
|
|
|
* \test This version tests the conversion around the vicinity of February 29 days when in leap year
|
|
|
|
*/
|
2017-10-27 00:43:18 +00:00
|
|
|
TEST(GlonassGnavEphemerisTest, ConvertGlonassT2GpsT3)
|
|
|
|
{
|
|
|
|
Glonass_Gnav_Ephemeris gnav_eph;
|
|
|
|
gnav_eph.d_yr = 2016;
|
|
|
|
gnav_eph.d_N_T = 62;
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
double glo2utc = 3600 * 3;
|
2017-11-14 05:41:12 +00:00
|
|
|
double tod = 7560;
|
2020-07-09 22:37:55 +00:00
|
|
|
int week = 0.0;
|
2017-10-27 00:43:18 +00:00
|
|
|
double tow = 0.0;
|
2017-11-14 05:41:12 +00:00
|
|
|
double true_leap_sec = 17;
|
|
|
|
double true_week = 1886;
|
2018-03-03 01:03:39 +00:00
|
|
|
double true_tow = 259200 + true_leap_sec + tod;
|
2017-10-27 00:43:18 +00:00
|
|
|
|
2018-01-26 13:52:57 +00:00
|
|
|
gnav_eph.glot_to_gpst(tod + glo2utc, 0.0, 0.0, &week, &tow);
|
2017-10-27 00:43:18 +00:00
|
|
|
|
|
|
|
// Perform assertions of decoded fields
|
2018-03-03 01:03:39 +00:00
|
|
|
ASSERT_TRUE(week - true_week < FLT_EPSILON);
|
|
|
|
ASSERT_TRUE(tow - true_tow < FLT_EPSILON);
|
2017-10-27 00:43:18 +00:00
|
|
|
}
|
2020-07-19 12:44:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
TEST(GlonassGnavEphemerisTest, ConvertGlonassT2GpsT4)
|
|
|
|
{
|
|
|
|
Glonass_Gnav_Ephemeris gnav_eph;
|
|
|
|
gnav_eph.d_yr = 2019;
|
|
|
|
gnav_eph.d_N_T = 1366;
|
|
|
|
|
|
|
|
double glo2utc = 3600 * 3;
|
|
|
|
double tod = 7560;
|
|
|
|
int week = 0.0;
|
|
|
|
double tow = 0.0;
|
|
|
|
double true_leap_sec = 18;
|
|
|
|
double true_week = 2072;
|
|
|
|
double true_tow = 447120 + true_leap_sec + tod;
|
|
|
|
|
|
|
|
gnav_eph.glot_to_gpst(tod + glo2utc, 0.0, 0.0, &week, &tow);
|
|
|
|
|
|
|
|
// Perform assertions of decoded fields
|
|
|
|
ASSERT_TRUE(week - true_week < FLT_EPSILON);
|
|
|
|
ASSERT_TRUE(tow - true_tow < FLT_EPSILON);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(GlonassGnavEphemerisTest, ConvertGlonassT2GpsT5)
|
|
|
|
{
|
|
|
|
Glonass_Gnav_Ephemeris gnav_eph;
|
|
|
|
gnav_eph.d_yr = 2020;
|
|
|
|
gnav_eph.d_N_T = 62;
|
|
|
|
|
|
|
|
double glo2utc = 3600 * 3;
|
|
|
|
double tod = 7560;
|
|
|
|
int week = 0.0;
|
|
|
|
double tow = 0.0;
|
|
|
|
double true_leap_sec = 18;
|
|
|
|
double true_week = 2095;
|
|
|
|
double true_tow = 259200 + true_leap_sec + tod;
|
|
|
|
|
|
|
|
gnav_eph.glot_to_gpst(tod + glo2utc, 0.0, 0.0, &week, &tow);
|
|
|
|
|
|
|
|
// Perform assertions of decoded fields
|
|
|
|
ASSERT_TRUE(week - true_week < FLT_EPSILON);
|
|
|
|
ASSERT_TRUE(tow - true_tow < FLT_EPSILON);
|
|
|
|
}
|