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