Xvt_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 "Xvt.hpp"
40 #include "Triple.hpp"
41 #include "GPSEllipsoid.hpp"
42 
43 #include "TestUtil.hpp"
44 #include <iostream>
45 #include <string>
46 #include <sstream>
47 
48 using namespace std;
49 using namespace gnsstk;
50 
51 class Xvt_T
52 {
53 public:
56  : eps(1E-12)
57  {}
60  {}
61 
62  /*Tests the get methods and constructor of Xvt */
63  unsigned getTest()
64  {
65  TUDEF("Xvt","Get");
66 
67  //Add in blank initialization check here
68 
69  Triple pos(1,2,3);
70  Triple vel(4,5,6);
71  double clockBias = 7, clockDrift = 8, relativityCorrection = 9;
72  Xvt compare;
73 
74  compare.x = pos;
75  compare.v = vel;
76  compare.clkbias = clockBias;
77  compare.clkdrift = clockDrift;
78  compare.relcorr = relativityCorrection;
79 
80  TUCSM("getPos");
81  TUASSERTE(Triple, pos, compare.getPos());
82  TUCSM("getVel");
83  TUASSERTE(Triple, vel, compare.getVel());
84  TUCSM("getClockBias");
85  TUASSERTFE(clockBias, compare.getClockBias());
86  TUCSM("getClockDrift");
87  TUASSERTFE(clockDrift, compare.getClockDrift());
88  TUCSM("getRelativityCorr");
89  TUASSERTFE(relativityCorrection, compare.getRelativityCorr());
90  TUCSM("Xvt()");
92  compare.health);
93 
94  TURETURN();
95  }
96 
97  /* Ensures the computeRelativityCorrection method is accurate */
99  {
100  TUDEF("Xvt","computeRelativityCorrection");
101 
102  Triple pos( 1234567000, 887654, 321 );
103  Triple vel(4321, 1234, 1342);
104  Xvt compare;
105  double relcorr = -0.00011873444357376972;
106  compare.x = pos;
107  compare.v = vel;
108 
109  TUASSERTFEPS(relcorr, compare.computeRelativityCorrection(), eps);
110 
111  pos[0] = -1234567000;
112  pos[1] = 887654;
113  pos[2] = -100000;
114  vel[0] = 3000;
115  vel[1] = -500;
116  vel[2] = -20;
117  relcorr =8.242829448184317e-05;
118  compare.x = pos;
119  compare.v = vel;
120 
121  TUASSERTFEPS(relcorr, compare.computeRelativityCorrection(), eps);
122 
123  pos[0] = 0;
124  pos[1] = 0;
125  pos[2] = 0;
126  vel[0] = 0;
127  vel[1] = 0;
128  vel[2] = 0;
129  relcorr =0;
130  compare.x = pos;
131  compare.v = vel;
132 
133  TUASSERTFEPS(relcorr, compare.computeRelativityCorrection(), eps);
134 
135  TURETURN();
136  }
137 
138  /* Ensures the preciseRho method is accurate */
139  unsigned preciseRhoTest()
140  {
141  TUDEF("Xvt","preciseRho");
142  std::string failMesg;
143 
144  Triple rxPos(-7.0e5, -5.0e6, 3.0e6);
145  Xvt xvt;
146  xvt.x = Triple(-9e5, -2e7, 9e6);
147  xvt.v = Triple(6e2, 1e3, 2e4);
148  xvt.clkbias = -0.3;
149  xvt.clkdrift = 0;
150  xvt.relcorr = -3.5e-6;
151 
152  double rho;
153  GPSEllipsoid ellipsoid;
154  rho = xvt.preciseRho(rxPos, ellipsoid);
155  TUASSERTFESMRT(106095516.70592290163, rho);
156  rho = xvt.preciseRho(rxPos, ellipsoid, 10);
157  TUASSERTFESMRT(106095506.70592290163, rho);
158 
159  TURETURN();
160  }
161 
162  /* Tests to see if the stream output operator << is functioning properly*/
163  unsigned operatorTest()
164  {
165  TUDEF("Xvt","operator<<");
166 
167  Triple pos(1,2,3);
168  Triple vel(4,5,6);
169  double clockBias = 7, clockDrift = 8, relativityCorrection = 9;
170  Xvt output;
171  output.x = pos;
172  output.v = vel;
173  output.clkbias = clockBias;
174  output.clkdrift = clockDrift;
175  output.relcorr = relativityCorrection;
176 
177  std::stringstream streamOutput;
178  std::stringstream streamCompare;
179  std::string stringOutput;
180  std::string stringCompare;
181 
182  try
183  {
184  // Creates a string with the contents of output via the
185  // stream output operator
186  streamOutput << output;
187  stringOutput = streamOutput.str();
188 
189  // Creates a string of what the output stream should be
190  streamCompare << "x:" << output.x
191  << ", v:" << output.v
192  << ", clk bias:" << output.clkbias
193  << ", clk drift:" << output.clkdrift
194  << ", relcorr:" << output.relcorr
195  << ", health:" << output.health
196  << ", frame:"
197  << gnsstk::StringUtils::asString(output.frame);
198  stringCompare = streamCompare.str();
199  TUASSERTE(std::string, stringCompare, stringOutput);
200  }
201  catch (...)
202  {
203  TUFAIL("Unexpected exception");
204  }
205  TURETURN();
206  }
207 
209  {
210  TUDEF("Xvt::HealthStatus", "operator<<");
211  for (unsigned i = static_cast<unsigned>(Xvt::HealthStatus::MinValue);
212  i <= static_cast<unsigned>(Xvt::HealthStatus::MaxValue);
213  i++)
214  {
215  ostringstream s;
216  s << static_cast<Xvt::HealthStatus>(i);
217  string str(s.str());
218  TUASSERT(!str.empty());
219  TUASSERT(str != "???");
220  }
221  unsigned i = static_cast<unsigned>(Xvt::HealthStatus::MaxValue) + 1;
222  ostringstream s;
223  s << static_cast<Xvt::HealthStatus>(i);
224  string str(s.str());
225  TUASSERT(!str.empty());
226  TUASSERTE(string, "???", str);
227  TURETURN();
228  }
229 
230 private:
231  double eps;
232 };
233 
234 
235 int main() //Main function to initialize and run all tests above
236 {
237  unsigned errorTotal = 0;
238  Xvt_T testClass;
239 
240  errorTotal += testClass.getTest();
241  errorTotal += testClass.preciseRhoTest();
242  errorTotal += testClass.computeRelativityCorrectionTest();
243  errorTotal += testClass.operatorTest();
244  errorTotal += testClass.healthStatusStreamTest();
245 
246  cout << "Total Failures for " << __FILE__ << ": " << errorTotal << endl;
247 
248  return errorTotal; //Return the total number of errors
249 }
250 
TUCSM
#define TUCSM(METHOD)
Definition: TestUtil.hpp:59
Xvt.hpp
Xvt_T::eps
double eps
Definition: Xvt_T.cpp:231
Xvt_T::healthStatusStreamTest
unsigned healthStatusStreamTest()
Definition: Xvt_T.cpp:208
TUASSERTE
#define TUASSERTE(TYPE, EXP, GOT)
Definition: TestUtil.hpp:81
TUFAIL
#define TUFAIL(MSG)
Definition: TestUtil.hpp:228
gnsstk::Xvt::getRelativityCorr
double getRelativityCorr() noexcept
access the relativity correction, in seconds
Definition: Xvt.hpp:128
gnsstk::StringUtils::asString
std::string asString(IonexStoreStrategy e)
Convert a IonexStoreStrategy to a whitespace-free string name.
Definition: IonexStoreStrategy.cpp:46
main
int main()
Definition: Xvt_T.cpp:235
gnsstk::GPSEllipsoid
Definition: GPSEllipsoid.hpp:67
gnsstk::Xvt::getClockBias
double getClockBias() noexcept
access the clock bias, in second
Definition: Xvt.hpp:120
gnsstk::Xvt::v
Triple v
satellite velocity in ECEF Cartesian, meters/second
Definition: Xvt.hpp:152
gnsstk::Triple
Definition: Triple.hpp:68
Xvt_T::getTest
unsigned getTest()
Definition: Xvt_T.cpp:63
gnsstk::Xvt::getVel
Triple getVel() noexcept
access the velocity in m/s
Definition: Xvt.hpp:116
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::Xvt::relcorr
double relcorr
relativity correction (standard 2R.V/c^2 term), seconds
Definition: Xvt.hpp:155
Xvt_T::Xvt_T
Xvt_T()
Default Constructor, set the precision value.
Definition: Xvt_T.cpp:55
gnsstk::Xvt::Uninitialized
@ Uninitialized
Health status has not been set.
Definition: Xvt.hpp:90
gnsstk::Xvt::x
Triple x
Sat position ECEF Cartesian (X,Y,Z) meters.
Definition: Xvt.hpp:151
TUASSERT
#define TUASSERT(EXPR)
Definition: TestUtil.hpp:63
gnsstk::Xvt::preciseRho
double preciseRho(const Triple &rxPos, const EllipsoidModel &ellipsoid, double correction=0) const noexcept
Definition: Xvt.cpp:113
TestUtil.hpp
TURETURN
#define TURETURN()
Definition: TestUtil.hpp:232
Xvt_T::operatorTest
unsigned operatorTest()
Definition: Xvt_T.cpp:163
Xvt_T::computeRelativityCorrectionTest
unsigned computeRelativityCorrectionTest()
Definition: Xvt_T.cpp:98
gnsstk::Xvt::getClockDrift
double getClockDrift() noexcept
access the clock drift, in second/second
Definition: Xvt.hpp:124
TUASSERTFESMRT
#define TUASSERTFESMRT(EXP, GOT)
Definition: TestUtil.hpp:150
gnsstk::Xvt::clkdrift
double clkdrift
satellite clock drift in seconds/second
Definition: Xvt.hpp:154
Xvt_T
Definition: Xvt_T.cpp:51
TUASSERTFEPS
#define TUASSERTFEPS(EXP, GOT, EPS)
Definition: TestUtil.hpp:126
gnsstk::Xvt
Definition: Xvt.hpp:60
TUDEF
#define TUDEF(CLASS, METHOD)
Definition: TestUtil.hpp:56
gnsstk::Xvt::getPos
Triple getPos() noexcept
access the position, ECEF Cartesian in meters
Definition: Xvt.hpp:112
example4.pos
pos
Definition: example4.py:125
GPSEllipsoid.hpp
gnsstk::Xvt::HealthStatus
HealthStatus
Definition: Xvt.hpp:87
gnsstk::Xvt::health
HealthStatus health
Health status of satellite at ref time.
Definition: Xvt.hpp:157
std
Definition: Angle.hpp:142
Triple.hpp
TUASSERTFE
#define TUASSERTFE(EXP, GOT)
Definition: TestUtil.hpp:103
Xvt_T::~Xvt_T
~Xvt_T()
Do-nothing Destructor.
Definition: Xvt_T.cpp:59
gnsstk::Xvt::clkbias
double clkbias
Sat clock correction in seconds.
Definition: Xvt.hpp:153
gnsstk::Xvt::computeRelativityCorrection
virtual double computeRelativityCorrection(void)
Definition: Xvt.cpp:98
Xvt_T::preciseRhoTest
unsigned preciseRhoTest()
Definition: Xvt_T.cpp:139


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