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