00001 /** 00002 \file GNSS_Estimator.h 00003 \brief The header file for the GNSS_Estimator class. 00004 00005 \author Glenn D. MacGougan (GDM) 00006 \date 2007-10-29 00007 \since 2006-11-16 00008 00009 \b "LICENSE INFORMATION" \n 00010 Copyright (c) 2007, refer to 'author' doxygen tags \n 00011 All rights reserved. \n 00012 00013 Redistribution and use in source and binary forms, with or without 00014 modification, are permitted provided the following conditions are met: \n 00015 00016 - Redistributions of source code must retain the above copyright 00017 notice, this list of conditions and the following disclaimer. \n 00018 - Redistributions in binary form must reproduce the above copyright 00019 notice, this list of conditions and the following disclaimer in the 00020 documentation and/or other materials provided with the distribution. \n 00021 - The name(s) of the contributor(s) may not be used to endorse or promote 00022 products derived from this software without specific prior written 00023 permission. \n 00024 00025 THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS 00026 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00027 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00028 DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 00029 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00030 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00031 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00032 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00033 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00034 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00035 SUCH DAMAGE. 00036 */ 00037 00038 #ifndef _GNSS_ESTIMATOR_H_ 00039 #define _GNSS_ESTIMATOR_H_ 00040 00041 #include <stdio.h> 00042 #include <list> 00043 #include "gnss_types.h" 00044 #include "Matrix.h" 00045 00046 using namespace Zenautics; // for Matrix 00047 using namespace std; 00048 00049 namespace GNSS 00050 { 00051 00052 // forwarding declaration 00053 class GNSS_RxData; 00054 00055 00056 /** 00057 \brief A class for estimating navigation information provided GNSS 00058 measurements. 00059 00060 \author Glenn D. MacGougan (GDM) 00061 \date 2006-11-16 00062 */ 00063 class GNSS_Estimator 00064 { 00065 public: 00066 00067 /// \brief The default constructor (no data allocated yet). 00068 GNSS_Estimator(); 00069 00070 /// \brief The destructor. 00071 virtual ~GNSS_Estimator(); 00072 00073 private: 00074 00075 /// \brief The copy constructor. Disabled! 00076 GNSS_Estimator( const GNSS_Estimator& rhs ); 00077 00078 /// \brief The assignment operator. Disabled! 00079 void operator=(const GNSS_Estimator& rhs) 00080 {} 00081 00082 public: 00083 00084 bool Initialize( 00085 double latitudeRads, 00086 double longitudeRads, 00087 double height, 00088 double std_lat, 00089 double std_lon, 00090 double std_hgt 00091 ); 00092 00093 bool InitializeDPGS( 00094 const double referenceLatitudeRads, 00095 const double referenceLongitudeRads, 00096 const double refernceHeight, 00097 double latitudeRads, 00098 double longitudeRads, 00099 double height, 00100 double std_lat, 00101 double std_lon, 00102 double std_hgt 00103 ); 00104 00105 00106 /// \brief Determine the satellite clock corrections, positions, and 00107 /// velocities for the rover receiver and the reference 00108 /// receiver if aviailable (!NULL). Also determine if the 00109 /// ephemeris is valid (not too old). If differential, 00110 /// rxBaseData != NULL, the reference station receiver 00111 /// ephemeris data is used. 00112 /// 00113 /// \pre The following must be valid: \n 00114 /// rxData.m_pvt must be a valid estimate. \n 00115 /// rxData.m_maxAgeEphemeris must be set. \n 00116 /// rxData.m_time must be a valid time. \n 00117 /// if differential \n 00118 /// rxBaseData.m_pvt must be a valid estimate. \n 00119 /// rxBaseData.m_maxAgeEphemeris must be set. \n 00120 /// rxBaseData.m_time must be a valid time. \n 00121 /// 00122 /// \post The following are set: \n 00123 /// rxData.m_ObsArray[i].flags.isEphemerisValid \n 00124 /// rxData.m_ObsArray[i].satellite \n 00125 /// rxData.m_ObsArray[i].corrections.prcSatClk \n 00126 /// rxData.m_ObsArray[i].corrections.rrcSatClkDrift \n 00127 /// if differntial \n 00128 /// rxBaseData.m_ObsArray[i].flags.isEphemerisValid \n 00129 /// rxBaseData.m_ObsArray[i].satellite \n 00130 /// rxBaseData.m_ObsArray[i].corrections.prcSatClk \n 00131 /// rxBaseData.m_ObsArray[i].corrections.rrcSatClkDrift \n 00132 /// 00133 /// \return true if successful, false if error. 00134 bool DetermineSatellitePVT_GPSL1( 00135 GNSS_RxData *rxData, //!< The pointer to the receiver data. 00136 GNSS_RxData *rxBaseData, //!< The pointer to the reference receiver data. NULL if not available. 00137 unsigned &nrValidEph //!< The number of GPS L1 channels with valid ephemeris for the rover. 00138 ); 00139 00140 /// \brief Determine the tropospheric and ionospheric delay for each 00141 /// GPS L1 channel in rxData. 00142 /// 00143 /// \pre The following values must be valid: \n 00144 /// rxData.m_time (all values) \n 00145 /// rxData.m_pvt must be a valid estimate \n 00146 /// rxData.m_ObsArray[i].satellite.elevation \n 00147 /// rxData.m_ObsArray[i].satellite.azimuth \n 00148 /// rxData.m_klobuchar \n 00149 /// 00150 /// \post The following values are set: \n 00151 /// rxData.m_ObsArray[i].corrections.prcTropoDry \n 00152 /// rxData.m_ObsArray[i].corrections.prcTropoWet \n 00153 /// rxData.m_ObsArray[i].corrections.prcIono \n 00154 bool DetermineAtmosphericCorrections_GPSL1( 00155 GNSS_RxData &rxData //!< The receiver data. 00156 ); 00157 00158 00159 00160 /// \brief Determine the usable GPS L1 pseudroange measurements. 00161 /// 00162 /// \pre The rxData.m_ObsArray[i].flags values must be set 00163 /// properly including: \n 00164 /// rxData.m_ObsArray[i].flags.isCodeLocked \n 00165 /// rxData.m_ObsArray[i].flags.isPsrValid \n 00166 /// rxData.m_ObsArray[i].flags.isEphemerisValid \n 00167 /// rxData.m_ObsArray[i].flags.isNotPsrRejected \n 00168 /// rxData.m_ObsArray[i].flags.isNotUserRejected \n 00169 /// 00170 /// \post The following flags are set: 00171 /// rxData.m_ObsArray[i].flags.isAboveElevationMask \n 00172 /// rxData.m_ObsArray[i].flags.isAboveCNoMask \n 00173 /// rxData.m_ObsArray[i].flags.isAboveLockTimeMask \n 00174 /// rxData.m_ObsArray[i].flags.isPsrUsedInSolution. 00175 /// 00176 /// \return true if successful, false if error. 00177 bool DetermineUsablePseudorangeMeasurementsForThePositionSolution_GPSL1( 00178 GNSS_RxData &rxData, //!< The receiver data. 00179 unsigned &nrUsablePseudoranges //!< the number of usable GPS L1 pseudorange measurements. 00180 ); 00181 00182 00183 /// \brief Determine the usable GPS L1 ADR measurements. 00184 /// 00185 /// \pre The rxData.m_ObsArray[i].flags values must be set 00186 /// properly including: \n 00187 /// rxData.m_ObsArray[i].flags.isCodeLocked & 00188 /// rxData.m_ObsArray[i].flags.isPhaseLocked & 00189 /// rxData.m_ObsArray[i].flags.isParityValid & // if not, there is a half cycle amibiguity. 00190 /// rxData.m_ObsArray[i].flags.isAdrValid & 00191 /// rxData.m_ObsArray[i].flags.isAboveElevationMask & 00192 /// rxData.m_ObsArray[i].flags.isAboveCNoMask & 00193 /// rxData.m_ObsArray[i].flags.isAboveLockTimeMask & 00194 /// rxData.m_ObsArray[i].flags.isNotUserRejected & 00195 /// rxData.m_ObsArray[i].flags.isNotAdrRejected & 00196 /// rxData.m_ObsArray[i].flags.isEphemerisValid 00197 /// 00198 /// \post The following flags are set: 00199 /// rxData.m_ObsArray[i].flags.isAboveElevationMask \n 00200 /// rxData.m_ObsArray[i].flags.isAboveCNoMask \n 00201 /// rxData.m_ObsArray[i].flags.isAboveLockTimeMask \n 00202 /// rxData.m_ObsArray[i].flags.isAdrUsedSolution. 00203 /// 00204 /// \return true if successful, false if error. 00205 bool DetermineUsableAdrMeasurements_GPSL1( 00206 GNSS_RxData &rxData, //!< The receiver data. 00207 unsigned &nrUsableAdr //!< The number of usable GPS L1 adr measurements. 00208 ); 00209 00210 00211 /** 00212 \brief Determine the corresponding indices for between receiver differencing. 00213 \author Glenn D. MacGougan 00214 \date 2007-12-13 00215 00216 \pre The following must be valid: for rxData and rxBaseData obsservations \n 00217 flags.isPsrUsedInSolution \n 00218 flags.isDopplerUsedInSolution \n 00219 flags.isAdrUsedInSolution \n 00220 00221 \post The following are set: for rxData and rxBaseData obsservations \n 00222 flags.isDifferentialPsrAvailable \n 00223 flags.isDifferentialDopplerAvailable \n 00224 flags.isDifferentialAdrAvailable \n 00225 index_differential \n 00226 00227 \return true if successful, false if error. 00228 */ 00229 bool DetermineBetweenReceiverDifferentialIndex( 00230 GNSS_RxData *rxData, //!< (input) The pointer to the receiver data. 00231 GNSS_RxData *rxBaseData, //!< (input) The pointer to the reference receiver data. NULL if not available. 00232 const bool setToUseOnlyDifferential //!< (input) This indicates that only differential measurements should be used. 00233 ); 00234 00235 00236 /// \brief Determine the design matrix for the GPS L1 00237 /// position solution based on pseudroange measurements. 00238 /// 00239 /// \pre The following must be valid: 00240 /// rxData.m_pvt 00241 /// rxData.m_ObsArray[i].satellite 00242 /// rxData.m_ObsArray[i].flags.isPsrUsedInSolution 00243 /// 00244 /// \return true if successful, false if error. 00245 bool DetermineDesignMatrixForThePositionSolution_GPSL1( 00246 GNSS_RxData &rxData, //!< The receiver data. 00247 const unsigned nrRowsInH, //!< The number of valid rows in H. 00248 Matrix &H //!< The position & rx clock design matrix [n x 4]. 00249 ); 00250 00251 00252 /// \brief Determine the measurement weight matrix for the GPS L1 00253 /// position solution based on pseudroange measurement 00254 /// standard deviation values specified in 00255 /// rxData.m_ObsArray[i].stdev_psr. 00256 /// 00257 /// \pre The following must be valid: \n 00258 /// rxData.m_ObsArray[i].flags.isPsrUsedInSolution \n 00259 /// rxData.m_ObsArray[i].stdev_psr (not zero) \n 00260 /// 00261 /// \return true if successful, false if error. 00262 bool DetermineMeasurementWeightMatrixForThePositionSolution_GPSL1( 00263 GNSS_RxData &rxData, //!< The receiver data. 00264 const unsigned nrUsablePseudoranges, //!< The number of usable GPS L1 pseudorange measurements. 00265 Matrix &W //!< The inverse of the pseudorange measurement variance-coraiance matrix [nP x nP]. 00266 ); 00267 00268 /// \brief Determine the measurement variance-coariance matrix for 00269 /// the GPS L1 position solution based on pseudroange measurement 00270 /// standard deviation values specified in 00271 /// rxData.m_ObsArray[i].stdev_psr. 00272 /// 00273 /// \pre The following must be valid: \n 00274 /// rxData.m_ObsArray[i].flags.isPsrUsedInSolution \n 00275 /// rxData.m_ObsArray[i].stdev_psr (not zero) \n 00276 /// 00277 /// \return true if successful, false if error. 00278 bool DetermineMeasurementVarianceCovarianceMatrixForThePositionSolution_GPSL1( 00279 GNSS_RxData &rxData, //!< The receiver data. 00280 const unsigned n, //!< The number of measurements and pseudo-measurements (constraints). 00281 Matrix &R //!< The pseudorange measurement variance-covariance matrix [n x n]. 00282 ); 00283 00284 00285 /// \brief Compute the GPS L1 pseudroange misclosures. 00286 /// 00287 /// \pre The following must be valid: \n 00288 /// rxData->m_ObsArray[i].flags.isPsrUsedInSolution \n 00289 /// rxData->m_ObsArray[i].satellite.clkdrift \n 00290 /// rxData->m_ObsArray[i].corrections.prcTropoDry \n 00291 /// rxData->m_ObsArray[i].corrections.prcTropoWet \n 00292 /// rxData->m_ObsArray[i].corrections.prcIono \n 00293 /// rxData->m_ObsArray[i].range \n 00294 /// rxData->m_pvt.clockOffset \n 00295 /// if diffential, the same above for rxBaseData. 00296 /// 00297 /// \post The following is set: \n 00298 /// rxData.m_ObsArray[i].psr_misclosure \n 00299 /// 00300 /// \return true if successful, false if error. 00301 bool DeterminePseudorangeMisclosures_GPSL1( 00302 GNSS_RxData *rxData, //!< The pointer to the receiver data. 00303 GNSS_RxData *rxBaseData, //!< The pointer to the reference receiver data. NULL if not available. 00304 const unsigned nrPsr, //!< The number of GPS L1 pseudorange measurements. 00305 Matrix &w //!< The pseudorange misclosure vector [nP x 1]. 00306 ); 00307 00308 00309 /// \brief Compute the differntial GPS L1 ADR misclosures. 00310 /// 00311 /// \pre The following must be valid: \n 00312 /// rxData->m_ObsArray[i].flags.isAdrUsedInSolution \n 00313 /// rxData->m_ObsArray[i].satellite.clkdrift \n 00314 /// rxData->m_ObsArray[i].corrections.prcTropoDry \n 00315 /// rxData->m_ObsArray[i].corrections.prcTropoWet \n 00316 /// rxData->m_ObsArray[i].corrections.prcIono \n 00317 /// rxData->m_ObsArray[i].range \n 00318 /// rxData->m_pvt.clockOffset \n 00319 /// if diffential, the same above for rxBaseData. 00320 /// 00321 /// \post The following is set: \n 00322 /// rxData.m_ObsArray[i].adr_misclosure \n 00323 /// 00324 /// \return true if successful, false if error. 00325 bool DetermineSingleDifferenceADR_Misclosures_GPSL1( 00326 GNSS_RxData *rxData, //!< The pointer to the receiver data. 00327 GNSS_RxData *rxBaseData, //!< The pointer to the reference receiver data. NULL if not available. 00328 const unsigned n, //!< The number of misclosures. 00329 Matrix &w //!< The adr misclosure vector [n x 1]. 00330 ); 00331 /// \brief Compute the double differntial GPS L1 ADR misclosures. 00332 /// 00333 /// \pre The following must be valid: \n 00334 /// rxData->m_ObsArray[i].flags.isAdrUsedInSolution \n 00335 /// rxData->m_ObsArray[i].satellite.clkdrift \n 00336 /// rxData->m_ObsArray[i].corrections.prcTropoDry \n 00337 /// rxData->m_ObsArray[i].corrections.prcTropoWet \n 00338 /// rxData->m_ObsArray[i].corrections.prcIono \n 00339 /// rxData->m_ObsArray[i].range \n 00340 /// rxData->m_pvt.clockOffset \n 00341 /// if diffential, the same above for rxBaseData. 00342 /// 00343 /// \post The following is set: \n 00344 /// rxData.m_ObsArray[i].adr_misclosure \n 00345 /// 00346 /// \return true if successful, false if error. 00347 bool GNSS_Estimator::DetermineDoubleDifferenceADR_Misclosures_GPSL1( 00348 GNSS_RxData *rxData, //!< The pointer to the receiver data. 00349 GNSS_RxData *rxBaseData, //!< The pointer to the reference receiver data. NULL if not available. 00350 Matrix &subB, //!< The matrix that describes the differencing from SD to DD adr measurements 00351 const unsigned n, //!< The number of DD misclosures required. 00352 Matrix &w //!< The adr misclosure vector [n x 1]. 00353 ); 00354 00355 /// \brief Determine the usable GPS L1 Doppler measurements. 00356 /// \pre The rxData.m_ObsArray[i].flags values must be set 00357 /// properly including: \n 00358 /// rxData.m_ObsArray[i].flags.isCodeLocked \n 00359 /// rxData.m_ObsArray[i].flags.isDopplerValid \n 00360 /// rxData.m_ObsArray[i].flags.isAboveElevationMask \n 00361 /// rxData.m_ObsArray[i].flags.isAboveCNoMask \n 00362 /// rxData.m_ObsArray[i].flags.isAboveLockTimeMask \n 00363 /// rxData.m_ObsArray[i].flags.isNotUserRejected \n 00364 /// rxData.m_ObsArray[i].flags.isNotDopplerRejected \n 00365 /// rxData.m_ObsArray[i].flags.isEphemerisValid \n 00366 /// 00367 /// \post The rxData.m_ObsArray[i].flags.isDopplerUsedInSolution 00368 /// will be set to 1(used) or 0(not used). 00369 /// \return true if successful, false if error. 00370 bool DetermineUsableDopplerMeasurementsForTheVelocitySolution_GPSL1( 00371 GNSS_RxData &rxData, //!< The receiver data. 00372 unsigned &nrUsableDopplers //!< the number of usable GPS L1 Doppler measurements. 00373 ); 00374 00375 00376 /// \brief Compute the GPS L1 Doppler misclosures. 00377 /// 00378 /// \pre The folloing must be valid: \n 00379 /// rxData.m_ObsArray[i].flags.isDopplerUsedInSolution \n 00380 /// rxData.m_ObsArray[i].satellite.clkdrift \n 00381 /// rxData.m_ObsArray[i].rangerate \n 00382 /// rxData.m_pvt.clockDrift \n 00383 /// 00384 /// \post The following is set: \n 00385 /// rxData.m_ObsArray[i].doppler_misclosure \n 00386 /// 00387 /// \return true if successful, false if error. 00388 bool DetermineDopplerMisclosures_GPSL1( 00389 GNSS_RxData *rxData, //!< The pointer to the receiver data. 00390 GNSS_RxData *rxBaseData, //!< The pointer to the reference receiver data. NULL if not available. 00391 const unsigned n, //!< The number of misclosures. 00392 Matrix &w //!< The pseudorange misclosure vector [n x 1]. 00393 ); 00394 00395 00396 00397 /// \brief Determine the design matrix for the GPS L1 00398 /// velocity solution based on Doppler measurements. 00399 /// 00400 /// \pre The following must be valid: 00401 /// rxData.m_pvt 00402 /// rxData.m_ObsArray[i].satellite 00403 /// rxData.m_ObsArray[i].flags.isDopplerUsedInSolution 00404 /// 00405 /// \return true if successful, false if error. 00406 bool DetermineDesignMatrixForTheVelocitySolution_GPSL1( 00407 GNSS_RxData &rxData, //!< The receiver data. 00408 const unsigned nrUsableDopplers, //!< The number of usable GPS L1 Doppler measurements. 00409 Matrix &H //!< The velocity & rx clock drift design matrix [nD x 4]. 00410 ); 00411 00412 /// \brief Determine the measurement weight matrix for the GPS L1 00413 /// velocity solution based on Doppler measurement 00414 /// standard deviation values specified in 00415 /// rxData.m_ObsArray[i].stdev_doppler. 00416 /// 00417 /// \pre The following must be valid: \n 00418 /// rxData.m_ObsArray[i].flags.isDopplerUsedInSolution \n 00419 /// rxData.m_ObsArray[i].stdev_doppler (not zero) \n 00420 /// 00421 /// \return true if successful, false if error. 00422 bool DetermineMeasurementWeightMatrixForTheVelocitySolution_GPSL1( 00423 GNSS_RxData &rxData, //!< The receiver data. 00424 const unsigned n, //!< The number of rows in W. 00425 Matrix &W //!< The inverse of the Doppler measurement variance-coraiance matrix [n x n]. 00426 ); 00427 00428 /// \brief Determine the measurement variance-covariance matrix for 00429 /// the GPS L1 velocity solution based on Doppler measurement 00430 /// standard deviation values specified in 00431 /// rxData.m_ObsArray[i].stdev_doppler. 00432 /// 00433 /// \pre The following must be valid: \n 00434 /// rxData.m_ObsArray[i].flags.isDopplerUsedInSolution \n 00435 /// rxData.m_ObsArray[i].stdev_doppler (not zero) \n 00436 /// 00437 /// \return true if successful, false if error. 00438 bool DetermineMeasurementVarianceCovarianceMatrixForTheVelocitySolution_GPSL1( 00439 GNSS_RxData &rxData, //!< The receiver data. 00440 const unsigned n, //!< The number of rows in R. 00441 Matrix &R //!< The inverse of the Doppler measurement variance-coraiance matrix [n x n]. 00442 ); 00443 00444 00445 /// \brief Perform the Global Internal Reliability Test, followed by a 00446 /// search using local testing for a single measurement fault if 00447 /// the global test fails. 00448 /// 00449 /// The Global Internal Reliability Test: \n 00450 /// The aposteriori variance factor is computed and compared to the value 00451 /// generated using Chi^2 lookup table. The aposerteriori variance factor 00452 /// indicates the following: \n 00453 /// if( apv ~= 1 ) \n 00454 /// solution and observations are well modelled. \n 00455 /// if( apv < 1 ) \n 00456 /// observation variance matrix is pessimistic. \n 00457 /// (observations are better than what you said). \n 00458 /// if( apv > 1 ) \n 00459 /// (1) The math model incorrect, (not likely) 00460 /// (2) The weight matrix/observation variance matrix is optimistic 00461 /// (observations are worse than what you said). \n 00462 /// (3) Their is a blunder in the observations that is skewing the normality 00463 /// of the solution, and a local test for blunder my be needed. \n 00464 /// 00465 /// \return true if successful, false if error. 00466 bool PerformGlobalTestAndTestForMeasurementFaults( 00467 GNSS_RxData &rxData, //!< The receiver data object. 00468 bool testPsrOrDoppler, //!< This indicates if the psr misclosures are checked, otherwise the Doppler misclosures are checked. 00469 Matrix& H, //!< The design matrix, H, [n x u]. 00470 Matrix& Ht, //!< The design matrix transposed, H, [n x u]. 00471 Matrix& W, //!< The observation weight matrix, W, [n x n]. 00472 Matrix& R, //!< The observation variance-covariance matrix, R, [n x n]. 00473 Matrix& r, //!< The observation residual vector, [n x 1]. 00474 Matrix& P, //!< The state variance-covariance matrix, [u x u]. 00475 const unsigned char n, //!< The number of observations, n. 00476 const unsigned char u, //!< The number of unknowns, u. 00477 double &avf, //!< The computed a-posteriori variance factor is returned. 00478 bool &isGlobalTestPassed, //!< This indicates if the global test passed. 00479 bool &hasRejectionOccurred, //!< This indicates if a rejection occurred. Only one measurement is flagged. 00480 unsigned char &indexOfRejected //!< This is the index of the rejected observation. 00481 ); 00482 00483 00484 00485 00486 00487 bool ComputeTransitionMatrix_8StatePVGM( 00488 const double dT, //!< The change in time since the last update [s]. 00489 Matrix &T //!< The transition matrix [8 x 8]. 00490 ); 00491 00492 bool ComputeTransitionMatrix_8StatePVGM_Float( 00493 const double dT, //!< The change in time since the last update [s]. 00494 Matrix &T //!< The transition matrix [(8 + nrAmb) x (8 + nrAmb)]. 00495 ); 00496 00497 bool ComputeTransitionMatrix_6StatePVGM_Float( 00498 const double dT, //!< The change in time since the last update [s]. 00499 Matrix &T //!< The transition matrix [(8 + nrAmb) x (8 + nrAmb)]. 00500 ); 00501 00502 00503 bool ComputeProcessNoiseMatrix_8StatePVGM( 00504 const double dT, //!< The change in time since the last update [s]. 00505 Matrix &Q //!< The process noise matrix [8 x 8]. 00506 ); 00507 00508 bool ComputeProcessNoiseMatrix_8StatePVGM_Float( 00509 const double dT, //!< The change in time since the last update [s]. 00510 Matrix &Q //!< The process noise matrix [(8 + nrAmb) x (8 + nrAmb)]. 00511 ); 00512 00513 bool ComputeProcessNoiseMatrix_6StatePVGM_Float( 00514 const double dT, //!< The change in time since the last update [s]. 00515 Matrix &Q //!< The process noise matrix [(8 + nrAmb) x (8 + nrAmb)]. 00516 ); 00517 00518 00519 00520 00521 /// \brief Initialize the state variance-covariance matrix 00522 /// for the 8 state PV Gauss Markov model. 00523 /// 00524 /// \return true if successful, false if error. 00525 bool InitializeStateVarianceCovariance_8StatePVGM( 00526 const double std_lat, //!< The standard deviation uncertainty in the latitude [m]. 00527 const double std_lon, //!< The standard deviation uncertainty in the longitude [m]. 00528 const double std_hgt, //!< The standard deviation uncertainty in the height [m]. 00529 const double std_vn, //!< The standard deviation uncertainty in the northing velocity [m/s]. 00530 const double std_ve, //!< The standard deviation uncertainty in the easting velocity [m/s]. 00531 const double std_vup, //!< The standard deviation uncertainty in the up velocity [m/s]. 00532 const double std_clk, //!< The standard deviation uncertainty in the clock offset [m]. 00533 const double std_clkdrift, //!< The standard deviation uncertainty in the clock drift [m/s]. 00534 Matrix &P //!< The variance covariance of the states [8x8]. 00535 ); 00536 00537 /// \brief Initialize the state variance-covariance matrix 00538 /// for the 6 state PV Gauss Markov model. 00539 /// 00540 /// \return true if successful, false if error. 00541 bool InitializeStateVarianceCovariance_6StatePVGM( 00542 const double std_lat, //!< The standard deviation uncertainty in the latitude [m]. 00543 const double std_lon, //!< The standard deviation uncertainty in the longitude [m]. 00544 const double std_hgt, //!< The standard deviation uncertainty in the height [m]. 00545 const double std_vn, //!< The standard deviation uncertainty in the northing velocity [m/s]. 00546 const double std_ve, //!< The standard deviation uncertainty in the easting velocity [m/s]. 00547 const double std_vup, //!< The standard deviation uncertainty in the up velocity [m/s]. 00548 Matrix &P //!< The variance covariance of the states [6x6]. 00549 ); 00550 00551 00552 00553 bool PredictAhead_8StatePVGM( 00554 GNSS_RxData &rxData, //!< The receiver data. 00555 const double dT, //!< The change in time since the last update [s]. 00556 Matrix &T, //!< The transition matrix [8 x 8] (output). 00557 Matrix &Q, //!< The process noise matrix [8 x 8] (output). 00558 Matrix &P //!< The state variance covariance matrix [8 x 8] (input/output). 00559 ); 00560 00561 bool PredictAhead_8StatePVGM_Float( 00562 GNSS_RxData &rxData, //!< The receiver data. 00563 const double dT, //!< The change in time since the last update [s]. 00564 Matrix &T, //!< The transition matrix [(8 + nrAmb) x (8 + nrAmb)] (output). 00565 Matrix &Q, //!< The process noise matrix [(8 + nrAmb) x (8 + nrAmb)] (output). 00566 Matrix &P //!< The state variance covariance matrix [(8 + nrAmb) x (8 + nrAmb)] (input/output). 00567 ); 00568 00569 bool PredictAhead_6StatePVGM_Float( 00570 GNSS_RxData &rxData, //!< The receiver data. 00571 const double dT, //!< The change in time since the last update [s]. 00572 Matrix &T, //!< The transition matrix [(8 + nrAmb) x (8 + nrAmb)] (output). 00573 Matrix &Q, //!< The process noise matrix [(8 + nrAmb) x (8 + nrAmb)] (output). 00574 Matrix &P //!< The state variance covariance matrix [(8 + nrAmb) x (8 + nrAmb)] (input/output). 00575 ); 00576 00577 00578 00579 00580 bool Kalman_Update_8StatePVGM( 00581 GNSS_RxData *rxData, //!< A pointer to the rover receiver data. This must be a valid pointer. 00582 GNSS_RxData *rxBaseData, //!< A pointer to the reference receiver data if available. NULL if not available. 00583 Matrix &P //!< The variance-covariance of the states. 00584 ); 00585 00586 bool Kalman_Update_8StatePVGM_SequentialMode( 00587 GNSS_RxData *rxData, //!< A pointer to the rover receiver data. This must be a valid pointer. 00588 GNSS_RxData *rxBaseData, //!< A pointer to the reference receiver data if available. NULL if not available. 00589 Matrix &P //!< The variance-covariance of the states. 00590 ); 00591 00592 00593 bool Kalman_Update_8StatePVGM_SequentialMode_FloatSolution( 00594 GNSS_RxData *rxData, //!< A pointer to the rover receiver data. This must be a valid pointer. 00595 GNSS_RxData *rxBaseData, //!< A pointer to the reference receiver data if available. NULL if not available. 00596 Matrix &P //!< The variance-covariance of the states. 00597 ); 00598 00599 bool Kalman_Update_6StatePVGM_FloatSolution( 00600 GNSS_RxData *rxData, //!< A pointer to the rover receiver data. This must be a valid pointer. 00601 GNSS_RxData *rxBaseData, //!< A pointer to the reference receiver data if available. NULL if not available. 00602 Matrix &P //!< The variance-covariance of the states. 00603 ); 00604 00605 00606 /// \brief Fix ambiguities, right now does nothing. 00607 /// 00608 /// \return true if successful, false if error. 00609 bool FixAmbiguities(); 00610 00611 00612 00613 /// \brief Update the rest of m_pvt.time struct based on the 00614 /// gps week and time of week only. 00615 /// 00616 /// \return true if successful, false if error. 00617 bool UpdateTime( 00618 GNSS_RxData &rxData //!< The receiver data. The m_pvt.time struct is updated. 00619 ); 00620 00621 00622 /// \brief Perform least squares using pseudoranges and Doppler 00623 /// measurments to determine the eight states: 00624 /// (lat,lon,hgt,vn,ve,vup,clk,clkdrift). 00625 /// 00626 /// \return true if successful, false if error. 00627 bool PerformLeastSquares_8StatePVT( 00628 GNSS_RxData *rxData, //!< A pointer to the rover receiver data. This must be a valid pointer. 00629 GNSS_RxData *rxBaseData, //!< A pointer to the reference receiver data if available. NULL if not available. 00630 bool &wasPositionComputed, //!< A boolean to indicate if a position solution was computed. 00631 bool &wasVelocityComputed //!< A boolean to indicate if a velocity solution was computed. 00632 ); 00633 00634 00635 /// \brief A static function for outputting a matrix to the console. 00636 bool PrintMatToDebug( const char *name, Matrix& M ); 00637 00638 00639 00640 /// \brief Deal with changes in ambiguities. Remove the 00641 /// rows and columns from P of the ambiguities that 00642 /// are no longer active. Add rows and columns to P 00643 /// for new ambiguities. 00644 /// 00645 /// \return true if successful, false if error. 00646 bool DetermineAmbiguitiesChanges( 00647 GNSS_RxData *rxData, //!< Pointer to the receiver data. 00648 GNSS_RxData *rxBaseData, //!< Pointer to the reference receiver data if any (NULL if not available). 00649 Matrix &P, //!< The state variance-covariance matrix. 00650 bool& changeOccured 00651 ); 00652 00653 // Publically accessable data 00654 public: 00655 00656 // number of unknown paramters: u 00657 // number of observations: n 00658 00659 struct stLSQ 00660 { 00661 Matrix x; //!< The states, [u x 1]. 00662 Matrix dx; //!< The iterative update to the states, [u x 1]. 00663 Matrix P; //!< The states variance-covariance matrix, [u x u]. 00664 Matrix H; //!< The design matrix, [n x u]. 00665 Matrix w; //!< The observation misclosure vector, [n x 1]. 00666 Matrix R; //!< The variance covariance matrix of the observations, [n x n]. 00667 Matrix W; //!< The inverse of m_R, [n x n]. 00668 Matrix r; //!< The diagonal of the observations variance-covariance matrix, [n x 1]. 00669 }; 00670 00671 struct stRTK 00672 { 00673 Matrix x; //!< The states, [u x 1]. 00674 Matrix dx; //!< The iterative update to the states, [u x 1]. 00675 Matrix P; //!< The states variance-covariance matrix, [u x u]. 00676 Matrix H; //!< The design matrix, [n x u]. 00677 Matrix w; //!< The observation misclosure vector, [n x 1]. 00678 Matrix R; //!< The variance covariance matrix of the observations, [n x n]. 00679 Matrix W; //!< The inverse of m_R, [n x n]. 00680 Matrix r; //!< The diagonal of the observations variance-covariance matrix, [n x 1]. 00681 Matrix T; //!< The transition matrix, [u x u]. 00682 Matrix Q; //!< The process noise matrix, [u x u]. 00683 }; 00684 00685 struct stRTKDD 00686 { 00687 Matrix x; //!< The states, [u x 1]. 00688 Matrix dx; //!< The iterative update to the states, [u x 1]. 00689 Matrix P; //!< The states variance-covariance matrix, [u x u]. 00690 Matrix H; //!< The design matrix, [n x u]. 00691 Matrix w; //!< The observation misclosure vector, [n x 1]. 00692 Matrix R; //!< The variance covariance matrix of the observations, [n x n]. 00693 Matrix W; //!< The inverse of m_R, [n x n]. 00694 Matrix r; //!< The diagonal of the observations variance-covariance matrix, [n x 1]. 00695 Matrix T; //!< The transition matrix, [u x u]. 00696 Matrix Q; //!< The process noise matrix, [u x u]. 00697 Matrix B; //!< The double difference operator matrix. [n x n-1/2/3]. 00698 Matrix prevB; //!< The previous double difference operator matrix. [n_prev x n_prev-1/2/3]. 00699 Matrix SubB; //!< The double difference operator matrix for just ambiguities. 00700 Matrix prevSubB; //!< The previuos double difference operator matrix just ambiguities. 00701 }; 00702 00703 struct stKalmanModel 00704 { 00705 double alphaVn; 00706 double alphaVe; 00707 double alphaVup; 00708 double alphaClkDrift; 00709 double sigmaVn; 00710 double sigmaVe; 00711 double sigmaVup; 00712 double sigmaClkDrift; 00713 00714 // default constructor 00715 stKalmanModel() 00716 : alphaVn(100.0), 00717 alphaVe(100.0), 00718 alphaVup(100.0), 00719 alphaClkDrift(100.0), 00720 sigmaVn(0.01), 00721 sigmaVe(0.01), 00722 sigmaVup(0.01), 00723 sigmaClkDrift(0.01) 00724 {} 00725 }; 00726 00727 stLSQ m_posLSQ; //!< The Least Sqaures estimation matrix information for the position and clock offset solution. 00728 stLSQ m_velLSQ; //!< The Least Sqaures estimation matrix information for the velocity and clock drift solution. 00729 00730 stRTK m_RTK; //!< The RTK estimation matrix information. 00731 stRTKDD m_RTKDD; //!< The double difference RTK estimation matrix information. 00732 00733 00734 /// Kalman filter model settings for 1st order Gauss Markov 00735 /// Velocity/ClkDrift states. 8 state PVGM model. 00736 stKalmanModel m_KF; 00737 00738 00739 struct stAmbiguityInfo 00740 { 00741 unsigned short channel; //!< The channel number associated with this measurement. 00742 unsigned short id; //!< The unique id for this channel (eg PRN for GPS). 00743 int state_index; //!< The index of the corresponding row and column of the state variance-covariance matrix. -1 means not estimated. 00744 int state_index_dd; //!< The index of the corresponding row and column of the state variance-covariance matrix for the double difference case. -1 means not estimated. 00745 GNSS_enumSystem system; //!< The satellite system associated with this channel. 00746 GNSS_enumFrequency freqType; //!< The frequency type for this channel. 00747 // GDM most recent ambiguity estimate 00748 // GDM time of last above 00749 // GDM flag indicating amb reset 00750 // GDM quality indicator? 00751 stAmbiguityInfo() 00752 : channel(0),id(0),state_index(-1),state_index_dd(-1) 00753 {} 00754 }; 00755 00756 /// This list keeps track of which amibiguities are active. i.e. already included in the state vector 00757 /// and state variance-covariance matrix. 00758 /// GDM store in RxData? 00759 std::list<stAmbiguityInfo> m_ActiveAmbiguitiesList; 00760 00761 protected: 00762 00763 Matrix HtW; //!< The design matrix, H, transposed times W u x n. 00764 Matrix Ninv; //!< The inverse of the normal matrix, N = (H^T*W*H)^-1, u x u. 00765 00766 FILE* m_debug; 00767 }; 00768 00769 } // end namespace GNSS 00770 00771 #endif // _GNSS_ESTIMATOR_H_ 00772