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