OrdRegressionChecks_T.cpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
39 #include <iostream>
40 #include <string>
41 
42 #include "FreqConsts.hpp"
43 #include "GNSSconstants.hpp"
44 #include "TestUtil.hpp"
45 #include "ord.hpp"
46 #include "EphemerisRange.hpp"
47 #include "NavLibrary.hpp"
48 #include "GPSLNavData.hpp"
49 #include "ObsID.hpp"
50 #include "RinexNavDataFactory.hpp"
51 
52 using namespace gnsstk::ord;
53 
55 {
56 public:
58  unsigned testIonoFreeRange();
59  unsigned testRawRange1();
60  unsigned testRawRange2();
61  unsigned testRawRange3();
62  unsigned testRawRange4();
63 
65 };
66 
69  : navLib()
70 {
72  ndfp(std::make_shared<gnsstk::RinexNavDataFactory>());
73 
74  std::string fname = gnsstk::getPathData() + gnsstk::getFileSep() +
75  "arlm2000.15n";
76 
77  navLib.addFactory(ndfp);
78 
80  dynamic_cast<gnsstk::RinexNavDataFactory*>(ndfp.get());
81 
82  GNSSTK_ASSERT(rndfp->addDataSource(fname));
83 }
84 
85 
88 {
89  TUDEF("ORD", "IonosphereFreeRange");
90 
91  std::vector<double> frequencies;
92  frequencies.push_back(gnsstk::FREQ_GPS_L1);
93  frequencies.push_back(gnsstk::FREQ_GPS_L2);
94 
95  std::vector<double> pseudoranges;
96  pseudoranges.push_back(5000.0);
97  pseudoranges.push_back(6000.0);
98 
99  for (int i = 0; i < pseudoranges.size(); i++) {
100  std::cout << "PR[" << i << "] is: " << pseudoranges[i] << std::endl;
101  }
102 
103  double range = IonosphereFreeRange(frequencies, pseudoranges);
104 
105  // Iononsphere Corrected Pseudorange: Old calculation in ObsRngDev.cpp
106  // for dual frequency see IS-GPS-200, section 20.3.3.3.3.3
107  double icpr = (pseudoranges[1] - gnsstk::GAMMA_GPS * pseudoranges[0])
108  / (1 - gnsstk::GAMMA_GPS);
109 
110  // Compare the new calculation to the old, for our contrived variables.
111  double delta = fabs(range-icpr);
112  std::cout << "difference of: " << delta << std::endl;
113  // @todo Is this an acceptable difference?
114  TUASSERTFEPS(icpr, range, 1e-5);
115  TURETURN();
116 }
117 
120 {
121  TUDEF("ORD", "RawRange1");
122 
123  gnsstk::Position rxLocation(10, 10, 0);
126  time(gnsstk::CivilTime(2015,7,19,2,0,0.0,gnsstk::TimeSystem::GPS));
127  gnsstk::Xvt xvt;
128 
129  double resultRange = RawRange1(rxLocation, satId, time, navLib, xvt);
130  resultRange += SvClockBiasCorrection(xvt);
131  resultRange += SvRelativityCorrection(xvt);
132 
134 
135  double originalRange =
136  cer.ComputeAtReceiveTime(time, rxLocation, satId, navLib);
137 
138  // Compare the new calculation to the old, for our contrived variables.
139  TUASSERTFE(originalRange, resultRange);
140  TURETURN();
141 }
142 
145 {
146  TUDEF("ORD", "RawRange2");
147 
148  gnsstk::Position rxLocation(10, 10, 0);
151  time(gnsstk::CivilTime(2015,7,19,2,0,0.0,gnsstk::TimeSystem::GPS));
152  gnsstk::Xvt xvt;
153  double pseduorange = 999999999;
154 
155  double resultRange =
156  RawRange2(pseduorange, rxLocation, satId, time, navLib, xvt);
157  resultRange += SvClockBiasCorrection(xvt);
158  resultRange += SvRelativityCorrection(xvt);
159 
161  double originalRange =
162  cer.ComputeAtTransmitTime(time, pseduorange, rxLocation, satId, navLib);
163 
164  // Compare the new calculation to the old, for our contrived variables.
165  TUASSERTFESMRT(originalRange, resultRange);
166  TURETURN();
167 }
168 
171 {
172  TUDEF("ORD", "RawRange3");
173 
174  gnsstk::Position rxLocation(10, 10, 0);
177  time(gnsstk::CivilTime(2015,7,19,2,0,0.0,gnsstk::TimeSystem::GPS));
178  gnsstk::Xvt xvt;
179  double pseduorange = 999999999;
180 
181  double resultRange =
182  RawRange3(pseduorange, rxLocation, satId, time, navLib, xvt);
183  resultRange += SvClockBiasCorrection(xvt);
184  resultRange += SvRelativityCorrection(xvt);
185 
187 
188  double originalRange =
189  cer.ComputeAtTransmitSvTime(time, pseduorange, rxLocation, satId, navLib);
190 
191  // Compare the new calculation to the old, for our contrived variables.
192  TUASSERTFESMRT(originalRange, resultRange);
193  TURETURN();
194 }
195 
198 {
199  TUDEF("ORD", "RawRange4");
200 
201  gnsstk::Position rxLocation(10, 10, 0);
204  time(gnsstk::CivilTime(2015,7,19,2,0,0.0,gnsstk::TimeSystem::GPS));
205  gnsstk::Xvt xvt;
206 
207  double resultRange = RawRange4(rxLocation, satId, time, navLib, xvt);
208  resultRange += SvClockBiasCorrection(xvt);
209  resultRange += SvRelativityCorrection(xvt);
210 
212  double originalRange =
213  cer.ComputeAtTransmitTime(time, rxLocation, satId, navLib);
214 
215  // Compare the new calculation to the old, for our contrived variables.
216  TUASSERTFESMRT(originalRange, resultRange);
217  TURETURN();
218 }
219 
220 int main()
221 {
222  OrdRegressionTests_T testClass;
223  unsigned errorTotal = 0;
224 
225  errorTotal += testClass.testIonoFreeRange();
226  errorTotal += testClass.testRawRange1();
227  errorTotal += testClass.testRawRange2();
228  errorTotal += testClass.testRawRange3();
229  errorTotal += testClass.testRawRange4();
230 
231  std::cout << "Total Failures for " << __FILE__ << ": " << errorTotal
232  << std::endl;
233 
234  return errorTotal;
235 }
FreqConsts.hpp
gnsstk::ord::SvClockBiasCorrection
double SvClockBiasCorrection(const gnsstk::Xvt &svXvt)
Definition: ord.cpp:204
gnsstk::FREQ_GPS_L2
const double FREQ_GPS_L2
GPS L2 carrier frequency in Hz.
Definition: FreqConsts.hpp:60
gnsstk::ord::RawRange1
double RawRange1(const Position &rxLoc, const SatID &satId, const CommonTime &timeReceived, NavLibrary &ephemeris, Xvt &svXvt)
Definition: ord.cpp:117
ord.hpp
gnsstk::ord
Definition: ord.cpp:58
gnsstk::SatID
Definition: SatID.hpp:89
OrdRegressionTests_T::navLib
gnsstk::NavLibrary navLib
Definition: OrdRegressionChecks_T.cpp:64
OrdRegressionTests_T::testRawRange1
unsigned testRawRange1()
Definition: OrdRegressionChecks_T.cpp:119
GNSSconstants.hpp
gnsstk::ord::RawRange4
double RawRange4(const gnsstk::Position &rxLoc, const gnsstk::SatID &satId, const gnsstk::CommonTime &time, NavLibrary &ephemeris, gnsstk::Xvt &svXvt)
Definition: ord.cpp:165
gnsstk::NavDataFactoryPtr
std::shared_ptr< NavDataFactory > NavDataFactoryPtr
Managed pointer to NavDataFactory.
Definition: NavDataFactory.hpp:398
OrdRegressionTests_T::testRawRange2
unsigned testRawRange2()
Definition: OrdRegressionChecks_T.cpp:144
gnsstk::SatelliteSystem::GPS
@ GPS
EphemerisRange.hpp
gnsstk::NavDataFactoryWithStoreFile::addDataSource
bool addDataSource(const std::string &source) override
Definition: NavDataFactoryWithStoreFile.hpp:64
TestUtil.hpp
NavLibrary.hpp
TURETURN
#define TURETURN()
Definition: TestUtil.hpp:232
gnsstk::NavLibrary
Definition: NavLibrary.hpp:944
example4.time
time
Definition: example4.py:103
gnsstk::FREQ_GPS_L1
const double FREQ_GPS_L1
GPS L1 carrier frequency in Hz.
Definition: FreqConsts.hpp:56
gnsstk::ord::SvRelativityCorrection
double SvRelativityCorrection(gnsstk::Xvt &svXvt)
Definition: ord.cpp:210
TUASSERTFESMRT
#define TUASSERTFESMRT(EXP, GOT)
Definition: TestUtil.hpp:150
OrdRegressionTests_T::OrdRegressionTests_T
OrdRegressionTests_T()
Definition: OrdRegressionChecks_T.cpp:68
gnsstk::CommonTime
Definition: CommonTime.hpp:84
main
int main()
Definition: OrdRegressionChecks_T.cpp:220
TUASSERTFEPS
#define TUASSERTFEPS(EXP, GOT, EPS)
Definition: TestUtil.hpp:126
OrdRegressionTests_T::testRawRange3
unsigned testRawRange3()
Definition: OrdRegressionChecks_T.cpp:170
gnsstk::Xvt
Definition: Xvt.hpp:60
gnsstk::CorrectedEphemerisRange::ComputeAtTransmitTime
double ComputeAtTransmitTime(const CommonTime &trNom, const double &pr, const Position &rx, const SatID sat, NavLibrary &navLib, NavSearchOrder order=NavSearchOrder::User, SVHealth xmitHealth=SVHealth::Any, NavValidityType valid=NavValidityType::ValidOnly, const EllipsoidModel &ellipsoid=GPSEllipsoid())
Definition: EphemerisRange.cpp:102
TUDEF
#define TUDEF(CLASS, METHOD)
Definition: TestUtil.hpp:56
gnsstk::ord::RawRange3
double RawRange3(double pseudorange, const gnsstk::Position &rxLoc, const gnsstk::SatID &satId, const gnsstk::CommonTime &time, NavLibrary &ephemeris, gnsstk::Xvt &svXvt)
Definition: ord.cpp:151
GPSLNavData.hpp
gnsstk::CivilTime
Definition: CivilTime.hpp:55
GNSSTK_ASSERT
#define GNSSTK_ASSERT(CONDITION)
Provide an "ASSERT" type macro.
Definition: Exception.hpp:373
ObsID.hpp
gnsstk::CorrectedEphemerisRange::ComputeAtTransmitSvTime
double ComputeAtTransmitSvTime(const CommonTime &ttNom, const double &pr, const Position &rx, const SatID sat, NavLibrary &navLib, NavSearchOrder order=NavSearchOrder::User, SVHealth xmitHealth=SVHealth::Any, NavValidityType valid=NavValidityType::ValidOnly, const EllipsoidModel &ellipsoid=GPSEllipsoid())
Definition: EphemerisRange.cpp:165
gnsstk::GAMMA_GPS
const double GAMMA_GPS
Definition: GNSSconstants.hpp:104
gnsstk::TimeSystem::GPS
@ GPS
GPS system time.
gnsstk::ord::RawRange2
double RawRange2(double pseudorange, const Position &rxLoc, const SatID &satId, const CommonTime &time, NavLibrary &ephemeris, Xvt &svXvt)
Definition: ord.cpp:136
gnsstk::NavLibrary::addFactory
void addFactory(NavDataFactoryPtr &fact)
Definition: NavLibrary.cpp:470
gnsstk::RinexNavDataFactory
Definition: RinexNavDataFactory.hpp:57
gnsstk::range
double range(const Position &A, const Position &B)
Definition: Position.cpp:1273
TUASSERTFE
#define TUASSERTFE(EXP, GOT)
Definition: TestUtil.hpp:103
gnsstk::Position
Definition: Position.hpp:136
gnsstk::CorrectedEphemerisRange::ComputeAtReceiveTime
double ComputeAtReceiveTime(const CommonTime &trNom, const Position &rx, const SatID sat, NavLibrary &navLib, NavSearchOrder order=NavSearchOrder::User, SVHealth xmitHealth=SVHealth::Any, NavValidityType valid=NavValidityType::ValidOnly, const EllipsoidModel &ellipsoid=GPSEllipsoid())
Definition: EphemerisRange.cpp:65
gnsstk::CorrectedEphemerisRange
Definition: EphemerisRange.hpp:84
OrdRegressionTests_T::testRawRange4
unsigned testRawRange4()
Definition: OrdRegressionChecks_T.cpp:197
OrdRegressionTests_T::testIonoFreeRange
unsigned testIonoFreeRange()
Definition: OrdRegressionChecks_T.cpp:87
gnsstk::ord::IonosphereFreeRange
double IonosphereFreeRange(const std::vector< double > &frequencies, const std::vector< double > &pseudoranges)
Definition: ord.cpp:60
RinexNavDataFactory.hpp
OrdRegressionTests_T
Definition: OrdRegressionChecks_T.cpp:54


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:40