From 7303f3c3fde67cd95db20bc6265f909978d73ac3 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 1 Mar 2015 21:16:29 +0100 Subject: [PATCH 01/12] hook for updating rinex headers --- .../PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc | 17 ++++++++++++++--- .../PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.h | 1 + src/algorithms/PVT/libs/rinex_printer.cc | 14 ++++++++++++++ src/algorithms/PVT/libs/rinex_printer.h | 4 ++++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc index 6b2fea3aa..e76d782ba 100644 --- a/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc @@ -106,6 +106,7 @@ gps_l1_ca_pvt_cc::gps_l1_ca_pvt_cc(unsigned int nchannels, d_rx_time = 0.0; b_rinex_header_writen = false; + b_rinex_header_updated = false; b_rinex_sbs_header_writen = false; rp = std::make_shared(); @@ -150,6 +151,9 @@ int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_ite std::map gnss_pseudoranges_map; Gnss_Synchro **in = (Gnss_Synchro **) &input_items[0]; //Get the input pointer + //Gnss_Synchro **out = (Gnss_Synchro **) &output_items[0]; //Get the output pointer + + //out = in; for (unsigned int i = 0; i < d_nchannels; i++) { @@ -168,6 +172,7 @@ int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_ite { // UTC MODEL data is shared for all the GPS satellites. Read always at ID=0 global_gps_utc_model_map.read(0, d_ls_pvt->gps_utc_model); + std::cout << d_ls_pvt->gps_utc_model.d_A0 << std::endl; } if (global_gps_iono_map.size() > 0) @@ -223,7 +228,7 @@ int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_ite } // ############ 2 COMPUTE THE PVT ################################ - if (gnss_pseudoranges_map.size() > 0 and d_ls_pvt->gps_ephemeris_map.size() >0) + if (gnss_pseudoranges_map.size() > 0 and d_ls_pvt->gps_ephemeris_map.size() > 0) { // compute on the fly PVT solution //mod 8/4/2012 Set the PVT computation rate in this block @@ -242,7 +247,7 @@ int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_ite gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.begin(); if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.end()) { - rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second,d_rx_time); + rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, d_rx_time); rp->rinex_nav_header(rp->navFile, d_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model); b_rinex_header_writen = true; // do not write header anymore } @@ -262,6 +267,12 @@ int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_ite { rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, d_rx_time, gnss_pseudoranges_map); } + if (!b_rinex_header_updated && (d_ls_pvt->gps_utc_model.d_A0 != 0)) + { + //rp->update_obs_header(rp->obsFile, d_ls_pvt->gps_utc_model, d_ls_pvt->gps_iono); + rp->update_nav_header(rp->navFile, d_ls_pvt->gps_utc_model, d_ls_pvt->gps_iono); + b_rinex_header_updated = true; + } } } } @@ -304,7 +315,7 @@ int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_ite } consume_each(1); //one by one - return 0; + return noutput_items; } diff --git a/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.h b/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.h index d66b8f81c..645760ee3 100644 --- a/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.h +++ b/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.h @@ -96,6 +96,7 @@ private: bool d_dump; bool b_rinex_header_writen; bool b_rinex_sbs_header_writen; + bool b_rinex_header_updated; std::shared_ptr rp; unsigned int d_nchannels; std::string d_dump_filename; diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 0bccdd268..758cbc8db 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -501,6 +501,20 @@ void Rinex_Printer::rinex_nav_header(std::ofstream& out, const Galileo_Iono& ion out << line << std::endl; } + +void Rinex_Printer::update_nav_header(std::ofstream& out, const Gps_Utc_Model& gps_utc, const Gps_Iono& gps_iono) +{ + if (version == 2) + { + + } + if (version == 3) + { + + } +} + + void Rinex_Printer::rinex_nav_header(std::ofstream& out, const Gps_Iono& iono, const Gps_Utc_Model& utc_model) { diff --git a/src/algorithms/PVT/libs/rinex_printer.h b/src/algorithms/PVT/libs/rinex_printer.h index df5829e56..bf0354580 100644 --- a/src/algorithms/PVT/libs/rinex_printer.h +++ b/src/algorithms/PVT/libs/rinex_printer.h @@ -59,6 +59,8 @@ #include #include #include "gps_navigation_message.h" +#include "gps_utc_model.h" +#include "gps_iono.h" #include "galileo_navigation_message.h" #include "sbas_telemetry_data.h" #include "GPS_L1_CA.h" @@ -180,6 +182,8 @@ public: */ void log_rinex_sbs(std::ofstream& out, const Sbas_Raw_Msg& sbs_message); + void update_nav_header(std::ofstream& out, const Gps_Utc_Model& gps_utc, const Gps_Iono& gps_iono); + std::map satelliteSystem; // observationType; // observationCode; // Date: Tue, 3 Mar 2015 14:56:22 +0100 Subject: [PATCH 02/12] Updating the nav RINEX printer when IONO and UTC data are received (v2.11) --- .../PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc | 2 - src/algorithms/PVT/libs/rinex_printer.cc | 128 +++++++++++++++--- src/algorithms/PVT/libs/rinex_printer.h | 40 +++--- 3 files changed, 132 insertions(+), 38 deletions(-) diff --git a/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc index e76d782ba..b15485a1a 100644 --- a/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc @@ -153,8 +153,6 @@ int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_ite Gnss_Synchro **in = (Gnss_Synchro **) &input_items[0]; //Get the input pointer //Gnss_Synchro **out = (Gnss_Synchro **) &output_items[0]; //Get the output pointer - //out = in; - for (unsigned int i = 0; i < d_nchannels; i++) { if (in[i][0].Flag_valid_pseudorange == true) diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 758cbc8db..0f35d38c3 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -33,6 +33,7 @@ #include // for min and max #include // for floor #include // for getenv() +#include #include #include #include @@ -57,7 +58,7 @@ Rinex_Printer::Rinex_Printer() navGalfilename = Rinex_Printer::createFilename("RINEX_FILE_TYPE_GAL_NAV"); navMixfilename = Rinex_Printer::createFilename("RINEX_FILE_TYPE_MIXED_NAV"); - Rinex_Printer::navFile.open(navfilename, std::ios::out | std::ios::app); + Rinex_Printer::navFile.open(navfilename, std::ios::out | std::ios::in | std::ios::app); Rinex_Printer::obsFile.open(obsfilename, std::ios::out | std::ios::app); Rinex_Printer::sbsFile.open(sbsfilename, std::ios::out | std::ios::app); Rinex_Printer::navGalFile.open(navGalfilename, std::ios::out | std::ios::app); @@ -391,7 +392,7 @@ std::string Rinex_Printer::getLocalTime() } -void Rinex_Printer::rinex_nav_header(std::ofstream& out, const Galileo_Iono& iono, const Galileo_Utc_Model& utc_model, const Galileo_Almanac& galileo_almanac) +void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& iono, const Galileo_Utc_Model& utc_model, const Galileo_Almanac& galileo_almanac) { std::string line; stringVersion = "3.02"; @@ -502,20 +503,115 @@ void Rinex_Printer::rinex_nav_header(std::ofstream& out, const Galileo_Iono& ion } -void Rinex_Printer::update_nav_header(std::ofstream& out, const Gps_Utc_Model& gps_utc, const Gps_Iono& gps_iono) +void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Utc_Model& utc_model, const Gps_Iono& iono) { + std::vector data; + std::string line_aux; + + long pos = out.tellp(); + out.seekp(0); + data.clear(); + if (version == 2) { + bool no_more_finds = false; + std::string line_str; + while(!out.eof()) + { + std::getline(out, line_str); + std::cout << line_str << std::endl; + if(!no_more_finds) + { + line_aux.clear(); + if (line_str.find("ION ALPHA", 59) != std::string::npos) + { + line_aux += std::string(2, ' '); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha0, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha1, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha2, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha3, 10, 2), 12); + line_aux += std::string(10, ' '); + line_aux += Rinex_Printer::leftJustify("ION ALPHA", 20); + data.push_back(line_aux); + } + else if (line_str.find("ION BETA", 59) != std::string::npos) + { + line_aux += std::string(2, ' '); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta0, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta1, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta2, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta3, 10, 2), 12); + line_aux += std::string(10, ' '); + line_aux += Rinex_Printer::leftJustify("ION BETA", 20); + data.push_back(line_aux); + } + else if (line_str.find("DELTA-UTC", 59) != std::string::npos) + { + line_aux += std::string(3, ' '); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A0, 18, 2), 19); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A1, 18, 2), 19); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_t_OT), 9); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_WN_T + 1024), 9); // valid until 2019 + line_aux += std::string(1, ' '); + line_aux += Rinex_Printer::leftJustify("DELTA-UTC: A0,A1,T,W", 20); + data.push_back(line_aux); + } + else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) + { + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_DeltaT_LS), 6); + line_aux += std::string(54, ' '); + line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); + data.push_back(line_aux); + } + else if (line_str.find("END OF HEADER", 59) != std::string::npos) + { + data.push_back(line_str); + no_more_finds = true; + } + else + { + data.push_back(line_str); + } + } + else + { + data.push_back(line_str); + } + } + + out.close(); + out.open(navfilename, std::ios::out | std::ios::trunc); + out.seekp(0); + for (int i = 0; i < (int) data.size(); i++) + { + out << data[i] << std::endl; + } + out.close(); + out.open(navfilename, std::ios::out | std::ios::app); } + if (version == 3) { + if (false) + { + // todo + } + else + { + // todo + } } + + //myFile.close(); + //remove(tmpfilename.c_str()); + out.seekp(pos); + std::cout << "The RINEX Navigation file header has been updated with UTC and IONO info." << std::endl; } -void Rinex_Printer::rinex_nav_header(std::ofstream& out, const Gps_Iono& iono, const Gps_Utc_Model& utc_model) +void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& iono, const Gps_Utc_Model& utc_model) { std::string line; @@ -694,7 +790,7 @@ void Rinex_Printer::rinex_nav_header(std::ofstream& out, const Gps_Iono& iono, c out << line << std::endl; } -void Rinex_Printer::rinex_nav_header(std::ofstream& out, const Gps_Iono& gps_iono, const Gps_Utc_Model& gps_utc_model, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model, const Galileo_Almanac& galileo_almanac) +void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono, const Gps_Utc_Model& gps_utc_model, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model, const Galileo_Almanac& galileo_almanac) { std::string line; stringVersion = "3.02"; @@ -828,7 +924,7 @@ void Rinex_Printer::rinex_nav_header(std::ofstream& out, const Gps_Iono& gps_ion out << line << std::endl; } -void Rinex_Printer::rinex_sbs_header(std::ofstream& out) +void Rinex_Printer::rinex_sbs_header(std::fstream& out) { std::string line; @@ -936,7 +1032,7 @@ void Rinex_Printer::rinex_sbs_header(std::ofstream& out) } -void Rinex_Printer::log_rinex_nav(std::ofstream& out, const std::map& eph_map) +void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) { std::string line; std::map::const_iterator gps_ephemeris_iter; @@ -1268,7 +1364,7 @@ void Rinex_Printer::log_rinex_nav(std::ofstream& out, const std::map& eph_map) +void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) { std::string line; std::map::const_iterator galileo_ephemeris_iter; @@ -1447,7 +1543,7 @@ void Rinex_Printer::log_rinex_nav(std::ofstream& out, const std::map& gps_eph_map, const std::map& galileo_eph_map) +void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& gps_eph_map, const std::map& galileo_eph_map) { version = 3; stringVersion = "3.02"; @@ -1456,7 +1552,7 @@ void Rinex_Printer::log_rinex_nav(std::ofstream& out, const std::map& pseudoranges) +void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, const double obs_time, const std::map& pseudoranges) { // RINEX observations timestamps are GPS timestamps. std::string line; @@ -2393,7 +2489,7 @@ void Rinex_Printer::log_rinex_obs(std::ofstream& out, const Gps_Ephemeris& eph, -void Rinex_Printer::log_rinex_obs(std::ofstream& out, const Galileo_Ephemeris& eph, double obs_time, const std::map& pseudoranges) +void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& eph, double obs_time, const std::map& pseudoranges) { // RINEX observations timestamps are Galileo timestamps. // See http://gage14.upc.es/gLAB/HTML/Observation_Rinex_v3.01.html @@ -2513,7 +2609,7 @@ void Rinex_Printer::log_rinex_obs(std::ofstream& out, const Galileo_Ephemeris& e } -void Rinex_Printer::log_rinex_obs(std::ofstream& out, const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& galileo_eph, double gps_obs_time, const std::map& pseudoranges) +void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& galileo_eph, double gps_obs_time, const std::map& pseudoranges) { std::string line; @@ -2706,7 +2802,7 @@ void Rinex_Printer::to_date_time(int gps_week, int gps_tow, int &year, int &mont -void Rinex_Printer::log_rinex_sbs(std::ofstream& out, const Sbas_Raw_Msg& sbs_message) +void Rinex_Printer::log_rinex_sbs(std::fstream& out, const Sbas_Raw_Msg& sbs_message) { // line 1: PRN / EPOCH / RCVR std::stringstream line1; diff --git a/src/algorithms/PVT/libs/rinex_printer.h b/src/algorithms/PVT/libs/rinex_printer.h index bf0354580..22620c9c2 100644 --- a/src/algorithms/PVT/libs/rinex_printer.h +++ b/src/algorithms/PVT/libs/rinex_printer.h @@ -86,46 +86,46 @@ public: */ ~Rinex_Printer(); - std::ofstream obsFile ; //& eph_map); + void log_rinex_nav(std::fstream& out, const std::map& eph_map); /*! * \brief Writes data from the Galileo navigation message into the RINEX file */ - void log_rinex_nav(std::ofstream& out, const std::map& eph_map); + void log_rinex_nav(std::fstream& out, const std::map& eph_map); /*! * \brief Writes data from the Mixed (GPS/Galileo) navigation message into the RINEX file */ - void log_rinex_nav(std::ofstream& out, const std::map& gps_eph_map, const std::map& galileo_eph_map); + void log_rinex_nav(std::fstream& out, const std::map& gps_eph_map, const std::map& galileo_eph_map); /*! * \brief Writes GPS observables into the RINEX file */ - void log_rinex_obs(std::ofstream& out, const Gps_Ephemeris& eph, double obs_time, const std::map& pseudoranges); + void log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, double obs_time, const std::map& pseudoranges); /*! * \brief Writes Galileo observables into the RINEX file */ - void log_rinex_obs(std::ofstream& out, const Galileo_Ephemeris& eph, double obs_time, const std::map& pseudoranges); + void log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& eph, double obs_time, const std::map& pseudoranges); /*! * \brief Writes Galileo observables into the RINEX file */ - void log_rinex_obs(std::ofstream& out, const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& galileo_eph, const double gps_obs_time, const std::map& pseudoranges); + void log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& galileo_eph, const double gps_obs_time, const std::map& pseudoranges); /*! * \brief Represents GPS time in the date time format. Leap years are considered, but leap seconds are not. @@ -180,9 +180,9 @@ public: /*! * \brief Writes raw SBAS messages into the RINEX file */ - void log_rinex_sbs(std::ofstream& out, const Sbas_Raw_Msg& sbs_message); + void log_rinex_sbs(std::fstream& out, const Sbas_Raw_Msg& sbs_message); - void update_nav_header(std::ofstream& out, const Gps_Utc_Model& gps_utc, const Gps_Iono& gps_iono); + void update_nav_header(std::fstream& out, const Gps_Utc_Model& gps_utc, const Gps_Iono& gps_iono); std::map satelliteSystem; // observationType; // Date: Tue, 3 Mar 2015 15:07:37 +0100 Subject: [PATCH 03/12] Removing a blank line in the RINEX file --- src/algorithms/PVT/libs/rinex_printer.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 0f35d38c3..a060bcc24 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -583,7 +583,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Utc_Model& ut out.close(); out.open(navfilename, std::ios::out | std::ios::trunc); out.seekp(0); - for (int i = 0; i < (int) data.size(); i++) + for (int i = 0; i < (int) data.size() - 1; i++) { out << data[i] << std::endl; } @@ -604,8 +604,6 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Utc_Model& ut } - //myFile.close(); - //remove(tmpfilename.c_str()); out.seekp(pos); std::cout << "The RINEX Navigation file header has been updated with UTC and IONO info." << std::endl; } From ee279e5e28512543244919e9148e6c762cbc3297 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 3 Mar 2015 15:39:23 +0100 Subject: [PATCH 04/12] Updating RINEX nav header for version 3.02 --- src/algorithms/PVT/libs/rinex_printer.cc | 107 ++++++++++++++++------- 1 file changed, 76 insertions(+), 31 deletions(-) diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index a060bcc24..d1644abec 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -512,18 +512,19 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Utc_Model& ut out.seekp(0); data.clear(); - if (version == 2) - { - bool no_more_finds = false; - std::string line_str; + bool no_more_finds = false; + std::string line_str; - while(!out.eof()) + while(!out.eof()) + { + std::getline(out, line_str); + + if(!no_more_finds) { - std::getline(out, line_str); - std::cout << line_str << std::endl; - if(!no_more_finds) + line_aux.clear(); + + if (version == 2) { - line_aux.clear(); if (line_str.find("ION ALPHA", 59) != std::string::npos) { line_aux += std::string(2, ' '); @@ -574,36 +575,80 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Utc_Model& ut data.push_back(line_str); } } - else + + if (version == 3) { - data.push_back(line_str); + if (line_str.find("GPSA", 0) != std::string::npos) + { + line_aux += std::string("GPSA"); + line_aux += std::string(1, ' '); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha0, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha1, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha2, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha3, 10, 2), 12); + line_aux += std::string(7, ' '); + line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + data.push_back(line_aux); + } + else if (line_str.find("GPSB", 0) != std::string::npos) + { + line_aux += std::string("GPSB"); + line_aux += std::string(1, ' '); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta0, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta1, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta2, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta3, 10, 2), 12); + line_aux += std::string(7, ' '); + line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + data.push_back(line_aux); + } + else if (line_str.find("GPUT", 0) != std::string::npos) + { + line_aux += std::string("GPUT"); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A0, 16, 2), 18); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A1, 15, 2), 16); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_t_OT), 7); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_WN_T + 1024), 5); // valid until 2019 + line_aux += std::string(10, ' '); + line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + data.push_back(line_aux); + } + else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) + { + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_DeltaT_LS), 6); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_DeltaT_LSF), 6); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_WN_LSF), 6); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_DN), 6); + line_aux += std::string(36, ' '); + line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); + data.push_back(line_aux); + } + else if (line_str.find("END OF HEADER", 59) != std::string::npos) + { + data.push_back(line_str); + no_more_finds = true; + } + else + { + data.push_back(line_str); + } } } - - out.close(); - out.open(navfilename, std::ios::out | std::ios::trunc); - out.seekp(0); - for (int i = 0; i < (int) data.size() - 1; i++) - { - out << data[i] << std::endl; - } - out.close(); - out.open(navfilename, std::ios::out | std::ios::app); - } - - if (version == 3) - { - if (false) - { - // todo - } else { - // todo + data.push_back(line_str); } - } + out.close(); + out.open(navfilename, std::ios::out | std::ios::trunc); + out.seekp(0); + for (int i = 0; i < (int) data.size() - 1; i++) + { + out << data[i] << std::endl; + } + out.close(); + out.open(navfilename, std::ios::out | std::ios::app); out.seekp(pos); std::cout << "The RINEX Navigation file header has been updated with UTC and IONO info." << std::endl; } From d3f669cebe60f34796ab9dcb1fd013e9c0155e1c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 3 Mar 2015 15:57:16 +0100 Subject: [PATCH 05/12] remove undesired terminal output --- src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc index b15485a1a..b0af5da17 100644 --- a/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc @@ -170,7 +170,6 @@ int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_ite { // UTC MODEL data is shared for all the GPS satellites. Read always at ID=0 global_gps_utc_model_map.read(0, d_ls_pvt->gps_utc_model); - std::cout << d_ls_pvt->gps_utc_model.d_A0 << std::endl; } if (global_gps_iono_map.size() > 0) From bf85e1fbe1bed218ce1e9c21aa748c3ebcb0390c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 3 Mar 2015 17:35:26 +0100 Subject: [PATCH 06/12] Updating RINEX nav file when IONO and UTC data are available (version 3.02) --- .../PVT/gnuradio_blocks/galileo_e1_pvt_cc.cc | 6 + .../PVT/gnuradio_blocks/galileo_e1_pvt_cc.h | 1 + .../PVT/gnuradio_blocks/hybrid_pvt_cc.cc | 6 + .../PVT/gnuradio_blocks/hybrid_pvt_cc.h | 1 + src/algorithms/PVT/libs/rinex_printer.cc | 228 ++++++++++++++++++ src/algorithms/PVT/libs/rinex_printer.h | 4 + 6 files changed, 246 insertions(+) diff --git a/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.cc index a1ba212f3..72a9eeab5 100644 --- a/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.cc @@ -92,6 +92,7 @@ galileo_e1_pvt_cc::galileo_e1_pvt_cc(unsigned int nchannels, boost::shared_ptr(); // ############# ENABLE DATA FILE LOG ################# @@ -211,6 +212,11 @@ int galileo_e1_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_it { rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_pseudoranges_map); } + if (!b_rinex_header_updated && (d_ls_pvt->galileo_utc_model.A0_6 != 0)) + { + rp->update_nav_header(rp->navGalFile, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac); + b_rinex_header_updated = true; + } } } } diff --git a/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.h b/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.h index bdb72ae16..49952afa0 100644 --- a/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.h +++ b/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.h @@ -96,6 +96,7 @@ private: boost::shared_ptr d_queue; bool d_dump; bool b_rinex_header_writen; + bool b_rinex_header_updated; std::shared_ptr rp; unsigned int d_nchannels; std::string d_dump_filename; diff --git a/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.cc index 4b42f6233..c8a220530 100644 --- a/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.cc @@ -98,6 +98,7 @@ hybrid_pvt_cc::hybrid_pvt_cc(unsigned int nchannels, boost::shared_ptr(); // ############# ENABLE DATA FILE LOG ################# @@ -250,6 +251,11 @@ int hybrid_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_items, { rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, d_rx_time, gnss_pseudoranges_map); } + if (!b_rinex_header_updated && (d_ls_pvt->gps_utc_model.d_A0 != 0)) + { + rp->update_nav_header(rp->navMixFile, d_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac); + b_rinex_header_updated = true; + } } } } diff --git a/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.h b/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.h index 8958f689a..dad4a2256 100644 --- a/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.h +++ b/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.h @@ -100,6 +100,7 @@ private: boost::shared_ptr d_queue; bool d_dump; bool b_rinex_header_writen; + bool b_rinex_header_updated; std::shared_ptr rp; unsigned int d_nchannels; std::string d_dump_filename; diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index d1644abec..e663d96b4 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -503,6 +503,103 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& iono } +void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& utc_model, const Galileo_Almanac& galileo_almanac) +{ + std::vector data; + std::string line_aux; + + long pos = out.tellp(); + out.seekp(0); + data.clear(); + + bool no_more_finds = false; + std::string line_str; + + while(!out.eof()) + { + std::getline(out, line_str); + + if(!no_more_finds) + { + line_aux.clear(); + + if ((line_str.find("GAL", 0) != std::string::npos) && (line_str.find("IONOSPHERIC CORR", 59) != std::string::npos)) + { + line_aux += std::string("GAL "); + line_aux += std::string(1, ' '); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0_5, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1_5, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2_5, 10, 2), 12); + double zero = 0.0; + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); + line_aux += std::string(7, ' '); + line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + data.push_back(line_aux); + } + else if ((line_str.find("GAUT", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) + { + line_aux += std::string("GAUT"); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A0_6, 16, 2), 18); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A1_6, 15, 2), 16); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.t0t_6), 7); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.WNot_6), 5); + line_aux += std::string(10, ' '); + line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + data.push_back(line_aux); + } + else if ((line_str.find("GPGA", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) + { + line_aux += std::string("GPGA"); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_almanac.A_0G_10, 16, 2), 18); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_almanac.A_1G_10, 15, 2), 16); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_almanac.t_0G_10), 7); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_almanac.WN_0G_10), 5); + line_aux += std::string(10, ' '); + line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + data.push_back(line_aux); + } + else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) + { + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.Delta_tLS_6), 6); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.Delta_tLSF_6), 6); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.WN_LSF_6), 6); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.DN_6), 6); + line_aux += std::string(36, ' '); + line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); + data.push_back(line_aux); + } + else if (line_str.find("END OF HEADER", 59) != std::string::npos) + { + data.push_back(line_str); + no_more_finds = true; + } + else + { + data.push_back(line_str); + } + + } + else + { + data.push_back(line_str); + } + } + + out.close(); + out.open(navfilename, std::ios::out | std::ios::trunc); + out.seekp(0); + for (int i = 0; i < (int) data.size() - 1; i++) + { + out << data[i] << std::endl; + } + out.close(); + out.open(navfilename, std::ios::out | std::ios::app); + out.seekp(pos); + std::cout << "The RINEX Navigation file header has been updated with UTC and IONO info." << std::endl; +} + + + void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Utc_Model& utc_model, const Gps_Iono& iono) { std::vector data; @@ -833,6 +930,137 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& iono, co out << line << std::endl; } + +void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_iono, const Gps_Utc_Model& gps_utc_model, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model, const Galileo_Almanac& galileo_almanac) +{ + std::vector data; + std::string line_aux; + + long pos = out.tellp(); + out.seekp(0); + data.clear(); + + bool no_more_finds = false; + std::string line_str; + + while(!out.eof()) + { + std::getline(out, line_str); + + if(!no_more_finds) + { + line_aux.clear(); + + if (line_str.find("GPSA", 0) != std::string::npos) + { + line_aux += std::string("GPSA"); + line_aux += std::string(1, ' '); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.d_alpha0, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.d_alpha1, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.d_alpha2, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.d_alpha3, 10, 2), 12); + line_aux += std::string(7, ' '); + line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + data.push_back(line_aux); + } + else if ((line_str.find("GAL", 0) != std::string::npos) && (line_str.find("IONOSPHERIC CORR", 59) != std::string::npos)) + { + line_aux += std::string("GAL "); + line_aux += std::string(1, ' '); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0_5, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1_5, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2_5, 10, 2), 12); + double zero = 0.0; + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); + line_aux += std::string(7, ' '); + line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + data.push_back(line_aux); + } + else if ((line_str.find("GPSB", 0) != std::string::npos) && (line_str.find("IONOSPHERIC CORR", 59) != std::string::npos)) + { + line_aux += std::string("GPSB"); + line_aux += std::string(1, ' '); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.d_beta0, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.d_beta1, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.d_beta2, 10, 2), 12); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.d_beta3, 10, 2), 12); + line_aux += std::string(7, ' '); + line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + data.push_back(line_aux); + } + else if ((line_str.find("GPUT", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) + { + line_aux += std::string("GPUT"); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A0, 16, 2), 18); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A1, 15, 2), 16); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_t_OT), 7); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_WN_T + 1024), 5); // valid until 2019 + line_aux += std::string(10, ' '); + line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + data.push_back(line_aux); + } + else if ((line_str.find("GAUT", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) + { + line_aux += std::string("GAUT"); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A0_6, 16, 2), 18); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A1_6, 15, 2), 16); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.t0t_6), 7); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.WNot_6), 5); + line_aux += std::string(10, ' '); + line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + data.push_back(line_aux); + } + else if ((line_str.find("GPGA", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) + { + line_aux += std::string("GPGA"); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_almanac.A_0G_10, 16, 2), 18); + line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_almanac.A_1G_10, 15, 2), 16); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_almanac.t_0G_10), 7); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_almanac.WN_0G_10), 5); + line_aux += std::string(10, ' '); + line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + data.push_back(line_aux); + } + else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) + { + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_DeltaT_LS), 6); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.d_DeltaT_LSF), 6); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_WN_LSF), 6); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(gps_utc_model.i_DN), 6); + line_aux += std::string(36, ' '); + line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); + data.push_back(line_aux); + } + else if (line_str.find("END OF HEADER", 59) != std::string::npos) + { + data.push_back(line_str); + no_more_finds = true; + } + else + { + data.push_back(line_str); + } + + } + else + { + data.push_back(line_str); + } + } + + out.close(); + out.open(navfilename, std::ios::out | std::ios::trunc); + out.seekp(0); + for (int i = 0; i < (int) data.size() - 1; i++) + { + out << data[i] << std::endl; + } + out.close(); + out.open(navfilename, std::ios::out | std::ios::app); + out.seekp(pos); + std::cout << "The RINEX Navigation file header has been updated with UTC and IONO info." << std::endl; +} + void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono, const Gps_Utc_Model& gps_utc_model, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model, const Galileo_Almanac& galileo_almanac) { std::string line; diff --git a/src/algorithms/PVT/libs/rinex_printer.h b/src/algorithms/PVT/libs/rinex_printer.h index 22620c9c2..402285124 100644 --- a/src/algorithms/PVT/libs/rinex_printer.h +++ b/src/algorithms/PVT/libs/rinex_printer.h @@ -184,6 +184,10 @@ public: void update_nav_header(std::fstream& out, const Gps_Utc_Model& gps_utc, const Gps_Iono& gps_iono); + void update_nav_header(std::fstream& out, const Gps_Iono& gps_iono, const Gps_Utc_Model& gps_utc_model, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model, const Galileo_Almanac& galileo_almanac); + + void update_nav_header(std::fstream& out, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& utc_model, const Galileo_Almanac& galileo_almanac); + std::map satelliteSystem; // observationType; // observationCode; // Date: Tue, 3 Mar 2015 18:01:53 +0100 Subject: [PATCH 07/12] Updating RINEX obs header when leap second is received (version 2.11) --- .../PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc | 2 +- src/algorithms/PVT/libs/rinex_printer.cc | 84 ++++++++++++++++++- src/algorithms/PVT/libs/rinex_printer.h | 2 + 3 files changed, 86 insertions(+), 2 deletions(-) diff --git a/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc index b0af5da17..6bc064349 100644 --- a/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc @@ -266,7 +266,7 @@ int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_ite } if (!b_rinex_header_updated && (d_ls_pvt->gps_utc_model.d_A0 != 0)) { - //rp->update_obs_header(rp->obsFile, d_ls_pvt->gps_utc_model, d_ls_pvt->gps_iono); + rp->update_obs_header(rp->obsFile, d_ls_pvt->gps_utc_model); rp->update_nav_header(rp->navFile, d_ls_pvt->gps_utc_model, d_ls_pvt->gps_iono); b_rinex_header_updated = true; } diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index e663d96b4..7b609312f 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -1822,6 +1822,88 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map data; + std::string line_aux; + + long pos = out.tellp(); + out.seekp(0); + data.clear(); + + bool no_more_finds = false; + std::string line_str; + + while(!out.eof()) + { + std::getline(out, line_str); + + if(!no_more_finds) + { + line_aux.clear(); + + if (version == 2) + { + if (line_str.find("TIME OF FIRST OBS", 59) != std::string::npos) // TIME OF FIRST OBS last header annotation might change in the future + { + data.push_back(line_str); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_DeltaT_LS), 6); + line_aux += std::string(54, ' '); + line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); + data.push_back(line_aux); + } + else if (line_str.find("END OF HEADER", 59) != std::string::npos) + { + data.push_back(line_str); + no_more_finds = true; + } + else + { + data.push_back(line_str); + } + } + + if (version == 3) + { + if (line_str.find("TIME OF FIRST OBS", 59) != std::string::npos) + { + data.push_back(line_str); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_DeltaT_LS), 6); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.d_DeltaT_LSF), 6); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_WN_LSF), 6); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(utc_model.i_DN), 6); + line_aux += std::string(36, ' '); + line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); + data.push_back(line_aux); + } + else if (line_str.find("END OF HEADER", 59) != std::string::npos) + { + data.push_back(line_str); + no_more_finds = true; + } + else + { + data.push_back(line_str); + } + } + } + else + { + data.push_back(line_str); + } + } + + out.close(); + out.open(navfilename, std::ios::out | std::ios::trunc); + out.seekp(0); + for (int i = 0; i < (int) data.size() - 1; i++) + { + out << data[i] << std::endl; + } + out.close(); + out.open(navfilename, std::ios::out | std::ios::app); + out.seekp(pos); +} void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph, const double d_TOW_first_observation) { @@ -2084,7 +2166,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph out << line << std::endl; } - +//void Rinex_Printer::update_obs_header(std::fstream& out, const Galileo_Ephemeris& eph, const double d_TOW_first_observation) void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& eph, const double d_TOW_first_observation) { diff --git a/src/algorithms/PVT/libs/rinex_printer.h b/src/algorithms/PVT/libs/rinex_printer.h index 402285124..bebf3ae88 100644 --- a/src/algorithms/PVT/libs/rinex_printer.h +++ b/src/algorithms/PVT/libs/rinex_printer.h @@ -188,6 +188,8 @@ public: void update_nav_header(std::fstream& out, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& utc_model, const Galileo_Almanac& galileo_almanac); + void update_obs_header(std::fstream& out, const Gps_Utc_Model& utc_model); + std::map satelliteSystem; // observationType; // observationCode; // Date: Tue, 3 Mar 2015 19:56:40 +0100 Subject: [PATCH 08/12] Updating RINEX obs header when leap second is available (version 3.02) --- .../PVT/gnuradio_blocks/galileo_e1_pvt_cc.cc | 1 + .../PVT/gnuradio_blocks/hybrid_pvt_cc.cc | 1 + src/algorithms/PVT/libs/rinex_printer.cc | 81 ++++++++++++++++--- src/algorithms/PVT/libs/rinex_printer.h | 2 + 4 files changed, 75 insertions(+), 10 deletions(-) diff --git a/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.cc index 72a9eeab5..fac0e5231 100644 --- a/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.cc @@ -215,6 +215,7 @@ int galileo_e1_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_it if (!b_rinex_header_updated && (d_ls_pvt->galileo_utc_model.A0_6 != 0)) { rp->update_nav_header(rp->navGalFile, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac); + rp->update_obs_header(rp->obsFile, d_ls_pvt->galileo_utc_model); b_rinex_header_updated = true; } } diff --git a/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.cc index c8a220530..e7389b726 100644 --- a/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.cc @@ -253,6 +253,7 @@ int hybrid_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_items, } if (!b_rinex_header_updated && (d_ls_pvt->gps_utc_model.d_A0 != 0)) { + rp->update_obs_header(rp->obsFile, d_ls_pvt->gps_utc_model); rp->update_nav_header(rp->navMixFile, d_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac); b_rinex_header_updated = true; } diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 7b609312f..0391765c4 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -586,14 +586,14 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& gal } out.close(); - out.open(navfilename, std::ios::out | std::ios::trunc); + out.open(navGalfilename, std::ios::out | std::ios::trunc); out.seekp(0); for (int i = 0; i < (int) data.size() - 1; i++) { out << data[i] << std::endl; } out.close(); - out.open(navfilename, std::ios::out | std::ios::app); + out.open(navGalfilename, std::ios::out | std::ios::app); out.seekp(pos); std::cout << "The RINEX Navigation file header has been updated with UTC and IONO info." << std::endl; } @@ -753,7 +753,6 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Utc_Model& ut void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& iono, const Gps_Utc_Model& utc_model) { - std::string line; // -------- Line 1 @@ -1049,18 +1048,19 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_ion } out.close(); - out.open(navfilename, std::ios::out | std::ios::trunc); + out.open(navMixfilename, std::ios::out | std::ios::trunc); out.seekp(0); for (int i = 0; i < (int) data.size() - 1; i++) { out << data[i] << std::endl; } out.close(); - out.open(navfilename, std::ios::out | std::ios::app); + out.open(navMixfilename, std::ios::out | std::ios::app); out.seekp(pos); std::cout << "The RINEX Navigation file header has been updated with UTC and IONO info." << std::endl; } + void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono, const Gps_Utc_Model& gps_utc_model, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model, const Galileo_Almanac& galileo_almanac) { std::string line; @@ -1195,6 +1195,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono out << line << std::endl; } + void Rinex_Printer::rinex_sbs_header(std::fstream& out) { std::string line; @@ -1313,7 +1314,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond, gps_ephemeris_iter->second.d_Toe); + boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_GPS_time(gps_ephemeris_iter->second, gps_ephemeris_iter->second.d_Toc); std::string timestring = boost::posix_time::to_iso_string(p_utc_time); std::string month (timestring, 4, 2); std::string day (timestring, 6, 2); @@ -1645,7 +1646,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond, galileo_ephemeris_iter->second.TOW_5); + boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_Galileo_time(galileo_ephemeris_iter->second, galileo_ephemeris_iter->second.t0e_1); std::string timestring = boost::posix_time::to_iso_string(p_utc_time); std::string month (timestring, 4, 2); std::string day (timestring, 6, 2); @@ -1907,7 +1908,6 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Gps_Utc_Model& ut void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph, const double d_TOW_first_observation) { - std::string line; // -------- Line 1 @@ -2166,7 +2166,66 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph out << line << std::endl; } -//void Rinex_Printer::update_obs_header(std::fstream& out, const Galileo_Ephemeris& eph, const double d_TOW_first_observation) +void Rinex_Printer::update_obs_header(std::fstream& out, const Galileo_Utc_Model& galileo_utc_model) +{ + std::vector data; + std::string line_aux; + + long pos = out.tellp(); + out.seekp(0); + data.clear(); + + bool no_more_finds = false; + std::string line_str; + + while(!out.eof()) + { + std::getline(out, line_str); + + if(!no_more_finds) + { + line_aux.clear(); + + if (line_str.find("TIME OF FIRST OBS", 59) != std::string::npos) + { + data.push_back(line_str); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.Delta_tLS_6), 6); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.Delta_tLSF_6), 6); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.WN_LSF_6), 6); + line_aux += Rinex_Printer::rightJustify(boost::lexical_cast(galileo_utc_model.DN_6), 6); + line_aux += std::string(36, ' '); + line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); + data.push_back(line_aux); + } + else if (line_str.find("END OF HEADER", 59) != std::string::npos) + { + data.push_back(line_str); + no_more_finds = true; + } + else + { + data.push_back(line_str); + } + + } + else + { + data.push_back(line_str); + } + } + + out.close(); + out.open(navfilename, std::ios::out | std::ios::trunc); + out.seekp(0); + for (int i = 0; i < (int) data.size() - 1; i++) + { + out << data[i] << std::endl; + } + out.close(); + out.open(navfilename, std::ios::out | std::ios::app); + out.seekp(pos); +} + void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& eph, const double d_TOW_first_observation) { @@ -2372,6 +2431,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& galileo_eph, const double d_TOW_first_observation) { + if(galileo_eph.e_1){} // avoid warning, not needed std::string line; version = 3; @@ -2598,6 +2658,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps out << line << std::endl; } + void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, const double obs_time, const std::map& pseudoranges) { // RINEX observations timestamps are GPS timestamps. @@ -2841,7 +2902,6 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c } - void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& eph, double obs_time, const std::map& pseudoranges) { // RINEX observations timestamps are Galileo timestamps. @@ -2964,6 +3024,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& galileo_eph, double gps_obs_time, const std::map& pseudoranges) { + if(galileo_eph.e_1){} // avoid warning, not needed std::string line; boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, gps_obs_time); diff --git a/src/algorithms/PVT/libs/rinex_printer.h b/src/algorithms/PVT/libs/rinex_printer.h index bebf3ae88..585f6f463 100644 --- a/src/algorithms/PVT/libs/rinex_printer.h +++ b/src/algorithms/PVT/libs/rinex_printer.h @@ -190,6 +190,8 @@ public: void update_obs_header(std::fstream& out, const Gps_Utc_Model& utc_model); + void update_obs_header(std::fstream& out, const Galileo_Utc_Model& galileo_utc_model); + std::map satelliteSystem; // observationType; // observationCode; // Date: Tue, 3 Mar 2015 20:07:35 +0100 Subject: [PATCH 09/12] Fixing bug in updating RINEX obs headers --- src/algorithms/PVT/libs/rinex_printer.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 0391765c4..f80eba4df 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -1895,17 +1895,18 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Gps_Utc_Model& ut } out.close(); - out.open(navfilename, std::ios::out | std::ios::trunc); + out.open(obsfilename, std::ios::out | std::ios::trunc); out.seekp(0); for (int i = 0; i < (int) data.size() - 1; i++) { out << data[i] << std::endl; } out.close(); - out.open(navfilename, std::ios::out | std::ios::app); + out.open(obsfilename, std::ios::out | std::ios::app); out.seekp(pos); } + void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph, const double d_TOW_first_observation) { std::string line; @@ -2166,6 +2167,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph out << line << std::endl; } + void Rinex_Printer::update_obs_header(std::fstream& out, const Galileo_Utc_Model& galileo_utc_model) { std::vector data; @@ -2215,14 +2217,14 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Galileo_Utc_Model } out.close(); - out.open(navfilename, std::ios::out | std::ios::trunc); + out.open(obsfilename, std::ios::out | std::ios::trunc); out.seekp(0); for (int i = 0; i < (int) data.size() - 1; i++) { out << data[i] << std::endl; } out.close(); - out.open(navfilename, std::ios::out | std::ios::app); + out.open(obsfilename, std::ios::out | std::ios::app); out.seekp(pos); } From 42ea31b677c7b09588d10ab7a64c985e277dcef6 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 3 Mar 2015 20:40:14 +0100 Subject: [PATCH 10/12] Fixing utc and iono info reading when channel 0 is out of lock --- .../PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc index 6bc064349..4329d5c52 100644 --- a/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc @@ -168,14 +168,40 @@ int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_ite if (global_gps_utc_model_map.size() > 0) { - // UTC MODEL data is shared for all the GPS satellites. Read always at ID=0 - global_gps_utc_model_map.read(0, d_ls_pvt->gps_utc_model); + // UTC MODEL data is shared for all the GPS satellites. Read always at a locked channel + int i = 0; + while(true) + { + if (in[i][0].Flag_valid_pseudorange == true) + { + global_gps_utc_model_map.read(i, d_ls_pvt->gps_utc_model); + break; + } + i++; + if (i == d_nchannels - 1) + { + break; + } + } } if (global_gps_iono_map.size() > 0) { - // IONO data is shared for all the GPS satellites. Read always at ID=0 - global_gps_iono_map.read(0, d_ls_pvt->gps_iono); + // IONO data is shared for all the GPS satellites. Read always at a locked channel + int i = 0; + while(true) + { + if (in[i][0].Flag_valid_pseudorange == true) + { + global_gps_iono_map.read(i, d_ls_pvt->gps_iono); + break; + } + i++; + if (i == d_nchannels - 1) + { + break; + } + } } // update SBAS data collections From a4e48eac4d170a6dd7f4de56b499cd2641a08c96 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 3 Mar 2015 21:56:17 +0100 Subject: [PATCH 11/12] Removing warning --- src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc index 4329d5c52..0532ae1a8 100644 --- a/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc @@ -169,7 +169,7 @@ int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_ite if (global_gps_utc_model_map.size() > 0) { // UTC MODEL data is shared for all the GPS satellites. Read always at a locked channel - int i = 0; + signed int i = 0; while(true) { if (in[i][0].Flag_valid_pseudorange == true) @@ -188,7 +188,7 @@ int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_ite if (global_gps_iono_map.size() > 0) { // IONO data is shared for all the GPS satellites. Read always at a locked channel - int i = 0; + signed int i = 0; while(true) { if (in[i][0].Flag_valid_pseudorange == true) From e50188304344a33c765bebff6519332ca2f482f0 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 3 Mar 2015 22:48:03 +0100 Subject: [PATCH 12/12] Fix update of RINEX observation header --- src/algorithms/PVT/libs/rinex_printer.cc | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index f80eba4df..75020c30f 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -59,10 +59,10 @@ Rinex_Printer::Rinex_Printer() navMixfilename = Rinex_Printer::createFilename("RINEX_FILE_TYPE_MIXED_NAV"); Rinex_Printer::navFile.open(navfilename, std::ios::out | std::ios::in | std::ios::app); - Rinex_Printer::obsFile.open(obsfilename, std::ios::out | std::ios::app); + Rinex_Printer::obsFile.open(obsfilename, std::ios::out | std::ios::in | std::ios::app); Rinex_Printer::sbsFile.open(sbsfilename, std::ios::out | std::ios::app); - Rinex_Printer::navGalFile.open(navGalfilename, std::ios::out | std::ios::app); - Rinex_Printer::navMixFile.open(navMixfilename, std::ios::out | std::ios::app); + Rinex_Printer::navGalFile.open(navGalfilename, std::ios::out | std::ios::in | std::ios::app); + Rinex_Printer::navMixFile.open(navMixfilename, std::ios::out | std::ios::in | std::ios::app); // RINEX v3.02 codes satelliteSystem["GPS"] = "G"; @@ -1507,7 +1507,6 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map data; std::string line_aux; - long pos = out.tellp(); out.seekp(0); data.clear(); @@ -1902,8 +1900,8 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Gps_Utc_Model& ut out << data[i] << std::endl; } out.close(); - out.open(obsfilename, std::ios::out | std::ios::app); - out.seekp(pos); + out.open(obsfilename, std::ios::out | std::ios::in | std::ios::app); + out.seekp(0, std::ios_base::end); } @@ -2173,7 +2171,6 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Galileo_Utc_Model std::vector data; std::string line_aux; - long pos = out.tellp(); out.seekp(0); data.clear(); @@ -2224,8 +2221,8 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Galileo_Utc_Model out << data[i] << std::endl; } out.close(); - out.open(obsfilename, std::ios::out | std::ios::app); - out.seekp(pos); + out.open(obsfilename, std::ios::out | std::ios::in |std::ios::app); + out.seekp(0, std::ios_base::end); }