Skip to content

Commit

Permalink
unit-test: Adds and fixes unit test for system-parameters block
Browse files Browse the repository at this point in the history
Adding unit test for system-parameters block, testing string decoding
logic for GLONASS GNAV messages. Bug fixes the code after several errors
were detected while debugging
  • Loading branch information
dmiralles2009 committed Aug 21, 2017
1 parent 76373d1 commit dc16205
Show file tree
Hide file tree
Showing 13 changed files with 312 additions and 176 deletions.
18 changes: 9 additions & 9 deletions src/algorithms/PVT/libs/rinex_printer.cc
Expand Up @@ -3293,14 +3293,13 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem
line += Rinex_Printer::rightJustify(boost::lexical_cast<std::string>(0), 3);
line += std::string(1, ' ');

// TODO Add this here, we need to know all satellites in system to get this done
line += satelliteSystem["GLONASS"];
line += Rinex_Printer::rightJustify(boost::lexical_cast<std::string>(0), 2); // Slot Number
line += std::string(1, ' ');
line += Rinex_Printer::rightJustify(boost::lexical_cast<std::string>(0), 2); // Frequency Number
line += std::string(1, ' ');


// TODO Add this here, we need to know all satellites in system to get this done
line += satelliteSystem["GLONASS"];
line += Rinex_Printer::rightJustify(boost::lexical_cast<std::string>(0), 2); // Slot Number
line += std::string(1, ' ');
line += Rinex_Printer::rightJustify(boost::lexical_cast<std::string>(0), 2); // Frequency Number
line += std::string(1, ' ');
line += std::string(60-line.size(), ' ');
line += Rinex_Printer::leftJustify("GLONASS SLOT / FRQ #", 20);
Rinex_Printer::lengthCheck(line);
out << line << std::endl;
Expand Down Expand Up @@ -3328,7 +3327,8 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem
line += observationCode["GLONASS_G2_P"];
line += std::string(1, ' ');
line += Rinex_Printer::rightJustify(asString(0.0, 3), 8);
line += Rinex_Printer::leftJustify("GLONASS SLOT / FRQ #", 20);
line += std::string(60-line.size(), ' ');
line += Rinex_Printer::leftJustify("GLONASS COD/PHS/BIS", 20);
Rinex_Printer::lengthCheck(line);
out << line << std::endl;

Expand Down
4 changes: 2 additions & 2 deletions src/core/system_parameters/GLONASS_L1_CA.h
Expand Up @@ -127,8 +127,8 @@ const std::vector<std::pair<int,int>> KX({{78,8}});
//STRING 1
const std::vector<std::pair<int,int>> P1({{8,2}});
const std::vector<std::pair<int,int>> T_K_HR({{10,5}});
const std::vector<std::pair<int,int>> T_K_MIN({{10,6}});
const std::vector<std::pair<int,int>> T_K_SEC({{10,1}});
const std::vector<std::pair<int,int>> T_K_MIN({{15,6}});
const std::vector<std::pair<int,int>> T_K_SEC({{21,1}});
const std::vector<std::pair<int,int>> X_N_DOT ({{22,24}});
const std::vector<std::pair<int,int>> X_N_DOT_DOT ({{46,5}});
const std::vector<std::pair<int,int>> X_N({{51,27}});
Expand Down
4 changes: 3 additions & 1 deletion src/core/system_parameters/glonass_gnav_almanac.h
@@ -1,7 +1,9 @@
/*!
* \file glonass_gnav_almanac.h
* \brief Interface of a GLONASS GNAV ALMANAC storage
* \author Damian Miralles, 2017. dmiralles2009@gmail.com
* \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>
*
* -------------------------------------------------------------------------
*
Expand Down
71 changes: 45 additions & 26 deletions src/core/system_parameters/glonass_gnav_ephemeris.cc
Expand Up @@ -39,13 +39,48 @@

Glonass_Gnav_Ephemeris::Glonass_Gnav_Ephemeris()
{
i_satellite_freq_channel = 0;
d_m = 0.0; //!< String number within frame [dimensionless]
d_t_k = 0.0; //!< Time referenced to the beginning of the frame within the current day [hours, minutes, seconds]
d_t_b = 0.0; //!< Index of a time interval within current day according to UTC(SU) + 03 hours 00 min. [minutes]
d_M = 0.0; //!< Type of satellite transmitting navigation signal [dimensionless]
d_gamma_n = 0.0; //!< Relative deviation of predicted carrier frequency value of n- satellite from nominal value at the instant tb [dimensionless]
d_tau_n = 0.0; //!< Correction to the nth satellite time (tn) relative to GLONASS time (te),
d_m = 0.0; //!< String number within frame [dimensionless]
d_t_k = 0.0; //!< GLONASS Time (UTC(SU) + 3 h) referenced to the beginning of the frame within the current day [s]
d_t_b = 0.0; //!< Reference ephemeris relative time in GLONASS Time (UTC(SU) + 3 h). Index of a time interval within current day according to UTC(SU) + 03 hours 00 min. [s]
d_M = 0.0; //!< Type of satellite transmitting navigation signal [dimensionless]
d_gamma_n = 0.0; //!< Relative deviation of predicted carrier frequency value of n- satellite from nominal value at the instant tb [dimensionless]
d_tau_n = 0.0; //!< Correction to the nth satellite time (tn) relative to GLONASS time (te),
d_Xn = 0.0; //!< Earth-fixed coordinate x of the satellite in PZ-90.02 coordinate system [km].
d_Yn = 0.0; //!< Earth-fixed coordinate y of the satellite in PZ-90.02 coordinate system [km]
d_Zn = 0.0; //!< Earth-fixed coordinate z of the satellite in PZ-90.02 coordinate system [km]
d_VXn = 0.0; //!< Earth-fixed velocity coordinate x of the satellite in PZ-90.02 coordinate system [km/s]
d_VYn = 0.0; //!< Earth-fixed velocity coordinate y of the satellite in PZ-90.02 coordinate system [km/s]
d_VZn = 0.0; //!< Earth-fixed velocity coordinate z of the satellite in PZ-90.02 coordinate system [km/s]
d_AXn = 0.0; //!< Earth-fixed acceleration coordinate x of the satellite in PZ-90.02 coordinate system [km/s^2]
d_AYn = 0.0; //!< Earth-fixed acceleration coordinate y of the satellite in PZ-90.02 coordinate system [km/s^2]
d_AZn = 0.0; //!< Earth-fixed acceleration coordinate z of the satellite in PZ-90.02 coordinate system [km/s^2]
d_B_n = 0.0; //!< Health flag [dimensionless]
d_P = 0.0; //!< Technological parameter of control segment, indication the satellite operation mode in respect of time parameters [dimensionless]
d_N_T = 0.0; //!< Current date, calendar number of day within four-year interval starting from the 1-st of January in a leap year [days]
d_F_T = 0.0; //!< Parameter that provides the predicted satellite user range accuracy at time tb [dimensionless]
d_n = 0.0; //!< Index of the satellite transmitting given navigation signal. It corresponds to a slot number within GLONASS constellation
d_Delta_tau_n = 0.0; //!< Time difference between navigation RF signal transmitted in L2 sub- band and aviation RF signal transmitted in L1 sub-band by nth satellite. [dimensionless]
d_E_n = 0.0; //!< Characterises "age" of a current information [days]
d_P_1 = 0.0; //!< Flag of the immediate data updating [minutes]
d_P_2 = 0.0; //!< Flag of oddness ("1") or evenness ("0") of the value of (tb) [dimensionless]
d_P_3 = 0.0; //!< Flag indicating a number of satellites for which almanac is transmitted within given frame: "1" corresponds to 5 satellites and "0" corresponds to 4 satellites [dimensionless]
d_P_4 = 0.0; //!< Flag to show that ephemeris parameters are present. "1" indicates that updated ephemeris or frequency/time parameters have been uploaded by the control segment [dimensionless]
d_l3rd_n = 0.0; //!< Health flag for nth satellite; ln = 0 indicates the n-th satellite is helthy, ln = 1 indicates malfunction of this nth satellite [dimensionless]
d_l5th_n = 0.0; //!< Health flag for nth satellite; ln = 0 indicates the n-th satellite is helthy, ln = 1 indicates malfunction of this nth satellite [dimensionless]

// Satellite Identification Information
i_satellite_freq_channel = 0; //!< SV Frequency Channel Number
i_satellite_PRN = 0; //!< SV PRN Number, equivalent to slot number for compatibility with GPS
i_satellite_slot_number = 0; //!< SV Slot Number
d_TOD = 0.0; //!< Time of Day of the ephemeris set based in start of frame [s]
d_D4Y = 0.0; //!< Day of Year after latest leap year (4 year interval)
d_yr = 1972; //!< Current year, defaults to 1972 (UTC Epoch with leap seconds)
d_satClkDrift = 0.0; //!< GLONASS clock error
d_dtr = 0.0; //!< relativistic clock correction term
d_iode = 0.0; //!< Issue of data, ephemeris (Bit 0-6 of tb)
d_tau_c = 0.0;
d_TOW = 0.0; // tow of the start of frame
d_WN = 0.0; // week number of the start of frame
// satellite positions
d_satpos_X = 0.0; //!< Earth-fixed coordinate x of the satellite in PZ-90.02 coordinate system [km].
d_satpos_Y = 0.0; //!< Earth-fixed coordinate y of the satellite in PZ-90.02 coordinate system [km]
Expand All @@ -58,31 +93,15 @@ Glonass_Gnav_Ephemeris::Glonass_Gnav_Ephemeris()
d_satacc_X = 0.0; //!< Earth-fixed acceleration coordinate x of the satellite in PZ-90.02 coordinate system [km/s^2]
d_satacc_Y = 0.0; //!< Earth-fixed acceleration coordinate y of the satellite in PZ-90.02 coordinate system [km/s^2]
d_satacc_Z = 0.0; //!< Earth-fixed acceleration coordinate z of the satellite in PZ-90.02 coordinate system [km/s^2]
d_B_n = 0.0; //!< Health flag [dimensionless]
d_P = 0.0; //!< Technological parameter of control segment, indication the satellite operation mode in respect of time parameters [dimensionless]
d_N_T = 0.0; //!< Current date, calendar number of day within four-year interval starting from the 1-st of January in a leap year [days]
d_F_T = 0.0; //!< Parameter that provides the predicted satellite user range accuracy at time tb [dimensionless]
d_n = 0.0; //!< Index of the satellite transmitting given navigation signal. It corresponds to a slot number within GLONASS constellation
d_Delta_tau_n = 0.0; //!< Time difference between navigation RF signal transmitted in L2 sub- band and aviation RF signal transmitted in L1 sub-band by nth satellite. [dimensionless]
d_E_n = 0.0; //!< Characterises "age" of a current information [days]
d_P_1 = 0.0; //!< Flag of the immediate data updating.
d_P_2 = 0.0; //!< Flag of oddness ("1") or evenness ("0") of the value of (tb) [dimensionless]
d_P_3 = 0.0; //!< Flag indicating a number of satellites for which almanac is transmitted within given frame: "1" corresponds to 5 satellites and "0" corresponds to 4 satellites [dimensionless]
d_P_4 = 0.0; //!< Flag to show that ephemeris parameters are present. "1" indicates that updated ephemeris or frequency/time parameters have been uploaded by the control segment [dimensionless]
d_l3rd_n = 0.0; //!< Health flag for nth satellite; ln = 0 indicates the n-th satellite is helthy, ln = 1 indicates malfunction of this nth satellite [dimensionless]
d_l5th_n = 0.0; //!< Health flag for nth satellite; ln = 0 indicates the n-th satellite is helthy, ln = 1 indicates malfunction of this nth satellite [dimensionless]

// clock terms derived from ephemeris data
d_satClkDrift = 0.0; //!< GLONASS clock error
d_dtr = 0.0;
}


boost::posix_time::ptime Glonass_Gnav_Ephemeris::compute_GLONASS_time(const double offset_time) const
{
boost::posix_time::time_duration t(0, 0, offset_time);
boost::gregorian::date d(d_yr, 1, d_N_T);
boost::posix_time::ptime glonass_time(d, t);
boost::gregorian::date d1(d_yr, 1, 1);
boost::gregorian::days d2(d_N_T);
boost::posix_time::ptime glonass_time(d1+d2, t);

return glonass_time;
}
Expand Down
7 changes: 3 additions & 4 deletions src/core/system_parameters/glonass_gnav_ephemeris.h
@@ -1,7 +1,9 @@
/*!
* \file glonass_gnav_ephemeris.h
* \brief Interface of a GLONASS EPHEMERIS storage
* \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>
*
* -------------------------------------------------------------------------
*
Expand Down Expand Up @@ -99,9 +101,8 @@ class Glonass_Gnav_Ephemeris
double d_l5th_n; //!< Health flag for nth satellite; ln = 0 indicates the n-th satellite is helthy, ln = 1 indicates malfunction of this nth satellite [dimensionless]

// Inmediate deliverables of ephemeris information
//TODO check how freq channel is managed in gnav message. I think it is a number greater thn 0
// Satellite Identification Information
int i_satellite_freq_channel; //!< SV Frequency Channel Number
int i_satellite_freq_channel; //!< SV Frequency Channel Number
unsigned int i_satellite_PRN; //!< SV PRN Number, equivalent to slot number for compatibility with GPS
unsigned int i_satellite_slot_number; //!< SV Slot Number
double d_TOD; //!< Time of Day of the ephemeris set based in start of frame [s]
Expand All @@ -114,8 +115,6 @@ class Glonass_Gnav_Ephemeris
double d_TOW; // tow of the start of frame
double d_WN; // week number of the start of frame

// Need to add a way to compute the GPS week number and GPS TIME OF WEEK from GLONASS ephemeris

// satellite positions after RK4 Integration
double d_satpos_X; //!< Earth-fixed coordinate x of the satellite in PZ-90.02 coordinate system [km].
double d_satpos_Y; //!< Earth-fixed coordinate y of the satellite in PZ-90.02 coordinate system [km]
Expand Down

0 comments on commit dc16205

Please sign in to comment.