mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-11-19 08:35:16 +00:00
bugreport: Time managment with boost posix time
Need to fix bug in time duration with posix time and deal with day offsets in the code. Something seems off with day duration for long periods of time.
This commit is contained in:
@@ -190,8 +190,8 @@ void rtklib_pvt_cc::msg_handler_telemetry(pmt::pmt_t msg)
|
||||
// TODO Add GLONASS with gps week number and tow,
|
||||
// insert new ephemeris record
|
||||
DLOG(INFO) << "GLONASS GNAV New Ephemeris record inserted in global map with TOW =" << glonass_gnav_eph->d_TOW
|
||||
<< ", GLONASS GNAV Week Number =" << glonass_gnav_eph->d_WN
|
||||
<< " and Ephemeris IOD = " << glonass_gnav_eph->compute_GLONASS_time(glonass_gnav_eph->d_t_b)
|
||||
<< ", Week Number =" << glonass_gnav_eph->d_WN
|
||||
<< " and Ephemeris IOD in UTC = " << glonass_gnav_eph->compute_GLONASS_time(glonass_gnav_eph->d_t_b)
|
||||
<< " from SV = " << glonass_gnav_eph->i_satellite_slot_number;
|
||||
// update/insert new ephemeris record to the global ephemeris map
|
||||
d_ls_pvt->glonass_gnav_ephemeris_map[glonass_gnav_eph->i_satellite_PRN] = *glonass_gnav_eph;
|
||||
@@ -542,7 +542,7 @@ int rtklib_pvt_cc::work (int noutput_items, gr_vector_const_void_star &input_ite
|
||||
std::map<int,Gps_Ephemeris>::const_iterator tmp_eph_iter_gps = d_ls_pvt->gps_ephemeris_map.find(in[i][epoch].PRN);
|
||||
std::map<int,Galileo_Ephemeris>::const_iterator tmp_eph_iter_gal = d_ls_pvt->galileo_ephemeris_map.find(in[i][epoch].PRN);
|
||||
std::map<int,Gps_CNAV_Ephemeris>::const_iterator tmp_eph_iter_cnav = d_ls_pvt->gps_cnav_ephemeris_map.find(in[i][epoch].PRN);
|
||||
std::map<int,Glonass_Gnav_Ephemeris>::const_iterator tmp_eph_iter_glo_gnav = d_ls_pvt->glonass_gnav_ephemeris_map.find(in[i][epoch].PRN);
|
||||
std::map<int,Glonass_Gnav_Ephemeris>::const_iterator tmp_eph_iter_glo_gnav = d_ls_pvt->glonass_gnav_ephemeris_map.find(in[i][epoch].PRN);
|
||||
if(((tmp_eph_iter_gps->second.i_satellite_PRN == in[i][epoch].PRN) && (std::string(in[i][epoch].Signal).compare("1C") == 0))
|
||||
|| ((tmp_eph_iter_cnav->second.i_satellite_PRN == in[i][epoch].PRN) && (std::string(in[i][epoch].Signal).compare("2S") == 0))
|
||||
|| ((tmp_eph_iter_gal->second.i_satellite_PRN == in[i][epoch].PRN) && (std::string(in[i][epoch].Signal).compare("1B") == 0))
|
||||
|
||||
@@ -116,6 +116,7 @@ bool rtklib_solver::get_PVT(const std::map<int,Gnss_Synchro> & gnss_observables_
|
||||
std::map<int,Gps_Ephemeris>::const_iterator gps_ephemeris_iter;
|
||||
std::map<int,Gps_CNAV_Ephemeris>::const_iterator gps_cnav_ephemeris_iter;
|
||||
std::map<int,Glonass_Gnav_Ephemeris>::const_iterator glonass_gnav_ephemeris_iter;
|
||||
const Glonass_Gnav_Utc_Model gnav_utc = this->glonass_gnav_utc_model;
|
||||
|
||||
this->set_averaging_flag(flag_averaging);
|
||||
|
||||
@@ -279,75 +280,75 @@ bool rtklib_solver::get_PVT(const std::map<int,Gnss_Synchro> & gnss_observables_
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'R': //TODO This should be using rtk lib nomenclature
|
||||
{
|
||||
std::string sig_(gnss_observables_iter->second.Signal);
|
||||
// GLONASS GNAV L1
|
||||
if(sig_.compare("1G") == 0)
|
||||
{
|
||||
// 1 Glo - find the ephemeris for the current GLONASS SV observation. The SV Slot Number (PRN ID) is the map key
|
||||
glonass_gnav_ephemeris_iter = glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN);
|
||||
if (glonass_gnav_ephemeris_iter != glonass_gnav_ephemeris_map.cend())
|
||||
{
|
||||
//convert ephemeris from GNSS-SDR class to RTKLIB structure
|
||||
geph_data[glo_valid_obs] = eph_to_rtklib(glonass_gnav_ephemeris_iter->second);
|
||||
//convert observation from GNSS-SDR class to RTKLIB structure
|
||||
obsd_t newobs = {{0,0}, '0', '0', {}, {}, {}, {}, {}, {}};
|
||||
obs_data[glo_valid_obs] = insert_obs_to_rtklib(newobs,
|
||||
gnss_observables_iter->second,
|
||||
glonass_gnav_ephemeris_iter->second.d_WN,
|
||||
0);//Band 0 (L1)
|
||||
glo_valid_obs++;
|
||||
}
|
||||
else // the ephemeris are not available for this SV
|
||||
{
|
||||
DLOG(INFO) << "No ephemeris data for SV " << gnss_observables_iter->second.PRN;
|
||||
}
|
||||
case 'R': //TODO This should be using rtk lib nomenclature
|
||||
{
|
||||
std::string sig_(gnss_observables_iter->second.Signal);
|
||||
// GLONASS GNAV L1
|
||||
if(sig_.compare("1G") == 0)
|
||||
{
|
||||
// 1 Glo - find the ephemeris for the current GLONASS SV observation. The SV Slot Number (PRN ID) is the map key
|
||||
glonass_gnav_ephemeris_iter = glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN);
|
||||
if (glonass_gnav_ephemeris_iter != glonass_gnav_ephemeris_map.cend())
|
||||
{
|
||||
//convert ephemeris from GNSS-SDR class to RTKLIB structure
|
||||
geph_data[glo_valid_obs] = eph_to_rtklib(glonass_gnav_ephemeris_iter->second, gnav_utc);
|
||||
//convert observation from GNSS-SDR class to RTKLIB structure
|
||||
obsd_t newobs = {{0,0}, '0', '0', {}, {}, {}, {}, {}, {}};
|
||||
obs_data[glo_valid_obs] = insert_obs_to_rtklib(newobs,
|
||||
gnss_observables_iter->second,
|
||||
glonass_gnav_ephemeris_iter->second.d_WN,
|
||||
0);//Band 0 (L1)
|
||||
glo_valid_obs++;
|
||||
}
|
||||
else // the ephemeris are not available for this SV
|
||||
{
|
||||
DLOG(INFO) << "No ephemeris data for SV " << gnss_observables_iter->second.PRN;
|
||||
}
|
||||
|
||||
}
|
||||
// GLONASS GNAV L2
|
||||
if(sig_.compare("2G") == 0)
|
||||
{
|
||||
// 1 GLONASS - find the ephemeris for the current GLONASS SV observation. The SV PRN ID is the map key
|
||||
glonass_gnav_ephemeris_iter = glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN);
|
||||
if (glonass_gnav_ephemeris_iter != glonass_gnav_ephemeris_map.cend())
|
||||
{
|
||||
bool found_L1_obs=false;
|
||||
for (int i = 0; i < glo_valid_obs; i++)
|
||||
{
|
||||
if (geph_data[i].sat == (static_cast<int>(gnss_observables_iter->second.PRN+NSATGPS)))
|
||||
{
|
||||
obs_data[i] = insert_obs_to_rtklib(obs_data[i],
|
||||
gnss_observables_iter->second,
|
||||
glonass_gnav_ephemeris_iter->second.d_WN,
|
||||
1);//Band 1 (L2)
|
||||
found_L1_obs=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found_L1_obs)
|
||||
}
|
||||
// GLONASS GNAV L2
|
||||
if(sig_.compare("2G") == 0)
|
||||
{
|
||||
// 1 GLONASS - find the ephemeris for the current GLONASS SV observation. The SV PRN ID is the map key
|
||||
glonass_gnav_ephemeris_iter = glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN);
|
||||
if (glonass_gnav_ephemeris_iter != glonass_gnav_ephemeris_map.cend())
|
||||
{
|
||||
bool found_L1_obs=false;
|
||||
for (int i = 0; i < glo_valid_obs; i++)
|
||||
{
|
||||
if (geph_data[i].sat == (static_cast<int>(gnss_observables_iter->second.PRN+NSATGPS)))
|
||||
{
|
||||
//insert GLONASS GNAV L2 obs as new obs and also insert its ephemeris
|
||||
//convert ephemeris from GNSS-SDR class to RTKLIB structure
|
||||
geph_data[glo_valid_obs] = eph_to_rtklib(glonass_gnav_ephemeris_iter->second);
|
||||
//convert observation from GNSS-SDR class to RTKLIB structure
|
||||
obsd_t newobs = {{0,0}, '0', '0', {}, {}, {}, {}, {}, {}};
|
||||
obs_data[glo_valid_obs] = insert_obs_to_rtklib(newobs,
|
||||
obs_data[i] = insert_obs_to_rtklib(obs_data[i],
|
||||
gnss_observables_iter->second,
|
||||
glonass_gnav_ephemeris_iter->second.d_WN,
|
||||
1); //Band 1 (L2)
|
||||
glo_valid_obs++;
|
||||
1);//Band 1 (L2)
|
||||
found_L1_obs=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else // the ephemeris are not available for this SV
|
||||
{
|
||||
DLOG(INFO) << "No ephemeris data for SV " << gnss_observables_iter->second.PRN;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (!found_L1_obs)
|
||||
{
|
||||
//insert GLONASS GNAV L2 obs as new obs and also insert its ephemeris
|
||||
//convert ephemeris from GNSS-SDR class to RTKLIB structure
|
||||
geph_data[glo_valid_obs] = eph_to_rtklib(glonass_gnav_ephemeris_iter->second, gnav_utc);
|
||||
//convert observation from GNSS-SDR class to RTKLIB structure
|
||||
obsd_t newobs = {{0,0}, '0', '0', {}, {}, {}, {}, {}, {}};
|
||||
obs_data[glo_valid_obs] = insert_obs_to_rtklib(newobs,
|
||||
gnss_observables_iter->second,
|
||||
glonass_gnav_ephemeris_iter->second.d_WN,
|
||||
1); //Band 1 (L2)
|
||||
glo_valid_obs++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else // the ephemeris are not available for this SV
|
||||
{
|
||||
DLOG(INFO) << "No ephemeris data for SV " << gnss_observables_iter->second.PRN;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
default :
|
||||
DLOG(INFO) << "Hybrid observables: Unknown GNSS";
|
||||
break;
|
||||
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
std::map<int,Galileo_Ephemeris> galileo_ephemeris_map; //!< Map storing new Galileo_Ephemeris
|
||||
std::map<int,Gps_Ephemeris> gps_ephemeris_map; //!< Map storing new GPS_Ephemeris
|
||||
std::map<int,Gps_CNAV_Ephemeris> gps_cnav_ephemeris_map; //!< Map storing new GPS_CNAV_Ephemeris
|
||||
std::map<int,Glonass_Gnav_Ephemeris> glonass_gnav_ephemeris_map; //!< Map storing new GLONASS GNAV Ephmeris
|
||||
std::map<int,Glonass_Gnav_Ephemeris> glonass_gnav_ephemeris_map; //!< Map storing new GLONASS GNAV Ephmeris
|
||||
|
||||
Galileo_Utc_Model galileo_utc_model;
|
||||
Galileo_Iono galileo_iono;
|
||||
|
||||
@@ -45,18 +45,18 @@ obsd_t insert_obs_to_rtklib(obsd_t & rtklib_obs, const Gnss_Synchro & gnss_synch
|
||||
//Galileo is the third satellite system for RTKLIB, so, add the required offset to discriminate Galileo ephemeris
|
||||
switch(gnss_synchro.System)
|
||||
{
|
||||
case 'G':
|
||||
rtklib_obs.sat = gnss_synchro.PRN;
|
||||
break;
|
||||
case 'E':
|
||||
rtklib_obs.sat = gnss_synchro.PRN+NSATGPS+NSATGLO;
|
||||
break;
|
||||
case 'R':
|
||||
rtklib_obs.sat = gnss_synchro.PRN+NSATGPS;
|
||||
break;
|
||||
case 'G':
|
||||
rtklib_obs.sat = gnss_synchro.PRN;
|
||||
break;
|
||||
case 'E':
|
||||
rtklib_obs.sat = gnss_synchro.PRN+NSATGPS+NSATGLO;
|
||||
break;
|
||||
case 'R':
|
||||
rtklib_obs.sat = gnss_synchro.PRN+NSATGPS;
|
||||
break;
|
||||
|
||||
default:
|
||||
rtklib_obs.sat = gnss_synchro.PRN;
|
||||
default:
|
||||
rtklib_obs.sat = gnss_synchro.PRN;
|
||||
}
|
||||
rtklib_obs.time = gpst2time(adjgpsweek(week), gnss_synchro.RX_time);
|
||||
rtklib_obs.rcv = 1;
|
||||
@@ -64,14 +64,12 @@ obsd_t insert_obs_to_rtklib(obsd_t & rtklib_obs, const Gnss_Synchro & gnss_synch
|
||||
return rtklib_obs;
|
||||
}
|
||||
|
||||
|
||||
geph_t eph_to_rtklib(const Glonass_Gnav_Ephemeris & glonass_gnav_eph)
|
||||
geph_t eph_to_rtklib(const Glonass_Gnav_Ephemeris & glonass_gnav_eph, const Glonass_Gnav_Utc_Model & gnav_clock_model)
|
||||
{
|
||||
int week;
|
||||
double week, sec;
|
||||
int adj_week;
|
||||
geph_t rtklib_sat = {0, 0, 0, 0, 0, 0, {0, 0}, {0, 0}, {0.0, 0.0, 0.0}, {0.0, 0.0,
|
||||
0.0}, {0.0, 0.0, 0.0}, 0.0, 0.0, 0.0};
|
||||
gtime_t t_utc;
|
||||
struct tm utcinfo;
|
||||
0.0}, {0.0, 0.0, 0.0}, 0.0, 0.0, 0.0};
|
||||
|
||||
rtklib_sat.sat = glonass_gnav_eph.i_satellite_slot_number + NSATGPS; /* satellite number */
|
||||
rtklib_sat.iode = static_cast<int>(glonass_gnav_eph.d_t_b); /* IODE (0-6 bit of tb field) */
|
||||
@@ -92,25 +90,15 @@ geph_t eph_to_rtklib(const Glonass_Gnav_Ephemeris & glonass_gnav_eph)
|
||||
rtklib_sat.gamn = glonass_gnav_eph.d_gamma_n; /* SV relative freq bias */
|
||||
rtklib_sat.age = static_cast<int>(glonass_gnav_eph.d_Delta_tau_n); /* delay between L1 and L2 (s) */
|
||||
|
||||
utcinfo.tm_mon = 0;
|
||||
utcinfo.tm_mday = glonass_gnav_eph.d_N_T;
|
||||
utcinfo.tm_year = glonass_gnav_eph.d_yr - 1900;
|
||||
utcinfo.tm_hour = -6;
|
||||
utcinfo.tm_min = 0;
|
||||
utcinfo.tm_sec = glonass_gnav_eph.d_tod;
|
||||
t_utc.time = mktime(&utcinfo);
|
||||
t_utc.sec = glonass_gnav_eph.d_tau_c;
|
||||
rtklib_sat.toe = utc2gpst(t_utc); /* message frame time (gpst) */
|
||||
// Time expressed in GPS Time but using RTKLib format
|
||||
glonass_gnav_eph.glot_to_gpst(glonass_gnav_eph.d_tod, gnav_clock_model.d_tau_c, gnav_clock_model.d_tau_gps, &week, &sec);
|
||||
adj_week = adjgpsweek(static_cast<int>(week));
|
||||
rtklib_sat.toe = gpst2time(adj_week, sec);
|
||||
|
||||
utcinfo.tm_mon = 0;
|
||||
utcinfo.tm_mday = glonass_gnav_eph.d_N_T;
|
||||
utcinfo.tm_year = glonass_gnav_eph.d_yr - 1900;
|
||||
utcinfo.tm_hour = -6;
|
||||
utcinfo.tm_min = 0;
|
||||
utcinfo.tm_sec = glonass_gnav_eph.d_t_k;
|
||||
t_utc.time = mktime(&utcinfo);
|
||||
t_utc.sec = glonass_gnav_eph.d_tau_c;
|
||||
rtklib_sat.tof = utc2gpst(t_utc); /* message frame time (gpst) */
|
||||
// Time expressed in GPS Time but using RTKLib format
|
||||
glonass_gnav_eph.glot_to_gpst(glonass_gnav_eph.d_t_k, gnav_clock_model.d_tau_c, gnav_clock_model.d_tau_gps, &week, &sec);
|
||||
adj_week = adjgpsweek(static_cast<int>(week));
|
||||
rtklib_sat.tof = gpst2time(adj_week, sec);
|
||||
|
||||
return rtklib_sat;
|
||||
}
|
||||
@@ -119,7 +107,7 @@ geph_t eph_to_rtklib(const Glonass_Gnav_Ephemeris & glonass_gnav_eph)
|
||||
eph_t eph_to_rtklib(const Galileo_Ephemeris & gal_eph)
|
||||
{
|
||||
eph_t rtklib_sat = {0, 0, 0, 0, 0, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0.0, 0.0, 0.0, 0.0, 0.0,
|
||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, 0.0, 0.0 };
|
||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, 0.0, 0.0 };
|
||||
//Galileo is the third satellite system for RTKLIB, so, add the required offset to discriminate Galileo ephemeris
|
||||
rtklib_sat.sat = gal_eph.i_satellite_PRN+NSATGPS+NSATGLO;
|
||||
rtklib_sat.A = gal_eph.A_1 * gal_eph.A_1;
|
||||
@@ -169,7 +157,7 @@ eph_t eph_to_rtklib(const Galileo_Ephemeris & gal_eph)
|
||||
eph_t eph_to_rtklib(const Gps_Ephemeris & gps_eph)
|
||||
{
|
||||
eph_t rtklib_sat = {0, 0, 0, 0, 0, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0.0, 0.0, 0.0, 0.0, 0.0,
|
||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, 0.0, 0.0 };
|
||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, 0.0, 0.0 };
|
||||
rtklib_sat.sat = gps_eph.i_satellite_PRN;
|
||||
rtklib_sat.A = gps_eph.d_sqrt_A * gps_eph.d_sqrt_A;
|
||||
rtklib_sat.M0 = gps_eph.d_M_0;
|
||||
@@ -220,7 +208,7 @@ eph_t eph_to_rtklib(const Gps_Ephemeris & gps_eph)
|
||||
eph_t eph_to_rtklib(const Gps_CNAV_Ephemeris & gps_cnav_eph)
|
||||
{
|
||||
eph_t rtklib_sat = {0, 0, 0, 0, 0, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0.0, 0.0, 0.0, 0.0, 0.0,
|
||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, 0.0, 0.0 };
|
||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, 0.0, 0.0 };
|
||||
rtklib_sat.sat = gps_cnav_eph.i_satellite_PRN;
|
||||
const double A_REF = 26559710.0; // See IS-GPS-200H, pp. 170
|
||||
rtklib_sat.A = A_REF + gps_cnav_eph.d_DELTA_A;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "gps_ephemeris.h"
|
||||
#include "gps_cnav_ephemeris.h"
|
||||
#include "glonass_gnav_ephemeris.h"
|
||||
#include "glonass_gnav_utc_model.h"
|
||||
|
||||
eph_t eph_to_rtklib(const Galileo_Ephemeris & gal_eph);
|
||||
eph_t eph_to_rtklib(const Gps_Ephemeris & gps_eph);
|
||||
@@ -46,7 +47,7 @@ eph_t eph_to_rtklib(const Gps_CNAV_Ephemeris & gps_cnav_eph);
|
||||
* \param glonass_gnav_eph GLONASS GNAV Ephemeris structure
|
||||
* \return Ephemeris structure for RTKLIB parsing
|
||||
*/
|
||||
geph_t eph_to_rtklib(const Glonass_Gnav_Ephemeris & glonass_gnav_eph);
|
||||
geph_t eph_to_rtklib(const Glonass_Gnav_Ephemeris & glonass_gnav_eph, const Glonass_Gnav_Utc_Model & gnav_clock_model);
|
||||
|
||||
obsd_t insert_obs_to_rtklib(obsd_t & rtklib_obs, const Gnss_Synchro & gnss_synchro, int week, int band);
|
||||
|
||||
|
||||
@@ -221,7 +221,8 @@ void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols,int
|
||||
if(d_nav.flag_update_slot_number == true)
|
||||
{
|
||||
LOG(INFO) << "GLONASS GNAV Slot Number Identified on channel " << d_channel;
|
||||
d_satellite.what_block(d_satellite.get_system(), d_nav.get_ephemeris().d_n);
|
||||
d_satellite.update_PRN(d_nav.gnav_ephemeris.d_n);
|
||||
d_satellite.what_block(d_satellite.get_system(), d_nav.gnav_ephemeris.d_n);
|
||||
d_nav.flag_update_slot_number = false;
|
||||
}
|
||||
}
|
||||
@@ -354,7 +355,8 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work (int noutput_items __attrib
|
||||
if (this->d_flag_preamble == true and d_nav.flag_TOW_new == true)
|
||||
//update TOW at the preamble instant
|
||||
{
|
||||
d_TOW_at_current_symbol = floor((d_nav.d_TOW - GLONASS_GNAV_PREAMBLE_DURATION_S)*1000.0)/1000.0;
|
||||
double dummy_dtow = d_nav.get_TOW() - GLONASS_GNAV_PREAMBLE_DURATION_S;
|
||||
d_TOW_at_current_symbol = d_nav.gnav_ephemeris.d_TOW - GLONASS_GNAV_PREAMBLE_DURATION_S;
|
||||
d_nav.flag_TOW_new = false;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user