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