From 12f2b73d4464cf3d50a7d8d171c0905481b9be15 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 1 Sep 2014 13:03:24 +0200 Subject: [PATCH] Adding RINEX observation file for Galileo --- .../PVT/gnuradio_blocks/galileo_e1_pvt_cc.cc | 12 +- src/algorithms/PVT/libs/rinex_printer.cc | 108 ++++++++++++++++-- src/algorithms/PVT/libs/rinex_printer.h | 2 + 3 files changed, 106 insertions(+), 16 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 1753e82e9..ee4bb40c7 100644 --- a/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.cc @@ -199,12 +199,12 @@ int galileo_e1_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_it rp->log_rinex_nav(rp->navGalFile, d_ls_pvt->galileo_ephemeris_map); d_last_sample_nav_output = d_sample_counter; } - // std::map::iterator galileo_ephemeris_iter; - // galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.begin(); - // if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) - // { - // rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_pseudoranges_map); - // } + std::map::iterator galileo_ephemeris_iter; + galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.begin(); + if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) + { + rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, d_rx_time, gnss_pseudoranges_map); + } } } } diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 97591bc80..ab4830b16 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -341,7 +341,6 @@ std::string Rinex_Printer::getLocalTime() if (version == 3) { - //line += std::string(1, ' '); line += boost::gregorian::to_iso_string(today); line += std::string(1, ' '); line += strmHour.str(); @@ -1767,15 +1766,7 @@ void Rinex_Printer::log_rinex_obs(std::ofstream& out, Gps_Ephemeris eph, double { lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); } - int ssi=signalStrength(54.0); // TODO: include estimated signal strength - if (ssi == 0) - { - lineObs += std::string(1, ' '); - } - else - { - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); - } + lineObs += Rinex_Printer::rightJustify(asString(pseudoranges_iter->second.CN0_dB_hz, 3), 14); if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); out << lineObs << std::endl; } @@ -1784,6 +1775,103 @@ void Rinex_Printer::log_rinex_obs(std::ofstream& out, Gps_Ephemeris eph, double +void Rinex_Printer::log_rinex_obs(std::ofstream& out, Galileo_Ephemeris eph, double obs_time, std::map pseudoranges) +{ + // RINEX observations timestamps are Galileo timestamps. + + std::string line; + + boost::posix_time::ptime p_galileo_time = Rinex_Printer::compute_Galileo_time(eph, obs_time); + std::string timestring = boost::posix_time::to_iso_string(p_galileo_time); + //double utc_t = nav_msg.utc_time(nav_msg.sv_clock_correction(obs_time)); + //double gps_t = eph.sv_clock_correction(obs_time); + double galileo_t = obs_time; + + std::string month (timestring, 4, 2); + std::string day (timestring, 6, 2); + std::string hour (timestring, 9, 2); + std::string minutes (timestring, 11, 2); + + + std::string year (timestring, 0, 4); + line += std::string(1, '>'); + line += std::string(1, ' '); + line += year; + line += std::string(1, ' '); + line += month; + line += std::string(1, ' '); + line += day; + line += std::string(1, ' '); + line += hour; + line += std::string(1, ' '); + line += minutes; + + line += std::string(1, ' '); + double seconds=fmod(galileo_t, 60); + // Add extra 0 if seconds are < 10 + if (seconds<10) + { + line +=std::string(1, '0'); + } + line += Rinex_Printer::asString(seconds, 7); + line += std::string(2, ' '); + // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event + line += std::string(1, '0'); + + //Number of satellites observed in current epoch + int numSatellitesObserved = 0; + std::map::iterator pseudoranges_iter; + for(pseudoranges_iter = pseudoranges.begin(); + pseudoranges_iter != pseudoranges.end(); + pseudoranges_iter++) + { + numSatellitesObserved++; + } + line += Rinex_Printer::rightJustify(boost::lexical_cast(numSatellitesObserved), 3); + + + // Receiver clock offset (optional) + //line += rightJustify(asString(clockOffset, 12), 15); + + line += std::string(80 - line.size(), ' '); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + for(pseudoranges_iter = pseudoranges.begin(); + pseudoranges_iter != pseudoranges.end(); + pseudoranges_iter++) + { + std::string lineObs; + lineObs.clear(); + lineObs += satelliteSystem["Galileo"]; + if ((int)pseudoranges_iter->first < 10) lineObs += std::string(1, '0'); + lineObs += boost::lexical_cast((int)pseudoranges_iter->first); + //lineObs += std::string(2, ' '); + lineObs += Rinex_Printer::rightJustify(asString(pseudoranges_iter->second.Pseudorange_m, 3), 14); + + //Loss of lock indicator (LLI) + int lli = 0; // Include in the observation!! + if (lli == 0) + { + lineObs += std::string(1, ' '); + } + else + { + lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + } + // Galileo E1B PHASE + lineObs += Rinex_Printer::rightJustify(asString(pseudoranges_iter->second.Carrier_phase_rads/(2*GALILEO_PI), 3), 14); + // Galileo E1B DOPPLER + lineObs += Rinex_Printer::rightJustify(asString(pseudoranges_iter->second.Carrier_Doppler_hz, 3), 14); + // Galileo E1B SIGNAL STRENGTH + lineObs += Rinex_Printer::rightJustify(asString(pseudoranges_iter->second.CN0_dB_hz, 3), 14); + if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + out << lineObs << std::endl; + } + // } +} + + // represents GPS time (week, TOW) in the date time format of the Gregorian calendar. // -> Leap years are considered, but leap seconds not. void Rinex_Printer::to_date_time(int gps_week, int gps_tow, int &year, int &month, int &day, int &hour, int &minute, int &second) diff --git a/src/algorithms/PVT/libs/rinex_printer.h b/src/algorithms/PVT/libs/rinex_printer.h index ce1a77d3a..f377b5a8d 100644 --- a/src/algorithms/PVT/libs/rinex_printer.h +++ b/src/algorithms/PVT/libs/rinex_printer.h @@ -130,6 +130,8 @@ public: */ void log_rinex_obs(std::ofstream& out, Gps_Ephemeris eph, double obs_time, std::map pseudoranges); + void log_rinex_obs(std::ofstream& out, Galileo_Ephemeris eph, double obs_time, std::map pseudoranges); + /*! * \brief Represents GPS time in the date time format. Leap years are considered, but leap seconds are not. */