| 1 | // Part of BNC, a utility for retrieving decoding and
|
|---|
| 2 | // converting GNSS data streams from NTRIP broadcasters.
|
|---|
| 3 | //
|
|---|
| 4 | // Copyright (C) 2007
|
|---|
| 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
|---|
| 6 | // http://www.bkg.bund.de
|
|---|
| 7 | // Czech Technical University Prague, Department of Geodesy
|
|---|
| 8 | // http://www.fsv.cvut.cz
|
|---|
| 9 | //
|
|---|
| 10 | // Email: euref-ip@bkg.bund.de
|
|---|
| 11 | //
|
|---|
| 12 | // This program is free software; you can redistribute it and/or
|
|---|
| 13 | // modify it under the terms of the GNU General Public License
|
|---|
| 14 | // as published by the Free Software Foundation, version 2.
|
|---|
| 15 | //
|
|---|
| 16 | // This program is distributed in the hope that it will be useful,
|
|---|
| 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 19 | // GNU General Public License for more details.
|
|---|
| 20 | //
|
|---|
| 21 | // You should have received a copy of the GNU General Public License
|
|---|
| 22 | // along with this program; if not, write to the Free Software
|
|---|
| 23 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|---|
| 24 |
|
|---|
| 25 | /* -------------------------------------------------------------------------
|
|---|
| 26 | * BKG NTRIP Client
|
|---|
| 27 | * -------------------------------------------------------------------------
|
|---|
| 28 | *
|
|---|
| 29 | * Class: t_pppParam, t_pppFilter
|
|---|
| 30 | *
|
|---|
| 31 | * Purpose: Model for PPP
|
|---|
| 32 | *
|
|---|
| 33 | * Author: L. Mervart
|
|---|
| 34 | *
|
|---|
| 35 | * Created: 01-Dec-2009
|
|---|
| 36 | *
|
|---|
| 37 | * Changes:
|
|---|
| 38 | *
|
|---|
| 39 | * -----------------------------------------------------------------------*/
|
|---|
| 40 |
|
|---|
| 41 | #include <iomanip>
|
|---|
| 42 | #include <cmath>
|
|---|
| 43 | #include <sstream>
|
|---|
| 44 | #include <newmatio.h>
|
|---|
| 45 | #include <newmatap.h>
|
|---|
| 46 |
|
|---|
| 47 | #include "pppFilter.h"
|
|---|
| 48 | #include "pppClient.h"
|
|---|
| 49 | #include "bncutils.h"
|
|---|
| 50 | #include "bncantex.h"
|
|---|
| 51 | #include "pppOptions.h"
|
|---|
| 52 | #include "pppModel.h"
|
|---|
| 53 |
|
|---|
| 54 | using namespace BNC_PPP;
|
|---|
| 55 | using namespace std;
|
|---|
| 56 |
|
|---|
| 57 | const double GLONASS_WEIGHT_FACTOR = 5.0;
|
|---|
| 58 | const double BDS_WEIGHT_FACTOR = 2.0; // 5.0;
|
|---|
| 59 |
|
|---|
| 60 | #define LOG (_pppClient->log())
|
|---|
| 61 | #define OPT (_pppClient->opt())
|
|---|
| 62 |
|
|---|
| 63 | // Constructor
|
|---|
| 64 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 65 | t_pppParam::t_pppParam(t_pppParam::parType typeIn, int indexIn,
|
|---|
| 66 | const QString& prnIn) {
|
|---|
| 67 | type = typeIn;
|
|---|
| 68 | index = indexIn;
|
|---|
| 69 | prn = prnIn;
|
|---|
| 70 | index_old = 0;
|
|---|
| 71 | xx = 0.0;
|
|---|
| 72 | numEpo = 0;
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | // Destructor
|
|---|
| 76 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 77 | t_pppParam::~t_pppParam() {
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | // Partial
|
|---|
| 81 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 82 | double t_pppParam::partial(t_satData* satData, bool phase) {
|
|---|
| 83 |
|
|---|
| 84 | Tracer tracer("t_pppParam::partial");
|
|---|
| 85 |
|
|---|
| 86 | // Coordinates
|
|---|
| 87 | // -----------
|
|---|
| 88 | if (type == CRD_X) {
|
|---|
| 89 | return (xx - satData->xx(1)) / satData->rho;
|
|---|
| 90 | }
|
|---|
| 91 | else if (type == CRD_Y) {
|
|---|
| 92 | return (xx - satData->xx(2)) / satData->rho;
|
|---|
| 93 | }
|
|---|
| 94 | else if (type == CRD_Z) {
|
|---|
| 95 | return (xx - satData->xx(3)) / satData->rho;
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | // Receiver Clocks
|
|---|
| 99 | // ---------------
|
|---|
| 100 | else if (type == RECCLK) {
|
|---|
| 101 | return 1.0;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | // Troposphere
|
|---|
| 105 | // -----------
|
|---|
| 106 | else if (type == TROPO) {
|
|---|
| 107 | return 1.0 / sin(satData->eleSat);
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | // Glonass Offset
|
|---|
| 111 | // --------------
|
|---|
| 112 | else if (type == GLONASS_OFFSET) {
|
|---|
| 113 | if (satData->prn[0] == 'R') {
|
|---|
| 114 | return 1.0;
|
|---|
| 115 | }
|
|---|
| 116 | else {
|
|---|
| 117 | return 0.0;
|
|---|
| 118 | }
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | // Galileo Offset
|
|---|
| 122 | // --------------
|
|---|
| 123 | else if (type == GALILEO_OFFSET) {
|
|---|
| 124 | if (satData->prn[0] == 'E') {
|
|---|
| 125 | return 1.0;
|
|---|
| 126 | }
|
|---|
| 127 | else {
|
|---|
| 128 | return 0.0;
|
|---|
| 129 | }
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 | // BDS Offset
|
|---|
| 133 | // ----------
|
|---|
| 134 | else if (type == BDS_OFFSET) {
|
|---|
| 135 | if (satData->prn[0] == 'C') {
|
|---|
| 136 | return 1.0;
|
|---|
| 137 | }
|
|---|
| 138 | else {
|
|---|
| 139 | return 0.0;
|
|---|
| 140 | }
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 | // Ambiguities
|
|---|
| 144 | // -----------
|
|---|
| 145 | else if (type == AMB_L3) {
|
|---|
| 146 | if (phase && satData->prn == prn) {
|
|---|
| 147 | return 1.0;
|
|---|
| 148 | }
|
|---|
| 149 | else {
|
|---|
| 150 | return 0.0;
|
|---|
| 151 | }
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 | // Default return
|
|---|
| 155 | // --------------
|
|---|
| 156 | return 0.0;
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 | // Constructor
|
|---|
| 160 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 161 | t_pppFilter::t_pppFilter(t_pppClient* pppClient) {
|
|---|
| 162 |
|
|---|
| 163 | _pppClient = pppClient;
|
|---|
| 164 | _tides = new t_tides();
|
|---|
| 165 |
|
|---|
| 166 | // Antenna Name, ANTEX File
|
|---|
| 167 | // ------------------------
|
|---|
| 168 | _antex = 0;
|
|---|
| 169 | if (!OPT->_antexFileName.empty()) {
|
|---|
| 170 | _antex = new bncAntex(OPT->_antexFileName.c_str());
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | // Bancroft Coordinates
|
|---|
| 174 | // --------------------
|
|---|
| 175 | _xcBanc.ReSize(4); _xcBanc = 0.0;
|
|---|
| 176 | _ellBanc.ReSize(3); _ellBanc = 0.0;
|
|---|
| 177 |
|
|---|
| 178 | // Save copy of data (used in outlier detection)
|
|---|
| 179 | // ---------------------------------------------
|
|---|
| 180 | _epoData_sav = new t_epoData();
|
|---|
| 181 |
|
|---|
| 182 | // Some statistics
|
|---|
| 183 | // ---------------
|
|---|
| 184 | _neu.ReSize(3); _neu = 0.0;
|
|---|
| 185 | _numSat = 0;
|
|---|
| 186 | _hDop = 0.0;
|
|---|
| 187 | }
|
|---|
| 188 |
|
|---|
| 189 | // Destructor
|
|---|
| 190 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 191 | t_pppFilter::~t_pppFilter() {
|
|---|
| 192 | delete _tides;
|
|---|
| 193 | delete _antex;
|
|---|
| 194 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 195 | delete _params[iPar-1];
|
|---|
| 196 | }
|
|---|
| 197 | for (int iPar = 1; iPar <= _params_sav.size(); iPar++) {
|
|---|
| 198 | delete _params_sav[iPar-1];
|
|---|
| 199 | }
|
|---|
| 200 | delete _epoData_sav;
|
|---|
| 201 | }
|
|---|
| 202 |
|
|---|
| 203 | // Reset Parameters and Variance-Covariance Matrix
|
|---|
| 204 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 205 | void t_pppFilter::reset() {
|
|---|
| 206 |
|
|---|
| 207 | Tracer tracer("t_pppFilter::reset");
|
|---|
| 208 |
|
|---|
| 209 | double lastTrp = 0.0;
|
|---|
| 210 | for (int ii = 0; ii < _params.size(); ii++) {
|
|---|
| 211 | t_pppParam* pp = _params[ii];
|
|---|
| 212 | if (pp->type == t_pppParam::TROPO) {
|
|---|
| 213 | lastTrp = pp->xx;
|
|---|
| 214 | }
|
|---|
| 215 | delete pp;
|
|---|
| 216 | }
|
|---|
| 217 | _params.clear();
|
|---|
| 218 |
|
|---|
| 219 | int nextPar = 0;
|
|---|
| 220 | _params.push_back(new t_pppParam(t_pppParam::CRD_X, ++nextPar, ""));
|
|---|
| 221 | _params.push_back(new t_pppParam(t_pppParam::CRD_Y, ++nextPar, ""));
|
|---|
| 222 | _params.push_back(new t_pppParam(t_pppParam::CRD_Z, ++nextPar, ""));
|
|---|
| 223 | _params.push_back(new t_pppParam(t_pppParam::RECCLK, ++nextPar, ""));
|
|---|
| 224 | if (OPT->estTrp()) {
|
|---|
| 225 | _params.push_back(new t_pppParam(t_pppParam::TROPO, ++nextPar, ""));
|
|---|
| 226 | }
|
|---|
| 227 | if (OPT->useSystem('R')) {
|
|---|
| 228 | _params.push_back(new t_pppParam(t_pppParam::GLONASS_OFFSET, ++nextPar, ""));
|
|---|
| 229 | }
|
|---|
| 230 | if (OPT->useSystem('E')) {
|
|---|
| 231 | _params.push_back(new t_pppParam(t_pppParam::GALILEO_OFFSET, ++nextPar, ""));
|
|---|
| 232 | }
|
|---|
| 233 | if (OPT->useSystem('C')) {
|
|---|
| 234 | _params.push_back(new t_pppParam(t_pppParam::BDS_OFFSET, ++nextPar, ""));
|
|---|
| 235 | }
|
|---|
| 236 |
|
|---|
| 237 | _QQ.ReSize(_params.size());
|
|---|
| 238 | _QQ = 0.0;
|
|---|
| 239 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 240 | t_pppParam* pp = _params[iPar-1];
|
|---|
| 241 | pp->xx = 0.0;
|
|---|
| 242 | if (pp->isCrd()) {
|
|---|
| 243 | _QQ(iPar,iPar) = OPT->_aprSigCrd(1) * OPT->_aprSigCrd(1);
|
|---|
| 244 | }
|
|---|
| 245 | else if (pp->type == t_pppParam::RECCLK) {
|
|---|
| 246 | _QQ(iPar,iPar) = OPT->_noiseClk * OPT->_noiseClk;
|
|---|
| 247 | }
|
|---|
| 248 | else if (pp->type == t_pppParam::TROPO) {
|
|---|
| 249 | _QQ(iPar,iPar) = OPT->_aprSigTrp * OPT->_aprSigTrp;
|
|---|
| 250 | pp->xx = lastTrp;
|
|---|
| 251 | }
|
|---|
| 252 | else if (pp->type == t_pppParam::GLONASS_OFFSET) {
|
|---|
| 253 | _QQ(iPar,iPar) = 1000.0 * 1000.0;
|
|---|
| 254 | }
|
|---|
| 255 | else if (pp->type == t_pppParam::GALILEO_OFFSET) {
|
|---|
| 256 | _QQ(iPar,iPar) = 1000.0 * 1000.0;
|
|---|
| 257 | }
|
|---|
| 258 | else if (pp->type == t_pppParam::BDS_OFFSET) {
|
|---|
| 259 | _QQ(iPar,iPar) = 1000.0 * 1000.0;
|
|---|
| 260 | }
|
|---|
| 261 | }
|
|---|
| 262 | }
|
|---|
| 263 |
|
|---|
| 264 | // Bancroft Solution
|
|---|
| 265 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 266 | t_irc t_pppFilter::cmpBancroft(t_epoData* epoData) {
|
|---|
| 267 |
|
|---|
| 268 | Tracer tracer("t_pppFilter::cmpBancroft");
|
|---|
| 269 |
|
|---|
| 270 | if (int(epoData->sizeSys('G')) < OPT->_minObs) {
|
|---|
| 271 | LOG << "t_pppFilter::cmpBancroft: not enough data\n";
|
|---|
| 272 | return failure;
|
|---|
| 273 | }
|
|---|
| 274 |
|
|---|
| 275 | Matrix BB(epoData->sizeSys('G'), 4);
|
|---|
| 276 |
|
|---|
| 277 | QMapIterator<QString, t_satData*> it(epoData->satData);
|
|---|
| 278 | int iObsBanc = 0;
|
|---|
| 279 | while (it.hasNext()) {
|
|---|
| 280 | it.next();
|
|---|
| 281 | t_satData* satData = it.value();
|
|---|
| 282 | if (satData->system() == 'G') {
|
|---|
| 283 | ++iObsBanc;
|
|---|
| 284 | QString prn = it.key();
|
|---|
| 285 | BB(iObsBanc, 1) = satData->xx(1);
|
|---|
| 286 | BB(iObsBanc, 2) = satData->xx(2);
|
|---|
| 287 | BB(iObsBanc, 3) = satData->xx(3);
|
|---|
| 288 | BB(iObsBanc, 4) = satData->P3 + satData->clk;
|
|---|
| 289 | }
|
|---|
| 290 | }
|
|---|
| 291 |
|
|---|
| 292 | bancroft(BB, _xcBanc);
|
|---|
| 293 |
|
|---|
| 294 | if (std::isnan(_xcBanc(1)) ||
|
|---|
| 295 | std::isnan(_xcBanc(2)) ||
|
|---|
| 296 | std::isnan(_xcBanc(3))) {
|
|---|
| 297 | return failure;
|
|---|
| 298 | }
|
|---|
| 299 |
|
|---|
| 300 | // Ellipsoidal Coordinates
|
|---|
| 301 | // ------------------------
|
|---|
| 302 | xyz2ell(_xcBanc.data(), _ellBanc.data());
|
|---|
| 303 |
|
|---|
| 304 | // Compute Satellite Elevations
|
|---|
| 305 | // ----------------------------
|
|---|
| 306 | QMutableMapIterator<QString, t_satData*> im(epoData->satData);
|
|---|
| 307 | while (im.hasNext()) {
|
|---|
| 308 | im.next();
|
|---|
| 309 | t_satData* satData = im.value();
|
|---|
| 310 | cmpEle(satData);
|
|---|
| 311 | if (satData->eleSat < OPT->_minEle) {
|
|---|
| 312 | delete satData;
|
|---|
| 313 | im.remove();
|
|---|
| 314 | }
|
|---|
| 315 | }
|
|---|
| 316 |
|
|---|
| 317 | return success;
|
|---|
| 318 | }
|
|---|
| 319 |
|
|---|
| 320 | // Computed Value
|
|---|
| 321 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 322 | double t_pppFilter::cmpValue(t_satData* satData, bool phase) {
|
|---|
| 323 |
|
|---|
| 324 | Tracer tracer("t_pppFilter::cmpValue");
|
|---|
| 325 |
|
|---|
| 326 | ColumnVector xRec(3);
|
|---|
| 327 | xRec(1) = x();
|
|---|
| 328 | xRec(2) = y();
|
|---|
| 329 | xRec(3) = z();
|
|---|
| 330 |
|
|---|
| 331 | double rho0 = (satData->xx - xRec).norm_Frobenius();
|
|---|
| 332 | double dPhi = t_CST::omega * rho0 / t_CST::c;
|
|---|
| 333 |
|
|---|
| 334 | xRec(1) = x() * cos(dPhi) - y() * sin(dPhi);
|
|---|
| 335 | xRec(2) = y() * cos(dPhi) + x() * sin(dPhi);
|
|---|
| 336 | xRec(3) = z();
|
|---|
| 337 |
|
|---|
| 338 | xRec += _tides->displacement(_time, xRec);
|
|---|
| 339 |
|
|---|
| 340 | satData->rho = (satData->xx - xRec).norm_Frobenius();
|
|---|
| 341 |
|
|---|
| 342 | double tropDelay = delay_saast(satData->eleSat) +
|
|---|
| 343 | trp() / sin(satData->eleSat);
|
|---|
| 344 |
|
|---|
| 345 | double wind = 0.0;
|
|---|
| 346 | if (phase) {
|
|---|
| 347 | wind = windUp(satData->prn, satData->xx, xRec) * satData->lambda3;
|
|---|
| 348 | }
|
|---|
| 349 |
|
|---|
| 350 | double offset = 0.0;
|
|---|
| 351 |
|
|---|
| 352 | t_frequency::type frqA;
|
|---|
| 353 | t_frequency::type frqB;
|
|---|
| 354 |
|
|---|
| 355 | if (satData->prn[0] == 'R') {
|
|---|
| 356 | offset = Glonass_offset();
|
|---|
| 357 | frqA = t_frequency::R1;
|
|---|
| 358 | frqB = t_frequency::R2;
|
|---|
| 359 | }
|
|---|
| 360 | else if (satData->prn[0] == 'E') {
|
|---|
| 361 | offset = Galileo_offset();
|
|---|
| 362 | frqA = t_frequency::E1;
|
|---|
| 363 | frqB = t_frequency::E5;
|
|---|
| 364 | }
|
|---|
| 365 | else if (satData->prn[0] == 'C') {
|
|---|
| 366 | offset = Bds_offset();
|
|---|
| 367 | frqA = t_frequency::C2;
|
|---|
| 368 | frqB = t_frequency::C6;
|
|---|
| 369 | }
|
|---|
| 370 | else {
|
|---|
| 371 | frqA = t_frequency::G1;
|
|---|
| 372 | frqB = t_frequency::G2;
|
|---|
| 373 | }
|
|---|
| 374 |
|
|---|
| 375 | double phaseCenter = 0.0;
|
|---|
| 376 |
|
|---|
| 377 | if (_antex) {
|
|---|
| 378 | bool found;
|
|---|
| 379 | phaseCenter = satData->lkA * _antex->rcvCorr(OPT->_antNameRover, frqA,
|
|---|
| 380 | satData->eleSat, satData->azSat,
|
|---|
| 381 | found)
|
|---|
| 382 | + satData->lkB * _antex->rcvCorr(OPT->_antNameRover, frqB,
|
|---|
| 383 | satData->eleSat, satData->azSat,
|
|---|
| 384 | found);
|
|---|
| 385 | if (!found) {
|
|---|
| 386 | LOG << "ANTEX: antenna >" << OPT->_antNameRover << "< not found\n";
|
|---|
| 387 | }
|
|---|
| 388 | }
|
|---|
| 389 |
|
|---|
| 390 | double antennaOffset = 0.0;
|
|---|
| 391 | double cosa = cos(satData->azSat);
|
|---|
| 392 | double sina = sin(satData->azSat);
|
|---|
| 393 | double cose = cos(satData->eleSat);
|
|---|
| 394 | double sine = sin(satData->eleSat);
|
|---|
| 395 | antennaOffset = -OPT->_neuEccRover(1) * cosa*cose
|
|---|
| 396 | -OPT->_neuEccRover(2) * sina*cose
|
|---|
| 397 | -OPT->_neuEccRover(3) * sine;
|
|---|
| 398 |
|
|---|
| 399 | return satData->rho + phaseCenter + antennaOffset + clk()
|
|---|
| 400 | + offset - satData->clk + tropDelay + wind;
|
|---|
| 401 | }
|
|---|
| 402 |
|
|---|
| 403 | // Tropospheric Model (Saastamoinen)
|
|---|
| 404 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 405 | double t_pppFilter::delay_saast(double Ele) {
|
|---|
| 406 |
|
|---|
| 407 | Tracer tracer("t_pppFilter::delay_saast");
|
|---|
| 408 |
|
|---|
| 409 | double xyz[3];
|
|---|
| 410 | xyz[0] = x();
|
|---|
| 411 | xyz[1] = y();
|
|---|
| 412 | xyz[2] = z();
|
|---|
| 413 | double ell[3];
|
|---|
| 414 | xyz2ell(xyz, ell);
|
|---|
| 415 | double height = ell[2];
|
|---|
| 416 | // Prevent pp from causing segmentation fault (Loukis)
|
|---|
| 417 | if (height > 40000.0 ) {
|
|---|
| 418 | return 0.000000001;
|
|---|
| 419 | }
|
|---|
| 420 |
|
|---|
| 421 | double pp = 1013.25 * pow(1.0 - 2.26e-5 * height, 5.225);
|
|---|
| 422 | double TT = 18.0 - height * 0.0065 + 273.15;
|
|---|
| 423 | double hh = 50.0 * exp(-6.396e-4 * height);
|
|---|
| 424 | double ee = hh / 100.0 * exp(-37.2465 + 0.213166*TT - 0.000256908*TT*TT);
|
|---|
| 425 |
|
|---|
| 426 | double h_km = height / 1000.0;
|
|---|
| 427 |
|
|---|
| 428 | if (h_km < 0.0) h_km = 0.0;
|
|---|
| 429 | if (h_km > 5.0) h_km = 5.0;
|
|---|
| 430 | int ii = int(h_km + 1);
|
|---|
| 431 | double href = ii - 1;
|
|---|
| 432 |
|
|---|
| 433 | double bCor[6];
|
|---|
| 434 | bCor[0] = 1.156;
|
|---|
| 435 | bCor[1] = 1.006;
|
|---|
| 436 | bCor[2] = 0.874;
|
|---|
| 437 | bCor[3] = 0.757;
|
|---|
| 438 | bCor[4] = 0.654;
|
|---|
| 439 | bCor[5] = 0.563;
|
|---|
| 440 |
|
|---|
| 441 | double BB = bCor[ii-1] + (bCor[ii]-bCor[ii-1]) * (h_km - href);
|
|---|
| 442 |
|
|---|
| 443 | double zen = M_PI/2.0 - Ele;
|
|---|
| 444 |
|
|---|
| 445 | return (0.002277/cos(zen)) * (pp + ((1255.0/TT)+0.05)*ee - BB*(tan(zen)*tan(zen)));
|
|---|
| 446 | }
|
|---|
| 447 |
|
|---|
| 448 | // Prediction Step of the Filter
|
|---|
| 449 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 450 | void t_pppFilter::predict(int iPhase, t_epoData* epoData) {
|
|---|
| 451 |
|
|---|
| 452 | Tracer tracer("t_pppFilter::predict");
|
|---|
| 453 |
|
|---|
| 454 | if (iPhase == 0) {
|
|---|
| 455 |
|
|---|
| 456 | const double maxSolGap = 60.0;
|
|---|
| 457 |
|
|---|
| 458 | bool firstCrd = false;
|
|---|
| 459 | if (!_lastTimeOK.valid() || (maxSolGap > 0.0 && _time - _lastTimeOK > maxSolGap)) {
|
|---|
| 460 | firstCrd = true;
|
|---|
| 461 | _startTime = epoData->tt;
|
|---|
| 462 | reset();
|
|---|
| 463 | }
|
|---|
| 464 |
|
|---|
| 465 | // Use different white noise for Quick-Start mode
|
|---|
| 466 | // ----------------------------------------------
|
|---|
| 467 | double sigCrdP_used = OPT->_noiseCrd(1);
|
|---|
| 468 | if ( OPT->_seedingTime > 0.0 && OPT->_seedingTime > (epoData->tt - _startTime) ) {
|
|---|
| 469 | sigCrdP_used = 0.0;
|
|---|
| 470 | }
|
|---|
| 471 |
|
|---|
| 472 | // Predict Parameter values, add white noise
|
|---|
| 473 | // -----------------------------------------
|
|---|
| 474 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 475 | t_pppParam* pp = _params[iPar-1];
|
|---|
| 476 |
|
|---|
| 477 | // Coordinates
|
|---|
| 478 | // -----------
|
|---|
| 479 | if (pp->type == t_pppParam::CRD_X) {
|
|---|
| 480 | if (firstCrd) {
|
|---|
| 481 | if (OPT->xyzAprRoverSet()) {
|
|---|
| 482 | pp->xx = OPT->_xyzAprRover[0];
|
|---|
| 483 | }
|
|---|
| 484 | else {
|
|---|
| 485 | pp->xx = _xcBanc(1);
|
|---|
| 486 | }
|
|---|
| 487 | }
|
|---|
| 488 | _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
|
|---|
| 489 | }
|
|---|
| 490 | else if (pp->type == t_pppParam::CRD_Y) {
|
|---|
| 491 | if (firstCrd) {
|
|---|
| 492 | if (OPT->xyzAprRoverSet()) {
|
|---|
| 493 | pp->xx = OPT->_xyzAprRover[1];
|
|---|
| 494 | }
|
|---|
| 495 | else {
|
|---|
| 496 | pp->xx = _xcBanc(2);
|
|---|
| 497 | }
|
|---|
| 498 | }
|
|---|
| 499 | _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
|
|---|
| 500 | }
|
|---|
| 501 | else if (pp->type == t_pppParam::CRD_Z) {
|
|---|
| 502 | if (firstCrd) {
|
|---|
| 503 | if (OPT->xyzAprRoverSet()) {
|
|---|
| 504 | pp->xx = OPT->_xyzAprRover[2];
|
|---|
| 505 | }
|
|---|
| 506 | else {
|
|---|
| 507 | pp->xx = _xcBanc(3);
|
|---|
| 508 | }
|
|---|
| 509 | }
|
|---|
| 510 | _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
|
|---|
| 511 | }
|
|---|
| 512 |
|
|---|
| 513 | // Receiver Clocks
|
|---|
| 514 | // ---------------
|
|---|
| 515 | else if (pp->type == t_pppParam::RECCLK) {
|
|---|
| 516 | pp->xx = _xcBanc(4);
|
|---|
| 517 | for (int jj = 1; jj <= _params.size(); jj++) {
|
|---|
| 518 | _QQ(iPar, jj) = 0.0;
|
|---|
| 519 | }
|
|---|
| 520 | _QQ(iPar,iPar) = OPT->_noiseClk * OPT->_noiseClk;
|
|---|
| 521 | }
|
|---|
| 522 |
|
|---|
| 523 | // Tropospheric Delay
|
|---|
| 524 | // ------------------
|
|---|
| 525 | else if (pp->type == t_pppParam::TROPO) {
|
|---|
| 526 | _QQ(iPar,iPar) += OPT->_noiseTrp * OPT->_noiseTrp;
|
|---|
| 527 | }
|
|---|
| 528 |
|
|---|
| 529 | // Glonass Offset
|
|---|
| 530 | // --------------
|
|---|
| 531 | else if (pp->type == t_pppParam::GLONASS_OFFSET) {
|
|---|
| 532 | pp->xx = 0.0;
|
|---|
| 533 | for (int jj = 1; jj <= _params.size(); jj++) {
|
|---|
| 534 | _QQ(iPar, jj) = 0.0;
|
|---|
| 535 | }
|
|---|
| 536 | _QQ(iPar,iPar) = 1000.0 * 1000.0;
|
|---|
| 537 | }
|
|---|
| 538 |
|
|---|
| 539 | // Galileo Offset
|
|---|
| 540 | // --------------
|
|---|
| 541 | else if (pp->type == t_pppParam::GALILEO_OFFSET) {
|
|---|
| 542 | if (_QQ(iPar,iPar)>pow(1000.0,2))
|
|---|
| 543 | _QQ(iPar,iPar) = 1000.0 * 1000.0;
|
|---|
| 544 | else
|
|---|
| 545 | _QQ(iPar,iPar) += 0.1 * 0.1;
|
|---|
| 546 | }
|
|---|
| 547 |
|
|---|
| 548 | // BDS Offset
|
|---|
| 549 | // ----------
|
|---|
| 550 | else if (pp->type == t_pppParam::BDS_OFFSET) {
|
|---|
| 551 | if (_QQ(iPar,iPar)>pow(1000.0,2))
|
|---|
| 552 | _QQ(iPar,iPar) = 1000.0 * 1000.0;
|
|---|
| 553 | else
|
|---|
| 554 | _QQ(iPar,iPar) += 0.1 * 0.1;
|
|---|
| 555 | }
|
|---|
| 556 | }
|
|---|
| 557 | }
|
|---|
| 558 |
|
|---|
| 559 | // Add New Ambiguities if necessary
|
|---|
| 560 | // --------------------------------
|
|---|
| 561 | if (OPT->ambLCs('G').size() || OPT->ambLCs('R').size() ||
|
|---|
| 562 | OPT->ambLCs('E').size() || OPT->ambLCs('C').size()) {
|
|---|
| 563 |
|
|---|
| 564 | // Make a copy of QQ and xx, set parameter indices
|
|---|
| 565 | // -----------------------------------------------
|
|---|
| 566 | SymmetricMatrix QQ_old = _QQ;
|
|---|
| 567 |
|
|---|
| 568 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 569 | _params[iPar-1]->index_old = _params[iPar-1]->index;
|
|---|
| 570 | _params[iPar-1]->index = 0;
|
|---|
| 571 | }
|
|---|
| 572 |
|
|---|
| 573 | // Remove Ambiguity Parameters without observations
|
|---|
| 574 | // ------------------------------------------------
|
|---|
| 575 | int iPar = 0;
|
|---|
| 576 | QMutableVectorIterator<t_pppParam*> im(_params);
|
|---|
| 577 | while (im.hasNext()) {
|
|---|
| 578 | t_pppParam* par = im.next();
|
|---|
| 579 | bool removed = false;
|
|---|
| 580 | if (par->type == t_pppParam::AMB_L3) {
|
|---|
| 581 | if (epoData->satData.find(par->prn) == epoData->satData.end()) {
|
|---|
| 582 | removed = true;
|
|---|
| 583 | delete par;
|
|---|
| 584 | im.remove();
|
|---|
| 585 | }
|
|---|
| 586 | }
|
|---|
| 587 | if (! removed) {
|
|---|
| 588 | ++iPar;
|
|---|
| 589 | par->index = iPar;
|
|---|
| 590 | }
|
|---|
| 591 | }
|
|---|
| 592 |
|
|---|
| 593 | // Add new ambiguity parameters
|
|---|
| 594 | // ----------------------------
|
|---|
| 595 | QMapIterator<QString, t_satData*> it(epoData->satData);
|
|---|
| 596 | while (it.hasNext()) {
|
|---|
| 597 | it.next();
|
|---|
| 598 | t_satData* satData = it.value();
|
|---|
| 599 | addAmb(satData);
|
|---|
| 600 | }
|
|---|
| 601 |
|
|---|
| 602 | int nPar = _params.size();
|
|---|
| 603 | _QQ.ReSize(nPar); _QQ = 0.0;
|
|---|
| 604 | for (int i1 = 1; i1 <= nPar; i1++) {
|
|---|
| 605 | t_pppParam* p1 = _params[i1-1];
|
|---|
| 606 | if (p1->index_old != 0) {
|
|---|
| 607 | _QQ(p1->index, p1->index) = QQ_old(p1->index_old, p1->index_old);
|
|---|
| 608 | for (int i2 = 1; i2 <= nPar; i2++) {
|
|---|
| 609 | t_pppParam* p2 = _params[i2-1];
|
|---|
| 610 | if (p2->index_old != 0) {
|
|---|
| 611 | _QQ(p1->index, p2->index) = QQ_old(p1->index_old, p2->index_old);
|
|---|
| 612 | }
|
|---|
| 613 | }
|
|---|
| 614 | }
|
|---|
| 615 | }
|
|---|
| 616 |
|
|---|
| 617 | for (int ii = 1; ii <= nPar; ii++) {
|
|---|
| 618 | t_pppParam* par = _params[ii-1];
|
|---|
| 619 | if (par->index_old == 0) {
|
|---|
| 620 | _QQ(par->index, par->index) = OPT->_aprSigAmb * OPT->_aprSigAmb;
|
|---|
| 621 | }
|
|---|
| 622 | par->index_old = par->index;
|
|---|
| 623 | }
|
|---|
| 624 | }
|
|---|
| 625 | }
|
|---|
| 626 |
|
|---|
| 627 | // Update Step of the Filter (currently just a single-epoch solution)
|
|---|
| 628 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 629 | t_irc t_pppFilter::update(t_epoData* epoData) {
|
|---|
| 630 |
|
|---|
| 631 | Tracer tracer("t_pppFilter::update");
|
|---|
| 632 |
|
|---|
| 633 | _time = epoData->tt; // current epoch time
|
|---|
| 634 |
|
|---|
| 635 | if (OPT->useOrbClkCorr()) {
|
|---|
| 636 | LOG << "Precise Point Positioning of Epoch " << _time.datestr() << "_" << _time.timestr(3)
|
|---|
| 637 | << "\n---------------------------------------------------------------\n";
|
|---|
| 638 | }
|
|---|
| 639 | else {
|
|---|
| 640 | LOG << "Single Point Positioning of Epoch " << _time.datestr() << "_" << _time.timestr(3)
|
|---|
| 641 | << "\n---------------------------------------------------------------\n";
|
|---|
| 642 | }
|
|---|
| 643 |
|
|---|
| 644 | // Outlier Detection Loop
|
|---|
| 645 | // ----------------------
|
|---|
| 646 | if (update_p(epoData) != success) {
|
|---|
| 647 | return failure;
|
|---|
| 648 | }
|
|---|
| 649 |
|
|---|
| 650 | // Set Solution Vector
|
|---|
| 651 | // -------------------
|
|---|
| 652 | LOG.setf(ios::fixed);
|
|---|
| 653 | QVectorIterator<t_pppParam*> itPar(_params);
|
|---|
| 654 | while (itPar.hasNext()) {
|
|---|
| 655 | t_pppParam* par = itPar.next();
|
|---|
| 656 | if (par->type == t_pppParam::RECCLK) {
|
|---|
| 657 | LOG << "\n" << _time.datestr() << "_" << _time.timestr(3)
|
|---|
| 658 | << " CLK " << setw(10) << setprecision(3) << par->xx
|
|---|
| 659 | << " +- " << setw(6) << setprecision(3)
|
|---|
| 660 | << sqrt(_QQ(par->index,par->index));
|
|---|
| 661 | }
|
|---|
| 662 | else if (par->type == t_pppParam::AMB_L3) {
|
|---|
| 663 | ++par->numEpo;
|
|---|
| 664 | LOG << "\n" << _time.datestr() << "_" << _time.timestr(3)
|
|---|
| 665 | << " AMB " << par->prn.mid(0,3).toAscii().data() << " "
|
|---|
| 666 | << setw(10) << setprecision(3) << par->xx
|
|---|
| 667 | << " +- " << setw(6) << setprecision(3)
|
|---|
| 668 | << sqrt(_QQ(par->index,par->index))
|
|---|
| 669 | << " epo = " << par->numEpo;
|
|---|
| 670 | }
|
|---|
| 671 | else if (par->type == t_pppParam::TROPO) {
|
|---|
| 672 | double aprTrp = delay_saast(M_PI/2.0);
|
|---|
| 673 | LOG << "\n" << _time.datestr() << "_" << _time.timestr(3)
|
|---|
| 674 | << " TRP " << par->prn.mid(0,3).toAscii().data()
|
|---|
| 675 | << setw(7) << setprecision(3) << aprTrp << " "
|
|---|
| 676 | << setw(6) << setprecision(3) << showpos << par->xx << noshowpos
|
|---|
| 677 | << " +- " << setw(6) << setprecision(3)
|
|---|
| 678 | << sqrt(_QQ(par->index,par->index));
|
|---|
| 679 | }
|
|---|
| 680 | else if (par->type == t_pppParam::GLONASS_OFFSET) {
|
|---|
| 681 | LOG << "\n" << _time.datestr() << "_" << _time.timestr(3)
|
|---|
| 682 | << " OFFGLO " << setw(10) << setprecision(3) << par->xx
|
|---|
| 683 | << " +- " << setw(6) << setprecision(3)
|
|---|
| 684 | << sqrt(_QQ(par->index,par->index));
|
|---|
| 685 | }
|
|---|
| 686 | else if (par->type == t_pppParam::GALILEO_OFFSET) {
|
|---|
| 687 | LOG << "\n" << _time.datestr() << "_" << _time.timestr(3)
|
|---|
| 688 | << " OFFGAL " << setw(10) << setprecision(3) << par->xx
|
|---|
| 689 | << " +- " << setw(6) << setprecision(3)
|
|---|
| 690 | << sqrt(_QQ(par->index,par->index));
|
|---|
| 691 | }
|
|---|
| 692 | else if (par->type == t_pppParam::BDS_OFFSET) {
|
|---|
| 693 | LOG << "\n" << _time.datestr() << "_" << _time.timestr(3)
|
|---|
| 694 | << " OFFBDS " << setw(10) << setprecision(3) << par->xx
|
|---|
| 695 | << " +- " << setw(6) << setprecision(3)
|
|---|
| 696 | << sqrt(_QQ(par->index,par->index));
|
|---|
| 697 | }
|
|---|
| 698 | }
|
|---|
| 699 |
|
|---|
| 700 | LOG << endl << endl;
|
|---|
| 701 |
|
|---|
| 702 | // Compute dilution of precision
|
|---|
| 703 | // -----------------------------
|
|---|
| 704 | cmpDOP(epoData);
|
|---|
| 705 |
|
|---|
| 706 | // Final Message (both log file and screen)
|
|---|
| 707 | // ----------------------------------------
|
|---|
| 708 | LOG << epoData->tt.datestr() << "_" << epoData->tt.timestr(3)
|
|---|
| 709 | << " " << OPT->_roverName
|
|---|
| 710 | << " X = "
|
|---|
| 711 | << setprecision(4) << x() << " +- "
|
|---|
| 712 | << setprecision(4) << sqrt(_QQ(1,1))
|
|---|
| 713 |
|
|---|
| 714 | << " Y = "
|
|---|
| 715 | << setprecision(4) << y() << " +- "
|
|---|
| 716 | << setprecision(4) << sqrt(_QQ(2,2))
|
|---|
| 717 |
|
|---|
| 718 | << " Z = "
|
|---|
| 719 | << setprecision(4) << z() << " +- "
|
|---|
| 720 | << setprecision(4) << sqrt(_QQ(3,3));
|
|---|
| 721 |
|
|---|
| 722 | // NEU Output
|
|---|
| 723 | // ----------
|
|---|
| 724 | if (OPT->xyzAprRoverSet()) {
|
|---|
| 725 | SymmetricMatrix QQxyz = _QQ.SymSubMatrix(1,3);
|
|---|
| 726 |
|
|---|
| 727 | ColumnVector xyz(3);
|
|---|
| 728 | xyz(1) = x() - OPT->_xyzAprRover[0];
|
|---|
| 729 | xyz(2) = y() - OPT->_xyzAprRover[1];
|
|---|
| 730 | xyz(3) = z() - OPT->_xyzAprRover[2];
|
|---|
| 731 |
|
|---|
| 732 | ColumnVector ellRef(3);
|
|---|
| 733 | xyz2ell(OPT->_xyzAprRover.data(), ellRef.data());
|
|---|
| 734 | xyz2neu(ellRef.data(), xyz.data(), _neu.data());
|
|---|
| 735 |
|
|---|
| 736 | SymmetricMatrix QQneu(3);
|
|---|
| 737 | covariXYZ_NEU(QQxyz, ellRef.data(), QQneu);
|
|---|
| 738 |
|
|---|
| 739 | LOG << " dN = "
|
|---|
| 740 | << setprecision(4) << _neu[0] << " +- "
|
|---|
| 741 | << setprecision(4) << sqrt(QQneu[0][0])
|
|---|
| 742 |
|
|---|
| 743 | << " dE = "
|
|---|
| 744 | << setprecision(4) << _neu[1] << " +- "
|
|---|
| 745 | << setprecision(4) << sqrt(QQneu[1][1])
|
|---|
| 746 |
|
|---|
| 747 | << " dU = "
|
|---|
| 748 | << setprecision(4) << _neu[2] << " +- "
|
|---|
| 749 | << setprecision(4) << sqrt(QQneu[2][2]) << endl << endl;
|
|---|
| 750 | }
|
|---|
| 751 | else {
|
|---|
| 752 | LOG << endl << endl;
|
|---|
| 753 | }
|
|---|
| 754 |
|
|---|
| 755 | _lastTimeOK = _time; // remember time of last successful update
|
|---|
| 756 | return success;
|
|---|
| 757 | }
|
|---|
| 758 |
|
|---|
| 759 | // Iono combi noise factor
|
|---|
| 760 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 761 | double ionFac(const QString prn, QMap<QString, t_satData*>& satData) {
|
|---|
| 762 | if (satData.contains(prn))
|
|---|
| 763 | return sqrt(pow(satData.value(prn)->lkA,2) +
|
|---|
| 764 | pow(satData.value(prn)->lkB,2) );
|
|---|
| 765 | else
|
|---|
| 766 | return 0.0;
|
|---|
| 767 | };
|
|---|
| 768 |
|
|---|
| 769 | // Outlier Detection
|
|---|
| 770 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 771 | QString t_pppFilter::outlierDetection(int iPhase, const ColumnVector& vv,
|
|---|
| 772 | QMap<QString, t_satData*>& satData) {
|
|---|
| 773 |
|
|---|
| 774 | Tracer tracer("t_pppFilter::outlierDetection");
|
|---|
| 775 |
|
|---|
| 776 | QString prnGPS;
|
|---|
| 777 | QString prnGlo;
|
|---|
| 778 |
|
|---|
| 779 | double ionFacGPS;
|
|---|
| 780 | double ionFacGLO;
|
|---|
| 781 |
|
|---|
| 782 | double maxResGPS = 0.0; // GPS + Galileo
|
|---|
| 783 | double maxResGlo = 0.0; // GLONASS + BDS
|
|---|
| 784 |
|
|---|
| 785 | findMaxRes(vv, satData, prnGPS, prnGlo, maxResGPS, maxResGlo);
|
|---|
| 786 |
|
|---|
| 787 | ionFacGLO = ionFac(prnGlo,satData);
|
|---|
| 788 | if (iPhase == 0)
|
|---|
| 789 | ionFacGLO *= (prnGlo[0]=='R'? GLONASS_WEIGHT_FACTOR : BDS_WEIGHT_FACTOR);
|
|---|
| 790 | ionFacGPS = ionFac(prnGPS,satData);
|
|---|
| 791 |
|
|---|
| 792 | if (iPhase == 1) {
|
|---|
| 793 | if (maxResGlo > ionFacGLO * OPT->_maxResL1) {
|
|---|
| 794 | LOG << "Outlier Phase " << prnGlo.mid(0,3).toAscii().data() << ' ' << maxResGlo << endl;
|
|---|
| 795 | return prnGlo;
|
|---|
| 796 | }
|
|---|
| 797 | else if (maxResGPS > ionFacGPS * OPT->_maxResL1) {
|
|---|
| 798 | LOG << "Outlier Phase " << prnGPS.mid(0,3).toAscii().data() << ' ' << maxResGPS << endl;
|
|---|
| 799 | return prnGPS;
|
|---|
| 800 | }
|
|---|
| 801 | }
|
|---|
| 802 | else if (iPhase == 0) {
|
|---|
| 803 | if (maxResGlo > ionFacGLO * OPT->_maxResC1) {
|
|---|
| 804 | LOG << "Outlier Code " << prnGlo.mid(0,3).toLatin1().data() << ' ' << maxResGlo << endl;
|
|---|
| 805 | return prnGlo;
|
|---|
| 806 | }
|
|---|
| 807 | else if (maxResGPS > ionFacGPS * OPT->_maxResC1) {
|
|---|
| 808 | LOG << "Outlier Code " << prnGPS.mid(0,3).toLatin1().data() << ' ' << maxResGPS << endl;
|
|---|
| 809 | return prnGPS;
|
|---|
| 810 | }
|
|---|
| 811 | }
|
|---|
| 812 |
|
|---|
| 813 | return QString();
|
|---|
| 814 | }
|
|---|
| 815 |
|
|---|
| 816 | // Phase Wind-Up Correction
|
|---|
| 817 | ///////////////////////////////////////////////////////////////////////////
|
|---|
| 818 | double t_pppFilter::windUp(const QString& prn, const ColumnVector& rSat,
|
|---|
| 819 | const ColumnVector& rRec) {
|
|---|
| 820 |
|
|---|
| 821 | Tracer tracer("t_pppFilter::windUp");
|
|---|
| 822 |
|
|---|
| 823 | double Mjd = _time.mjd() + _time.daysec() / 86400.0;
|
|---|
| 824 |
|
|---|
| 825 | // First time - initialize to zero
|
|---|
| 826 | // -------------------------------
|
|---|
| 827 | if (!_windUpTime.contains(prn)) {
|
|---|
| 828 | _windUpSum[prn] = 0.0;
|
|---|
| 829 | }
|
|---|
| 830 |
|
|---|
| 831 | // Compute the correction for new time
|
|---|
| 832 | // -----------------------------------
|
|---|
| 833 | if (!_windUpTime.contains(prn) || _windUpTime[prn] != Mjd) {
|
|---|
| 834 | _windUpTime[prn] = Mjd;
|
|---|
| 835 |
|
|---|
| 836 | // Unit Vector GPS Satellite --> Receiver
|
|---|
| 837 | // --------------------------------------
|
|---|
| 838 | ColumnVector rho = rRec - rSat;
|
|---|
| 839 | rho /= rho.norm_Frobenius();
|
|---|
| 840 |
|
|---|
| 841 | // GPS Satellite unit Vectors sz, sy, sx
|
|---|
| 842 | // -------------------------------------
|
|---|
| 843 | ColumnVector sz = -rSat / rSat.norm_Frobenius();
|
|---|
| 844 |
|
|---|
| 845 | ColumnVector xSun = t_astro::Sun(Mjd);
|
|---|
| 846 | xSun /= xSun.norm_Frobenius();
|
|---|
| 847 |
|
|---|
| 848 | ColumnVector sy = crossproduct(sz, xSun);
|
|---|
| 849 | ColumnVector sx = crossproduct(sy, sz);
|
|---|
| 850 |
|
|---|
| 851 | // Effective Dipole of the GPS Satellite Antenna
|
|---|
| 852 | // ---------------------------------------------
|
|---|
| 853 | ColumnVector dipSat = sx - rho * DotProduct(rho,sx)
|
|---|
| 854 | - crossproduct(rho, sy);
|
|---|
| 855 |
|
|---|
| 856 | // Receiver unit Vectors rx, ry
|
|---|
| 857 | // ----------------------------
|
|---|
| 858 | ColumnVector rx(3);
|
|---|
| 859 | ColumnVector ry(3);
|
|---|
| 860 |
|
|---|
| 861 | double recEll[3]; xyz2ell(rRec.data(), recEll) ;
|
|---|
| 862 | double neu[3];
|
|---|
| 863 |
|
|---|
| 864 | neu[0] = 1.0;
|
|---|
| 865 | neu[1] = 0.0;
|
|---|
| 866 | neu[2] = 0.0;
|
|---|
| 867 | neu2xyz(recEll, neu, rx.data());
|
|---|
| 868 |
|
|---|
| 869 | neu[0] = 0.0;
|
|---|
| 870 | neu[1] = -1.0;
|
|---|
| 871 | neu[2] = 0.0;
|
|---|
| 872 | neu2xyz(recEll, neu, ry.data());
|
|---|
| 873 |
|
|---|
| 874 | // Effective Dipole of the Receiver Antenna
|
|---|
| 875 | // ----------------------------------------
|
|---|
| 876 | ColumnVector dipRec = rx - rho * DotProduct(rho,rx)
|
|---|
| 877 | + crossproduct(rho, ry);
|
|---|
| 878 |
|
|---|
| 879 | // Resulting Effect
|
|---|
| 880 | // ----------------
|
|---|
| 881 | double alpha = DotProduct(dipSat,dipRec) /
|
|---|
| 882 | (dipSat.norm_Frobenius() * dipRec.norm_Frobenius());
|
|---|
| 883 |
|
|---|
| 884 | if (alpha > 1.0) alpha = 1.0;
|
|---|
| 885 | if (alpha < -1.0) alpha = -1.0;
|
|---|
| 886 |
|
|---|
| 887 | double dphi = acos(alpha) / 2.0 / M_PI; // in cycles
|
|---|
| 888 |
|
|---|
| 889 | if ( DotProduct(rho, crossproduct(dipSat, dipRec)) < 0.0 ) {
|
|---|
| 890 | dphi = -dphi;
|
|---|
| 891 | }
|
|---|
| 892 |
|
|---|
| 893 | _windUpSum[prn] = floor(_windUpSum[prn] - dphi + 0.5) + dphi;
|
|---|
| 894 | }
|
|---|
| 895 |
|
|---|
| 896 | return _windUpSum[prn];
|
|---|
| 897 | }
|
|---|
| 898 |
|
|---|
| 899 | //
|
|---|
| 900 | ///////////////////////////////////////////////////////////////////////////
|
|---|
| 901 | void t_pppFilter::cmpEle(t_satData* satData) {
|
|---|
| 902 | Tracer tracer("t_pppFilter::cmpEle");
|
|---|
| 903 | ColumnVector rr = satData->xx - _xcBanc.Rows(1,3);
|
|---|
| 904 | double rho = rr.norm_Frobenius();
|
|---|
| 905 |
|
|---|
| 906 | double neu[3];
|
|---|
| 907 | xyz2neu(_ellBanc.data(), rr.data(), neu);
|
|---|
| 908 |
|
|---|
| 909 | satData->eleSat = acos( sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / rho );
|
|---|
| 910 | if (neu[2] < 0) {
|
|---|
| 911 | satData->eleSat *= -1.0;
|
|---|
| 912 | }
|
|---|
| 913 | satData->azSat = atan2(neu[1], neu[0]);
|
|---|
| 914 | }
|
|---|
| 915 |
|
|---|
| 916 | //
|
|---|
| 917 | ///////////////////////////////////////////////////////////////////////////
|
|---|
| 918 | void t_pppFilter::addAmb(t_satData* satData) {
|
|---|
| 919 | Tracer tracer("t_pppFilter::addAmb");
|
|---|
| 920 | if (!OPT->ambLCs(satData->system()).size()){
|
|---|
| 921 | return;
|
|---|
| 922 | }
|
|---|
| 923 | bool found = false;
|
|---|
| 924 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 925 | if (_params[iPar-1]->type == t_pppParam::AMB_L3 &&
|
|---|
| 926 | _params[iPar-1]->prn == satData->prn) {
|
|---|
| 927 | found = true;
|
|---|
| 928 | break;
|
|---|
| 929 | }
|
|---|
| 930 | }
|
|---|
| 931 | if (!found) {
|
|---|
| 932 | t_pppParam* par = new t_pppParam(t_pppParam::AMB_L3,
|
|---|
| 933 | _params.size()+1, satData->prn);
|
|---|
| 934 | _params.push_back(par);
|
|---|
| 935 | par->xx = satData->L3 - cmpValue(satData, true);
|
|---|
| 936 | }
|
|---|
| 937 | }
|
|---|
| 938 |
|
|---|
| 939 | //
|
|---|
| 940 | ///////////////////////////////////////////////////////////////////////////
|
|---|
| 941 | void t_pppFilter::addObs(int iPhase, unsigned& iObs, t_satData* satData,
|
|---|
| 942 | Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP) {
|
|---|
| 943 |
|
|---|
| 944 | Tracer tracer("t_pppFilter::addObs");
|
|---|
| 945 |
|
|---|
| 946 | const double ELEWGHT = 20.0;
|
|---|
| 947 | double ellWgtCoef = 1.0;
|
|---|
| 948 | double eleD = satData->eleSat * 180.0 / M_PI;
|
|---|
| 949 | if (eleD < ELEWGHT) {
|
|---|
| 950 | ellWgtCoef = 1.5 - 0.5 / (ELEWGHT - 10.0) * (eleD - 10.0);
|
|---|
| 951 | }
|
|---|
| 952 |
|
|---|
| 953 | // Remember Observation Index
|
|---|
| 954 | // --------------------------
|
|---|
| 955 | ++iObs;
|
|---|
| 956 | satData->obsIndex = iObs;
|
|---|
| 957 |
|
|---|
| 958 | // Iono-free combination noise factor
|
|---|
| 959 | // ----------------------------------
|
|---|
| 960 | double ionFac = sqrt(pow(satData->lkA,2) + pow(satData->lkB,2));
|
|---|
| 961 |
|
|---|
| 962 | // Phase Observations
|
|---|
| 963 | // ------------------
|
|---|
| 964 |
|
|---|
| 965 | if (iPhase == 1) {
|
|---|
| 966 | double sigL3 = ionFac * ellWgtCoef * OPT->_sigmaL1;
|
|---|
| 967 | if (satData->system() == 'R') {
|
|---|
| 968 | sigL3 *= GLONASS_WEIGHT_FACTOR;
|
|---|
| 969 | }
|
|---|
| 970 | if (satData->system() == 'C') {
|
|---|
| 971 | sigL3 *= BDS_WEIGHT_FACTOR;
|
|---|
| 972 | }
|
|---|
| 973 | satData->L3sig = sigL3;
|
|---|
| 974 | ll(iObs) = satData->L3 - cmpValue(satData, true);
|
|---|
| 975 | PP(iObs,iObs) = 1.0 / (sigL3 * sigL3);
|
|---|
| 976 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 977 | if (_params[iPar-1]->type == t_pppParam::AMB_L3 &&
|
|---|
| 978 | _params[iPar-1]->prn == satData->prn) {
|
|---|
| 979 | ll(iObs) -= _params[iPar-1]->xx;
|
|---|
| 980 | }
|
|---|
| 981 | AA(iObs, iPar) = _params[iPar-1]->partial(satData, true);
|
|---|
| 982 | }
|
|---|
| 983 | }
|
|---|
| 984 |
|
|---|
| 985 | // Code Observations
|
|---|
| 986 | // -----------------
|
|---|
| 987 | else {
|
|---|
| 988 | double sigP3 = ionFac * ellWgtCoef * OPT->_sigmaC1;
|
|---|
| 989 | if (satData->system() == 'R') {
|
|---|
| 990 | sigP3 *= GLONASS_WEIGHT_FACTOR;
|
|---|
| 991 | }
|
|---|
| 992 | if (satData->system() == 'C') {
|
|---|
| 993 | sigP3 *= BDS_WEIGHT_FACTOR;
|
|---|
| 994 | }
|
|---|
| 995 | satData->P3sig = sigP3;
|
|---|
| 996 | ll(iObs) = satData->P3 - cmpValue(satData, false);
|
|---|
| 997 | PP(iObs,iObs) = 1.0 / (sigP3 * sigP3);
|
|---|
| 998 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
|---|
| 999 | AA(iObs, iPar) = _params[iPar-1]->partial(satData, false);
|
|---|
| 1000 | }
|
|---|
| 1001 | }
|
|---|
| 1002 | }
|
|---|
| 1003 |
|
|---|
| 1004 | //
|
|---|
| 1005 | ///////////////////////////////////////////////////////////////////////////
|
|---|
| 1006 | QByteArray t_pppFilter::printRes(int iPhase, const ColumnVector& vv,
|
|---|
| 1007 | const QMap<QString, t_satData*>& satDataMap) {
|
|---|
| 1008 |
|
|---|
| 1009 | Tracer tracer("t_pppFilter::printRes");
|
|---|
| 1010 |
|
|---|
| 1011 | ostringstream str;
|
|---|
| 1012 | str.setf(ios::fixed);
|
|---|
| 1013 | bool useObs;
|
|---|
| 1014 | QMapIterator<QString, t_satData*> it(satDataMap);
|
|---|
| 1015 | while (it.hasNext()) {
|
|---|
| 1016 | it.next();
|
|---|
| 1017 | t_satData* satData = it.value();
|
|---|
| 1018 | (iPhase == 0) ? useObs = OPT->codeLCs(satData->system()).size() :
|
|---|
| 1019 | useObs = OPT->ambLCs(satData->system()).size();
|
|---|
| 1020 | if (satData->obsIndex != 0 && useObs) {
|
|---|
| 1021 | str << _time.datestr() << "_" << _time.timestr(3)
|
|---|
| 1022 | << " RES " << satData->prn.mid(0,3).toAscii().data()
|
|---|
| 1023 | << (iPhase ? " L3 " : " P3 ")
|
|---|
| 1024 | << setw(9) << setprecision(4) << vv(satData->obsIndex) << endl;
|
|---|
| 1025 | }
|
|---|
| 1026 | }
|
|---|
| 1027 |
|
|---|
| 1028 | return QByteArray(str.str().c_str());
|
|---|
| 1029 | }
|
|---|
| 1030 |
|
|---|
| 1031 | //
|
|---|
| 1032 | ///////////////////////////////////////////////////////////////////////////
|
|---|
| 1033 | void t_pppFilter::findMaxRes(const ColumnVector& vv,
|
|---|
| 1034 | const QMap<QString, t_satData*>& satData,
|
|---|
| 1035 | QString& prnGPS, QString& prnGlo,
|
|---|
| 1036 | double& maxResGPS, double& maxResGlo) {
|
|---|
| 1037 |
|
|---|
| 1038 | Tracer tracer("t_pppFilter::findMaxRes");
|
|---|
| 1039 |
|
|---|
| 1040 | maxResGPS = 0.0;
|
|---|
| 1041 | maxResGlo = 0.0;
|
|---|
| 1042 |
|
|---|
| 1043 | QMapIterator<QString, t_satData*> it(satData);
|
|---|
| 1044 | while (it.hasNext()) {
|
|---|
| 1045 | it.next();
|
|---|
| 1046 | t_satData* satData = it.value();
|
|---|
| 1047 | if (satData->obsIndex != 0) {
|
|---|
| 1048 | QString prn = satData->prn;
|
|---|
| 1049 | if (prn[0] == 'R' || prn[0] == 'C') {
|
|---|
| 1050 | if (fabs(vv(satData->obsIndex)) > maxResGlo) {
|
|---|
| 1051 | maxResGlo = fabs(vv(satData->obsIndex));
|
|---|
| 1052 | prnGlo = prn;
|
|---|
| 1053 | }
|
|---|
| 1054 | }
|
|---|
| 1055 | else {
|
|---|
| 1056 | if (fabs(vv(satData->obsIndex)) > maxResGPS) {
|
|---|
| 1057 | maxResGPS = fabs(vv(satData->obsIndex));
|
|---|
| 1058 | prnGPS = prn;
|
|---|
| 1059 | }
|
|---|
| 1060 | }
|
|---|
| 1061 | }
|
|---|
| 1062 | }
|
|---|
| 1063 | }
|
|---|
| 1064 |
|
|---|
| 1065 | // Update Step (private - loop over outliers)
|
|---|
| 1066 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1067 | t_irc t_pppFilter::update_p(t_epoData* epoData) {
|
|---|
| 1068 |
|
|---|
| 1069 | Tracer tracer("t_pppFilter::update_p");
|
|---|
| 1070 |
|
|---|
| 1071 | // Save Variance-Covariance Matrix, and Status Vector
|
|---|
| 1072 | // --------------------------------------------------
|
|---|
| 1073 | rememberState(epoData);
|
|---|
| 1074 |
|
|---|
| 1075 | QString lastOutlierPrn;
|
|---|
| 1076 |
|
|---|
| 1077 | // Try with all satellites, then with all minus one, etc.
|
|---|
| 1078 | // ------------------------------------------------------
|
|---|
| 1079 | while (selectSatellites(lastOutlierPrn, epoData->satData) == success) {
|
|---|
| 1080 |
|
|---|
| 1081 | QByteArray strResCode;
|
|---|
| 1082 | QByteArray strResPhase;
|
|---|
| 1083 |
|
|---|
| 1084 | // Bancroft Solution
|
|---|
| 1085 | // -----------------
|
|---|
| 1086 | if (cmpBancroft(epoData) != success) {
|
|---|
| 1087 | break;
|
|---|
| 1088 | }
|
|---|
| 1089 |
|
|---|
| 1090 | // First update using code observations, then phase observations
|
|---|
| 1091 | // -------------------------------------------------------------
|
|---|
| 1092 | bool usePhase = OPT->ambLCs('G').size() || OPT->ambLCs('R').size() ||
|
|---|
| 1093 | OPT->ambLCs('E').size() || OPT->ambLCs('C').size() ;
|
|---|
| 1094 |
|
|---|
| 1095 | char sys[] ={'G', 'R', 'E', 'C'};
|
|---|
| 1096 |
|
|---|
| 1097 | bool satnumPrinted[] = {false, false, false, false};
|
|---|
| 1098 |
|
|---|
| 1099 | for (int iPhase = 0; iPhase <= (usePhase ? 1 : 0); iPhase++) {
|
|---|
| 1100 |
|
|---|
| 1101 | // Status Prediction
|
|---|
| 1102 | // -----------------
|
|---|
| 1103 | predict(iPhase, epoData);
|
|---|
| 1104 |
|
|---|
| 1105 | // Create First-Design Matrix
|
|---|
| 1106 | // --------------------------
|
|---|
| 1107 | unsigned nPar = _params.size();
|
|---|
| 1108 | unsigned nObs = 0;
|
|---|
| 1109 | nObs = epoData->sizeAll();
|
|---|
| 1110 | bool useObs = false;
|
|---|
| 1111 | for (unsigned ii = 0; ii < sizeof(sys); ii++) {
|
|---|
| 1112 | const char s = sys[ii];
|
|---|
| 1113 | (iPhase == 0) ? useObs = OPT->codeLCs(s).size() : useObs = OPT->ambLCs(s).size();
|
|---|
| 1114 | if (!useObs) {
|
|---|
| 1115 | nObs -= epoData->sizeSys(s);
|
|---|
| 1116 | }
|
|---|
| 1117 | else {
|
|---|
| 1118 | if (!satnumPrinted[ii]) {
|
|---|
| 1119 | satnumPrinted[ii] = true;
|
|---|
| 1120 | LOG << _time.datestr() << "_" << _time.timestr(3)
|
|---|
| 1121 | << " SATNUM " << s << ' ' << right << setw(2)
|
|---|
| 1122 | << epoData->sizeSys(s) << endl;
|
|---|
| 1123 | }
|
|---|
| 1124 | }
|
|---|
| 1125 | }
|
|---|
| 1126 |
|
|---|
| 1127 | if (int(nObs) < OPT->_minObs) {
|
|---|
| 1128 | restoreState(epoData);
|
|---|
| 1129 | return failure;
|
|---|
| 1130 | }
|
|---|
| 1131 |
|
|---|
| 1132 | // Prepare first-design Matrix, vector observed-computed
|
|---|
| 1133 | // -----------------------------------------------------
|
|---|
| 1134 | Matrix AA(nObs, nPar); // first design matrix
|
|---|
| 1135 | ColumnVector ll(nObs); // terms observed-computed
|
|---|
| 1136 | DiagonalMatrix PP(nObs); PP = 0.0;
|
|---|
| 1137 |
|
|---|
| 1138 | unsigned iObs = 0;
|
|---|
| 1139 | QMapIterator<QString, t_satData*> it(epoData->satData);
|
|---|
| 1140 |
|
|---|
| 1141 | while (it.hasNext()) {
|
|---|
| 1142 | it.next();
|
|---|
| 1143 | t_satData* satData = it.value();
|
|---|
| 1144 | QString prn = satData->prn;
|
|---|
| 1145 | (iPhase == 0) ? useObs = OPT->codeLCs(satData->system()).size() :
|
|---|
| 1146 | useObs = OPT->ambLCs(satData->system()).size();
|
|---|
| 1147 | if (useObs) {
|
|---|
| 1148 | addObs(iPhase, iObs, satData, AA, ll, PP);
|
|---|
| 1149 | } else {
|
|---|
| 1150 | satData->obsIndex = 0;
|
|---|
| 1151 | }
|
|---|
| 1152 | }
|
|---|
| 1153 |
|
|---|
| 1154 | // Compute Filter Update
|
|---|
| 1155 | // ---------------------
|
|---|
| 1156 | ColumnVector dx(nPar); dx = 0.0;
|
|---|
| 1157 | kalman(AA, ll, PP, _QQ, dx);
|
|---|
| 1158 | ColumnVector vv = ll - AA * dx;
|
|---|
| 1159 |
|
|---|
| 1160 | // Print Residuals
|
|---|
| 1161 | // ---------------
|
|---|
| 1162 | if (iPhase == 0) {
|
|---|
| 1163 | strResCode = printRes(iPhase, vv, epoData->satData);
|
|---|
| 1164 | }
|
|---|
| 1165 | else {
|
|---|
| 1166 | strResPhase = printRes(iPhase, vv, epoData->satData);
|
|---|
| 1167 | }
|
|---|
| 1168 |
|
|---|
| 1169 | // Check the residuals
|
|---|
| 1170 | // -------------------
|
|---|
| 1171 | lastOutlierPrn = outlierDetection(iPhase, vv, epoData->satData);
|
|---|
| 1172 |
|
|---|
| 1173 | // No Outlier Detected
|
|---|
| 1174 | // -------------------
|
|---|
| 1175 | if (lastOutlierPrn.isEmpty()) {
|
|---|
| 1176 |
|
|---|
| 1177 | QVectorIterator<t_pppParam*> itPar(_params);
|
|---|
| 1178 | while (itPar.hasNext()) {
|
|---|
| 1179 | t_pppParam* par = itPar.next();
|
|---|
| 1180 | par->xx += dx(par->index);
|
|---|
| 1181 | }
|
|---|
| 1182 |
|
|---|
| 1183 | if (!usePhase || iPhase == 1) {
|
|---|
| 1184 | if (_outlierGPS.size() > 0 || _outlierGlo.size() > 0) {
|
|---|
| 1185 | LOG << "Neglected PRNs: ";
|
|---|
| 1186 | if (!_outlierGPS.isEmpty()) {
|
|---|
| 1187 | LOG << _outlierGPS.last().mid(0,3).toAscii().data() << ' ';
|
|---|
| 1188 | }
|
|---|
| 1189 | QStringListIterator itGlo(_outlierGlo);
|
|---|
| 1190 | while (itGlo.hasNext()) {
|
|---|
| 1191 | QString prn = itGlo.next();
|
|---|
| 1192 | LOG << prn.mid(0,3).toAscii().data() << ' ';
|
|---|
| 1193 | }
|
|---|
| 1194 | LOG << endl;
|
|---|
| 1195 | }
|
|---|
| 1196 | LOG << strResCode.data() << strResPhase.data();
|
|---|
| 1197 |
|
|---|
| 1198 | return success;
|
|---|
| 1199 | }
|
|---|
| 1200 | }
|
|---|
| 1201 |
|
|---|
| 1202 | // Outlier Found
|
|---|
| 1203 | // -------------
|
|---|
| 1204 | else {
|
|---|
| 1205 | restoreState(epoData);
|
|---|
| 1206 | break;
|
|---|
| 1207 | }
|
|---|
| 1208 |
|
|---|
| 1209 | } // for iPhase
|
|---|
| 1210 |
|
|---|
| 1211 | } // while selectSatellites
|
|---|
| 1212 |
|
|---|
| 1213 | restoreState(epoData);
|
|---|
| 1214 | return failure;
|
|---|
| 1215 | }
|
|---|
| 1216 |
|
|---|
| 1217 | // Remember Original State Vector and Variance-Covariance Matrix
|
|---|
| 1218 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1219 | void t_pppFilter::rememberState(t_epoData* epoData) {
|
|---|
| 1220 |
|
|---|
| 1221 | _QQ_sav = _QQ;
|
|---|
| 1222 |
|
|---|
| 1223 | QVectorIterator<t_pppParam*> itSav(_params_sav);
|
|---|
| 1224 | while (itSav.hasNext()) {
|
|---|
| 1225 | t_pppParam* par = itSav.next();
|
|---|
| 1226 | delete par;
|
|---|
| 1227 | }
|
|---|
| 1228 | _params_sav.clear();
|
|---|
| 1229 |
|
|---|
| 1230 | QVectorIterator<t_pppParam*> it(_params);
|
|---|
| 1231 | while (it.hasNext()) {
|
|---|
| 1232 | t_pppParam* par = it.next();
|
|---|
| 1233 | _params_sav.push_back(new t_pppParam(*par));
|
|---|
| 1234 | }
|
|---|
| 1235 |
|
|---|
| 1236 | _epoData_sav->deepCopy(epoData);
|
|---|
| 1237 | }
|
|---|
| 1238 |
|
|---|
| 1239 | // Restore Original State Vector and Variance-Covariance Matrix
|
|---|
| 1240 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1241 | void t_pppFilter::restoreState(t_epoData* epoData) {
|
|---|
| 1242 |
|
|---|
| 1243 | _QQ = _QQ_sav;
|
|---|
| 1244 |
|
|---|
| 1245 | QVectorIterator<t_pppParam*> it(_params);
|
|---|
| 1246 | while (it.hasNext()) {
|
|---|
| 1247 | t_pppParam* par = it.next();
|
|---|
| 1248 | delete par;
|
|---|
| 1249 | }
|
|---|
| 1250 | _params.clear();
|
|---|
| 1251 |
|
|---|
| 1252 | QVectorIterator<t_pppParam*> itSav(_params_sav);
|
|---|
| 1253 | while (itSav.hasNext()) {
|
|---|
| 1254 | t_pppParam* par = itSav.next();
|
|---|
| 1255 | _params.push_back(new t_pppParam(*par));
|
|---|
| 1256 | }
|
|---|
| 1257 |
|
|---|
| 1258 | epoData->deepCopy(_epoData_sav);
|
|---|
| 1259 | }
|
|---|
| 1260 |
|
|---|
| 1261 | //
|
|---|
| 1262 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1263 | t_irc t_pppFilter::selectSatellites(const QString& lastOutlierPrn,
|
|---|
| 1264 | QMap<QString, t_satData*>& satData) {
|
|---|
| 1265 |
|
|---|
| 1266 | // First Call
|
|---|
| 1267 | // ----------
|
|---|
| 1268 | if (lastOutlierPrn.isEmpty()) {
|
|---|
| 1269 | _outlierGPS.clear();
|
|---|
| 1270 | _outlierGlo.clear();
|
|---|
| 1271 | return success;
|
|---|
| 1272 | }
|
|---|
| 1273 |
|
|---|
| 1274 | // Second and next trials
|
|---|
| 1275 | // ----------------------
|
|---|
| 1276 | else {
|
|---|
| 1277 |
|
|---|
| 1278 | if (lastOutlierPrn[0] == 'R' || lastOutlierPrn[0] == 'C') {
|
|---|
| 1279 | _outlierGlo << lastOutlierPrn;
|
|---|
| 1280 | }
|
|---|
| 1281 |
|
|---|
| 1282 | // Remove all Glonass Outliers
|
|---|
| 1283 | // ---------------------------
|
|---|
| 1284 | QStringListIterator it(_outlierGlo);
|
|---|
| 1285 | while (it.hasNext()) {
|
|---|
| 1286 | QString prn = it.next();
|
|---|
| 1287 | if (satData.contains(prn)) {
|
|---|
| 1288 | delete satData.take(prn);
|
|---|
| 1289 | }
|
|---|
| 1290 | }
|
|---|
| 1291 |
|
|---|
| 1292 | if (lastOutlierPrn[0] == 'R' || lastOutlierPrn[0] == 'C') {
|
|---|
| 1293 | _outlierGPS.clear();
|
|---|
| 1294 | return success;
|
|---|
| 1295 | }
|
|---|
| 1296 |
|
|---|
| 1297 | // GPS Outlier appeared for the first time - try to delete it
|
|---|
| 1298 | // ----------------------------------------------------------
|
|---|
| 1299 | if (_outlierGPS.indexOf(lastOutlierPrn) == -1) {
|
|---|
| 1300 | _outlierGPS << lastOutlierPrn;
|
|---|
| 1301 | if (satData.contains(lastOutlierPrn)) {
|
|---|
| 1302 | delete satData.take(lastOutlierPrn);
|
|---|
| 1303 | }
|
|---|
| 1304 | return success;
|
|---|
| 1305 | }
|
|---|
| 1306 |
|
|---|
| 1307 | }
|
|---|
| 1308 |
|
|---|
| 1309 | return failure;
|
|---|
| 1310 | }
|
|---|
| 1311 |
|
|---|
| 1312 | //
|
|---|
| 1313 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1314 | double lorentz(const ColumnVector& aa, const ColumnVector& bb) {
|
|---|
| 1315 | return aa(1)*bb(1) + aa(2)*bb(2) + aa(3)*bb(3) - aa(4)*bb(4);
|
|---|
| 1316 | }
|
|---|
| 1317 |
|
|---|
| 1318 | //
|
|---|
| 1319 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1320 | void t_pppFilter::bancroft(const Matrix& BBpass, ColumnVector& pos) {
|
|---|
| 1321 |
|
|---|
| 1322 | if (pos.Nrows() != 4) {
|
|---|
| 1323 | pos.ReSize(4);
|
|---|
| 1324 | }
|
|---|
| 1325 | pos = 0.0;
|
|---|
| 1326 |
|
|---|
| 1327 | for (int iter = 1; iter <= 2; iter++) {
|
|---|
| 1328 | Matrix BB = BBpass;
|
|---|
| 1329 | int mm = BB.Nrows();
|
|---|
| 1330 | for (int ii = 1; ii <= mm; ii++) {
|
|---|
| 1331 | double xx = BB(ii,1);
|
|---|
| 1332 | double yy = BB(ii,2);
|
|---|
| 1333 | double traveltime = 0.072;
|
|---|
| 1334 | if (iter > 1) {
|
|---|
| 1335 | double zz = BB(ii,3);
|
|---|
| 1336 | double rho = sqrt( (xx-pos(1)) * (xx-pos(1)) +
|
|---|
| 1337 | (yy-pos(2)) * (yy-pos(2)) +
|
|---|
| 1338 | (zz-pos(3)) * (zz-pos(3)) );
|
|---|
| 1339 | traveltime = rho / t_CST::c;
|
|---|
| 1340 | }
|
|---|
| 1341 | double angle = traveltime * t_CST::omega;
|
|---|
| 1342 | double cosa = cos(angle);
|
|---|
| 1343 | double sina = sin(angle);
|
|---|
| 1344 | BB(ii,1) = cosa * xx + sina * yy;
|
|---|
| 1345 | BB(ii,2) = -sina * xx + cosa * yy;
|
|---|
| 1346 | }
|
|---|
| 1347 |
|
|---|
| 1348 | Matrix BBB;
|
|---|
| 1349 | if (mm > 4) {
|
|---|
| 1350 | SymmetricMatrix hlp; hlp << BB.t() * BB;
|
|---|
| 1351 | BBB = hlp.i() * BB.t();
|
|---|
| 1352 | }
|
|---|
| 1353 | else {
|
|---|
| 1354 | BBB = BB.i();
|
|---|
| 1355 | }
|
|---|
| 1356 | ColumnVector ee(mm); ee = 1.0;
|
|---|
| 1357 | ColumnVector alpha(mm); alpha = 0.0;
|
|---|
| 1358 | for (int ii = 1; ii <= mm; ii++) {
|
|---|
| 1359 | alpha(ii) = lorentz(BB.Row(ii).t(),BB.Row(ii).t())/2.0;
|
|---|
| 1360 | }
|
|---|
| 1361 | ColumnVector BBBe = BBB * ee;
|
|---|
| 1362 | ColumnVector BBBalpha = BBB * alpha;
|
|---|
| 1363 | double aa = lorentz(BBBe, BBBe);
|
|---|
| 1364 | double bb = lorentz(BBBe, BBBalpha)-1;
|
|---|
| 1365 | double cc = lorentz(BBBalpha, BBBalpha);
|
|---|
| 1366 | double root = sqrt(bb*bb-aa*cc);
|
|---|
| 1367 |
|
|---|
| 1368 | Matrix hlpPos(4,2);
|
|---|
| 1369 | hlpPos.Column(1) = (-bb-root)/aa * BBBe + BBBalpha;
|
|---|
| 1370 | hlpPos.Column(2) = (-bb+root)/aa * BBBe + BBBalpha;
|
|---|
| 1371 |
|
|---|
| 1372 | ColumnVector omc(2);
|
|---|
| 1373 | for (int pp = 1; pp <= 2; pp++) {
|
|---|
| 1374 | hlpPos(4,pp) = -hlpPos(4,pp);
|
|---|
| 1375 | omc(pp) = BB(1,4) -
|
|---|
| 1376 | sqrt( (BB(1,1)-hlpPos(1,pp)) * (BB(1,1)-hlpPos(1,pp)) +
|
|---|
| 1377 | (BB(1,2)-hlpPos(2,pp)) * (BB(1,2)-hlpPos(2,pp)) +
|
|---|
| 1378 | (BB(1,3)-hlpPos(3,pp)) * (BB(1,3)-hlpPos(3,pp)) ) -
|
|---|
| 1379 | hlpPos(4,pp);
|
|---|
| 1380 | }
|
|---|
| 1381 | if ( fabs(omc(1)) > fabs(omc(2)) ) {
|
|---|
| 1382 | pos = hlpPos.Column(2);
|
|---|
| 1383 | }
|
|---|
| 1384 | else {
|
|---|
| 1385 | pos = hlpPos.Column(1);
|
|---|
| 1386 | }
|
|---|
| 1387 | }
|
|---|
| 1388 | }
|
|---|
| 1389 |
|
|---|
| 1390 | //
|
|---|
| 1391 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 1392 | void t_pppFilter::cmpDOP(t_epoData* epoData) {
|
|---|
| 1393 |
|
|---|
| 1394 | Tracer tracer("t_pppFilter::cmpDOP");
|
|---|
| 1395 |
|
|---|
| 1396 | _numSat = 0;
|
|---|
| 1397 | _hDop = 0.0;
|
|---|
| 1398 |
|
|---|
| 1399 | if (_params.size() < 4) {
|
|---|
| 1400 | return;
|
|---|
| 1401 | }
|
|---|
| 1402 |
|
|---|
| 1403 | const unsigned numPar = 4;
|
|---|
| 1404 | Matrix AA(epoData->sizeAll(), numPar);
|
|---|
| 1405 | QMapIterator<QString, t_satData*> it(epoData->satData);
|
|---|
| 1406 | while (it.hasNext()) {
|
|---|
| 1407 | it.next();
|
|---|
| 1408 | t_satData* satData = it.value();
|
|---|
| 1409 | _numSat += 1;
|
|---|
| 1410 | for (unsigned iPar = 0; iPar < numPar; iPar++) {
|
|---|
| 1411 | AA[_numSat-1][iPar] = _params[iPar]->partial(satData, false);
|
|---|
| 1412 | }
|
|---|
| 1413 | }
|
|---|
| 1414 | if (_numSat < 4) {
|
|---|
| 1415 | return;
|
|---|
| 1416 | }
|
|---|
| 1417 | AA = AA.Rows(1, _numSat);
|
|---|
| 1418 | SymmetricMatrix NN; NN << AA.t() * AA;
|
|---|
| 1419 | SymmetricMatrix QQ = NN.i();
|
|---|
| 1420 |
|
|---|
| 1421 | _hDop = sqrt(QQ(1,1) + QQ(2,2));
|
|---|
| 1422 | }
|
|---|