From e5ffc2b46c4009e839a515b1937403286a06a63d Mon Sep 17 00:00:00 2001 From: Damian Miralles Date: Wed, 30 Aug 2017 22:44:03 -0600 Subject: [PATCH] Adding proper TOW computation for GLONASS processing --- src/core/system_parameters/GLONASS_L1_CA.h | 25 +++++++++++++++++++ .../glonass_gnav_navigation_message.cc | 17 +++++++++---- .../glonass_gnav_navigation_message.h | 4 ++- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/core/system_parameters/GLONASS_L1_CA.h b/src/core/system_parameters/GLONASS_L1_CA.h index 913f42fcd..56c208d31 100644 --- a/src/core/system_parameters/GLONASS_L1_CA.h +++ b/src/core/system_parameters/GLONASS_L1_CA.h @@ -88,6 +88,31 @@ const double GLONASS_L1_CA_CODE_PERIOD = 0.001; //!< GLONASS L1 C/ const double GLONASS_L1_CA_CHIP_PERIOD = 1.9569e-06; //!< GLONASS L1 C/A chip period [seconds] const double GLONASS_L1_CA_SYMBOL_RATE_BPS = 1000; +//FIXME Probably should use leap seconds definitions of rtklib +const double GLONASS_LEAP_SECONDS[21][7] = { /* leap seconds (y,m,d,h,m,s,utc-gpst) */ + {2019, 1, 1, 0, 0, 0, -20}, + {2018, 1, 1, 0, 0, 0, -19}, + {2017, 1, 1, 0, 0, 0, -18}, + {2015, 7, 1, 0, 0, 0, -17}, + {2012, 7, 1, 0, 0, 0, -16}, + {2009, 1, 1, 0, 0, 0, -15}, + {2006, 1, 1, 0, 0, 0, -14}, + {1999, 1, 1, 0, 0, 0, -13}, + {1997, 7, 1, 0, 0, 0, -12}, + {1996, 1, 1, 0, 0, 0, -11}, + {1994, 7, 1, 0, 0, 0, -10}, + {1993, 7, 1, 0, 0, 0, -9}, + {1992, 7, 1, 0, 0, 0, -8}, + {1991, 1, 1, 0, 0, 0, -7}, + {1990, 1, 1, 0, 0, 0, -6}, + {1988, 1, 1, 0, 0, 0, -5}, + {1985, 7, 1, 0, 0, 0, -4}, + {1983, 7, 1, 0, 0, 0, -3}, + {1982, 7, 1, 0, 0, 0, -2}, + {1981, 7, 1, 0, 0, 0, -1}, + {} +}; + // GLONASS SV's orbital slots PRN = (orbital_slot - 1) const std::map GLONASS_PRN = {{ 0, 8,}, //For test diff --git a/src/core/system_parameters/glonass_gnav_navigation_message.cc b/src/core/system_parameters/glonass_gnav_navigation_message.cc index 424376129..5149d5b46 100644 --- a/src/core/system_parameters/glonass_gnav_navigation_message.cc +++ b/src/core/system_parameters/glonass_gnav_navigation_message.cc @@ -319,11 +319,12 @@ double Glonass_Gnav_Navigation_Message::get_TOW() TOW = gnav_ephemeris.d_t_k + glot2utcsu + utcsu2utc + gnav_utc_model.d_tau_c + gnav_utc_model.d_tau_gps; - for (i = 0; leaps[i][0]>0; i++) + for (i = 0; GLONASS_LEAP_SECONDS[i][0]>0; i++) { - if (leaps[i][0] == gnav_ephemeris.d_yr) + if (GLONASS_LEAP_SECONDS[i][0] == gnav_ephemeris.d_yr) { - TOW -= leaps[i][6]; + TOW -= GLONASS_LEAP_SECONDS[i][6]; + } } return TOW; } @@ -354,8 +355,6 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) gnav_ephemeris.d_Xn = static_cast(read_navigation_signed(string_bits, X_N)) * TWO_N11; flag_ephemeris_str_1 = true; - d_TOW = get_TOW(); - flag_TOW_set = true; break; @@ -441,6 +440,14 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) // 2). Current year in common form is calculated by the following formula: gnav_ephemeris.d_yr = 1996 + 4.0*(gnav_utc_model.d_N_4 - 1.0) + (J - 1.0); gnav_ephemeris.d_tau_c = gnav_utc_model.d_tau_c; + + // 3). Set TOW once the year has been defined, it helps with leap second determination + if(flag_ephemeris_str_1 == true) + { + d_TOW = get_TOW(); + flag_TOW_set = true; + } + } break; diff --git a/src/core/system_parameters/glonass_gnav_navigation_message.h b/src/core/system_parameters/glonass_gnav_navigation_message.h index 0c71040f0..651ccbebd 100644 --- a/src/core/system_parameters/glonass_gnav_navigation_message.h +++ b/src/core/system_parameters/glonass_gnav_navigation_message.h @@ -156,9 +156,11 @@ public: /* * \brief Gets the time of week in GPS Time + * \details This converts from GLONASS Time to GPS Time of Week based on the + * start of frame */ double get_TOW(); - + /*! * \brief Computes the Coordinated Universal Time (UTC) and returns it in [s] */