[2057] | 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: bncParam, bncModel
|
---|
| 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>
|
---|
[2063] | 42 | #include <cmath>
|
---|
[2060] | 43 | #include <newmatio.h>
|
---|
[2113] | 44 | #include <sstream>
|
---|
[2057] | 45 |
|
---|
| 46 | #include "bncmodel.h"
|
---|
[2113] | 47 | #include "bncapp.h"
|
---|
[2058] | 48 | #include "bncpppclient.h"
|
---|
| 49 | #include "bancroft.h"
|
---|
[2063] | 50 | #include "bncutils.h"
|
---|
[2077] | 51 | #include "bncsettings.h"
|
---|
[2580] | 52 | #include "bnctides.h"
|
---|
[2881] | 53 | #include "bncantex.h"
|
---|
[2057] | 54 |
|
---|
| 55 | using namespace std;
|
---|
| 56 |
|
---|
[2243] | 57 | const unsigned MINOBS = 4;
|
---|
[2287] | 58 | const double MINELE_GPS = 10.0 * M_PI / 180.0;
|
---|
| 59 | const double MINELE_GLO = 10.0 * M_PI / 180.0;
|
---|
[2780] | 60 | const double MINELE_GAL = 10.0 * M_PI / 180.0;
|
---|
[2243] | 61 | const double MAXRES_CODE_GPS = 10.0;
|
---|
| 62 | const double MAXRES_PHASE_GPS = 0.10;
|
---|
[2539] | 63 | const double MAXRES_PHASE_GLO = 0.05;
|
---|
[2784] | 64 | const double MAXRES_CODE_GAL = 10.0;
|
---|
| 65 | const double MAXRES_PHASE_GAL = 0.10;
|
---|
[2070] | 66 |
|
---|
[2057] | 67 | // Constructor
|
---|
| 68 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2080] | 69 | bncParam::bncParam(bncParam::parType typeIn, int indexIn,
|
---|
| 70 | const QString& prnIn) {
|
---|
| 71 | type = typeIn;
|
---|
| 72 | index = indexIn;
|
---|
| 73 | prn = prnIn;
|
---|
| 74 | index_old = 0;
|
---|
| 75 | xx = 0.0;
|
---|
[2473] | 76 |
|
---|
[2057] | 77 | }
|
---|
| 78 |
|
---|
| 79 | // Destructor
|
---|
| 80 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 81 | bncParam::~bncParam() {
|
---|
| 82 | }
|
---|
| 83 |
|
---|
[2060] | 84 | // Partial
|
---|
| 85 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2239] | 86 | double bncParam::partial(t_satData* satData, bool phase) {
|
---|
| 87 |
|
---|
| 88 | // Coordinates
|
---|
| 89 | // -----------
|
---|
[2060] | 90 | if (type == CRD_X) {
|
---|
[2109] | 91 | return (xx - satData->xx(1)) / satData->rho;
|
---|
[2060] | 92 | }
|
---|
| 93 | else if (type == CRD_Y) {
|
---|
[2109] | 94 | return (xx - satData->xx(2)) / satData->rho;
|
---|
[2060] | 95 | }
|
---|
| 96 | else if (type == CRD_Z) {
|
---|
[2109] | 97 | return (xx - satData->xx(3)) / satData->rho;
|
---|
[2060] | 98 | }
|
---|
[2239] | 99 |
|
---|
| 100 | // Receiver Clocks
|
---|
| 101 | // ---------------
|
---|
[2265] | 102 | else if (type == RECCLK) {
|
---|
| 103 | return 1.0;
|
---|
[2060] | 104 | }
|
---|
[2239] | 105 |
|
---|
| 106 | // Troposphere
|
---|
| 107 | // -----------
|
---|
[2084] | 108 | else if (type == TROPO) {
|
---|
| 109 | return 1.0 / sin(satData->eleSat);
|
---|
| 110 | }
|
---|
[2239] | 111 |
|
---|
[2782] | 112 | // Galileo Offset
|
---|
| 113 | // --------------
|
---|
| 114 | else if (type == GALILEO_OFFSET) {
|
---|
| 115 | if (satData->prn[0] == 'E') {
|
---|
| 116 | return 1.0;
|
---|
| 117 | }
|
---|
| 118 | else {
|
---|
| 119 | return 0.0;
|
---|
| 120 | }
|
---|
| 121 | }
|
---|
| 122 |
|
---|
[2239] | 123 | // Ambiguities
|
---|
| 124 | // -----------
|
---|
[2080] | 125 | else if (type == AMB_L3) {
|
---|
[2239] | 126 | if (phase && satData->prn == prn) {
|
---|
[2080] | 127 | return 1.0;
|
---|
| 128 | }
|
---|
| 129 | else {
|
---|
| 130 | return 0.0;
|
---|
| 131 | }
|
---|
| 132 | }
|
---|
[2239] | 133 |
|
---|
| 134 | // Default return
|
---|
| 135 | // --------------
|
---|
[2060] | 136 | return 0.0;
|
---|
| 137 | }
|
---|
| 138 |
|
---|
[2058] | 139 | // Constructor
|
---|
| 140 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2113] | 141 | bncModel::bncModel(QByteArray staID) {
|
---|
[2084] | 142 |
|
---|
[2113] | 143 | _staID = staID;
|
---|
| 144 |
|
---|
[3107] | 145 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
| 146 | ((bncApp*)qApp), SLOT(slotMessage(const QByteArray,bool)));
|
---|
| 147 |
|
---|
[2648] | 148 | bncSettings settings;
|
---|
| 149 |
|
---|
[2720] | 150 | // Observation Sigmas
|
---|
| 151 | // ------------------
|
---|
| 152 | _sigP3 = 5.0;
|
---|
| 153 | if (!settings.value("pppSigmaCode").toString().isEmpty()) {
|
---|
| 154 | _sigP3 = settings.value("pppSigmaCode").toDouble();
|
---|
| 155 | }
|
---|
| 156 | _sigL3 = 0.02;
|
---|
| 157 | if (!settings.value("pppSigmaPhase").toString().isEmpty()) {
|
---|
[2741] | 158 | _sigL3 = settings.value("pppSigmaPhase").toDouble();
|
---|
[2720] | 159 | }
|
---|
[2648] | 160 |
|
---|
[2720] | 161 | // Parameter Sigmas
|
---|
| 162 | // ----------------
|
---|
| 163 | _sigCrd0 = 100.0;
|
---|
| 164 | if (!settings.value("pppSigCrd0").toString().isEmpty()) {
|
---|
| 165 | _sigCrd0 = settings.value("pppSigCrd0").toDouble();
|
---|
| 166 | }
|
---|
| 167 | _sigCrdP = 100.0;
|
---|
| 168 | if (!settings.value("pppSigCrdP").toString().isEmpty()) {
|
---|
| 169 | _sigCrdP = settings.value("pppSigCrdP").toDouble();
|
---|
| 170 | }
|
---|
| 171 | _sigTrp0 = 0.1;
|
---|
| 172 | if (!settings.value("pppSigTrp0").toString().isEmpty()) {
|
---|
| 173 | _sigTrp0 = settings.value("pppSigTrp0").toDouble();
|
---|
| 174 | }
|
---|
| 175 | _sigTrpP = 1e-6;
|
---|
| 176 | if (!settings.value("pppSigTrpP").toString().isEmpty()) {
|
---|
| 177 | _sigTrpP = settings.value("pppSigTrpP").toDouble();
|
---|
| 178 | }
|
---|
[2782] | 179 | _sigClk0 = 1000.0;
|
---|
| 180 | _sigAmb0 = 1000.0;
|
---|
| 181 | _sigGalileoOffset0 = 1000.0;
|
---|
[2784] | 182 | _sigGalileoOffsetP = 0.0;
|
---|
[2648] | 183 |
|
---|
[2720] | 184 | // Quick-Start Mode
|
---|
| 185 | // ----------------
|
---|
| 186 | _quickStart = 0;
|
---|
[2726] | 187 | if (settings.value("pppRefCrdX").toString() != "" &&
|
---|
| 188 | settings.value("pppRefCrdY").toString() != "" &&
|
---|
| 189 | settings.value("pppRefCrdZ").toString() != "" &&
|
---|
[2720] | 190 | !settings.value("pppQuickStart").toString().isEmpty()) {
|
---|
[2745] | 191 | _quickStart = settings.value("pppQuickStart").toDouble();
|
---|
[2720] | 192 | }
|
---|
| 193 |
|
---|
[3107] | 194 | // Several options
|
---|
| 195 | // ---------------
|
---|
[2084] | 196 | _usePhase = false;
|
---|
| 197 | if ( Qt::CheckState(settings.value("pppUsePhase").toInt()) == Qt::Checked) {
|
---|
| 198 | _usePhase = true;
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 | _estTropo = false;
|
---|
| 202 | if ( Qt::CheckState(settings.value("pppEstTropo").toInt()) == Qt::Checked) {
|
---|
| 203 | _estTropo = true;
|
---|
| 204 | }
|
---|
| 205 |
|
---|
[3107] | 206 | _useGalileo = false;
|
---|
[2799] | 207 | if ( Qt::CheckState(settings.value("pppGalileo").toInt()) == Qt::Checked) {
|
---|
[3107] | 208 | _useGalileo = true;
|
---|
[2782] | 209 | }
|
---|
[2073] | 210 |
|
---|
[2125] | 211 | // NMEA Output
|
---|
| 212 | // -----------
|
---|
| 213 | QString nmeaFileName = settings.value("nmeaFile").toString();
|
---|
| 214 | if (nmeaFileName.isEmpty()) {
|
---|
| 215 | _nmeaFile = 0;
|
---|
| 216 | _nmeaStream = 0;
|
---|
| 217 | }
|
---|
| 218 | else {
|
---|
| 219 | expandEnvVar(nmeaFileName);
|
---|
| 220 | _nmeaFile = new QFile(nmeaFileName);
|
---|
| 221 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
|
---|
| 222 | _nmeaFile->open(QIODevice::WriteOnly | QIODevice::Append);
|
---|
| 223 | }
|
---|
| 224 | else {
|
---|
| 225 | _nmeaFile->open(QIODevice::WriteOnly);
|
---|
| 226 | }
|
---|
| 227 | _nmeaStream = new QTextStream();
|
---|
| 228 | _nmeaStream->setDevice(_nmeaFile);
|
---|
| 229 | }
|
---|
[2881] | 230 |
|
---|
[3107] | 231 | // Antenna Name, ANTEX File
|
---|
| 232 | // ------------------------
|
---|
[2896] | 233 | _antex = 0;
|
---|
[2881] | 234 | QString antexFileName = settings.value("pppAntex").toString();
|
---|
| 235 | if (!antexFileName.isEmpty()) {
|
---|
| 236 | _antex = new bncAntex();
|
---|
[2883] | 237 | if (_antex->readFile(antexFileName) != success) {
|
---|
[2938] | 238 | emit newMessage("wrong ANTEX file", true);
|
---|
[2887] | 239 | delete _antex;
|
---|
| 240 | _antex = 0;
|
---|
[2883] | 241 | }
|
---|
[2938] | 242 | else {
|
---|
| 243 | _antennaName = settings.value("pppAntenna").toString();
|
---|
| 244 | }
|
---|
[2881] | 245 | }
|
---|
[3107] | 246 |
|
---|
[3286] | 247 | // Antenna Eccentricities
|
---|
| 248 | // ----------------------
|
---|
| 249 | _dN = settings.value("pppRefdN").toDouble();
|
---|
| 250 | _dE = settings.value("pppRefdE").toDouble();
|
---|
| 251 | _dU = settings.value("pppRefdU").toDouble();
|
---|
| 252 |
|
---|
[3107] | 253 | // Bancroft Coordinates
|
---|
| 254 | // --------------------
|
---|
| 255 | _xcBanc.ReSize(4); _xcBanc = 0.0;
|
---|
| 256 | _ellBanc.ReSize(3); _ellBanc = 0.0;
|
---|
[2058] | 257 | }
|
---|
| 258 |
|
---|
[3108] | 259 | // Destructor
|
---|
[3107] | 260 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3108] | 261 | bncModel::~bncModel() {
|
---|
| 262 | delete _nmeaStream;
|
---|
| 263 | delete _nmeaFile;
|
---|
| 264 | for (int ii = 0; ii < _posAverage.size(); ++ii) {
|
---|
| 265 | delete _posAverage[ii];
|
---|
| 266 | }
|
---|
| 267 | delete _antex;
|
---|
| 268 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 269 | delete _params[iPar-1];
|
---|
| 270 | }
|
---|
| 271 | }
|
---|
| 272 |
|
---|
| 273 | // Reset Parameters and Variance-Covariance Matrix
|
---|
| 274 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3107] | 275 | void bncModel::reset() {
|
---|
| 276 |
|
---|
| 277 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 278 | delete _params[iPar-1];
|
---|
| 279 | }
|
---|
| 280 | _params.clear();
|
---|
| 281 |
|
---|
| 282 | int nextPar = 0;
|
---|
| 283 | _params.push_back(new bncParam(bncParam::CRD_X, ++nextPar, ""));
|
---|
| 284 | _params.push_back(new bncParam(bncParam::CRD_Y, ++nextPar, ""));
|
---|
| 285 | _params.push_back(new bncParam(bncParam::CRD_Z, ++nextPar, ""));
|
---|
| 286 | _params.push_back(new bncParam(bncParam::RECCLK, ++nextPar, ""));
|
---|
| 287 | if (_estTropo) {
|
---|
| 288 | _params.push_back(new bncParam(bncParam::TROPO, ++nextPar, ""));
|
---|
| 289 | }
|
---|
| 290 | if (_useGalileo) {
|
---|
| 291 | _params.push_back(new bncParam(bncParam::GALILEO_OFFSET, ++nextPar, ""));
|
---|
| 292 | }
|
---|
| 293 |
|
---|
| 294 | _QQ.ReSize(_params.size());
|
---|
| 295 | _QQ = 0.0;
|
---|
| 296 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 297 | bncParam* pp = _params[iPar-1];
|
---|
| 298 | pp->xx = 0.0;
|
---|
| 299 | if (pp->isCrd()) {
|
---|
| 300 | _QQ(iPar,iPar) = _sigCrd0 * _sigCrd0;
|
---|
| 301 | }
|
---|
| 302 | else if (pp->type == bncParam::RECCLK) {
|
---|
| 303 | _QQ(iPar,iPar) = _sigClk0 * _sigClk0;
|
---|
| 304 | }
|
---|
| 305 | else if (pp->type == bncParam::TROPO) {
|
---|
| 306 | _QQ(iPar,iPar) = _sigTrp0 * _sigTrp0;
|
---|
| 307 | }
|
---|
| 308 | else if (pp->type == bncParam::GALILEO_OFFSET) {
|
---|
| 309 | _QQ(iPar,iPar) = _sigGalileoOffset0 * _sigGalileoOffset0;
|
---|
| 310 | }
|
---|
| 311 | }
|
---|
| 312 | }
|
---|
| 313 |
|
---|
[2058] | 314 | // Bancroft Solution
|
---|
| 315 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 316 | t_irc bncModel::cmpBancroft(t_epoData* epoData) {
|
---|
| 317 |
|
---|
[2231] | 318 | if (epoData->sizeGPS() < MINOBS) {
|
---|
[2547] | 319 | _log += "bncModel::cmpBancroft: not enough data\n";
|
---|
[2058] | 320 | return failure;
|
---|
| 321 | }
|
---|
| 322 |
|
---|
[2231] | 323 | Matrix BB(epoData->sizeGPS(), 4);
|
---|
[2058] | 324 |
|
---|
[2231] | 325 | QMapIterator<QString, t_satData*> it(epoData->satDataGPS);
|
---|
[2791] | 326 | int iObsBanc = 0;
|
---|
[2058] | 327 | while (it.hasNext()) {
|
---|
[2791] | 328 | ++iObsBanc;
|
---|
[2058] | 329 | it.next();
|
---|
| 330 | QString prn = it.key();
|
---|
| 331 | t_satData* satData = it.value();
|
---|
[2791] | 332 | BB(iObsBanc, 1) = satData->xx(1);
|
---|
| 333 | BB(iObsBanc, 2) = satData->xx(2);
|
---|
| 334 | BB(iObsBanc, 3) = satData->xx(3);
|
---|
| 335 | BB(iObsBanc, 4) = satData->P3 + satData->clk;
|
---|
[2058] | 336 | }
|
---|
| 337 |
|
---|
| 338 | bancroft(BB, _xcBanc);
|
---|
| 339 |
|
---|
[2064] | 340 | // Ellipsoidal Coordinates
|
---|
| 341 | // ------------------------
|
---|
| 342 | xyz2ell(_xcBanc.data(), _ellBanc.data());
|
---|
[2063] | 343 |
|
---|
[2064] | 344 | // Compute Satellite Elevations
|
---|
| 345 | // ----------------------------
|
---|
[2231] | 346 | QMutableMapIterator<QString, t_satData*> iGPS(epoData->satDataGPS);
|
---|
| 347 | while (iGPS.hasNext()) {
|
---|
| 348 | iGPS.next();
|
---|
| 349 | t_satData* satData = iGPS.value();
|
---|
[2789] | 350 | cmpEle(satData);
|
---|
[2287] | 351 | if (satData->eleSat < MINELE_GPS) {
|
---|
[2070] | 352 | delete satData;
|
---|
[2231] | 353 | iGPS.remove();
|
---|
[2070] | 354 | }
|
---|
[2064] | 355 | }
|
---|
| 356 |
|
---|
[2231] | 357 | QMutableMapIterator<QString, t_satData*> iGlo(epoData->satDataGlo);
|
---|
| 358 | while (iGlo.hasNext()) {
|
---|
| 359 | iGlo.next();
|
---|
| 360 | t_satData* satData = iGlo.value();
|
---|
[2789] | 361 | cmpEle(satData);
|
---|
[2287] | 362 | if (satData->eleSat < MINELE_GLO) {
|
---|
[2231] | 363 | delete satData;
|
---|
| 364 | iGlo.remove();
|
---|
| 365 | }
|
---|
| 366 | }
|
---|
| 367 |
|
---|
[2780] | 368 | QMutableMapIterator<QString, t_satData*> iGal(epoData->satDataGal);
|
---|
| 369 | while (iGal.hasNext()) {
|
---|
| 370 | iGal.next();
|
---|
| 371 | t_satData* satData = iGal.value();
|
---|
[2789] | 372 | cmpEle(satData);
|
---|
[2780] | 373 | if (satData->eleSat < MINELE_GAL) {
|
---|
| 374 | delete satData;
|
---|
| 375 | iGal.remove();
|
---|
| 376 | }
|
---|
| 377 | }
|
---|
| 378 |
|
---|
[2058] | 379 | return success;
|
---|
| 380 | }
|
---|
[2060] | 381 |
|
---|
| 382 | // Computed Value
|
---|
| 383 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2583] | 384 | double bncModel::cmpValue(t_satData* satData, bool phase) {
|
---|
[2060] | 385 |
|
---|
[2073] | 386 | ColumnVector xRec(3);
|
---|
| 387 | xRec(1) = x();
|
---|
| 388 | xRec(2) = y();
|
---|
| 389 | xRec(3) = z();
|
---|
[2060] | 390 |
|
---|
[2073] | 391 | double rho0 = (satData->xx - xRec).norm_Frobenius();
|
---|
[2060] | 392 | double dPhi = t_CST::omega * rho0 / t_CST::c;
|
---|
| 393 |
|
---|
[2073] | 394 | xRec(1) = x() * cos(dPhi) - y() * sin(dPhi);
|
---|
| 395 | xRec(2) = y() * cos(dPhi) + x() * sin(dPhi);
|
---|
| 396 | xRec(3) = z();
|
---|
| 397 |
|
---|
[2580] | 398 | tides(_time, xRec);
|
---|
| 399 |
|
---|
[2060] | 400 | satData->rho = (satData->xx - xRec).norm_Frobenius();
|
---|
| 401 |
|
---|
[2084] | 402 | double tropDelay = delay_saast(satData->eleSat) +
|
---|
| 403 | trp() / sin(satData->eleSat);
|
---|
[2060] | 404 |
|
---|
[2583] | 405 | double wind = 0.0;
|
---|
| 406 | if (phase) {
|
---|
| 407 | wind = windUp(satData->prn, satData->xx, xRec) * satData->lambda3;
|
---|
| 408 | }
|
---|
| 409 |
|
---|
[2783] | 410 | double offset = 0.0;
|
---|
| 411 | if (satData->prn[0] == 'E') {
|
---|
| 412 | offset = Galileo_offset();
|
---|
| 413 | }
|
---|
| 414 |
|
---|
[2894] | 415 | double phaseCenter = 0.0;
|
---|
[2938] | 416 | if (_antex) {
|
---|
| 417 | bool found;
|
---|
| 418 | phaseCenter = _antex->pco(_antennaName, satData->eleSat, found);
|
---|
| 419 | if (!found) {
|
---|
| 420 | emit newMessage("ANTEX: antenna >"
|
---|
| 421 | + _antennaName.toAscii() + "< not found", true);
|
---|
| 422 | }
|
---|
[2894] | 423 | }
|
---|
| 424 |
|
---|
[3286] | 425 | double antennaOffset = 0.0;
|
---|
| 426 | if (_dN != 0.0 || _dE != 0.0 || _dU != 0.0) {
|
---|
[3287] | 427 | double cosa = cos(satData->azSat);
|
---|
| 428 | double sina = sin(satData->azSat);
|
---|
| 429 | double cose = cos(satData->eleSat);
|
---|
| 430 | double sine = sin(satData->eleSat);
|
---|
| 431 | antennaOffset = -_dN * cosa*cose - _dE * sina*cose - _dU * sine;
|
---|
[3286] | 432 | }
|
---|
| 433 |
|
---|
| 434 | return satData->rho + phaseCenter + antennaOffset + clk()
|
---|
[2894] | 435 | + offset - satData->clk + tropDelay + wind;
|
---|
[2060] | 436 | }
|
---|
| 437 |
|
---|
[2063] | 438 | // Tropospheric Model (Saastamoinen)
|
---|
| 439 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2065] | 440 | double bncModel::delay_saast(double Ele) {
|
---|
[2063] | 441 |
|
---|
[2769] | 442 | double xyz[3];
|
---|
| 443 | xyz[0] = x();
|
---|
| 444 | xyz[1] = y();
|
---|
| 445 | xyz[2] = z();
|
---|
| 446 | double ell[3];
|
---|
| 447 | xyz2ell(xyz, ell);
|
---|
| 448 | double height = ell[2];
|
---|
[2063] | 449 |
|
---|
[2064] | 450 | double pp = 1013.25 * pow(1.0 - 2.26e-5 * height, 5.225);
|
---|
| 451 | double TT = 18.0 - height * 0.0065 + 273.15;
|
---|
| 452 | double hh = 50.0 * exp(-6.396e-4 * height);
|
---|
[2063] | 453 | double ee = hh / 100.0 * exp(-37.2465 + 0.213166*TT - 0.000256908*TT*TT);
|
---|
| 454 |
|
---|
[2064] | 455 | double h_km = height / 1000.0;
|
---|
[2063] | 456 |
|
---|
| 457 | if (h_km < 0.0) h_km = 0.0;
|
---|
| 458 | if (h_km > 5.0) h_km = 5.0;
|
---|
| 459 | int ii = int(h_km + 1);
|
---|
| 460 | double href = ii - 1;
|
---|
| 461 |
|
---|
| 462 | double bCor[6];
|
---|
| 463 | bCor[0] = 1.156;
|
---|
| 464 | bCor[1] = 1.006;
|
---|
| 465 | bCor[2] = 0.874;
|
---|
| 466 | bCor[3] = 0.757;
|
---|
| 467 | bCor[4] = 0.654;
|
---|
| 468 | bCor[5] = 0.563;
|
---|
| 469 |
|
---|
| 470 | double BB = bCor[ii-1] + (bCor[ii]-bCor[ii-1]) * (h_km - href);
|
---|
| 471 |
|
---|
| 472 | double zen = M_PI/2.0 - Ele;
|
---|
| 473 |
|
---|
| 474 | return (0.002277/cos(zen)) * (pp + ((1255.0/TT)+0.05)*ee - BB*(tan(zen)*tan(zen)));
|
---|
| 475 | }
|
---|
| 476 |
|
---|
[2073] | 477 | // Prediction Step of the Filter
|
---|
| 478 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2080] | 479 | void bncModel::predict(t_epoData* epoData) {
|
---|
[2073] | 480 |
|
---|
[2648] | 481 | bncSettings settings;
|
---|
[2244] | 482 |
|
---|
[3106] | 483 | _time = epoData->tt; // current epoch time
|
---|
| 484 |
|
---|
[3118] | 485 | _maxSolGap = settings.value("pppMaxSolGap").toDouble();
|
---|
| 486 |
|
---|
[2648] | 487 | bool firstCrd = false;
|
---|
[3118] | 488 | if (!_lastTimeOK.valid() || (_maxSolGap > 0 && _time - _lastTimeOK > _maxSolGap)) {
|
---|
[2648] | 489 | firstCrd = true;
|
---|
[2874] | 490 | _startTime = epoData->tt;
|
---|
[3107] | 491 | reset();
|
---|
[2648] | 492 | }
|
---|
| 493 |
|
---|
[2726] | 494 | // Use different white noise for Quick-Start mode
|
---|
[2720] | 495 | // ----------------------------------------------
|
---|
| 496 | double sigCrdP_used = _sigCrdP;
|
---|
[2874] | 497 | if ( _quickStart > 0.0 && _quickStart > (epoData->tt - _startTime) ) {
|
---|
[2720] | 498 | sigCrdP_used = 0.0;
|
---|
[2648] | 499 | }
|
---|
| 500 |
|
---|
[2244] | 501 | // Predict Parameter values, add white noise
|
---|
| 502 | // -----------------------------------------
|
---|
| 503 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 504 | bncParam* pp = _params[iPar-1];
|
---|
| 505 |
|
---|
| 506 | // Coordinates
|
---|
| 507 | // -----------
|
---|
| 508 | if (pp->type == bncParam::CRD_X) {
|
---|
[2720] | 509 | if (firstCrd) {
|
---|
[2726] | 510 | if (settings.value("pppRefCrdX").toString() != "" &&
|
---|
| 511 | settings.value("pppRefCrdY").toString() != "" &&
|
---|
| 512 | settings.value("pppRefCrdZ").toString() != "") {
|
---|
[2648] | 513 | pp->xx = settings.value("pppRefCrdX").toDouble();
|
---|
| 514 | }
|
---|
| 515 | else {
|
---|
| 516 | pp->xx = _xcBanc(1);
|
---|
| 517 | }
|
---|
[2244] | 518 | }
|
---|
[2720] | 519 | _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
|
---|
[2244] | 520 | }
|
---|
| 521 | else if (pp->type == bncParam::CRD_Y) {
|
---|
[2720] | 522 | if (firstCrd) {
|
---|
[2726] | 523 | if (settings.value("pppRefCrdX").toString() != "" &&
|
---|
| 524 | settings.value("pppRefCrdY").toString() != "" &&
|
---|
| 525 | settings.value("pppRefCrdZ").toString() != "") {
|
---|
[2648] | 526 | pp->xx = settings.value("pppRefCrdY").toDouble();
|
---|
| 527 | }
|
---|
| 528 | else {
|
---|
| 529 | pp->xx = _xcBanc(2);
|
---|
| 530 | }
|
---|
[2244] | 531 | }
|
---|
[2720] | 532 | _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
|
---|
[2244] | 533 | }
|
---|
| 534 | else if (pp->type == bncParam::CRD_Z) {
|
---|
[2720] | 535 | if (firstCrd) {
|
---|
[2726] | 536 | if (settings.value("pppRefCrdX").toString() != "" &&
|
---|
| 537 | settings.value("pppRefCrdY").toString() != "" &&
|
---|
| 538 | settings.value("pppRefCrdZ").toString() != "") {
|
---|
[2648] | 539 | pp->xx = settings.value("pppRefCrdZ").toDouble();
|
---|
| 540 | }
|
---|
| 541 | else {
|
---|
| 542 | pp->xx = _xcBanc(3);
|
---|
| 543 | }
|
---|
[2244] | 544 | }
|
---|
[2720] | 545 | _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
|
---|
[2244] | 546 | }
|
---|
| 547 |
|
---|
| 548 | // Receiver Clocks
|
---|
| 549 | // ---------------
|
---|
[2265] | 550 | else if (pp->type == bncParam::RECCLK) {
|
---|
[2244] | 551 | pp->xx = _xcBanc(4);
|
---|
| 552 | for (int jj = 1; jj <= _params.size(); jj++) {
|
---|
| 553 | _QQ(iPar, jj) = 0.0;
|
---|
| 554 | }
|
---|
[2720] | 555 | _QQ(iPar,iPar) = _sigClk0 * _sigClk0;
|
---|
[2244] | 556 | }
|
---|
| 557 |
|
---|
| 558 | // Tropospheric Delay
|
---|
| 559 | // ------------------
|
---|
| 560 | else if (pp->type == bncParam::TROPO) {
|
---|
[2720] | 561 | _QQ(iPar,iPar) += _sigTrpP * _sigTrpP;
|
---|
[2244] | 562 | }
|
---|
[2782] | 563 |
|
---|
| 564 | // Galileo Offset
|
---|
| 565 | // --------------
|
---|
| 566 | else if (pp->type == bncParam::GALILEO_OFFSET) {
|
---|
| 567 | _QQ(iPar,iPar) += _sigGalileoOffsetP * _sigGalileoOffsetP;
|
---|
| 568 | }
|
---|
[2244] | 569 | }
|
---|
| 570 |
|
---|
| 571 | // Add New Ambiguities if necessary
|
---|
| 572 | // --------------------------------
|
---|
[2083] | 573 | if (_usePhase) {
|
---|
[2080] | 574 |
|
---|
[2083] | 575 | // Make a copy of QQ and xx, set parameter indices
|
---|
| 576 | // -----------------------------------------------
|
---|
| 577 | SymmetricMatrix QQ_old = _QQ;
|
---|
| 578 |
|
---|
| 579 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 580 | _params[iPar-1]->index_old = _params[iPar-1]->index;
|
---|
| 581 | _params[iPar-1]->index = 0;
|
---|
| 582 | }
|
---|
| 583 |
|
---|
| 584 | // Remove Ambiguity Parameters without observations
|
---|
| 585 | // ------------------------------------------------
|
---|
| 586 | int iPar = 0;
|
---|
| 587 | QMutableVectorIterator<bncParam*> it(_params);
|
---|
| 588 | while (it.hasNext()) {
|
---|
| 589 | bncParam* par = it.next();
|
---|
| 590 | bool removed = false;
|
---|
| 591 | if (par->type == bncParam::AMB_L3) {
|
---|
[2231] | 592 | if (epoData->satDataGPS.find(par->prn) == epoData->satDataGPS.end() &&
|
---|
[2780] | 593 | epoData->satDataGlo.find(par->prn) == epoData->satDataGlo.end() &&
|
---|
| 594 | epoData->satDataGal.find(par->prn) == epoData->satDataGal.end() ) {
|
---|
[2083] | 595 | removed = true;
|
---|
| 596 | delete par;
|
---|
| 597 | it.remove();
|
---|
| 598 | }
|
---|
[2080] | 599 | }
|
---|
[2083] | 600 | if (! removed) {
|
---|
| 601 | ++iPar;
|
---|
| 602 | par->index = iPar;
|
---|
| 603 | }
|
---|
[2080] | 604 | }
|
---|
[2083] | 605 |
|
---|
| 606 | // Add new ambiguity parameters
|
---|
| 607 | // ----------------------------
|
---|
[2231] | 608 | QMapIterator<QString, t_satData*> iGPS(epoData->satDataGPS);
|
---|
| 609 | while (iGPS.hasNext()) {
|
---|
| 610 | iGPS.next();
|
---|
[2244] | 611 | t_satData* satData = iGPS.value();
|
---|
[2789] | 612 | addAmb(satData);
|
---|
[2080] | 613 | }
|
---|
[2231] | 614 |
|
---|
| 615 | QMapIterator<QString, t_satData*> iGlo(epoData->satDataGlo);
|
---|
| 616 | while (iGlo.hasNext()) {
|
---|
| 617 | iGlo.next();
|
---|
[2233] | 618 | t_satData* satData = iGlo.value();
|
---|
[2789] | 619 | addAmb(satData);
|
---|
[2231] | 620 | }
|
---|
[2780] | 621 |
|
---|
| 622 | QMapIterator<QString, t_satData*> iGal(epoData->satDataGal);
|
---|
| 623 | while (iGal.hasNext()) {
|
---|
| 624 | iGal.next();
|
---|
| 625 | t_satData* satData = iGal.value();
|
---|
[2789] | 626 | addAmb(satData);
|
---|
[2780] | 627 | }
|
---|
[2083] | 628 |
|
---|
| 629 | int nPar = _params.size();
|
---|
| 630 | _QQ.ReSize(nPar); _QQ = 0.0;
|
---|
| 631 | for (int i1 = 1; i1 <= nPar; i1++) {
|
---|
| 632 | bncParam* p1 = _params[i1-1];
|
---|
| 633 | if (p1->index_old != 0) {
|
---|
| 634 | _QQ(p1->index, p1->index) = QQ_old(p1->index_old, p1->index_old);
|
---|
| 635 | for (int i2 = 1; i2 <= nPar; i2++) {
|
---|
| 636 | bncParam* p2 = _params[i2-1];
|
---|
| 637 | if (p2->index_old != 0) {
|
---|
| 638 | _QQ(p1->index, p2->index) = QQ_old(p1->index_old, p2->index_old);
|
---|
| 639 | }
|
---|
[2080] | 640 | }
|
---|
| 641 | }
|
---|
| 642 | }
|
---|
[2083] | 643 |
|
---|
| 644 | for (int ii = 1; ii <= nPar; ii++) {
|
---|
| 645 | bncParam* par = _params[ii-1];
|
---|
| 646 | if (par->index_old == 0) {
|
---|
[2720] | 647 | _QQ(par->index, par->index) = _sigAmb0 * _sigAmb0;
|
---|
[2083] | 648 | }
|
---|
| 649 | par->index_old = par->index;
|
---|
[2080] | 650 | }
|
---|
| 651 | }
|
---|
[2073] | 652 | }
|
---|
| 653 |
|
---|
[2060] | 654 | // Update Step of the Filter (currently just a single-epoch solution)
|
---|
| 655 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 656 | t_irc bncModel::update(t_epoData* epoData) {
|
---|
| 657 |
|
---|
[2473] | 658 | bncSettings settings;
|
---|
| 659 |
|
---|
[2248] | 660 | _log.clear();
|
---|
[2124] | 661 |
|
---|
[2827] | 662 | if (settings.value("pppSPP").toString() == "PPP") {
|
---|
| 663 | _log += "Precise Point Positioning of Epoch "
|
---|
| 664 | + QByteArray(_time.timestr(1).c_str()) +
|
---|
| 665 | "\n---------------------------------------------------------------\n";
|
---|
| 666 | }
|
---|
| 667 | else {
|
---|
| 668 | _log += "Single Point Positioning of Epoch "
|
---|
| 669 | + QByteArray(_time.timestr(1).c_str()) +
|
---|
[2547] | 670 | "\n--------------------------------------------------------------\n";
|
---|
[2827] | 671 | }
|
---|
[2547] | 672 |
|
---|
[3307] | 673 | // Outlier Detection Loop
|
---|
[2113] | 674 | // ----------------------
|
---|
[3307] | 675 | ColumnVector dx;
|
---|
| 676 | if (update_p(epoData, dx) != success) {
|
---|
| 677 | return failure;
|
---|
| 678 | }
|
---|
[2080] | 679 |
|
---|
[2670] | 680 | // Remember the Epoch-specific Results for the computation of means
|
---|
| 681 | // ----------------------------------------------------------------
|
---|
| 682 | pppPos* newPos = new pppPos;
|
---|
| 683 | newPos->time = epoData->tt;
|
---|
| 684 |
|
---|
[2109] | 685 | // Set Solution Vector
|
---|
| 686 | // -------------------
|
---|
[2265] | 687 | ostringstream strB;
|
---|
| 688 | strB.setf(ios::fixed);
|
---|
[2073] | 689 | QVectorIterator<bncParam*> itPar(_params);
|
---|
[2060] | 690 | while (itPar.hasNext()) {
|
---|
| 691 | bncParam* par = itPar.next();
|
---|
[2109] | 692 | par->xx += dx(par->index);
|
---|
[2265] | 693 |
|
---|
| 694 | if (par->type == bncParam::RECCLK) {
|
---|
[2798] | 695 | strB << "\n clk = " << setw(10) << setprecision(3) << par->xx
|
---|
[2124] | 696 | << " +- " << setw(6) << setprecision(3)
|
---|
| 697 | << sqrt(_QQ(par->index,par->index));
|
---|
| 698 | }
|
---|
| 699 | else if (par->type == bncParam::AMB_L3) {
|
---|
[2265] | 700 | strB << "\n amb " << par->prn.toAscii().data() << " = "
|
---|
[2798] | 701 | << setw(10) << setprecision(3) << par->xx
|
---|
[2124] | 702 | << " +- " << setw(6) << setprecision(3)
|
---|
| 703 | << sqrt(_QQ(par->index,par->index));
|
---|
| 704 | }
|
---|
[2212] | 705 | else if (par->type == bncParam::TROPO) {
|
---|
[2670] | 706 | double aprTrp = delay_saast(M_PI/2.0);
|
---|
[2547] | 707 | strB << "\n trp = " << par->prn.toAscii().data()
|
---|
[2670] | 708 | << setw(7) << setprecision(3) << aprTrp << " "
|
---|
[2213] | 709 | << setw(6) << setprecision(3) << showpos << par->xx << noshowpos
|
---|
[2212] | 710 | << " +- " << setw(6) << setprecision(3)
|
---|
| 711 | << sqrt(_QQ(par->index,par->index));
|
---|
[2670] | 712 | newPos->xnt[6] = aprTrp + par->xx;
|
---|
[2212] | 713 | }
|
---|
[2782] | 714 | else if (par->type == bncParam::GALILEO_OFFSET) {
|
---|
[2798] | 715 | strB << "\n offset = " << setw(10) << setprecision(3) << par->xx
|
---|
[2782] | 716 | << " +- " << setw(6) << setprecision(3)
|
---|
| 717 | << sqrt(_QQ(par->index,par->index));
|
---|
| 718 | }
|
---|
[2060] | 719 | }
|
---|
[2265] | 720 | strB << '\n';
|
---|
[2547] | 721 | _log += strB.str().c_str();
|
---|
| 722 | emit newMessage(_log, false);
|
---|
[2060] | 723 |
|
---|
[2547] | 724 | // Final Message (both log file and screen)
|
---|
| 725 | // ----------------------------------------
|
---|
| 726 | ostringstream strC;
|
---|
| 727 | strC.setf(ios::fixed);
|
---|
| 728 | strC << _staID.data() << " PPP "
|
---|
[2599] | 729 | << epoData->tt.timestr(1) << " " << epoData->sizeAll() << " "
|
---|
[2231] | 730 | << setw(14) << setprecision(3) << x() << " +- "
|
---|
| 731 | << setw(6) << setprecision(3) << sqrt(_QQ(1,1)) << " "
|
---|
| 732 | << setw(14) << setprecision(3) << y() << " +- "
|
---|
| 733 | << setw(6) << setprecision(3) << sqrt(_QQ(2,2)) << " "
|
---|
| 734 | << setw(14) << setprecision(3) << z() << " +- "
|
---|
[2124] | 735 | << setw(6) << setprecision(3) << sqrt(_QQ(3,3));
|
---|
[2113] | 736 |
|
---|
[2370] | 737 | // NEU Output
|
---|
| 738 | // ----------
|
---|
[2862] | 739 | double xyzRef[3];
|
---|
| 740 |
|
---|
[2726] | 741 | if (settings.value("pppRefCrdX").toString() != "" &&
|
---|
| 742 | settings.value("pppRefCrdY").toString() != "" &&
|
---|
| 743 | settings.value("pppRefCrdZ").toString() != "") {
|
---|
[2649] | 744 |
|
---|
[2370] | 745 | xyzRef[0] = settings.value("pppRefCrdX").toDouble();
|
---|
| 746 | xyzRef[1] = settings.value("pppRefCrdY").toDouble();
|
---|
| 747 | xyzRef[2] = settings.value("pppRefCrdZ").toDouble();
|
---|
[2649] | 748 |
|
---|
[2670] | 749 | newPos->xnt[0] = x() - xyzRef[0];
|
---|
| 750 | newPos->xnt[1] = y() - xyzRef[1];
|
---|
| 751 | newPos->xnt[2] = z() - xyzRef[2];
|
---|
[2649] | 752 |
|
---|
| 753 | double ellRef[3];
|
---|
[2370] | 754 | xyz2ell(xyzRef, ellRef);
|
---|
[2670] | 755 | xyz2neu(ellRef, newPos->xnt, &newPos->xnt[3]);
|
---|
[2649] | 756 |
|
---|
[2547] | 757 | strC << " NEU "
|
---|
[2670] | 758 | << setw(8) << setprecision(3) << newPos->xnt[3] << " "
|
---|
| 759 | << setw(8) << setprecision(3) << newPos->xnt[4] << " "
|
---|
[2797] | 760 | << setw(8) << setprecision(3) << newPos->xnt[5] << endl;
|
---|
[2649] | 761 |
|
---|
[2370] | 762 | }
|
---|
| 763 |
|
---|
[2547] | 764 | emit newMessage(QByteArray(strC.str().c_str()), true);
|
---|
| 765 |
|
---|
[2671] | 766 | if (settings.value("pppAverage").toString() == "") {
|
---|
| 767 | delete newPos;
|
---|
| 768 | }
|
---|
| 769 | else {
|
---|
| 770 |
|
---|
| 771 | _posAverage.push_back(newPos);
|
---|
[2599] | 772 |
|
---|
[2648] | 773 | // Time Span for Average Computation
|
---|
| 774 | // ---------------------------------
|
---|
| 775 | double tRangeAverage = settings.value("pppAverage").toDouble() * 60.;
|
---|
| 776 | if (tRangeAverage < 0) {
|
---|
| 777 | tRangeAverage = 0;
|
---|
| 778 | }
|
---|
| 779 | if (tRangeAverage > 86400) {
|
---|
| 780 | tRangeAverage = 86400;
|
---|
| 781 | }
|
---|
[2599] | 782 |
|
---|
[2648] | 783 | // Compute the Mean
|
---|
| 784 | // ----------------
|
---|
[2670] | 785 | ColumnVector mean(7); mean = 0.0;
|
---|
[2648] | 786 |
|
---|
[2599] | 787 | QMutableVectorIterator<pppPos*> it(_posAverage);
|
---|
| 788 | while (it.hasNext()) {
|
---|
| 789 | pppPos* pp = it.next();
|
---|
[2648] | 790 | if ( (epoData->tt - pp->time) >= tRangeAverage ) {
|
---|
[2599] | 791 | delete pp;
|
---|
| 792 | it.remove();
|
---|
| 793 | }
|
---|
[2648] | 794 | else {
|
---|
[2670] | 795 | for (int ii = 0; ii < 7; ++ii) {
|
---|
| 796 | mean[ii] += pp->xnt[ii];
|
---|
[2649] | 797 | }
|
---|
[2648] | 798 | }
|
---|
[2599] | 799 | }
|
---|
[2648] | 800 |
|
---|
| 801 | int nn = _posAverage.size();
|
---|
| 802 |
|
---|
[2649] | 803 | if (nn > 0) {
|
---|
[2648] | 804 |
|
---|
[2649] | 805 | mean /= nn;
|
---|
| 806 |
|
---|
| 807 | // Compute the Deviation
|
---|
| 808 | // ---------------------
|
---|
[2670] | 809 | ColumnVector std(7); std = 0.0;
|
---|
[2649] | 810 | QVectorIterator<pppPos*> it2(_posAverage);
|
---|
| 811 | while (it2.hasNext()) {
|
---|
| 812 | pppPos* pp = it2.next();
|
---|
[2670] | 813 | for (int ii = 0; ii < 7; ++ii) {
|
---|
| 814 | std[ii] += (pp->xnt[ii] - mean[ii]) * (pp->xnt[ii] - mean[ii]);
|
---|
[2649] | 815 | }
|
---|
| 816 | }
|
---|
[2670] | 817 | for (int ii = 0; ii < 7; ++ii) {
|
---|
[2649] | 818 | std[ii] = sqrt(std[ii] / nn);
|
---|
| 819 | }
|
---|
[3169] | 820 |
|
---|
| 821 | if (settings.value("pppRefCrdX").toString() != "" &&
|
---|
| 822 | settings.value("pppRefCrdY").toString() != "" &&
|
---|
| 823 | settings.value("pppRefCrdZ").toString() != "") {
|
---|
[2649] | 824 |
|
---|
[3169] | 825 | ostringstream strD; strD.setf(ios::fixed);
|
---|
| 826 | strD << _staID.data() << " AVE-XYZ "
|
---|
| 827 | << epoData->tt.timestr(1) << " "
|
---|
| 828 | << setw(13) << setprecision(3) << mean[0] + xyzRef[0] << " +- "
|
---|
| 829 | << setw(6) << setprecision(3) << std[0] << " "
|
---|
| 830 | << setw(14) << setprecision(3) << mean[1] + xyzRef[1] << " +- "
|
---|
| 831 | << setw(6) << setprecision(3) << std[1] << " "
|
---|
| 832 | << setw(14) << setprecision(3) << mean[2] + xyzRef[2] << " +- "
|
---|
| 833 | << setw(6) << setprecision(3) << std[2];
|
---|
| 834 | emit newMessage(QByteArray(strD.str().c_str()), true);
|
---|
[2649] | 835 |
|
---|
[3169] | 836 | ostringstream strE; strE.setf(ios::fixed);
|
---|
| 837 | strE << _staID.data() << " AVE-NEU "
|
---|
| 838 | << epoData->tt.timestr(1) << " "
|
---|
| 839 | << setw(13) << setprecision(3) << mean[3] << " +- "
|
---|
| 840 | << setw(6) << setprecision(3) << std[3] << " "
|
---|
| 841 | << setw(14) << setprecision(3) << mean[4] << " +- "
|
---|
| 842 | << setw(6) << setprecision(3) << std[4] << " "
|
---|
| 843 | << setw(14) << setprecision(3) << mean[5] << " +- "
|
---|
| 844 | << setw(6) << setprecision(3) << std[5];
|
---|
| 845 | emit newMessage(QByteArray(strE.str().c_str()), true);
|
---|
[2649] | 846 |
|
---|
[3169] | 847 | if ( Qt::CheckState(settings.value("pppEstTropo").toInt()) == Qt::Checked) {
|
---|
| 848 | ostringstream strF; strF.setf(ios::fixed);
|
---|
| 849 | strF << _staID.data() << " AVE-TRP "
|
---|
| 850 | << epoData->tt.timestr(1) << " "
|
---|
| 851 | << setw(13) << setprecision(3) << mean[6] << " +- "
|
---|
| 852 | << setw(6) << setprecision(3) << std[6] << endl;
|
---|
| 853 | emit newMessage(QByteArray(strF.str().c_str()), true);
|
---|
| 854 | }
|
---|
[2726] | 855 | }
|
---|
[2599] | 856 | }
|
---|
| 857 | }
|
---|
| 858 |
|
---|
[2131] | 859 | // NMEA Output
|
---|
| 860 | // -----------
|
---|
[2181] | 861 | double xyz[3];
|
---|
| 862 | xyz[0] = x();
|
---|
| 863 | xyz[1] = y();
|
---|
| 864 | xyz[2] = z();
|
---|
| 865 | double ell[3];
|
---|
| 866 | xyz2ell(xyz, ell);
|
---|
| 867 | double phiDeg = ell[0] * 180 / M_PI;
|
---|
| 868 | double lamDeg = ell[1] * 180 / M_PI;
|
---|
[2132] | 869 |
|
---|
[2181] | 870 | char phiCh = 'N';
|
---|
| 871 | if (phiDeg < 0) {
|
---|
| 872 | phiDeg = -phiDeg;
|
---|
| 873 | phiCh = 'S';
|
---|
| 874 | }
|
---|
| 875 | char lamCh = 'E';
|
---|
| 876 | if (lamDeg < 0) {
|
---|
[2563] | 877 | lamDeg = -lamDeg;
|
---|
| 878 | lamCh = 'W';
|
---|
[2181] | 879 | }
|
---|
[2132] | 880 |
|
---|
[2566] | 881 | string datestr = epoData->tt.datestr(0); // yyyymmdd
|
---|
| 882 | ostringstream strRMC;
|
---|
| 883 | strRMC.setf(ios::fixed);
|
---|
| 884 | strRMC << "GPRMC,"
|
---|
| 885 | << epoData->tt.timestr(0,0) << ",A,"
|
---|
| 886 | << setw(2) << setfill('0') << int(phiDeg)
|
---|
| 887 | << setw(6) << setprecision(3) << setfill('0')
|
---|
| 888 | << fmod(60*phiDeg,60) << ',' << phiCh << ','
|
---|
| 889 | << setw(3) << setfill('0') << int(lamDeg)
|
---|
| 890 | << setw(6) << setprecision(3) << setfill('0')
|
---|
| 891 | << fmod(60*lamDeg,60) << ',' << lamCh << ",,,"
|
---|
[2569] | 892 | << datestr[6] << datestr[7] << datestr[4] << datestr[5]
|
---|
| 893 | << datestr[2] << datestr[3] << ",,";
|
---|
[2566] | 894 |
|
---|
| 895 | writeNMEAstr(QString(strRMC.str().c_str()));
|
---|
| 896 |
|
---|
[2181] | 897 | double dop = 2.0; // TODO
|
---|
[2133] | 898 |
|
---|
[2566] | 899 | ostringstream strGGA;
|
---|
| 900 | strGGA.setf(ios::fixed);
|
---|
| 901 | strGGA << "GPGGA,"
|
---|
| 902 | << epoData->tt.timestr(0,0) << ','
|
---|
| 903 | << setw(2) << setfill('0') << int(phiDeg)
|
---|
| 904 | << setw(10) << setprecision(7) << setfill('0')
|
---|
| 905 | << fmod(60*phiDeg,60) << ',' << phiCh << ','
|
---|
| 906 | << setw(3) << setfill('0') << int(lamDeg)
|
---|
| 907 | << setw(10) << setprecision(7) << setfill('0')
|
---|
| 908 | << fmod(60*lamDeg,60) << ',' << lamCh
|
---|
| 909 | << ",1," << setw(2) << setfill('0') << epoData->sizeAll() << ','
|
---|
| 910 | << setw(3) << setprecision(1) << dop << ','
|
---|
[2569] | 911 | << setprecision(3) << ell[2] << ",M,0.0,M,,";
|
---|
[2181] | 912 |
|
---|
[2566] | 913 | writeNMEAstr(QString(strGGA.str().c_str()));
|
---|
[2131] | 914 |
|
---|
[3106] | 915 | _lastTimeOK = _time; // remember time of last successful update
|
---|
[2060] | 916 | return success;
|
---|
| 917 | }
|
---|
[2112] | 918 |
|
---|
| 919 | // Outlier Detection
|
---|
| 920 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3308] | 921 | int bncModel::outlierDetection(int phase, const SymmetricMatrix& QQsav,
|
---|
[2112] | 922 | const ColumnVector& vv,
|
---|
[2231] | 923 | QMap<QString, t_satData*>& satDataGPS,
|
---|
[2780] | 924 | QMap<QString, t_satData*>& satDataGlo,
|
---|
| 925 | QMap<QString, t_satData*>& satDataGal) {
|
---|
[2112] | 926 |
|
---|
[2792] | 927 | QString prnCode;
|
---|
| 928 | QString prnPhase;
|
---|
| 929 | double maxResCode = 0.0;
|
---|
| 930 | double maxResPhase = 0.0;
|
---|
[2231] | 931 |
|
---|
[2792] | 932 | QString prnRemoved;
|
---|
| 933 | double maxRes;
|
---|
[2112] | 934 |
|
---|
[2793] | 935 | int irc = 0;
|
---|
| 936 |
|
---|
[3308] | 937 | if (phase == 0) {
|
---|
[3281] | 938 |
|
---|
[3308] | 939 | // Check GPS Code
|
---|
| 940 | // --------------
|
---|
| 941 | if (irc == 0) {
|
---|
| 942 | findMaxRes(vv,satDataGPS, prnCode, maxResCode, prnPhase, maxResPhase);
|
---|
| 943 | if (maxResCode > MAXRES_CODE_GPS) {
|
---|
| 944 | satDataGPS.remove(prnCode);
|
---|
| 945 | prnRemoved = prnCode;
|
---|
| 946 | maxRes = maxResCode;
|
---|
| 947 | irc = 1;
|
---|
| 948 | }
|
---|
[3281] | 949 | }
|
---|
[3308] | 950 |
|
---|
| 951 | // Check Galileo Code
|
---|
| 952 | // ------------------
|
---|
| 953 | if (irc == 0) {
|
---|
| 954 | findMaxRes(vv,satDataGal, prnCode, maxResCode, prnPhase, maxResPhase);
|
---|
| 955 | if (maxResCode > MAXRES_CODE_GAL) {
|
---|
| 956 | satDataGal.remove(prnCode);
|
---|
| 957 | prnRemoved = prnCode;
|
---|
| 958 | maxRes = maxResCode;
|
---|
| 959 | irc = 1;
|
---|
| 960 | }
|
---|
[2793] | 961 | }
|
---|
[2792] | 962 | }
|
---|
[2112] | 963 |
|
---|
[3308] | 964 | else {
|
---|
| 965 | // Check Glonass Phase
|
---|
| 966 | // -------------------
|
---|
| 967 | if (irc == 0) {
|
---|
| 968 | findMaxRes(vv,satDataGlo, prnCode, maxResCode, prnPhase, maxResPhase);
|
---|
| 969 | if (maxResPhase > MAXRES_PHASE_GLO) {
|
---|
| 970 | satDataGlo.remove(prnPhase);
|
---|
| 971 | prnRemoved = prnPhase;
|
---|
| 972 | maxRes = maxResPhase;
|
---|
| 973 | irc = 1;
|
---|
| 974 | }
|
---|
[2112] | 975 | }
|
---|
[3308] | 976 |
|
---|
| 977 | // Check Galileo Phase
|
---|
| 978 | // -------------------
|
---|
| 979 | if (irc == 0) {
|
---|
| 980 | findMaxRes(vv,satDataGal, prnCode, maxResCode, prnPhase, maxResPhase);
|
---|
| 981 | if (maxResPhase > MAXRES_PHASE_GAL) {
|
---|
| 982 | satDataGal.remove(prnPhase);
|
---|
| 983 | prnRemoved = prnPhase;
|
---|
| 984 | maxRes = maxResPhase;
|
---|
| 985 | irc = 1;
|
---|
| 986 | }
|
---|
[2780] | 987 | }
|
---|
[3308] | 988 |
|
---|
| 989 | // Check GPS Phase
|
---|
| 990 | // ---------------
|
---|
| 991 | if (irc == 0) {
|
---|
| 992 | findMaxRes(vv,satDataGPS, prnCode, maxResCode, prnPhase, maxResPhase);
|
---|
| 993 | if (maxResPhase > MAXRES_PHASE_GPS) {
|
---|
| 994 | satDataGPS.remove(prnPhase);
|
---|
| 995 | prnRemoved = prnPhase;
|
---|
| 996 | maxRes = maxResPhase;
|
---|
| 997 | irc = 1;
|
---|
| 998 | }
|
---|
| 999 | }
|
---|
[2780] | 1000 | }
|
---|
| 1001 |
|
---|
[2793] | 1002 | if (irc != 0) {
|
---|
[2792] | 1003 | _log += "Outlier " + prnRemoved.toAscii() + " "
|
---|
| 1004 | + QByteArray::number(maxRes, 'f', 3) + "\n";
|
---|
[2248] | 1005 | _QQ = QQsav;
|
---|
| 1006 | }
|
---|
[2793] | 1007 |
|
---|
| 1008 | return irc;
|
---|
[2112] | 1009 | }
|
---|
[2130] | 1010 |
|
---|
| 1011 | //
|
---|
| 1012 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 1013 | void bncModel::writeNMEAstr(const QString& nmStr) {
|
---|
| 1014 |
|
---|
| 1015 | unsigned char XOR = 0;
|
---|
| 1016 | for (int ii = 0; ii < nmStr.length(); ii++) {
|
---|
| 1017 | XOR ^= (unsigned char) nmStr[ii].toAscii();
|
---|
| 1018 | }
|
---|
[2181] | 1019 |
|
---|
| 1020 | QString outStr = '$' + nmStr
|
---|
| 1021 | + QString("*%1\n").arg(int(XOR), 0, 16).toUpper();
|
---|
[2130] | 1022 |
|
---|
[2178] | 1023 | if (_nmeaStream) {
|
---|
[2181] | 1024 | *_nmeaStream << outStr;
|
---|
[2178] | 1025 | _nmeaStream->flush();
|
---|
| 1026 | }
|
---|
[2130] | 1027 |
|
---|
[2181] | 1028 | emit newNMEAstr(outStr.toAscii());
|
---|
[2130] | 1029 | }
|
---|
[2283] | 1030 |
|
---|
| 1031 | ////
|
---|
| 1032 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 1033 | void bncModel::kalman(const Matrix& AA, const ColumnVector& ll,
|
---|
| 1034 | const DiagonalMatrix& PP,
|
---|
| 1035 | SymmetricMatrix& QQ, ColumnVector& dx) {
|
---|
| 1036 |
|
---|
| 1037 | int nObs = AA.Nrows();
|
---|
| 1038 | int nPar = AA.Ncols();
|
---|
| 1039 |
|
---|
| 1040 | UpperTriangularMatrix SS = Cholesky(QQ).t();
|
---|
| 1041 |
|
---|
| 1042 | Matrix SA = SS*AA.t();
|
---|
| 1043 | Matrix SRF(nObs+nPar, nObs+nPar); SRF = 0;
|
---|
| 1044 | for (int ii = 1; ii <= nObs; ++ii) {
|
---|
| 1045 | SRF(ii,ii) = 1.0 / sqrt(PP(ii,ii));
|
---|
| 1046 | }
|
---|
| 1047 |
|
---|
| 1048 | SRF.SubMatrix (nObs+1, nObs+nPar, 1, nObs) = SA;
|
---|
| 1049 | SRF.SymSubMatrix(nObs+1, nObs+nPar) = SS;
|
---|
| 1050 |
|
---|
| 1051 | UpperTriangularMatrix UU;
|
---|
| 1052 | QRZ(SRF, UU);
|
---|
| 1053 |
|
---|
| 1054 | SS = UU.SymSubMatrix(nObs+1, nObs+nPar);
|
---|
| 1055 | UpperTriangularMatrix SH_rt = UU.SymSubMatrix(1, nObs);
|
---|
| 1056 | Matrix YY = UU.SubMatrix(1, nObs, nObs+1, nObs+nPar);
|
---|
| 1057 |
|
---|
| 1058 | UpperTriangularMatrix SHi = SH_rt.i();
|
---|
| 1059 |
|
---|
| 1060 | Matrix KT = SHi * YY;
|
---|
| 1061 | SymmetricMatrix Hi; Hi << SHi * SHi.t();
|
---|
| 1062 |
|
---|
| 1063 | dx = KT.t() * ll;
|
---|
| 1064 | QQ << (SS.t() * SS);
|
---|
| 1065 | }
|
---|
[2582] | 1066 |
|
---|
| 1067 | // Phase Wind-Up Correction
|
---|
| 1068 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 1069 | double bncModel::windUp(const QString& prn, const ColumnVector& rSat,
|
---|
| 1070 | const ColumnVector& rRec) {
|
---|
| 1071 |
|
---|
| 1072 | double Mjd = _time.mjd() + _time.daysec() / 86400.0;
|
---|
| 1073 |
|
---|
| 1074 | // First time - initialize to zero
|
---|
| 1075 | // -------------------------------
|
---|
| 1076 | if (!_windUpTime.contains(prn)) {
|
---|
| 1077 | _windUpSum[prn] = 0.0;
|
---|
| 1078 | }
|
---|
| 1079 |
|
---|
| 1080 | // Compute the correction for new time
|
---|
| 1081 | // -----------------------------------
|
---|
[2942] | 1082 | if (!_windUpTime.contains(prn) || _windUpTime[prn] != Mjd) {
|
---|
[2582] | 1083 | _windUpTime[prn] = Mjd;
|
---|
| 1084 |
|
---|
| 1085 | // Unit Vector GPS Satellite --> Receiver
|
---|
| 1086 | // --------------------------------------
|
---|
| 1087 | ColumnVector rho = rRec - rSat;
|
---|
| 1088 | rho /= rho.norm_Frobenius();
|
---|
| 1089 |
|
---|
| 1090 | // GPS Satellite unit Vectors sz, sy, sx
|
---|
| 1091 | // -------------------------------------
|
---|
| 1092 | ColumnVector sz = -rSat / rSat.norm_Frobenius();
|
---|
| 1093 |
|
---|
| 1094 | ColumnVector xSun = Sun(Mjd);
|
---|
| 1095 | xSun /= xSun.norm_Frobenius();
|
---|
| 1096 |
|
---|
| 1097 | ColumnVector sy = crossproduct(sz, xSun);
|
---|
| 1098 | ColumnVector sx = crossproduct(sy, sz);
|
---|
| 1099 |
|
---|
| 1100 | // Effective Dipole of the GPS Satellite Antenna
|
---|
| 1101 | // ---------------------------------------------
|
---|
| 1102 | ColumnVector dipSat = sx - rho * DotProduct(rho,sx)
|
---|
| 1103 | - crossproduct(rho, sy);
|
---|
| 1104 |
|
---|
| 1105 | // Receiver unit Vectors rx, ry
|
---|
| 1106 | // ----------------------------
|
---|
| 1107 | ColumnVector rx(3);
|
---|
| 1108 | ColumnVector ry(3);
|
---|
| 1109 |
|
---|
| 1110 | double recEll[3]; xyz2ell(rRec.data(), recEll) ;
|
---|
| 1111 | double neu[3];
|
---|
| 1112 |
|
---|
| 1113 | neu[0] = 1.0;
|
---|
| 1114 | neu[1] = 0.0;
|
---|
| 1115 | neu[2] = 0.0;
|
---|
| 1116 | neu2xyz(recEll, neu, rx.data());
|
---|
| 1117 |
|
---|
| 1118 | neu[0] = 0.0;
|
---|
| 1119 | neu[1] = -1.0;
|
---|
| 1120 | neu[2] = 0.0;
|
---|
| 1121 | neu2xyz(recEll, neu, ry.data());
|
---|
| 1122 |
|
---|
| 1123 | // Effective Dipole of the Receiver Antenna
|
---|
| 1124 | // ----------------------------------------
|
---|
| 1125 | ColumnVector dipRec = rx - rho * DotProduct(rho,rx)
|
---|
| 1126 | + crossproduct(rho, ry);
|
---|
| 1127 |
|
---|
| 1128 | // Resulting Effect
|
---|
| 1129 | // ----------------
|
---|
| 1130 | double alpha = DotProduct(dipSat,dipRec) /
|
---|
| 1131 | (dipSat.norm_Frobenius() * dipRec.norm_Frobenius());
|
---|
| 1132 |
|
---|
| 1133 | if (alpha > 1.0) alpha = 1.0;
|
---|
| 1134 | if (alpha < -1.0) alpha = -1.0;
|
---|
| 1135 |
|
---|
| 1136 | double dphi = acos(alpha) / 2.0 / M_PI; // in cycles
|
---|
| 1137 |
|
---|
| 1138 | if ( DotProduct(rho, crossproduct(dipSat, dipRec)) < 0.0 ) {
|
---|
| 1139 | dphi = -dphi;
|
---|
| 1140 | }
|
---|
| 1141 |
|
---|
| 1142 | _windUpSum[prn] = floor(_windUpSum[prn] - dphi + 0.5) + dphi;
|
---|
| 1143 | }
|
---|
| 1144 |
|
---|
| 1145 | return _windUpSum[prn];
|
---|
| 1146 | }
|
---|
[2789] | 1147 |
|
---|
| 1148 | //
|
---|
| 1149 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 1150 | void bncModel::cmpEle(t_satData* satData) {
|
---|
| 1151 | ColumnVector rr = satData->xx - _xcBanc.Rows(1,3);
|
---|
| 1152 | double rho = rr.norm_Frobenius();
|
---|
| 1153 |
|
---|
| 1154 | double neu[3];
|
---|
| 1155 | xyz2neu(_ellBanc.data(), rr.data(), neu);
|
---|
| 1156 |
|
---|
| 1157 | satData->eleSat = acos( sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / rho );
|
---|
| 1158 | if (neu[2] < 0) {
|
---|
| 1159 | satData->eleSat *= -1.0;
|
---|
| 1160 | }
|
---|
| 1161 | satData->azSat = atan2(neu[1], neu[0]);
|
---|
| 1162 | }
|
---|
| 1163 |
|
---|
| 1164 | //
|
---|
| 1165 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 1166 | void bncModel::addAmb(t_satData* satData) {
|
---|
| 1167 | bool found = false;
|
---|
| 1168 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 1169 | if (_params[iPar-1]->type == bncParam::AMB_L3 &&
|
---|
| 1170 | _params[iPar-1]->prn == satData->prn) {
|
---|
| 1171 | found = true;
|
---|
| 1172 | break;
|
---|
| 1173 | }
|
---|
| 1174 | }
|
---|
| 1175 | if (!found) {
|
---|
| 1176 | bncParam* par = new bncParam(bncParam::AMB_L3,
|
---|
| 1177 | _params.size()+1, satData->prn);
|
---|
| 1178 | _params.push_back(par);
|
---|
| 1179 | par->xx = satData->L3 - cmpValue(satData, true);
|
---|
| 1180 | }
|
---|
| 1181 | }
|
---|
[2790] | 1182 |
|
---|
| 1183 | //
|
---|
| 1184 | ///////////////////////////////////////////////////////////////////////////
|
---|
[3307] | 1185 | void bncModel::addObs(int phase, unsigned& iObs, t_satData* satData,
|
---|
[2790] | 1186 | Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP) {
|
---|
| 1187 |
|
---|
[2791] | 1188 | // Phase Observations
|
---|
| 1189 | // ------------------
|
---|
[3307] | 1190 | if (phase == 1) {
|
---|
[2790] | 1191 | ++iObs;
|
---|
| 1192 | ll(iObs) = satData->L3 - cmpValue(satData, true);
|
---|
| 1193 | PP(iObs,iObs) = 1.0 / (_sigL3 * _sigL3);
|
---|
| 1194 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 1195 | if (_params[iPar-1]->type == bncParam::AMB_L3 &&
|
---|
| 1196 | _params[iPar-1]->prn == satData->prn) {
|
---|
| 1197 | ll(iObs) -= _params[iPar-1]->xx;
|
---|
| 1198 | }
|
---|
| 1199 | AA(iObs, iPar) = _params[iPar-1]->partial(satData, true);
|
---|
| 1200 | }
|
---|
[2791] | 1201 | satData->indexPhase = iObs;
|
---|
[2790] | 1202 | }
|
---|
[3307] | 1203 |
|
---|
| 1204 | // Code Observations
|
---|
| 1205 | // -----------------
|
---|
| 1206 | else {
|
---|
| 1207 | ++iObs;
|
---|
| 1208 | ll(iObs) = satData->P3 - cmpValue(satData, false);
|
---|
| 1209 | PP(iObs,iObs) = 1.0 / (_sigP3 * _sigP3);
|
---|
| 1210 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 1211 | AA(iObs, iPar) = _params[iPar-1]->partial(satData, false);
|
---|
| 1212 | }
|
---|
| 1213 | satData->indexCode = iObs;
|
---|
| 1214 | }
|
---|
[2790] | 1215 | }
|
---|
[2791] | 1216 |
|
---|
| 1217 | //
|
---|
| 1218 | ///////////////////////////////////////////////////////////////////////////
|
---|
[3308] | 1219 | void bncModel::printRes(int phase, const ColumnVector& vv,
|
---|
[2791] | 1220 | ostringstream& str, t_satData* satData) {
|
---|
[3308] | 1221 | if (phase) {
|
---|
[2797] | 1222 | str << _time.timestr(1)
|
---|
[2800] | 1223 | << " RES " << satData->prn.toAscii().data() << " L3 "
|
---|
[3307] | 1224 | << setw(9) << setprecision(4) << vv(satData->indexPhase) << endl;
|
---|
[2791] | 1225 | }
|
---|
[3308] | 1226 | else {
|
---|
[3307] | 1227 | str << _time.timestr(1)
|
---|
| 1228 | << " RES " << satData->prn.toAscii().data() << " P3 "
|
---|
| 1229 | << setw(9) << setprecision(4) << vv(satData->indexCode) << endl;
|
---|
| 1230 | }
|
---|
[2791] | 1231 | }
|
---|
[2792] | 1232 |
|
---|
| 1233 | //
|
---|
| 1234 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 1235 | void bncModel::findMaxRes(const ColumnVector& vv,
|
---|
| 1236 | const QMap<QString, t_satData*>& satData,
|
---|
| 1237 | QString& prnCode, double& maxResCode,
|
---|
| 1238 | QString& prnPhase, double& maxResPhase) {
|
---|
| 1239 | maxResCode = 0.0;
|
---|
| 1240 | maxResPhase = 0.0;
|
---|
| 1241 |
|
---|
| 1242 | QMapIterator<QString, t_satData*> it(satData);
|
---|
| 1243 | while (it.hasNext()) {
|
---|
| 1244 | it.next();
|
---|
| 1245 | t_satData* satData = it.value();
|
---|
| 1246 | if (satData->indexCode) {
|
---|
| 1247 | if (fabs(vv(satData->indexCode)) > maxResCode) {
|
---|
| 1248 | maxResCode = fabs(vv(satData->indexCode));
|
---|
| 1249 | prnCode = satData->prn;
|
---|
| 1250 | }
|
---|
| 1251 | }
|
---|
| 1252 | if (satData->indexPhase) {
|
---|
| 1253 | if (fabs(vv(satData->indexPhase)) > maxResPhase) {
|
---|
| 1254 | maxResPhase = fabs(vv(satData->indexPhase));
|
---|
| 1255 | prnPhase = satData->prn;
|
---|
| 1256 | }
|
---|
| 1257 | }
|
---|
| 1258 | }
|
---|
| 1259 | }
|
---|
| 1260 |
|
---|
[3307] | 1261 | // Update Step (private - loop over outliers)
|
---|
| 1262 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 1263 | t_irc bncModel::update_p(t_epoData* epoData, ColumnVector& dx) {
|
---|
| 1264 |
|
---|
| 1265 | SymmetricMatrix QQsav;
|
---|
| 1266 | ColumnVector vv;
|
---|
| 1267 |
|
---|
[3308] | 1268 | for (int iPhase = 0; iPhase <= (_usePhase ? 1 : 0); iPhase++) {
|
---|
[3307] | 1269 |
|
---|
| 1270 | do {
|
---|
| 1271 |
|
---|
| 1272 | if (iPhase == 0) {
|
---|
| 1273 |
|
---|
| 1274 | // Bancroft Solution
|
---|
| 1275 | // -----------------
|
---|
| 1276 | if (cmpBancroft(epoData) != success) {
|
---|
| 1277 | emit newMessage(_log, false);
|
---|
| 1278 | return failure;
|
---|
| 1279 | }
|
---|
| 1280 | }
|
---|
| 1281 |
|
---|
[3308] | 1282 | // Status Prediction
|
---|
| 1283 | // -----------------
|
---|
| 1284 | predict(epoData);
|
---|
| 1285 |
|
---|
[3307] | 1286 | // Create First-Design Matrix
|
---|
| 1287 | // --------------------------
|
---|
| 1288 | unsigned nPar = _params.size();
|
---|
| 1289 | unsigned nObs = 0;
|
---|
[3308] | 1290 | if (iPhase == 0) {
|
---|
| 1291 | nObs = epoData->sizeGPS() + epoData->sizeGal(); // Glonass code not used
|
---|
| 1292 | }
|
---|
| 1293 | else {
|
---|
| 1294 | nObs = epoData->sizeGPS() + epoData->sizeGal() + epoData->sizeGlo();
|
---|
| 1295 | }
|
---|
[3307] | 1296 |
|
---|
| 1297 | Matrix AA(nObs, nPar); // first design matrix
|
---|
| 1298 | ColumnVector ll(nObs); // tems observed-computed
|
---|
| 1299 | DiagonalMatrix PP(nObs); PP = 0.0;
|
---|
| 1300 |
|
---|
| 1301 | unsigned iObs = 0;
|
---|
| 1302 |
|
---|
| 1303 | // GPS
|
---|
| 1304 | // ---
|
---|
| 1305 | QMapIterator<QString, t_satData*> itGPS(epoData->satDataGPS);
|
---|
| 1306 | while (itGPS.hasNext()) {
|
---|
| 1307 | itGPS.next();
|
---|
| 1308 | t_satData* satData = itGPS.value();
|
---|
| 1309 | addObs(iPhase, iObs, satData, AA, ll, PP);
|
---|
| 1310 | }
|
---|
| 1311 |
|
---|
[3308] | 1312 | // Glonass
|
---|
| 1313 | // -------
|
---|
| 1314 | if (iPhase == 1) {
|
---|
| 1315 | QMapIterator<QString, t_satData*> itGlo(epoData->satDataGlo);
|
---|
| 1316 | while (itGlo.hasNext()) {
|
---|
| 1317 | itGlo.next();
|
---|
| 1318 | t_satData* satData = itGlo.value();
|
---|
| 1319 | addObs(iPhase, iObs, satData, AA, ll, PP);
|
---|
| 1320 | }
|
---|
| 1321 | }
|
---|
| 1322 |
|
---|
[3307] | 1323 | // Galileo
|
---|
| 1324 | // -------
|
---|
| 1325 | QMapIterator<QString, t_satData*> itGal(epoData->satDataGal);
|
---|
| 1326 | while (itGal.hasNext()) {
|
---|
| 1327 | itGal.next();
|
---|
| 1328 | t_satData* satData = itGal.value();
|
---|
| 1329 | addObs(iPhase, iObs, satData, AA, ll, PP);
|
---|
| 1330 | }
|
---|
| 1331 |
|
---|
| 1332 | // Compute Filter Update
|
---|
| 1333 | // ---------------------
|
---|
| 1334 | QQsav = _QQ;
|
---|
| 1335 |
|
---|
| 1336 | kalman(AA, ll, PP, _QQ, dx);
|
---|
| 1337 |
|
---|
| 1338 | vv = ll - AA * dx;
|
---|
[3308] | 1339 |
|
---|
[3307] | 1340 | // Print Residuals
|
---|
| 1341 | // ---------------
|
---|
| 1342 | if (true) {
|
---|
| 1343 | ostringstream str;
|
---|
| 1344 | str.setf(ios::fixed);
|
---|
| 1345 |
|
---|
| 1346 | QMapIterator<QString, t_satData*> itGPS(epoData->satDataGPS);
|
---|
| 1347 | while (itGPS.hasNext()) {
|
---|
| 1348 | itGPS.next();
|
---|
| 1349 | t_satData* satData = itGPS.value();
|
---|
[3308] | 1350 | printRes(iPhase, vv, str, satData);
|
---|
[3307] | 1351 | }
|
---|
[3308] | 1352 | if (iPhase == 1) {
|
---|
| 1353 | QMapIterator<QString, t_satData*> itGlo(epoData->satDataGlo);
|
---|
| 1354 | while (itGlo.hasNext()) {
|
---|
| 1355 | itGlo.next();
|
---|
| 1356 | t_satData* satData = itGlo.value();
|
---|
| 1357 | printRes(iPhase, vv, str, satData);
|
---|
| 1358 | }
|
---|
[3307] | 1359 | }
|
---|
| 1360 | QMapIterator<QString, t_satData*> itGal(epoData->satDataGal);
|
---|
| 1361 | while (itGal.hasNext()) {
|
---|
| 1362 | itGal.next();
|
---|
| 1363 | t_satData* satData = itGal.value();
|
---|
[3308] | 1364 | printRes(iPhase, vv, str, satData);
|
---|
[3307] | 1365 | }
|
---|
| 1366 | _log += str.str().c_str();
|
---|
| 1367 | }
|
---|
| 1368 |
|
---|
[3308] | 1369 | } while (outlierDetection(iPhase, QQsav, vv, epoData->satDataGPS,
|
---|
[3307] | 1370 | epoData->satDataGlo, epoData->satDataGal) != 0);
|
---|
| 1371 | }
|
---|
| 1372 |
|
---|
| 1373 | return success;
|
---|
| 1374 | }
|
---|