RawRange_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 
41 #include "Triple.hpp"
42 #include "TestUtil.hpp"
43 #include "NavDataFactory.hpp"
44 #include "RinexNavDataFactory.hpp"
45 #include "NavLibrary.hpp"
46 #include "EphemerisRange.hpp"
47 #include "GPSEllipsoid.hpp"
48 #include "SatID.hpp"
49 #include "NavSatelliteID.hpp"
50 
51 #include "RawRange.hpp"
52 
53 using namespace gnsstk;
54 
56 {
57 public:
58  RawRange_T();
59 
60  unsigned testRotateECEFTriple();
61  unsigned testRotateECEFPosition();
62  unsigned testRotateECEFXvt();
63  unsigned testComputeRangePosition();
64  unsigned testComputeRangeTriple();
65  unsigned testComputeRangeXvt();
66  unsigned testEstTransmitFromReceive();
67  unsigned testEstTransmitFromObs();
68  unsigned testFromSvPos();
69  unsigned testFromSvTransmit();
70  unsigned testFromSvTransmitWithObs();
71  unsigned testFromReceive();
72  unsigned testFromNominalReceive();
73  unsigned testFromNominalReceiveWithObs();
75 };
76 
77 
80  : navLib()
81 {
83  ndfp(std::make_shared<RinexNavDataFactory>());
84 
85  std::string fname = getPathData() + getFileSep() +
86  "arlm2000.15n";
87 
88  navLib.addFactory(ndfp);
89 
90  RinexNavDataFactory *rndfp =
91  dynamic_cast<RinexNavDataFactory*>(ndfp.get());
92 
93  GNSSTK_ASSERT(rndfp->addDataSource(fname));
94 }
95 
96 
97 unsigned RawRange_T ::
99 {
100  TUDEF("RawRange", "rotateECEF(Triple)");
101  Triple t(-7.0e5, -5.0e6, 3.0e6);
102  double dt = 0.07;
103  GPSEllipsoid ellipsoid;
104  Triple actual;
105 
106  actual = RawRange::rotateECEF(t, dt, ellipsoid);
107  TUASSERTFESMRT(-700025.52239389379974, actual[0]);
108  TUASSERTFESMRT(-4999996.4267984386533, actual[1]);
109  TUASSERTFESMRT(3000000.0, actual[2]);
110 
111  // The small angle approximation approach can make a slight difference
112  actual = RawRange::rotateECEF(t, dt, ellipsoid, true);
113  TUASSERTFESMRT(-700025.52240301342681, actual[0]);
114  TUASSERTFESMRT(-4999996.4268635781482, actual[1]);
115  TUASSERTFESMRT(3000000.0, actual[2]);
116 
117  TURETURN();
118 }
119 
120 unsigned RawRange_T ::
122 {
123  TUDEF("RawRange", "rotateECEF(Position)");
124  // The geodetic equivalent of ECEF -7.0e5, -5.0e6, 3.0e6
125  Position p(30.902726259175704, 262.03038960567716,
126  -499714.8540719012,
127  Position::CoordinateSystem::Geodetic);
128  double dt = 0.07;
129  GPSEllipsoid ellipsoid;
130  Position actual;
131 
132  // Return result should still be in the coordinate system as provided
133  actual = RawRange::rotateECEF(p, dt, ellipsoid);
135  Position::CoordinateSystem::Geodetic,
136  actual.getCoordinateSystem());
137  TUASSERTFESMRT(30.902726259174816192, actual[0]);
138  TUASSERTFESMRT(262.03009714047612988, actual[1]);
139  TUASSERTFESMRT(-499714.85406564455479, actual[2]);
140 
141  // Should be the same as the results from testRotateECEFTriple
142  // but with additional fudge factor due to geodetic to ECEF conversions
143  actual.asECEF();
144  TUASSERTFEPS(-700025.52239389379974, actual[0], 1e-4);
145  TUASSERTFEPS(-4999996.4267984386533, actual[1], 1e-4);
146  TUASSERTFEPS(3000000.0, actual[2], 1e-5);
147 
148  // The small angle approximation approach can make a slight difference
149  actual = RawRange::rotateECEF(p, dt, ellipsoid, true);
150  actual.asECEF();
151  TUASSERTFEPS(-700025.52240301342681, actual[0], 1e-4);
152  TUASSERTFEPS(-4999996.4268635781482, actual[1], 1e-4);
153  TUASSERTFEPS(3000000.0, actual[2], 1e-5);
154 
155  TURETURN();
156 }
157 
158 unsigned RawRange_T ::
160 {
161  TUDEF("RawRange", "rotateECEF(Triple)");
162  Xvt xvt;
163  xvt.x = Triple(-7.0e5, -5.0e6, 3.0e6);
164  xvt.v = Triple(100, 200, 300);
165  xvt.clkbias = 0.3;
166  xvt.relcorr = 0.002;
167  double dt = 0.07;
168  GPSEllipsoid ellipsoid;
169  Xvt actual;
170 
171  actual = RawRange::rotateECEF(xvt, dt, ellipsoid);
172  TUASSERTFESMRT(-700025.52239389379974, actual.x[0]);
173  TUASSERTFESMRT(-4999996.4267984386533, actual.x[1]);
174  TUASSERTFESMRT(3000000.0, actual.x[2]);
175  TUASSERTFESMRT(100.00102089481774215, actual.v[0]);
176  TUASSERTFESMRT(199.99948954933415735, actual.v[1]);
177  TUASSERTFESMRT(300.0, actual.v[2]);
178  // Other Xvt member variables should be the same
179  TUASSERTFE(0.3, xvt.clkbias);
180  TUASSERTFE(0.002, xvt.relcorr);
181 
182  // The small angle approximation approach can make a slight difference
183  actual = RawRange::rotateECEF(xvt, dt, ellipsoid, true);
184  TUASSERTFESMRT(-700025.52240301342681, actual.x[0]);
185  TUASSERTFESMRT(-4999996.4268635781482, actual.x[1]);
186  TUASSERTFESMRT(3000000.0, actual.x[2]);
187  TUASSERTFESMRT(100.00102089612053646, actual.v[0]);
188  TUASSERTFESMRT(199.99948955193971756, actual.v[1]);
189  TUASSERTFESMRT(300.0, actual.v[2]);
190 
191  TURETURN();
192 }
193 
194 
195 unsigned RawRange_T ::
197 {
198  TUDEF("RawRange", "computeRange(Position)");
199  // Should be able to handle Positions in non-ECEF coordinates
200  Position loc1(-7.0e5, -5.0e6, 3.0e6);
201  loc1.transformTo(Position::CoordinateSystem::Geodetic);
202  Position loc2(-7.0e6, -5.0e7, 3.0e7);
203  loc2.transformTo(Position::CoordinateSystem::Geodetic);
204 
205  double dt = 0.07;
207  GPSEllipsoid ellipsoid;
208 
209  double range;
210  Position rotatedLoc2;
211  std::tie(range, rotatedLoc2) =
212  RawRange::computeRange(loc1, loc2, dt, ellipsoid);
213  TUASSERTFEPS(52855368.696156509221, range, 1.0e-4);
214  // Returned triple should be the rotated position of loc2
215  rotatedLoc2.transformTo(Position::CoordinateSystem::Cartesian);
216  TUASSERTFEPS(-7000255.2239389382303, rotatedLoc2[0], 1.0e-4);
217  TUASSERTFEPS(-49999964.267984382808, rotatedLoc2[1], 1.0e-4);
218  TUASSERTFEPS(30000000.0, rotatedLoc2[2], 1.0e-4);
219 
220  // Again with small angle approximation
221  std::tie(range, rotatedLoc2) =
222  RawRange::computeRange(loc1, loc2, dt, ellipsoid, true);
223  TUASSERTFEPS(52855368.696721956134, range, 1.0e-4);
224  // Returned triple should be the rotated position of loc2
225  rotatedLoc2.transformTo(Position::CoordinateSystem::Cartesian);
226  TUASSERTFEPS(-7000255.2240301342681, rotatedLoc2[0], 1.0e-4);
227  TUASSERTFEPS(-49999964.268635779619, rotatedLoc2[1], 1.0e-4);
228  TUASSERTFEPS(30000000.0, rotatedLoc2[2], 1.0e-4);
229 
230  // Again with time stamp version
231  std::tie(range, rotatedLoc2) =
232  RawRange::computeRange(loc1, t1 + dt, loc2, t1, ellipsoid);
233  TUASSERTFEPS(52855368.696156509221, range, 1.0e-4);
234  // Returned triple should be the rotated position of loc2
235  rotatedLoc2.transformTo(Position::CoordinateSystem::Cartesian);
236  TUASSERTFEPS(-7000255.2239389382303, rotatedLoc2[0], 1.0e-4);
237  TUASSERTFEPS(-49999964.267984382808, rotatedLoc2[1], 1.0e-4);
238  TUASSERTFEPS(30000000.0, rotatedLoc2[2], 1.0e-4);
239 
240  // Again with time stamp version and small angle approximation
241  std::tie(range, rotatedLoc2) =
242  RawRange::computeRange(loc1, t1 + dt, loc2, t1, ellipsoid, true);
243  TUASSERTFEPS(52855368.696721956134, range, 1.0e-4);
244  // Returned triple should be the rotated position of loc2
245  rotatedLoc2.transformTo(Position::CoordinateSystem::Cartesian);
246  TUASSERTFEPS(-7000255.2240301342681, rotatedLoc2[0], 1.0e-4);
247  TUASSERTFEPS(-49999964.268635779619, rotatedLoc2[1], 1.0e-4);
248  TUASSERTFEPS(30000000.0, rotatedLoc2[2], 1.0e-4);
249 
250  TURETURN();
251 }
252 
253 unsigned RawRange_T ::
255 {
256  TUDEF("RawRange", "computeRange(Triple)");
257  Triple loc1(-7.0e5, -5.0e6, 3.0e6);
258  Triple loc2(-7.0e6, -5.0e7, 3.0e7);
259  double dt = 0.07;
261  GPSEllipsoid ellipsoid;
262 
263  double range;
264  Triple rotatedLoc2;
265  std::tie(range, rotatedLoc2) =
266  RawRange::computeRange(loc1, loc2, dt, ellipsoid);
267  TUASSERTFESMRT(52855368.696156509221, range);
268  // Returned triple should be the rotated position of loc2
269  TUASSERTFESMRT(-7000255.2239389382303, rotatedLoc2[0]);
270  TUASSERTFESMRT(-49999964.267984382808, rotatedLoc2[1]);
271  TUASSERTFESMRT(30000000.0, rotatedLoc2[2]);
272 
273  // Again with small angle approximation
274  std::tie(range, rotatedLoc2) =
275  RawRange::computeRange(loc1, loc2, dt, ellipsoid, true);
276  TUASSERTFESMRT(52855368.696721956134, range);
277  // Returned triple should be the rotated position of loc2
278  TUASSERTFESMRT(-7000255.2240301342681, rotatedLoc2[0]);
279  TUASSERTFESMRT(-49999964.268635779619, rotatedLoc2[1]);
280  TUASSERTFESMRT(30000000.0, rotatedLoc2[2]);
281 
282  // Again with time stamp version
283  std::tie(range, rotatedLoc2) =
284  RawRange::computeRange(loc1, t1 + dt, loc2, t1, ellipsoid);
285  TUASSERTFESMRT(52855368.696156509221, range);
286  // Returned triple should be the rotated position of loc2
287  TUASSERTFESMRT(-7000255.2239389382303, rotatedLoc2[0]);
288  TUASSERTFESMRT(-49999964.267984382808, rotatedLoc2[1]);
289  TUASSERTFESMRT(30000000.0, rotatedLoc2[2]);
290 
291  // Again with time stamp version and small angle approximation
292  std::tie(range, rotatedLoc2) =
293  RawRange::computeRange(loc1, t1 + dt, loc2, t1, ellipsoid, true);
294  TUASSERTFESMRT(52855368.696721956134, range);
295  // Returned triple should be the rotated position of loc2
296  TUASSERTFESMRT(-7000255.2240301342681, rotatedLoc2[0]);
297  TUASSERTFESMRT(-49999964.268635779619, rotatedLoc2[1]);
298  TUASSERTFESMRT(30000000.0, rotatedLoc2[2]);
299 
300  TURETURN();
301 }
302 
303 unsigned RawRange_T ::
305 {
306  TUDEF("RawRange", "computeRange(Xvt)");
307  Triple loc1(-7.0e5, -5.0e6, 3.0e6);
308 
309  Xvt xvt;
310  xvt.x = Triple(-7.0e6, -5.0e7, 3.0e7);
311  xvt.v = Triple(100, 200, 300);
312 
313  double dt = 0.07;
315  GPSEllipsoid ellipsoid;
316 
317  double range;
318  Xvt rotatedXvt;
319  std::tie(range, rotatedXvt) =
320  RawRange::computeRange(loc1, xvt, dt, ellipsoid);
321  TUASSERTFESMRT(52855368.696156509221, range);
322  // Returned xvt should be the rotated position and velocity
323  TUASSERTFESMRT(-7000255.2239389382303, rotatedXvt.x[0]);
324  TUASSERTFESMRT(-49999964.267984382808, rotatedXvt.x[1]);
325  TUASSERTFESMRT(30000000.0, rotatedXvt.x[2]);
326  TUASSERTFESMRT(100.00102089481774215, rotatedXvt.v[0]);
327  TUASSERTFESMRT(199.99948954933415735, rotatedXvt.v[1]);
328  TUASSERTFESMRT(300.0, rotatedXvt.v[2]);
329 
330  // Again with small angle approximation
331  std::tie(range, rotatedXvt) =
332  RawRange::computeRange(loc1, xvt, dt, ellipsoid, true);
333  TUASSERTFESMRT(52855368.696721956134, range);
334  // Returned xvt should be the rotated position and velocity
335  TUASSERTFESMRT(-7000255.2240301342681, rotatedXvt.x[0]);
336  TUASSERTFESMRT(-49999964.268635779619, rotatedXvt.x[1]);
337  TUASSERTFESMRT(30000000.0, rotatedXvt.x[2]);
338  TUASSERTFESMRT(100.00102089612053646, rotatedXvt.v[0]);
339  TUASSERTFESMRT(199.99948955193971756, rotatedXvt.v[1]);
340  TUASSERTFESMRT(300.0, rotatedXvt.v[2]);
341 
342  // Again with time stamp version
343  std::tie(range, rotatedXvt) =
344  RawRange::computeRange(loc1, t1 + dt, xvt, t1, ellipsoid);
345  TUASSERTFESMRT(52855368.696156509221, range);
346  // Returned xvt should be the rotated position and velocity
347  TUASSERTFESMRT(-7000255.2239389382303, rotatedXvt.x[0]);
348  TUASSERTFESMRT(-49999964.267984382808, rotatedXvt.x[1]);
349  TUASSERTFESMRT(30000000.0, rotatedXvt.x[2]);
350  TUASSERTFESMRT(100.00102089481774215, rotatedXvt.v[0]);
351  TUASSERTFESMRT(199.99948954933415735, rotatedXvt.v[1]);
352  TUASSERTFESMRT(300.0, rotatedXvt.v[2]);
353 
354  // Again with time stamp version and small angle approximation
355  std::tie(range, rotatedXvt) =
356  RawRange::computeRange(loc1, t1 + dt, xvt, t1, ellipsoid, true);
357  TUASSERTFESMRT(52855368.696721956134, range);
358  // Returned xvt should be the rotated position and velocity
359  TUASSERTFESMRT(-7000255.2240301342681, rotatedXvt.x[0]);
360  TUASSERTFESMRT(-49999964.268635779619, rotatedXvt.x[1]);
361  TUASSERTFESMRT(30000000.0, rotatedXvt.x[2]);
362  TUASSERTFESMRT(100.00102089612053646, rotatedXvt.v[0]);
363  TUASSERTFESMRT(199.99948955193971756, rotatedXvt.v[1]);
364  TUASSERTFESMRT(300.0, rotatedXvt.v[2]);
365 
366  TURETURN();
367 }
368 
369 unsigned RawRange_T ::
371 {
372  TUDEF("RawRange", "estTransmitFromReceive()");
373 
374  Triple rxPos(-7.0e5, -5.0e6, 3.0e6);
375  NavSatelliteID sat(SatID(5, SatelliteSystem::GPS));
376  CommonTime receive(CivilTime(2015, 7, 19, 2, 0, 0.0, TimeSystem::GPS));
377  GPSEllipsoid ellipsoid;
378 
379  bool success;
381  std::tie(success, time) = RawRange::estTransmitFromReceive(
382  rxPos,
383  receive,
384  navLib,
385  sat,
386  ellipsoid);
387 
388  TUASSERT(success);
389  CommonTime exp(CivilTime(2015, 7, 19, 1, 59, 59.92565104107503, TimeSystem::GPS));
390  TUASSERT(abs(exp - time) < 1e-9);
391 
392  TURETURN();
393 }
394 
395 unsigned RawRange_T ::
397 {
398  TUDEF("RawRange", "estTransmitFromObs()");
399 
400  Triple rxPos(-7.0e5, -5.0e6, 3.0e6);
401  NavSatelliteID sat(SatID(5, SatelliteSystem::GPS));
402  CommonTime receive(CivilTime(2015, 7, 19, 2, 0, 0.0, TimeSystem::GPS));
403  double pseudorange = 2e7;
404  GPSEllipsoid ellipsoid;
405 
406  bool success;
408  std::tie(success, time) = RawRange::estTransmitFromObs(
409  receive,
410  pseudorange,
411  navLib,
412  sat);
413 
414  TUASSERT(success);
415  CommonTime exp(CivilTime(2015, 7, 19, 1, 59, 59.93350360018778, TimeSystem::GPS));
416  TUASSERT(abs(exp - time) < 1e-9);
417 
418  TURETURN();
419 }
420 
421 unsigned RawRange_T ::
423 {
424  TUDEF("RawRange", "fromReceive()");
425 
426  Position rxLocation(-7.0e5, -5.0e6, 3.0e6);
427  NavSatelliteID satId(SatID(5, SatelliteSystem::GPS));
428  CommonTime time(CivilTime(2015,7,19,2,0,0.0,TimeSystem::GPS));
429  GPSEllipsoid ellipsoid;
430 
431  Xvt xvt;
432  double range;
433  bool success;
434  std::tie(success, range, xvt) =
435  RawRange::fromReceive(rxLocation, time, navLib, satId, ellipsoid);
436 
437  // @note These fields are slightly different than the Xvt tagged
438  // at the given time. RawRange tries to determine the position of the SV
439  // at time of transmit but rotates the coordinates into the ECEF frame
440  // at time of receive.
441  TUASSERT(success);
442  TUASSERTFESMRT(9272533.3762740660459, xvt.x[0]);
443  TUASSERTFESMRT(-12471159.893898375332, xvt.x[1]);
444  TUASSERTFESMRT(21480836.886172864586, xvt.x[2]);
445  TUASSERTFESMRT(2077.3531590469665389, xvt.v[0]);
446  TUASSERTFESMRT(1796.0597201257969573, xvt.v[1]);
447  TUASSERTFESMRT(164.40771415613258455, xvt.v[2]);
448  TUASSERTFESMRT(-0.00021641042654059759786, xvt.clkbias);
449  TUASSERTFESMRT(4.3200998334200003381e-12, xvt.clkdrift);
450  TUASSERTFESMRT(-8.8008986915573278037e-09, xvt.relcorr);
451  TUASSERTFESMRT(22289257.145863413811, range);
452  TURETURN();
453 }
454 
455 
456 unsigned RawRange_T ::
458 {
459  TUDEF("RawRange", "testFromNominalReceiveWithObs");
460 
461  Position rxLocation(-7.0e5, -5.0e6, 3.0e6);
462  NavSatelliteID satId(SatID(5, SatelliteSystem::GPS));
463  CommonTime
464  time(CivilTime(2015,7,19,2,0,0.0,TimeSystem::GPS));
465  double pseduorange = 2e7;
466  GPSEllipsoid ellipsoid;
467 
468  Xvt xvt;
469  double range;
470  bool success;
471  std::tie(success, range, xvt) =
472  RawRange::fromNominalReceiveWithObs(rxLocation, time, pseduorange,
473  navLib, satId, ellipsoid);
474 
475  // @note These fields are slightly different than the Xvt tagged
476  // at the given time. RawRange tries to determine the position of the SV
477  // at time of transmit but rotates the coordinates into the ECEF frame
478  // at time of receive.
479  TUASSERT(success);
480  TUASSERTFESMRT(9272549.688764328137, xvt.x[0]);
481  TUASSERTFESMRT(-12471145.790274851024, xvt.x[1]);
482  TUASSERTFESMRT(21480838.177179995924, xvt.x[2]);
483  TUASSERTFESMRT(2077.3540461841112119, xvt.v[0]);
484  TUASSERTFESMRT(1796.058914385570688, xvt.v[1]);
485  TUASSERTFESMRT(164.40410655412986785, xvt.v[2]);
486  TUASSERTFESMRT(-0.000216410426506673752147, xvt.clkbias);
487  TUASSERTFESMRT(4.3200998334200003381e-12, xvt.clkdrift);
488  TUASSERTFESMRT(-8.8009032843852035206e-09, xvt.relcorr);
489  TUASSERTFESMRT(22289260.787328250706, range);
490  TURETURN();
491 }
492 
493 
494 unsigned RawRange_T ::
496 {
497  TUDEF("RawRange", "fromSvTransmitWithObs");
498 
499  Position rxLocation(-7.0e5, -5.0e6, 3.0e6);
500  NavSatelliteID satId(SatID(5, SatelliteSystem::GPS));
501  CommonTime
502  time(CivilTime(2015,7,19,2,0,0.0,TimeSystem::GPS));
503  double pseduorange = 2e7;
504  GPSEllipsoid ellipsoid;
505 
506  Xvt xvt;
507  double range;
508  bool success;
509  std::tie(success, range, xvt) =
510  RawRange::fromSvTransmitWithObs(rxLocation, pseduorange, navLib,
511  satId, time, ellipsoid);
512 
513  // @note These fields are slightly different than the Xvt tagged
514  // at the given time. RawRange tries to determine the position of the SV
515  // at time of transmit but rotates the coordinates into the ECEF frame
516  // at time of receive.
517  TUASSERT(success);
518  TUASSERTFESMRT(9272694.5731354933232, xvt.x[0]);
519  TUASSERTFESMRT(-12471021.341979622841, xvt.x[1]);
520  TUASSERTFESMRT(21480849.108445473015, xvt.x[2]);
521  TUASSERTFESMRT(2077.3605866147809138, xvt.v[0]);
522  TUASSERTFESMRT(1796.0532152160560599, xvt.v[1]);
523  TUASSERTFESMRT(164.37355694668559636, xvt.v[2]);
524  TUASSERTFESMRT(-0.00021641042621940267715, xvt.clkbias);
525  TUASSERTFESMRT(4.3200998334200003381e-12, xvt.clkdrift);
526  TUASSERTFESMRT(-8.8009421765298224418e-09, xvt.relcorr);
527  TUASSERTFESMRT(22289292.961206533015, range);
528  TURETURN();
529 }
530 
531 
532 unsigned RawRange_T ::
534 {
535  TUDEF("RawRange", "fromNominalReceive");
536 
537  Position rxLocation(-7.0e5, -5.0e6, 3.0e6);
538  NavSatelliteID satId(SatID(5, SatelliteSystem::GPS));
539  CommonTime
540  time(CivilTime(2015,7,19,2,0,0.0,TimeSystem::GPS));
541  GPSEllipsoid ellipsoid;
542 
543  Xvt xvt;
544  double range;
545  bool success;
546  std::tie(success, range, xvt) =
547  RawRange::fromNominalReceive(rxLocation, time, navLib, satId, ellipsoid);
548 
549  // @note These fields are slightly different than the Xvt tagged
550  // at the given time. RawRange tries to determine the position of the SV
551  // at time of transmit but rotates the coordinates into the ECEF frame
552  // at time of receive.
553  TUASSERT(success);
554  TUASSERTFESMRT(9272533.3759945072234, xvt.x[0]);
555  TUASSERTFESMRT(-12471159.894135156646, xvt.x[1]);
556  TUASSERTFESMRT(21480836.886153958738, xvt.x[2]);
557  TUASSERTFESMRT(2077.353159039827915, xvt.v[0]);
558  TUASSERTFESMRT(1796.0597201308269177, xvt.v[1]);
559  TUASSERTFESMRT(164.40771420896862764, xvt.v[2]);
560  TUASSERTFESMRT(-0.00021641042654059808575, xvt.clkbias);
561  TUASSERTFESMRT(4.3200998334200003381e-12, xvt.clkdrift);
562  TUASSERTFESMRT(-8.8008986914900614763e-09, xvt.relcorr);
563  TUASSERTFESMRT(22289257.145802032202, range);
564  TURETURN();
565 }
566 
567 unsigned RawRange_T ::
569 {
570  TUDEF("RawRange","fromSvPos");
571 
572  Position rxPos(-7.0e5, -5.0e6, 3.0e6);
573  Xvt xvt;
574  xvt.x = Triple(-9e5, -2e7, 9e6);
575  xvt.v = Triple(6e2, 1e3, 2e4);
576  xvt.clkbias = -0.3;
577  xvt.clkdrift = 0;
578  xvt.relcorr = -3.5e-6;
579  GPSEllipsoid ellipsoid;
580 
581  double range;
582  bool success;
583  Xvt returnXvt;
584  std::tie(success, range, returnXvt) =
585  RawRange::fromSvPos(rxPos, xvt, ellipsoid);
586  TUASSERT(success);
587  TUASSERTFESMRT(16156730.032176425681, range);
588  TUASSERTFESMRT(-900078.59885879501235, returnXvt.x[0]);
589  TUASSERTFESMRT(-19999996.462896592915, returnXvt.x[1]);
590  TUASSERTFESMRT(9000000.0, returnXvt.x[2]);
591  TUASSERTFESMRT(600.00392993865398239, returnXvt.v[0]);
592  TUASSERTFESMRT(999.99764202630535692, returnXvt.v[1]);
593  TUASSERTFESMRT(20000.0, returnXvt.v[2]);
594 
595  TURETURN();
596 }
597 
598 unsigned RawRange_T ::
600 {
601  TUDEF("RawRange","fromSvTransmit");
602 
603  Position rxPos(-7.0e5, -5.0e6, 3.0e6);
604  NavSatelliteID satId(SatID(5, SatelliteSystem::GPS));
605  CommonTime
606  time(CivilTime(2015,7,19,2,0,0.0,TimeSystem::GPS));
607  GPSEllipsoid ellipsoid;
608 
609  double range;
610  bool success;
611  Xvt returnXvt;
612  std::tie(success, range, returnXvt) =
613  RawRange::fromSvTransmit(rxPos, navLib, satId, time, ellipsoid);
614  TUASSERT(success);
615  TUASSERTFESMRT(22289291.623843517154, range);
616  TUASSERTFESMRT(9272687.8255264088511, returnXvt.x[0]);
617  TUASSERTFESMRT(-12471026.359089374542, returnXvt.x[1]);
618  TUASSERTFESMRT(21480849.108445473015, returnXvt.x[2]);
619  TUASSERTFESMRT(2077.361558392346069, returnXvt.v[0]);
620  TUASSERTFESMRT(1796.0520912329243401, returnXvt.v[1]);
621  TUASSERTFESMRT(164.37355694668559636, returnXvt.v[2]);
622 
623  TURETURN();
624 }
625 
626 
627 int main()
628 {
629  RawRange_T testClass;
630  unsigned errorTotal = 0;
631 
632  errorTotal += testClass.testRotateECEFTriple();
633  errorTotal += testClass.testRotateECEFPosition();
634  errorTotal += testClass.testRotateECEFXvt();
635  errorTotal += testClass.testComputeRangePosition();
636  errorTotal += testClass.testComputeRangeTriple();
637  errorTotal += testClass.testComputeRangeXvt();
638  errorTotal += testClass.testEstTransmitFromReceive();
639  errorTotal += testClass.testEstTransmitFromObs();
640  errorTotal += testClass.testFromSvPos();
641  errorTotal += testClass.testFromSvTransmit();
642  errorTotal += testClass.testFromSvTransmitWithObs();
643  errorTotal += testClass.testFromReceive();
644  errorTotal += testClass.testFromNominalReceive();
645  errorTotal += testClass.testFromNominalReceiveWithObs();
646 
647  std::cout << "Total Failures for " << __FILE__ << ": " << errorTotal
648  << std::endl;
649 
650  return errorTotal;
651 }
gnsstk::Position::getCoordinateSystem
CoordinateSystem getCoordinateSystem() const noexcept
return the coordinate system for this Position
Definition: Position.hpp:449
RawRange_T::testFromSvTransmit
unsigned testFromSvTransmit()
Definition: RawRange_T.cpp:599
gnsstk::Position::transformTo
Position & transformTo(CoordinateSystem sys) noexcept
Definition: Position.cpp:247
gnsstk::BEGINNING_OF_TIME
const Epoch BEGINNING_OF_TIME(CommonTime::BEGINNING_OF_TIME)
Earliest representable Epoch.
RawRange_T
Definition: RawRange_T.cpp:55
TUASSERTE
#define TUASSERTE(TYPE, EXP, GOT)
Definition: TestUtil.hpp:81
gnsstk::NavSatelliteID
Definition: NavSatelliteID.hpp:57
main
int main()
Definition: RawRange_T.cpp:627
NavSatelliteID.hpp
gnsstk::SatID
Definition: SatID.hpp:89
SatID.hpp
gnsstk::GPSEllipsoid
Definition: GPSEllipsoid.hpp:67
gnsstk::Xvt::v
Triple v
satellite velocity in ECEF Cartesian, meters/second
Definition: Xvt.hpp:152
RawRange_T::testFromNominalReceiveWithObs
unsigned testFromNominalReceiveWithObs()
Definition: RawRange_T.cpp:457
gnsstk::Triple
Definition: Triple.hpp:68
gnsstk::Position::asECEF
Position & asECEF() noexcept
Definition: Position.hpp:390
RawRange_T::testComputeRangeXvt
unsigned testComputeRangeXvt()
Definition: RawRange_T.cpp:304
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
gnsstk::NavDataFactoryPtr
std::shared_ptr< NavDataFactory > NavDataFactoryPtr
Managed pointer to NavDataFactory.
Definition: NavDataFactory.hpp:398
RawRange_T::testComputeRangeTriple
unsigned testComputeRangeTriple()
Definition: RawRange_T.cpp:254
EphemerisRange.hpp
gnsstk::Xvt::x
Triple x
Sat position ECEF Cartesian (X,Y,Z) meters.
Definition: Xvt.hpp:151
gnsstk::NavDataFactoryWithStoreFile::addDataSource
bool addDataSource(const std::string &source) override
Definition: NavDataFactoryWithStoreFile.hpp:64
TUASSERT
#define TUASSERT(EXPR)
Definition: TestUtil.hpp:63
TestUtil.hpp
NavLibrary.hpp
TURETURN
#define TURETURN()
Definition: TestUtil.hpp:232
gnsstk::NavLibrary
Definition: NavLibrary.hpp:944
example4.time
time
Definition: example4.py:103
RawRange_T::testRotateECEFTriple
unsigned testRotateECEFTriple()
Definition: RawRange_T.cpp:98
TUASSERTFESMRT
#define TUASSERTFESMRT(EXP, GOT)
Definition: TestUtil.hpp:150
gnsstk::CommonTime
Definition: CommonTime.hpp:84
gnsstk::Xvt::clkdrift
double clkdrift
satellite clock drift in seconds/second
Definition: Xvt.hpp:154
RawRange.hpp
TUASSERTFEPS
#define TUASSERTFEPS(EXP, GOT, EPS)
Definition: TestUtil.hpp:126
gnsstk::Xvt
Definition: Xvt.hpp:60
gnsstk::Position::CoordinateSystem
CoordinateSystem
The coordinate systems supported by Position.
Definition: Position.hpp:142
TUDEF
#define TUDEF(CLASS, METHOD)
Definition: TestUtil.hpp:56
RawRange_T::testComputeRangePosition
unsigned testComputeRangePosition()
Definition: RawRange_T.cpp:196
RawRange_T::RawRange_T
RawRange_T()
Definition: RawRange_T.cpp:79
GPSEllipsoid.hpp
gnsstk::CivilTime
Definition: CivilTime.hpp:55
RawRange_T::testRotateECEFXvt
unsigned testRotateECEFXvt()
Definition: RawRange_T.cpp:159
GNSSTK_ASSERT
#define GNSSTK_ASSERT(CONDITION)
Provide an "ASSERT" type macro.
Definition: Exception.hpp:373
RawRange_T::testFromSvPos
unsigned testFromSvPos()
Definition: RawRange_T.cpp:568
RawRange_T::testEstTransmitFromObs
unsigned testEstTransmitFromObs()
Definition: RawRange_T.cpp:396
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
Triple.hpp
TUASSERTFE
#define TUASSERTFE(EXP, GOT)
Definition: TestUtil.hpp:103
gnsstk::Position
Definition: Position.hpp:136
gnsstk::Xvt::clkbias
double clkbias
Sat clock correction in seconds.
Definition: Xvt.hpp:153
RawRange_T::testEstTransmitFromReceive
unsigned testEstTransmitFromReceive()
Definition: RawRange_T.cpp:370
RawRange_T::testFromNominalReceive
unsigned testFromNominalReceive()
Definition: RawRange_T.cpp:533
RawRange_T::navLib
NavLibrary navLib
Definition: RawRange_T.cpp:74
RawRange_T::testFromReceive
unsigned testFromReceive()
Definition: RawRange_T.cpp:422
RawRange_T::testFromSvTransmitWithObs
unsigned testFromSvTransmitWithObs()
Definition: RawRange_T.cpp:495
NavDataFactory.hpp
RawRange_T::testRotateECEFPosition
unsigned testRotateECEFPosition()
Definition: RawRange_T.cpp:121
RinexNavDataFactory.hpp


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