EphemerisRange.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 
45 #include <utility>
46 
47 #include "EllipsoidModel.hpp"
48 #include "EphemerisRange.hpp"
49 #include "MiscMath.hpp"
50 #include "GNSSconstants.hpp"
51 #include "GPSLNavEph.hpp"
52 #include "TimeString.hpp"
53 #include "RawRange.hpp"
54 
55 using namespace std;
56 using namespace gnsstk;
57 
58 namespace gnsstk
59 {
60  // Compute the corrected range at RECEIVE time, from receiver at position Rx,
61  // to the GPS satellite given by SatID sat, as well as all the CER quantities,
62  // given the nominal receive time trNom and an EphemerisStore. Note that this
63  // routine does not intrinsicly account for the receiver clock error
64  // like the ComputeAtTransmitTime routine does.
65  double CorrectedEphemerisRange::ComputeAtReceiveTime(
66  const CommonTime& trNom,
67  const Position& Rx,
68  const SatID sat,
69  NavLibrary& navLib,
70  NavSearchOrder order,
71  SVHealth xmitHealth,
73  const EllipsoidModel& ellipsoid)
74  {
75  try {
76  int nit;
77  double tof,tof_old;
78  bool success;
79  std::tie(success, rawrange, svPosVel) =
80  RawRange::fromReceive(Rx, trNom, navLib,
81  NavSatelliteID(sat), ellipsoid);
82 
83  if(!success)
84  {
85  InvalidRequest ir("getXvt failed");
86  GNSSTK_THROW(ir);
87  }
88 
89  updateCER(Rx);
90  return (rawrange-svclkbias-relativity);
91  }
92  catch(gnsstk::Exception& e) {
93  GNSSTK_RETHROW(e);
94  }
95  }
96 
97 
98  // Compute the corrected range at TRANSMIT time, from receiver at position Rx,
99  // to the GPS satellite given by SatID sat, as well as all the CER quantities,
100  // given the nominal receive time trNom and an EphemerisStore, as well as
101  // the raw measured pseudorange.
102  double CorrectedEphemerisRange::ComputeAtTransmitTime(
103  const CommonTime& trNom,
104  const double& pr,
105  const Position& Rx,
106  const SatID sat,
107  NavLibrary& navLib,
108  NavSearchOrder order,
109  SVHealth xmitHealth,
111  const EllipsoidModel& ellipsoid)
112  {
113  try {
114  bool success;
115  std::tie(success, rawrange, svPosVel) =
116  RawRange::fromNominalReceiveWithObs(Rx, trNom, pr, navLib,
117  NavSatelliteID(sat), ellipsoid);
118  if(!success)
119  {
120  InvalidRequest ir("getXvt failed");
121  GNSSTK_THROW(ir);
122  }
123 
124  updateCER(Rx);
125  return (rawrange-svclkbias-relativity);
126  }
127  catch(gnsstk::Exception& e) {
128  GNSSTK_RETHROW(e);
129  }
130  }
131 
132 
133  double CorrectedEphemerisRange::ComputeAtTransmitTime(
134  const CommonTime& trNom,
135  const Position& Rx,
136  const SatID sat,
137  NavLibrary& navLib,
138  NavSearchOrder order,
139  SVHealth xmitHealth,
141  const EllipsoidModel& ellipsoid)
142  {
143  try {
144  bool success;
145  std::tie(success, rawrange, svPosVel) =
146  RawRange::fromNominalReceive(Rx, trNom, navLib,
147  NavSatelliteID(sat), ellipsoid);
148 
149  if(!success)
150  {
151  InvalidRequest ir("getXvt failed");
152  GNSSTK_THROW(ir);
153  }
154 
155  updateCER(Rx);
156 
157  return (rawrange - svclkbias - relativity);
158  }
159  catch(gnsstk::Exception& e) {
160  GNSSTK_RETHROW(e);
161  }
162  }
163 
164 
165  double CorrectedEphemerisRange::ComputeAtTransmitSvTime(
166  const CommonTime& ttNom,
167  const double& pr,
168  const Position& rx,
169  const SatID sat,
170  NavLibrary& navLib,
171  NavSearchOrder order,
172  SVHealth xmitHealth,
174  const EllipsoidModel& ellipsoid)
175  {
176  try
177  {
178  bool success;
179  std::tie(success, rawrange, svPosVel)
180  = RawRange::fromSvTransmitWithObs(rx, pr, navLib,
181  NavSatelliteID(sat), ttNom,
182  ellipsoid, true);
183 
184  if(!success)
185  {
186  InvalidRequest ir("getXvt failed");
187  GNSSTK_THROW(ir);
188  }
189 
190  updateCER(rx);
191 
192  return rawrange - svclkbias - relativity;
193  }
194  catch (Exception& e) {
195  GNSSTK_RETHROW(e);
196  }
197  }
198 
199 
200  void CorrectedEphemerisRange::updateCER(const Position& Rx)
201  {
202  relativity = svPosVel.computeRelativityCorrection() * C_MPS;
203 
204  svclkbias = svPosVel.clkbias * C_MPS;
205  svclkdrift = svPosVel.clkdrift * C_MPS;
206 
207  cosines[0] = (Rx.X()-svPosVel.x[0])/rawrange;
208  cosines[1] = (Rx.Y()-svPosVel.x[1])/rawrange;
209  cosines[2] = (Rx.Z()-svPosVel.x[2])/rawrange;
210 
211  Position SV(svPosVel);
212  elevation = Rx.elevation(SV);
213  azimuth = Rx.azimuth(SV);
214  elevationGeodetic = Rx.elevationGeodetic(SV);
215  azimuthGeodetic = Rx.azimuthGeodetic(SV);
216  }
217 
218  double RelativityCorrection(const Xvt& svPosVel)
219  {
220  // relativity correction
221  // dtr = -2*dot(R,V)/(c*c) = -4.4428e-10(s/sqrt(m)) * ecc * sqrt(A(m)) * sinE
222  // compute it separately here, in units seconds.
223  double dtr = ( -2.0 *( svPosVel.x[0] * svPosVel.v[0]
224  + svPosVel.x[1] * svPosVel.v[1]
225  + svPosVel.x[2] * svPosVel.v[2] ) / C_MPS ) / C_MPS;
226  return dtr;
227  }
228 
229 } // namespace gnsstk
gnsstk::NavSatelliteID
Definition: NavSatelliteID.hpp:57
gnsstk::SatID
Definition: SatID.hpp:89
gnsstk::Position::Y
double Y() const noexcept
return Y coordinate (meters)
Definition: Position.cpp:364
gnsstk::Position::Z
double Z() const noexcept
return Z coordinate (meters)
Definition: Position.cpp:375
gnsstk::Xvt::v
Triple v
satellite velocity in ECEF Cartesian, meters/second
Definition: Xvt.hpp:152
gnsstk::SVHealth
SVHealth
Identify different types of SV health states.
Definition: SVHealth.hpp:52
gnsstk::NavValidityType
NavValidityType
Definition: NavValidityType.hpp:53
GNSSconstants.hpp
gnsstk::NavSearchOrder
NavSearchOrder
Specify the behavior of nav data searches in NavLibrary/NavDataFactory.
Definition: NavSearchOrder.hpp:51
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::Position::azimuth
double azimuth(const Position &Target) const
Definition: Position.cpp:1365
gnsstk::Position::azimuthGeodetic
double azimuthGeodetic(const Position &Target) const
Definition: Position.cpp:1391
MiscMath.hpp
gnsstk::Exception
Definition: Exception.hpp:151
EphemerisRange.hpp
gnsstk::Xvt::x
Triple x
Sat position ECEF Cartesian (X,Y,Z) meters.
Definition: Xvt.hpp:151
gnsstk::NavLibrary
Definition: NavLibrary.hpp:944
gnsstk::C_MPS
const double C_MPS
m/s, speed of light; this value defined by GPS but applies to GAL and GLO.
Definition: GNSSconstants.hpp:74
gnsstk::CommonTime
Definition: CommonTime.hpp:84
RawRange.hpp
example6.valid
valid
Definition: example6.py:20
gnsstk::Xvt
Definition: Xvt.hpp:60
GNSSTK_RETHROW
#define GNSSTK_RETHROW(exc)
Definition: Exception.hpp:369
gnsstk::Position::X
double X() const noexcept
return X coordinate (meters)
Definition: Position.cpp:353
std
Definition: Angle.hpp:142
gnsstk::Position
Definition: Position.hpp:136
GNSSTK_THROW
#define GNSSTK_THROW(exc)
Definition: Exception.hpp:366
gnsstk::EllipsoidModel
Definition: EllipsoidModel.hpp:56
GPSLNavEph.hpp
gnsstk::Position::elevationGeodetic
double elevationGeodetic(const Position &Target) const
Definition: Position.cpp:1331
gnsstk::Position::elevation
double elevation(const Position &Target) const
Definition: Position.cpp:1308
TimeString.hpp
EllipsoidModel.hpp
gnsstk::RelativityCorrection
double RelativityCorrection(const Xvt &svPosVel)
Definition: EphemerisRange.cpp:218


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