[hamradio-commits] [gnss-sdr] 133/303: Improve log of dual-band GPS observations in RINEX files

Carles Fernandez carles_fernandez-guest at moszumanska.debian.org
Mon Feb 13 22:35:54 UTC 2017


This is an automated email from the git hooks/post-receive script.

carles_fernandez-guest pushed a commit to branch master
in repository gnss-sdr.

commit ece71a53fb5dae7c8c3b2b7bccd21486b6daf020
Author: Carles Fernandez <carles.fernandez at gmail.com>
Date:   Tue Nov 1 13:01:35 2016 +0100

    Improve log of dual-band GPS observations in RINEX files
---
 src/algorithms/PVT/libs/rinex_printer.cc           | 177 ++++++++-------------
 .../pvt/rinex_printer_test.cc                      |  78 +++++++++
 2 files changed, 146 insertions(+), 109 deletions(-)

diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc
index 0a4a041..a3e2179 100644
--- a/src/algorithms/PVT/libs/rinex_printer.cc
+++ b/src/algorithms/PVT/libs/rinex_printer.cc
@@ -4064,142 +4064,101 @@ void  Rinex_Printer::log_rinex_obs(std::fstream & out, const Gps_Ephemeris & eph
                 }
         }
 
-    // Get common observables
-    std::vector< std::pair< Gnss_Synchro, Gnss_Synchro > >  common_pseudoranges;
-    std::vector< std::pair< Gnss_Synchro, Gnss_Synchro > >::const_iterator common_pseudoranges_iter;
-
+    std::multimap<unsigned int, Gnss_Synchro> total_map;
+    std::set<unsigned int> available_prns;
+    std::set<unsigned int>::iterator it;
     for(pseudoranges_iter = pseudorangesL1.begin();
             pseudoranges_iter != pseudorangesL1.end();
             pseudoranges_iter++)
         {
             unsigned int prn_ = pseudoranges_iter->second.PRN;
-            for(pseudoranges_iter2 = pseudorangesL2.begin();
-                    pseudoranges_iter2 != pseudorangesL2.end();
-                    pseudoranges_iter2++)
+            total_map.insert(std::pair<unsigned int, Gnss_Synchro>(prn_, pseudoranges_iter->second));
+            it = available_prns.find(prn_);
+            if(it == available_prns.end())
                 {
-                    if(pseudoranges_iter2->second.PRN == prn_)
-                        {
-                            std::pair<Gnss_Synchro, Gnss_Synchro> p;
-                            Gnss_Synchro pr1 = pseudoranges_iter->second;
-                            Gnss_Synchro pr2 = pseudoranges_iter2->second;
-                            p = std::make_pair(pr1, pr2);
-                            common_pseudoranges.push_back(p);
-                        }
+                    available_prns.insert(prn_);
                 }
         }
 
-    int numSatellitesObserved = common_pseudoranges.size();
-    line += Rinex_Printer::rightJustify(boost::lexical_cast<std::string>(numSatellitesObserved), 3);
+    for(pseudoranges_iter = pseudorangesL2.begin();
+            pseudoranges_iter != pseudorangesL2.end();
+            pseudoranges_iter++)
+        {
+            unsigned int prn_ = pseudoranges_iter->second.PRN;
+            total_map.insert(std::pair<unsigned int, Gnss_Synchro>(prn_, pseudoranges_iter->second));
+            it = available_prns.find(prn_);
+            if(it == available_prns.end())
+                {
+                    available_prns.insert(prn_);
+                }
+        }
 
+    int numSatellitesObserved = available_prns.size();
+    line += Rinex_Printer::rightJustify(boost::lexical_cast<std::string>(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(common_pseudoranges_iter = common_pseudoranges.begin();
-            common_pseudoranges_iter != common_pseudoranges.end();
-            common_pseudoranges_iter++)
+    std::string lineObs;
+    std::pair <std::multimap<unsigned int, Gnss_Synchro>::iterator, std::multimap<unsigned int, Gnss_Synchro>::iterator> ret;
+    for(it = available_prns.begin();
+            it != available_prns.end();
+            it++)
         {
-            std::string lineObs;
             lineObs.clear();
             lineObs += satelliteSystem["GPS"];
-            if (static_cast<int>(std::get<0>(*common_pseudoranges_iter).PRN) < 10) lineObs += std::string(1, '0');
-            lineObs += boost::lexical_cast<std::string>(static_cast<int>(std::get<0>(*common_pseudoranges_iter).PRN));
-            //lineObs += std::string(2, ' ');
-            // GPS L1 CA PSEUDORANGE
-            lineObs += Rinex_Printer::rightJustify(asString(std::get<0>(*common_pseudoranges_iter).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<short>(lli), 1);
-                }
-
-            // Signal Strength Indicator (SSI)
-            int ssi = Rinex_Printer::signalStrength(std::get<0>(*common_pseudoranges_iter).CN0_dB_hz);
-            lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString<int>(ssi), 1);
-
-            // GPS L1 CA PHASE
-            lineObs += Rinex_Printer::rightJustify(asString(std::get<0>(*common_pseudoranges_iter).Carrier_phase_rads / GPS_TWO_PI, 3), 14);
-            if (lli == 0)
-                {
-                    lineObs += std::string(1, ' ');
-                }
-            else
-                {
-                    lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString<short>(lli), 1);
-                }
-            lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString<int>(ssi), 1);
-
-            // GPS L1 CA DOPPLER
-            lineObs += Rinex_Printer::rightJustify(asString(std::get<0>(*common_pseudoranges_iter).Carrier_Doppler_hz, 3), 14);
-            if (lli == 0)
-                {
-                    lineObs += std::string(1, ' ');
-                }
-            else
+            if (static_cast<int>(*it) < 10) lineObs += std::string(1, '0');
+            lineObs += boost::lexical_cast<std::string>(static_cast<int>(*it));
+            ret = total_map.equal_range(*it);
+            for (std::multimap<unsigned int, Gnss_Synchro>::iterator iter = ret.first; iter != ret.second; ++iter)
                 {
-                    lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString<short>(lli), 1);
-                }
-
-            lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString<int>(ssi), 1);
-
-            //GPS L1 SIGNAL STRENGTH
-            lineObs += Rinex_Printer::rightJustify(asString(std::get<0>(*common_pseudoranges_iter).CN0_dB_hz, 3), 14);
+                    lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14);
 
-            // GPS L2 PSEUDORANGE
-            lineObs += Rinex_Printer::rightJustify(asString(std::get<1>(*common_pseudoranges_iter).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<short>(lli), 1);
+                        }
 
-            //Loss of lock indicator (LLI)
-            int lli_2 = 0; // Include in the observation!!
-            if (lli_2 == 0)
-                {
-                    lineObs += std::string(1, ' ');
-                }
-            else
-                {
-                    lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString<short>(lli_2), 1);
-                }
+                    // Signal Strength Indicator (SSI)
+                    int ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz);
+                    lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString<int>(ssi), 1);
 
-            // Signal Strength Indicator (SSI)
-            int ssi_2 = Rinex_Printer::signalStrength(std::get<1>(*common_pseudoranges_iter).CN0_dB_hz);
-            lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString<int>(ssi_2), 1);
+                    // GPS CARRIER PHASE
+                    lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (GALILEO_TWO_PI), 3), 14);
+                    if (lli == 0)
+                        {
+                            lineObs += std::string(1, ' ');
+                        }
+                    else
+                        {
+                            lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString<short>(lli), 1);
+                        }
+                    lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString<int>(ssi), 1);
 
-            // GPS L2 PHASE
-            lineObs += Rinex_Printer::rightJustify(asString(std::get<0>(*common_pseudoranges_iter).Carrier_phase_rads / GPS_TWO_PI, 3), 14);
-            if (lli_2 == 0)
-                {
-                    lineObs += std::string(1, ' ');
-                }
-            else
-                {
-                    lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString<short>(lli_2), 1);
-                }
-            lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString<int>(ssi_2), 1);
+                    // GPS  DOPPLER
+                    lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14);
+                    if (lli == 0)
+                        {
+                            lineObs += std::string(1, ' ');
+                        }
+                    else
+                        {
+                            lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString<short>(lli), 1);
+                        }
+                    lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString<int>(ssi), 1);
 
-            // GPS L2 DOPPLER
-            lineObs += Rinex_Printer::rightJustify(asString(std::get<1>(*common_pseudoranges_iter).Carrier_Doppler_hz, 3), 14);
-            if (lli_2 == 0)
-                {
-                    lineObs += std::string(1, ' ');
-                }
-            else
-                {
-                    lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString<short>(lli_2), 1);
+                    // GPS SIGNAL STRENGTH
+                    lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14);
                 }
 
-            lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString<int>(ssi_2), 1);
-
-            //GPS L2 SIGNAL STRENGTH
-            lineObs += Rinex_Printer::rightJustify(asString(std::get<1>(*common_pseudoranges_iter).CN0_dB_hz, 3), 14);
-
             if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' ');
             out << lineObs << std::endl;
         }
diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc
index 8e7e71c..e03d382 100644
--- a/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc
+++ b/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc
@@ -200,6 +200,84 @@ TEST(Rinex_Printer_Test, GalileoObsLog)
     if(remove(rp->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file";
 }
 
+
+TEST(Rinex_Printer_Test, GpsObsLogDualBand)
+{
+    std::string line_aux;
+    std::string line_str;
+    bool no_more_finds = false;
+    const Gps_Ephemeris eph_gps = Gps_Ephemeris();
+    const Gps_CNAV_Ephemeris eph_cnav = Gps_CNAV_Ephemeris();
+
+    std::shared_ptr<Rinex_Printer> rp;
+    rp = std::make_shared<Rinex_Printer>();
+    rp->rinex_obs_header(rp->obsFile, eph_gps, eph_cnav, 0.0);
+
+    std::map<int,Gnss_Synchro> gnss_pseudoranges_map;
+
+    Gnss_Synchro gs1 = Gnss_Synchro();
+    Gnss_Synchro gs2 = Gnss_Synchro();
+    Gnss_Synchro gs3 = Gnss_Synchro();
+    Gnss_Synchro gs4 = Gnss_Synchro();
+
+    std::string sys = "G";
+    gs1.System = *sys.c_str();
+    gs2.System = *sys.c_str();
+    gs3.System = *sys.c_str();
+    gs4.System = *sys.c_str();
+
+    std::string sig = "1C";
+    std::memcpy((void*)gs1.Signal, sig.c_str(), 3);
+    std::memcpy((void*)gs2.Signal, sig.c_str(), 3);
+
+    sig = "2S";
+    std::memcpy((void*)gs3.Signal, sig.c_str(), 3);
+    std::memcpy((void*)gs4.Signal, sig.c_str(), 3);
+
+    gs1.PRN = 3;
+    gs2.PRN = 8;
+    gs3.PRN = 7;
+    gs4.PRN = 8;
+
+    gs2.Pseudorange_m = 22000002.1;
+    gs2.Carrier_phase_rads = 45.4;
+    gs2.Carrier_Doppler_hz = 321;
+    gs2.CN0_dB_hz = 39;
+
+    gs4.Pseudorange_m = 22000000;
+    gs4.Carrier_phase_rads = 23.4;
+    gs4.Carrier_Doppler_hz = 1534;
+    gs4.CN0_dB_hz = 42;
+
+    gnss_pseudoranges_map.insert( std::pair<int, Gnss_Synchro>(1,gs1) );
+    gnss_pseudoranges_map.insert( std::pair<int, Gnss_Synchro>(2,gs2) );
+    gnss_pseudoranges_map.insert( std::pair<int, Gnss_Synchro>(3,gs3) );
+    gnss_pseudoranges_map.insert( std::pair<int, Gnss_Synchro>(4,gs4) );
+
+    rp->log_rinex_obs(rp->obsFile, eph_gps, eph_cnav, 0.0, gnss_pseudoranges_map);
+    rp->obsFile.seekp(0);
+
+    while(!rp->obsFile.eof())
+        {
+            std::getline(rp->obsFile, line_str);
+            if(!no_more_finds)
+                {
+                    if (line_str.find("G08", 0) != std::string::npos)
+                        {
+                            no_more_finds = true;
+                            line_aux = std::string(line_str);
+                        }
+                }
+        }
+
+    std::string expected_str("G08  22000002.100 6         7.226 6       321.000 6        39.000  22000000.000 7         3.724 7      1534.000 7        42.000");
+    EXPECT_EQ(0, expected_str.compare(line_aux));
+
+    if(remove(rp->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file";
+
+}
+
+
 TEST(Rinex_Printer_Test, GalileoObsLogDualBand)
 {
     std::string line_aux;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/gnss-sdr.git



More information about the pkg-hamradio-commits mailing list