mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-18 13:13:03 +00:00
Fixing compile warnings and adding work on unit test
This commit is contained in:
parent
50f133e960
commit
8a0689fbb1
@ -178,7 +178,10 @@ const std::vector<std::pair<int,int>> T_LAMBDA_N_A({{22,21}});
|
|||||||
const std::vector<std::pair<int,int>> DELTA_T_N_A({{43,22}});
|
const std::vector<std::pair<int,int>> DELTA_T_N_A({{43,22}});
|
||||||
const std::vector<std::pair<int,int>> DELTA_T_DOT_N_A({{65,7}});
|
const std::vector<std::pair<int,int>> DELTA_T_DOT_N_A({{65,7}});
|
||||||
const std::vector<std::pair<int,int>> H_N_A({{72,5}});
|
const std::vector<std::pair<int,int>> H_N_A({{72,5}});
|
||||||
//const std::vector<std::pair<int,int>> L_N({{77,1}});
|
|
||||||
|
// STRING 14 FRAME 5
|
||||||
|
const std::vector<std::pair<int,int>> B1({{6,11}});
|
||||||
|
const std::vector<std::pair<int,int>> B2({{17,10}});
|
||||||
|
|
||||||
|
|
||||||
#endif /* GNSS_SDR_GLONASS_L1_CA_H_ */
|
#endif /* GNSS_SDR_GLONASS_L1_CA_H_ */
|
||||||
|
@ -52,7 +52,7 @@ Glonass_Gnav_Almanac::Glonass_Gnav_Almanac()
|
|||||||
d_M_n_A = 0.0;
|
d_M_n_A = 0.0;
|
||||||
d_KP = 0.0;
|
d_KP = 0.0;
|
||||||
d_tau_n_A = 0.0;
|
d_tau_n_A = 0.0;
|
||||||
d_C_n_A = 0.0;
|
d_C_n = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Glonass_Gnav_Almanac::satellite_position(double N_i, double t_i)
|
void Glonass_Gnav_Almanac::satellite_position(double N_i, double t_i)
|
||||||
|
@ -62,7 +62,7 @@ public:
|
|||||||
double d_M_n_A; //!< Type of satellite n_A [dimensionless]
|
double d_M_n_A; //!< Type of satellite n_A [dimensionless]
|
||||||
double d_KP; //!< Notification on forthcoming leap second correction of UTC [dimensionless]
|
double d_KP; //!< Notification on forthcoming leap second correction of UTC [dimensionless]
|
||||||
double d_tau_n_A; //!< Coarse value of d_n_A satellite time correction to GLONASS time at instant t_lambdan_A[s]
|
double d_tau_n_A; //!< Coarse value of d_n_A satellite time correction to GLONASS time at instant t_lambdan_A[s]
|
||||||
double d_C_n_A; //!< Generalized “unhealthy flag” of n_A satellite at instant of almanac upload [dimensionless]
|
double d_C_n; //!< Generalized “unhealthy flag” of n_A satellite at instant of almanac upload [dimensionless]
|
||||||
|
|
||||||
// satellite positions
|
// satellite positions
|
||||||
double d_satpos_Xo; //!< Earth-fixed coordinate x of the satellite in PZ-90.02 coordinate system [km].
|
double d_satpos_Xo; //!< Earth-fixed coordinate x of the satellite in PZ-90.02 coordinate system [km].
|
||||||
@ -108,7 +108,7 @@ public:
|
|||||||
archive & make_nvp("d_M_n_A", d_M_n_A);
|
archive & make_nvp("d_M_n_A", d_M_n_A);
|
||||||
archive & make_nvp("d_KP", d_KP);
|
archive & make_nvp("d_KP", d_KP);
|
||||||
archive & make_nvp("d_tau_n_A", d_tau_n_A);
|
archive & make_nvp("d_tau_n_A", d_tau_n_A);
|
||||||
archive & make_nvp("d_C_n_A", d_C_n_A);
|
archive & make_nvp("d_C_n", d_C_n);
|
||||||
}
|
}
|
||||||
|
|
||||||
void satellite_position(double N_i, double t_i);
|
void satellite_position(double N_i, double t_i);
|
||||||
|
@ -32,6 +32,7 @@ m * \file glonass_gnav_navigation_message.cc
|
|||||||
#include "glonass_gnav_navigation_message.h"
|
#include "glonass_gnav_navigation_message.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
#include <gnss_satellite.h>
|
#include <gnss_satellite.h>
|
||||||
|
|
||||||
|
|
||||||
@ -103,7 +104,7 @@ Glonass_Gnav_Navigation_Message::Glonass_Gnav_Navigation_Message()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Glonass_Gnav_Navigation_Message::_CRC_test(std::bitset<GLONASS_GNAV_STRING_BITS> data_bits, std::bitset<GLONASS_GNAV_HAMMING_CODE_BITS> hamming_code_bits )
|
bool Glonass_Gnav_Navigation_Message::_CRC_test(std::bitset<GLONASS_GNAV_STRING_BITS> bits)
|
||||||
{
|
{
|
||||||
int sum_bits;
|
int sum_bits;
|
||||||
int sum_hamming;
|
int sum_hamming;
|
||||||
@ -115,66 +116,75 @@ bool Glonass_Gnav_Navigation_Message::_CRC_test(std::bitset<GLONASS_GNAV_STRING_
|
|||||||
int C6 = 0;
|
int C6 = 0;
|
||||||
int C7 = 0;
|
int C7 = 0;
|
||||||
int C_Sigma = 0;
|
int C_Sigma = 0;
|
||||||
|
|
||||||
|
std::bitset<GLONASS_GNAV_STRING_BITS> data = std::bitset<GLONASS_GNAV_STRING_BITS>(bits.to_string(), 0, 77);
|
||||||
|
std::bitset<GLONASS_GNAV_HAMMING_CODE_BITS> hamming_code = std::bitset<GLONASS_GNAV_STRING_BITS>(bits.to_string(), 77, 8);
|
||||||
|
|
||||||
|
std::istringstream dsb = std::istringstream( data.to_string() );
|
||||||
|
std::istringstream hcb = std::istringstream( hamming_code.to_string() );
|
||||||
|
std::vector<int> data_bits = std::vector<int>( std::istream_iterator<int>( dsb ), std::istream_iterator<int>() );
|
||||||
|
std::vector<int> hamming_code_bits = std::vector<int>( std::istream_iterator<int>( dsb ), std::istream_iterator<int>() );
|
||||||
|
|
||||||
//!< Compute C1 term
|
//!< Compute C1 term
|
||||||
sum_bits = 0;
|
sum_bits = 0;
|
||||||
for(int i = 0; i < GLONASS_GNAV_CRC_I_INDEX.size(); i++)
|
for(int i = 0; i < static_cast<int>(GLONASS_GNAV_CRC_I_INDEX.size()); i++)
|
||||||
{
|
{
|
||||||
sum_bits += static_cast<int>(data_bits[GLONASS_GNAV_CRC_I_INDEX[i]]);
|
sum_bits += data_bits[GLONASS_GNAV_CRC_I_INDEX[i]];
|
||||||
}
|
}
|
||||||
C1 = static_cast<int>(hamming_code_bits[0])^static_cast<int>(fmod(sum_bits,2));
|
C1 = hamming_code_bits[0]^(sum_bits%2);
|
||||||
|
|
||||||
//!< Compute C2 term
|
//!< Compute C2 term
|
||||||
sum_bits = 0;
|
sum_bits = 0;
|
||||||
for(int j = 0; j < GLONASS_GNAV_CRC_J_INDEX.size(); j++)
|
for(int j = 0; j < static_cast<int>(GLONASS_GNAV_CRC_J_INDEX.size()); j++)
|
||||||
{
|
{
|
||||||
sum_bits += static_cast<int>data_bits[GLONASS_GNAV_CRC_J_INDEX[j]];
|
sum_bits += data_bits[GLONASS_GNAV_CRC_J_INDEX[j]];
|
||||||
}
|
}
|
||||||
C2 = static_cast<int>(hamming_code_bits[1])^static_cast<int>(fmod(sum_bits,2));
|
C2 = (hamming_code_bits[1])^(sum_bits%2);
|
||||||
|
|
||||||
//!< Compute C3 term
|
//!< Compute C3 term
|
||||||
sum_bits = 0;
|
sum_bits = 0;
|
||||||
for(int k = 0; k < GLONASS_GNAV_CRC_K_INDEX.size(); k++)
|
for(int k = 0; k < static_cast<int>(GLONASS_GNAV_CRC_K_INDEX.size()); k++)
|
||||||
{
|
{
|
||||||
sum_bits += data_bits[GLONASS_GNAV_CRC_K_INDEX[k]];
|
sum_bits += data_bits[GLONASS_GNAV_CRC_K_INDEX[k]];
|
||||||
}
|
}
|
||||||
C3 = hamming_code_bits[2]^fmod(sum_bits,2);
|
C3 = hamming_code_bits[2]^(sum_bits%2);
|
||||||
|
|
||||||
//!< Compute C4 term
|
//!< Compute C4 term
|
||||||
sum_bits = 0;
|
sum_bits = 0;
|
||||||
for(int l = 0; l < GLONASS_GNAV_CRC_L_INDEX.size(); l++)
|
for(int l = 0; l < static_cast<int>(GLONASS_GNAV_CRC_L_INDEX.size()); l++)
|
||||||
{
|
{
|
||||||
sum_bits += data_bits[GLONASS_GNAV_CRC_L_INDEX[l]];
|
sum_bits += data_bits[GLONASS_GNAV_CRC_L_INDEX[l]];
|
||||||
}
|
}
|
||||||
C4 = hamming_code_bits[3]^fmod(sum_bits,2);
|
C4 = hamming_code_bits[3]^(sum_bits%2);
|
||||||
|
|
||||||
//!< Compute C5 term
|
//!< Compute C5 term
|
||||||
sum_bits = 0;
|
sum_bits = 0;
|
||||||
for(int m = 0; m < GLONASS_GNAV_CRC_M_INDEX.size(); m++)
|
for(int m = 0; m < static_cast<int>(GLONASS_GNAV_CRC_M_INDEX.size()); m++)
|
||||||
{
|
{
|
||||||
sum_bits += data_bits[GLONASS_GNAV_CRC_M_INDEX[m]];
|
sum_bits += data_bits[GLONASS_GNAV_CRC_M_INDEX[m]];
|
||||||
}
|
}
|
||||||
C5 = hamming_code_bits[4]^fmod(sum_bits,2);
|
C5 = hamming_code_bits[4]^(sum_bits%2);
|
||||||
|
|
||||||
//!< Compute C6 term
|
//!< Compute C6 term
|
||||||
sum_bits = 0;
|
sum_bits = 0;
|
||||||
for(int n = 0; n < GLONASS_GNAV_CRC_N_INDEX.size(); n++)
|
for(int n = 0; n < static_cast<int>(GLONASS_GNAV_CRC_N_INDEX.size()); n++)
|
||||||
{
|
{
|
||||||
sum_bits += data_bits[GLONASS_GNAV_CRC_N_INDEX[n]];
|
sum_bits += data_bits[GLONASS_GNAV_CRC_N_INDEX[n]];
|
||||||
}
|
}
|
||||||
C6 = hamming_code_bits[5]^fmod(sum_bits,2);
|
C6 = hamming_code_bits[5]^(sum_bits%2);
|
||||||
|
|
||||||
//!< Compute C7 term
|
//!< Compute C7 term
|
||||||
sum_bits = 0;
|
sum_bits = 0;
|
||||||
for(int p = 0; p < GLONASS_GNAV_CRC_P_INDEX.size(); p++)
|
for(int p = 0; p < static_cast<int>(GLONASS_GNAV_CRC_P_INDEX.size()); p++)
|
||||||
{
|
{
|
||||||
sum_bits += data_bits[GLONASS_GNAV_CRC_P_INDEX[p]];
|
sum_bits += data_bits[GLONASS_GNAV_CRC_P_INDEX[p]];
|
||||||
}
|
}
|
||||||
C7 = hamming_code_bits[6]^fmod(sum_bits,2);
|
C7 = hamming_code_bits[6]^(sum_bits%2);
|
||||||
|
|
||||||
//!< Compute C_Sigma term
|
//!< Compute C_Sigma term
|
||||||
sum_bits = 0;
|
sum_bits = 0;
|
||||||
sum_hamming = 0;
|
sum_hamming = 0;
|
||||||
for(int q = 0; q < GLONASS_GNAV_CRC_Q_INDEX.size(); q++)
|
for(int q = 0; q < static_cast<int>(GLONASS_GNAV_CRC_Q_INDEX.size()); q++)
|
||||||
{
|
{
|
||||||
sum_bits += data_bits[GLONASS_GNAV_CRC_Q_INDEX[q]];
|
sum_bits += data_bits[GLONASS_GNAV_CRC_Q_INDEX[q]];
|
||||||
}
|
}
|
||||||
@ -182,7 +192,7 @@ bool Glonass_Gnav_Navigation_Message::_CRC_test(std::bitset<GLONASS_GNAV_STRING_
|
|||||||
{
|
{
|
||||||
sum_hamming += hamming_code_bits[q];
|
sum_hamming += hamming_code_bits[q];
|
||||||
}
|
}
|
||||||
C_Sigma = fmod(sum_bits, 2)^fmod(sum_bits,2);
|
C_Sigma = (sum_hamming%2)^(sum_bits%2);
|
||||||
|
|
||||||
|
|
||||||
//!< Verification of the data
|
//!< Verification of the data
|
||||||
@ -338,12 +348,11 @@ int Glonass_Gnav_Navigation_Message::string_decoder(char * frame_string)
|
|||||||
int frame_ID = 0;
|
int frame_ID = 0;
|
||||||
|
|
||||||
// UNPACK BYTES TO BITS AND REMOVE THE CRC REDUNDANCE
|
// UNPACK BYTES TO BITS AND REMOVE THE CRC REDUNDANCE
|
||||||
std::bitset<GLONASS_GNAV_STRING_BITS> string_bits(std::string(frame_string));
|
std::bitset<GLONASS_GNAV_STRING_BITS> string_bits = std::bitset<GLONASS_GNAV_STRING_BITS>(std::string(frame_string));
|
||||||
std::bitset<GLONASS_GNAV_STRING_BITS> data_bits(std::string(frame_string), 0, 77);
|
|
||||||
std::bitset<GLONASS_GNAV_STRING_BITS> hamming_code_bits(std::string(frame_string), 77, 8);
|
|
||||||
|
|
||||||
string_ID = static_cast<int>(read_navigation_unsigned(string_bits, STRING_ID));
|
string_ID = static_cast<int>(read_navigation_unsigned(string_bits, STRING_ID));
|
||||||
|
|
||||||
|
_CRC_test(string_bits);
|
||||||
|
|
||||||
// Decode all 15 string messages
|
// Decode all 15 string messages
|
||||||
switch (string_ID)
|
switch (string_ID)
|
||||||
{
|
{
|
||||||
@ -355,6 +364,8 @@ int Glonass_Gnav_Navigation_Message::string_decoder(char * frame_string)
|
|||||||
gnav_ephemeris.d_AXn = static_cast<double>(read_navigation_signed(string_bits, X_N_DOT_DOT));
|
gnav_ephemeris.d_AXn = static_cast<double>(read_navigation_signed(string_bits, X_N_DOT_DOT));
|
||||||
gnav_ephemeris.d_Xn = static_cast<double>(read_navigation_signed(string_bits, X_N));
|
gnav_ephemeris.d_Xn = static_cast<double>(read_navigation_signed(string_bits, X_N));
|
||||||
|
|
||||||
|
flag_ephemeris_str_1 = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
@ -366,6 +377,8 @@ int Glonass_Gnav_Navigation_Message::string_decoder(char * frame_string)
|
|||||||
gnav_ephemeris.d_AYn = static_cast<double>(read_navigation_signed(string_bits, Y_N_DOT_DOT));
|
gnav_ephemeris.d_AYn = static_cast<double>(read_navigation_signed(string_bits, Y_N_DOT_DOT));
|
||||||
gnav_ephemeris.d_Yn = static_cast<double>(read_navigation_signed(string_bits, Y_N));
|
gnav_ephemeris.d_Yn = static_cast<double>(read_navigation_signed(string_bits, Y_N));
|
||||||
|
|
||||||
|
flag_ephemeris_str_2 = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
@ -378,6 +391,8 @@ int Glonass_Gnav_Navigation_Message::string_decoder(char * frame_string)
|
|||||||
gnav_ephemeris.d_AZn = static_cast<double>(read_navigation_signed(string_bits, Z_N_DOT_DOT));
|
gnav_ephemeris.d_AZn = static_cast<double>(read_navigation_signed(string_bits, Z_N_DOT_DOT));
|
||||||
gnav_ephemeris.d_Zn = static_cast<double>(read_navigation_signed(string_bits, Z_N));
|
gnav_ephemeris.d_Zn = static_cast<double>(read_navigation_signed(string_bits, Z_N));
|
||||||
|
|
||||||
|
flag_ephemeris_str_3 = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
@ -392,25 +407,27 @@ int Glonass_Gnav_Navigation_Message::string_decoder(char * frame_string)
|
|||||||
gnav_ephemeris.d_n = static_cast<double>(read_navigation_unsigned(string_bits, N));
|
gnav_ephemeris.d_n = static_cast<double>(read_navigation_unsigned(string_bits, N));
|
||||||
gnav_ephemeris.d_M = static_cast<double>(read_navigation_unsigned(string_bits, M));
|
gnav_ephemeris.d_M = static_cast<double>(read_navigation_unsigned(string_bits, M));
|
||||||
|
|
||||||
|
flag_ephemeris_str_4 = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
// --- It is string 5 ----------------------------------------------
|
// --- It is string 5 ----------------------------------------------
|
||||||
// TODO signed vs unsigned reading from datasheet
|
// TODO signed vs unsigned reading from datasheet
|
||||||
d_N_A = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
gnav_utc_model.d_N_A = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
||||||
d_tau_c = static_cast<double>(read_navigation_unsigned(string_bits, TAU_C));
|
gnav_utc_model.d_tau_c = static_cast<double>(read_navigation_unsigned(string_bits, TAU_C));
|
||||||
d_N_4 = static_cast<double>(read_navigation_unsigned(string_bits, N_4));
|
gnav_utc_model.d_N_4 = static_cast<double>(read_navigation_unsigned(string_bits, N_4));
|
||||||
d_tau_c = static_cast<double>(read_navigation_unsigned(string_bits, TAU_C));
|
gnav_utc_model.d_tau_c = static_cast<double>(read_navigation_unsigned(string_bits, TAU_C));
|
||||||
d_l_n = static_cast<double>(read_navigation_unsigned(string_bits, ALM_L_N));
|
gnav_ephemeris.d_l_n = static_cast<double>(read_navigation_unsigned(string_bits, ALM_L_N));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
// --- It is string 6 ----------------------------------------------
|
// --- It is string 6 ----------------------------------------------
|
||||||
// TODO signed vs unsigned reading from datasheet
|
// TODO signed vs unsigned reading from datasheet
|
||||||
i_satellite_slot_number = = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
i_satellite_slot_number = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
||||||
|
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_C_N = static_cast<double>(read_navigation_unsigned(string_bits, C_N));
|
gnav_almanac[i_satellite_slot_number - 1].d_C_n = static_cast<double>(read_navigation_unsigned(string_bits, C_N));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_M_n_A = static_cast<double>(read_navigation_unsigned(string_bits, M_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_M_n_A = static_cast<double>(read_navigation_unsigned(string_bits, M_N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_n_A = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_n_A = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_tau_n_A = static_cast<double>(read_navigation_unsigned(string_bits, TAU_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_tau_n_A = static_cast<double>(read_navigation_unsigned(string_bits, TAU_N_A));
|
||||||
@ -432,7 +449,7 @@ int Glonass_Gnav_Navigation_Message::string_decoder(char * frame_string)
|
|||||||
gnav_almanac[i_satellite_slot_number - 1].d_Delta_T_n_A = static_cast<double>(read_navigation_unsigned(string_bits, DELTA_T_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_Delta_T_n_A = static_cast<double>(read_navigation_unsigned(string_bits, DELTA_T_N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_Delta_T_n_A_dot = static_cast<double>(read_navigation_unsigned(string_bits, DELTA_T_DOT_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_Delta_T_n_A_dot = static_cast<double>(read_navigation_unsigned(string_bits, DELTA_T_DOT_N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_H_n_A = static_cast<double>(read_navigation_unsigned(string_bits, H_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_H_n_A = static_cast<double>(read_navigation_unsigned(string_bits, H_N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_l_n = static_cast<double>(read_navigation_unsigned(string_bits, ALM_L_N));
|
gnav_ephemeris.d_l_n = static_cast<double>(read_navigation_unsigned(string_bits, ALM_L_N));
|
||||||
|
|
||||||
flag_almanac_str_7 = true;
|
flag_almanac_str_7 = true;
|
||||||
}
|
}
|
||||||
@ -442,8 +459,8 @@ int Glonass_Gnav_Navigation_Message::string_decoder(char * frame_string)
|
|||||||
case 8:
|
case 8:
|
||||||
// --- It is string 8 ----------------------------------------------
|
// --- It is string 8 ----------------------------------------------
|
||||||
// TODO signed vs unsigned reading from datasheet
|
// TODO signed vs unsigned reading from datasheet
|
||||||
i_satellite_slot_number = = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
i_satellite_slot_number = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_C_N = static_cast<double>(read_navigation_unsigned(string_bits, C_N));
|
gnav_almanac[i_satellite_slot_number - 1].d_C_n = static_cast<double>(read_navigation_unsigned(string_bits, C_N));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_M_n_A = static_cast<double>(read_navigation_unsigned(string_bits, M_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_M_n_A = static_cast<double>(read_navigation_unsigned(string_bits, M_N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_n_A = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_n_A = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_tau_n_A = static_cast<double>(read_navigation_unsigned(string_bits, TAU_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_tau_n_A = static_cast<double>(read_navigation_unsigned(string_bits, TAU_N_A));
|
||||||
@ -465,15 +482,15 @@ int Glonass_Gnav_Navigation_Message::string_decoder(char * frame_string)
|
|||||||
gnav_almanac[i_satellite_slot_number - 1].d_Delta_T_n_A = static_cast<double>(read_navigation_unsigned(string_bits, DELTA_T_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_Delta_T_n_A = static_cast<double>(read_navigation_unsigned(string_bits, DELTA_T_N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_Delta_T_n_A_dot = static_cast<double>(read_navigation_unsigned(string_bits, DELTA_T_DOT_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_Delta_T_n_A_dot = static_cast<double>(read_navigation_unsigned(string_bits, DELTA_T_DOT_N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_H_n_A = static_cast<double>(read_navigation_unsigned(string_bits, H_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_H_n_A = static_cast<double>(read_navigation_unsigned(string_bits, H_N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_l_n = static_cast<double>(read_navigation_unsigned(string_bits, ALM_L_N));
|
gnav_ephemeris.d_l_n = static_cast<double>(read_navigation_unsigned(string_bits, ALM_L_N));
|
||||||
|
|
||||||
flag_almanac_str_9 = true;
|
flag_almanac_str_9 = true;
|
||||||
}
|
}
|
||||||
case 10:
|
case 10:
|
||||||
// --- It is string 8 ----------------------------------------------
|
// --- It is string 8 ----------------------------------------------
|
||||||
// TODO signed vs unsigned reading from datasheet
|
// TODO signed vs unsigned reading from datasheet
|
||||||
i_satellite_slot_number = = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
i_satellite_slot_number = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_C_N = static_cast<double>(read_navigation_unsigned(string_bits, C_N));
|
gnav_almanac[i_satellite_slot_number - 1].d_C_n = static_cast<double>(read_navigation_unsigned(string_bits, C_N));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_M_n_A = static_cast<double>(read_navigation_unsigned(string_bits, M_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_M_n_A = static_cast<double>(read_navigation_unsigned(string_bits, M_N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_n_A = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_n_A = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_tau_n_A = static_cast<double>(read_navigation_unsigned(string_bits, TAU_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_tau_n_A = static_cast<double>(read_navigation_unsigned(string_bits, TAU_N_A));
|
||||||
@ -495,7 +512,7 @@ int Glonass_Gnav_Navigation_Message::string_decoder(char * frame_string)
|
|||||||
gnav_almanac[i_satellite_slot_number - 1].d_Delta_T_n_A = static_cast<double>(read_navigation_unsigned(string_bits, DELTA_T_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_Delta_T_n_A = static_cast<double>(read_navigation_unsigned(string_bits, DELTA_T_N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_Delta_T_n_A_dot = static_cast<double>(read_navigation_unsigned(string_bits, DELTA_T_DOT_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_Delta_T_n_A_dot = static_cast<double>(read_navigation_unsigned(string_bits, DELTA_T_DOT_N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_H_n_A = static_cast<double>(read_navigation_unsigned(string_bits, H_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_H_n_A = static_cast<double>(read_navigation_unsigned(string_bits, H_N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_l_n = static_cast<double>(read_navigation_unsigned(string_bits, ALM_L_N));
|
gnav_ephemeris.d_l_n = static_cast<double>(read_navigation_unsigned(string_bits, ALM_L_N));
|
||||||
|
|
||||||
flag_almanac_str_11 = true;
|
flag_almanac_str_11 = true;
|
||||||
}
|
}
|
||||||
@ -503,8 +520,8 @@ int Glonass_Gnav_Navigation_Message::string_decoder(char * frame_string)
|
|||||||
case 12:
|
case 12:
|
||||||
// --- It is string 8 ----------------------------------------------
|
// --- It is string 8 ----------------------------------------------
|
||||||
// TODO signed vs unsigned reading from datasheet
|
// TODO signed vs unsigned reading from datasheet
|
||||||
i_satellite_slot_number = = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
i_satellite_slot_number = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_C_N = static_cast<double>(read_navigation_unsigned(string_bits, C_N));
|
gnav_almanac[i_satellite_slot_number - 1].d_C_n = static_cast<double>(read_navigation_unsigned(string_bits, C_N));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_M_n_A = static_cast<double>(read_navigation_unsigned(string_bits, M_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_M_n_A = static_cast<double>(read_navigation_unsigned(string_bits, M_N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_n_A = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_n_A = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_tau_n_A = static_cast<double>(read_navigation_unsigned(string_bits, TAU_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_tau_n_A = static_cast<double>(read_navigation_unsigned(string_bits, TAU_N_A));
|
||||||
@ -526,7 +543,7 @@ int Glonass_Gnav_Navigation_Message::string_decoder(char * frame_string)
|
|||||||
gnav_almanac[i_satellite_slot_number - 1].d_Delta_T_n_A = static_cast<double>(read_navigation_unsigned(string_bits, DELTA_T_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_Delta_T_n_A = static_cast<double>(read_navigation_unsigned(string_bits, DELTA_T_N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_Delta_T_n_A_dot = static_cast<double>(read_navigation_unsigned(string_bits, DELTA_T_DOT_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_Delta_T_n_A_dot = static_cast<double>(read_navigation_unsigned(string_bits, DELTA_T_DOT_N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_H_n_A = static_cast<double>(read_navigation_unsigned(string_bits, H_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_H_n_A = static_cast<double>(read_navigation_unsigned(string_bits, H_N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_l_n = static_cast<double>(read_navigation_unsigned(string_bits, ALM_L_N));
|
gnav_ephemeris.d_l_n = static_cast<double>(read_navigation_unsigned(string_bits, ALM_L_N));
|
||||||
|
|
||||||
flag_almanac_str_13 = true;
|
flag_almanac_str_13 = true;
|
||||||
}
|
}
|
||||||
@ -534,14 +551,14 @@ int Glonass_Gnav_Navigation_Message::string_decoder(char * frame_string)
|
|||||||
// --- It is string 8 ----------------------------------------------
|
// --- It is string 8 ----------------------------------------------
|
||||||
if( frame_number == 5)
|
if( frame_number == 5)
|
||||||
{
|
{
|
||||||
gnav_utc_model.B1 = static_cast<double>(read_navigation_unsigned(string_bits, B1));
|
gnav_utc_model.d_B1 = static_cast<double>(read_navigation_unsigned(string_bits, B1));
|
||||||
gnav_utc_model.B2 = static_cast<double>(read_navigation_unsigned(string_bits, B2));
|
gnav_utc_model.d_B2 = static_cast<double>(read_navigation_unsigned(string_bits, B2));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO signed vs unsigned reading from datasheet
|
// TODO signed vs unsigned reading from datasheet
|
||||||
i_satellite_slot_number = = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
i_satellite_slot_number = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_C_N = static_cast<double>(read_navigation_unsigned(string_bits, C_N));
|
gnav_almanac[i_satellite_slot_number - 1].d_C_n = static_cast<double>(read_navigation_unsigned(string_bits, C_N));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_M_n_A = static_cast<double>(read_navigation_unsigned(string_bits, M_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_M_n_A = static_cast<double>(read_navigation_unsigned(string_bits, M_N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_n_A = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_n_A = static_cast<double>(read_navigation_unsigned(string_bits, N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_tau_n_A = static_cast<double>(read_navigation_unsigned(string_bits, TAU_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_tau_n_A = static_cast<double>(read_navigation_unsigned(string_bits, TAU_N_A));
|
||||||
@ -565,7 +582,7 @@ int Glonass_Gnav_Navigation_Message::string_decoder(char * frame_string)
|
|||||||
gnav_almanac[i_satellite_slot_number - 1].d_Delta_T_n_A = static_cast<double>(read_navigation_unsigned(string_bits, DELTA_T_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_Delta_T_n_A = static_cast<double>(read_navigation_unsigned(string_bits, DELTA_T_N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_Delta_T_n_A_dot = static_cast<double>(read_navigation_unsigned(string_bits, DELTA_T_DOT_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_Delta_T_n_A_dot = static_cast<double>(read_navigation_unsigned(string_bits, DELTA_T_DOT_N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_H_n_A = static_cast<double>(read_navigation_unsigned(string_bits, H_N_A));
|
gnav_almanac[i_satellite_slot_number - 1].d_H_n_A = static_cast<double>(read_navigation_unsigned(string_bits, H_N_A));
|
||||||
gnav_almanac[i_satellite_slot_number - 1].d_l_n = static_cast<double>(read_navigation_unsigned(string_bits, ALM_L_N));
|
gnav_ephemeris.d_l_n = static_cast<double>(read_navigation_unsigned(string_bits, ALM_L_N));
|
||||||
|
|
||||||
flag_almanac_str_15 = true;
|
flag_almanac_str_15 = true;
|
||||||
}
|
}
|
||||||
@ -573,7 +590,7 @@ int Glonass_Gnav_Navigation_Message::string_decoder(char * frame_string)
|
|||||||
break;
|
break;
|
||||||
} // switch subframeID ...
|
} // switch subframeID ...
|
||||||
|
|
||||||
return subframe_ID;
|
return frame_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -581,7 +598,7 @@ double Glonass_Gnav_Navigation_Message::utc_time(const double glonass_time_corre
|
|||||||
{
|
{
|
||||||
double t_utc;
|
double t_utc;
|
||||||
|
|
||||||
t_utc = glonass_time_corrected + 3*3600 + d_tau_c;
|
t_utc = glonass_time_corrected + 3*3600 + gnav_utc_model.d_tau_c;
|
||||||
return t_utc;
|
return t_utc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -598,43 +615,29 @@ Glonass_Gnav_Utc_Model Glonass_Gnav_Navigation_Message::get_utc_model()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Glonass_Gnav_Almanac get_almanac()
|
Glonass_Gnav_Almanac Glonass_Gnav_Navigation_Message::get_almanac( int satellite_slot_number)
|
||||||
{
|
{
|
||||||
return gnav_almanac;
|
return gnav_almanac[satellite_slot_number - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Glonass_Gnav_Navigation_Message::have_new_ephemeris() //Check if we have a new ephemeris stored in the galileo navigation class
|
bool Glonass_Gnav_Navigation_Message::have_new_ephemeris() //Check if we have a new ephemeris stored in the galileo navigation class
|
||||||
{
|
{
|
||||||
bool flag_data_valid = false;
|
bool flag_data_valid = false;
|
||||||
b_valid_ephemeris_set_flag = false;
|
bool b_valid_ephemeris_set_flag = false;
|
||||||
|
|
||||||
// First Step:
|
|
||||||
// check Issue Of Ephemeris Data (IODE IODC..) to find a possible interrupted reception
|
|
||||||
// and check if the data have been filled (!=0)
|
|
||||||
if (d_TOW_F1 != 0 and d_TOW_F2 != 0 and d_TOW_F3 != 0)
|
|
||||||
{
|
|
||||||
if (d_IODE_SF2 == d_IODE_SF3 and d_IODC == d_IODE_SF2 and d_IODC!= -1)
|
|
||||||
{
|
|
||||||
flag_data_valid = true;
|
|
||||||
b_valid_ephemeris_set_flag = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ((flag_ephemeris_str_1 == true) and (flag_ephemeris_str_2 == true) and (flag_ephemeris_str_3 == true) and (flag_ephemeris_str_4 == true))
|
if ((flag_ephemeris_str_1 == true) and (flag_ephemeris_str_2 == true) and (flag_ephemeris_str_3 == true) and (flag_ephemeris_str_4 == true))
|
||||||
{
|
{
|
||||||
//if all ephemeris pages have the same IOD, then they belong to the same block
|
//if all ephemeris pages have the same IOD, then they belong to the same block
|
||||||
if ((gnav_ephemeris.d_t_b == IOD_nav_2) and (IOD_nav_3 == IOD_nav_4) and (IOD_nav_1 == IOD_nav_3))
|
if ((gnav_ephemeris.d_t_b == 0) )
|
||||||
{
|
{
|
||||||
std::cout << "Ephemeris (1, 2, 3, 4) have been received and belong to the same batch" << std::endl;
|
|
||||||
flag_ephemeris_str_1 = false;// clear the flag
|
flag_ephemeris_str_1 = false;// clear the flag
|
||||||
flag_ephemeris_str_2 = false;// clear the flag
|
flag_ephemeris_str_2 = false;// clear the flag
|
||||||
flag_ephemeris_str_3 = false;// clear the flag
|
flag_ephemeris_str_3 = false;// clear the flag
|
||||||
flag_ephemeris_str_4 = false;// clear the flag
|
flag_ephemeris_str_4 = false;// clear the flag
|
||||||
flag_all_ephemeris = true;
|
flag_all_ephemeris = true;
|
||||||
IOD_ephemeris = IOD_nav_1;
|
// std::cout << "Ephemeris (1, 2, 3, 4) have been received and belong to the same batch" << std::endl;
|
||||||
std::cout << "Batch number: "<< IOD_ephemeris << std::endl;
|
// std::cout << "Batch number: "<< IOD_ephemeris << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -649,6 +652,7 @@ bool Glonass_Gnav_Navigation_Message::have_new_ephemeris() //Check if we have a
|
|||||||
|
|
||||||
bool Glonass_Gnav_Navigation_Message::have_new_utc_model() // Check if we have a new utc data set stored in the galileo navigation class
|
bool Glonass_Gnav_Navigation_Message::have_new_utc_model() // Check if we have a new utc data set stored in the galileo navigation class
|
||||||
{
|
{
|
||||||
|
bool flag_utc_model = true;
|
||||||
if (flag_utc_model == true)
|
if (flag_utc_model == true)
|
||||||
{
|
{
|
||||||
flag_utc_model = false; // clear the flag
|
flag_utc_model = false; // clear the flag
|
||||||
|
@ -58,7 +58,7 @@ private:
|
|||||||
unsigned long int read_navigation_unsigned(std::bitset<GLONASS_GNAV_STRING_BITS> bits, const std::vector<std::pair<int,int>> parameter);
|
unsigned long int read_navigation_unsigned(std::bitset<GLONASS_GNAV_STRING_BITS> bits, const std::vector<std::pair<int,int>> parameter);
|
||||||
signed long int read_navigation_signed(std::bitset<GLONASS_GNAV_STRING_BITS> bits, const std::vector<std::pair<int,int>> parameter);
|
signed long int read_navigation_signed(std::bitset<GLONASS_GNAV_STRING_BITS> bits, const std::vector<std::pair<int,int>> parameter);
|
||||||
bool read_navigation_bool(std::bitset<GLONASS_GNAV_STRING_BITS> bits, const std::vector<std::pair<int,int>> parameter);
|
bool read_navigation_bool(std::bitset<GLONASS_GNAV_STRING_BITS> bits, const std::vector<std::pair<int,int>> parameter);
|
||||||
bool _CRC_test(std::bitset<GLONASS_GNAV_STRING_BITS> bits, std::bitset<GLONASS_GNAV_HAMMING_CODE_BITS> hamming_code);
|
bool _CRC_test(std::bitset<GLONASS_GNAV_STRING_BITS> bits);
|
||||||
|
|
||||||
unsigned int get_frame_number(unsigned int satellite_slot_number);
|
unsigned int get_frame_number(unsigned int satellite_slot_number);
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ public:
|
|||||||
/*
|
/*
|
||||||
* \brief Returns a Galileo_Almanac object filled with the latest navigation data received
|
* \brief Returns a Galileo_Almanac object filled with the latest navigation data received
|
||||||
*/
|
*/
|
||||||
Glonass_Gnav_Almanac get_almanac();
|
Glonass_Gnav_Almanac get_almanac(int satellite_slot_number);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* \brief Returns true if new Ephemeris has arrived. The flag is set to false when the function is executed
|
* \brief Returns true if new Ephemeris has arrived. The flag is set to false when the function is executed
|
||||||
|
@ -61,7 +61,6 @@
|
|||||||
|
|
||||||
#include "glonass_gnav_ephemeris.h"
|
#include "glonass_gnav_ephemeris.h"
|
||||||
#include "glonass_gnav_almanac.h"
|
#include "glonass_gnav_almanac.h"
|
||||||
#include "glonass_gnav_iono.h"
|
|
||||||
#include "glonass_gnav_utc_model.h"
|
#include "glonass_gnav_utc_model.h"
|
||||||
|
|
||||||
using google::LogMessage;
|
using google::LogMessage;
|
||||||
|
@ -43,18 +43,18 @@
|
|||||||
#include "glonass_gnav_almanac.h"
|
#include "glonass_gnav_almanac.h"
|
||||||
|
|
||||||
// See A 3.2.3
|
// See A 3.2.3
|
||||||
TEST(GlonassGnavEphemerisTest, SatellitePosition)
|
TEST(GlonassGnavAlmanacTest, SatellitePosition)
|
||||||
{
|
{
|
||||||
double N_i = 615; // [days]
|
double N_i = 615; // [days]
|
||||||
double t_i = 33300.0 // [seconds]
|
double t_i = 33300.0; // [seconds]
|
||||||
double Xoi = 10947.021572; // [km]
|
double Xoi = 10947.021572; // [km]
|
||||||
double Yoi = 13078.978287; // [km]
|
double Yoi = 13078.978287; // [km]
|
||||||
double Zoi = 18922.063362; // [km]
|
double Zoi = 18922.063362; // [km]
|
||||||
double Vxoi = -3.375497 // [m/s]
|
double Vxoi = -3.375497; // [m/s]
|
||||||
double Vyoi = -0.161453; // [Кm/s]
|
double Vyoi = -0.161453; // [Кm/s]
|
||||||
double Vzoi = 2.060844; // [Кm/s]
|
double Vzoi = 2.060844; // [Кm/s]
|
||||||
|
|
||||||
Glonass_Gnav_Ephemeris gnav_almanac;
|
Glonass_Gnav_Almanac gnav_almanac;
|
||||||
|
|
||||||
gnav_almanac.d_N_A = 615; // [days]
|
gnav_almanac.d_N_A = 615; // [days]
|
||||||
gnav_almanac.d_lambda_n_A = -0.189986229; // [half cycles]
|
gnav_almanac.d_lambda_n_A = -0.189986229; // [half cycles]
|
||||||
|
Loading…
Reference in New Issue
Block a user