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