[2057] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
| 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
| 3 | //
|
---|
| 4 | // Copyright (C) 2007
|
---|
| 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
| 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
| 8 | // http://www.fsv.cvut.cz
|
---|
| 9 | //
|
---|
| 10 | // Email: euref-ip@bkg.bund.de
|
---|
| 11 | //
|
---|
| 12 | // This program is free software; you can redistribute it and/or
|
---|
| 13 | // modify it under the terms of the GNU General Public License
|
---|
| 14 | // as published by the Free Software Foundation, version 2.
|
---|
| 15 | //
|
---|
| 16 | // This program is distributed in the hope that it will be useful,
|
---|
| 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | // GNU General Public License for more details.
|
---|
| 20 | //
|
---|
| 21 | // You should have received a copy of the GNU General Public License
|
---|
| 22 | // along with this program; if not, write to the Free Software
|
---|
| 23 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
| 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
| 26 | * BKG NTRIP Client
|
---|
| 27 | * -------------------------------------------------------------------------
|
---|
| 28 | *
|
---|
| 29 | * Class: bncParam, bncModel
|
---|
| 30 | *
|
---|
| 31 | * Purpose: Model for PPP
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 01-Dec-2009
|
---|
| 36 | *
|
---|
| 37 | * Changes:
|
---|
| 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
| 41 | #include <iomanip>
|
---|
[2063] | 42 | #include <cmath>
|
---|
[2060] | 43 | #include <newmatio.h>
|
---|
[2113] | 44 | #include <sstream>
|
---|
[2057] | 45 |
|
---|
| 46 | #include "bncmodel.h"
|
---|
[2113] | 47 | #include "bncapp.h"
|
---|
[2058] | 48 | #include "bncpppclient.h"
|
---|
| 49 | #include "bancroft.h"
|
---|
[2063] | 50 | #include "bncutils.h"
|
---|
[2077] | 51 | #include "bncsettings.h"
|
---|
[2057] | 52 |
|
---|
| 53 | using namespace std;
|
---|
| 54 |
|
---|
[2243] | 55 | const unsigned MINOBS = 4;
|
---|
[2287] | 56 | const double MINELE_GPS = 10.0 * M_PI / 180.0;
|
---|
| 57 | const double MINELE_GLO = 10.0 * M_PI / 180.0;
|
---|
[2243] | 58 | const double MAXRES_CODE_GPS = 10.0;
|
---|
| 59 | const double MAXRES_PHASE_GPS = 0.10;
|
---|
[2539] | 60 | const double MAXRES_PHASE_GLO = 0.05;
|
---|
[2243] | 61 | const double sig_crd_0 = 100.0;
|
---|
| 62 | const double sig_crd_p = 100.0;
|
---|
[2283] | 63 | const double sig_clk_0 = 1000.0;
|
---|
[2489] | 64 | const double sig_trp_0 = 0.10;
|
---|
| 65 | const double sig_trp_p = 1e-8;
|
---|
[2540] | 66 | const double sig_amb_0_GPS = 1000.0;
|
---|
[2265] | 67 | const double sig_amb_0_GLO = 1000.0;
|
---|
[2286] | 68 | const double sig_L3_GPS = 0.02;
|
---|
[2538] | 69 | const double sig_L3_GLO = 0.05;
|
---|
[2070] | 70 |
|
---|
[2057] | 71 | // Constructor
|
---|
| 72 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2080] | 73 | bncParam::bncParam(bncParam::parType typeIn, int indexIn,
|
---|
| 74 | const QString& prnIn) {
|
---|
| 75 | type = typeIn;
|
---|
| 76 | index = indexIn;
|
---|
| 77 | prn = prnIn;
|
---|
| 78 | index_old = 0;
|
---|
| 79 | xx = 0.0;
|
---|
[2473] | 80 |
|
---|
[2057] | 81 | }
|
---|
| 82 |
|
---|
| 83 | // Destructor
|
---|
| 84 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 85 | bncParam::~bncParam() {
|
---|
| 86 | }
|
---|
| 87 |
|
---|
[2060] | 88 | // Partial
|
---|
| 89 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2239] | 90 | double bncParam::partial(t_satData* satData, bool phase) {
|
---|
| 91 |
|
---|
| 92 | // Coordinates
|
---|
| 93 | // -----------
|
---|
[2060] | 94 | if (type == CRD_X) {
|
---|
[2109] | 95 | return (xx - satData->xx(1)) / satData->rho;
|
---|
[2060] | 96 | }
|
---|
| 97 | else if (type == CRD_Y) {
|
---|
[2109] | 98 | return (xx - satData->xx(2)) / satData->rho;
|
---|
[2060] | 99 | }
|
---|
| 100 | else if (type == CRD_Z) {
|
---|
[2109] | 101 | return (xx - satData->xx(3)) / satData->rho;
|
---|
[2060] | 102 | }
|
---|
[2239] | 103 |
|
---|
| 104 | // Receiver Clocks
|
---|
| 105 | // ---------------
|
---|
[2265] | 106 | else if (type == RECCLK) {
|
---|
| 107 | return 1.0;
|
---|
[2060] | 108 | }
|
---|
[2239] | 109 |
|
---|
| 110 | // Troposphere
|
---|
| 111 | // -----------
|
---|
[2084] | 112 | else if (type == TROPO) {
|
---|
| 113 | return 1.0 / sin(satData->eleSat);
|
---|
| 114 | }
|
---|
[2239] | 115 |
|
---|
| 116 | // Ambiguities
|
---|
| 117 | // -----------
|
---|
[2080] | 118 | else if (type == AMB_L3) {
|
---|
[2239] | 119 | if (phase && satData->prn == prn) {
|
---|
[2080] | 120 | return 1.0;
|
---|
| 121 | }
|
---|
| 122 | else {
|
---|
| 123 | return 0.0;
|
---|
| 124 | }
|
---|
| 125 | }
|
---|
[2239] | 126 |
|
---|
| 127 | // Default return
|
---|
| 128 | // --------------
|
---|
[2060] | 129 | return 0.0;
|
---|
| 130 | }
|
---|
| 131 |
|
---|
[2058] | 132 | // Constructor
|
---|
| 133 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2113] | 134 | bncModel::bncModel(QByteArray staID) {
|
---|
[2084] | 135 |
|
---|
[2113] | 136 | _staID = staID;
|
---|
| 137 |
|
---|
| 138 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
[2548] | 139 | ((bncApp*)qApp), SLOT(slotMessage(const QByteArray,bool)));
|
---|
[2113] | 140 |
|
---|
[2084] | 141 | bncSettings settings;
|
---|
| 142 |
|
---|
| 143 | _static = false;
|
---|
| 144 | if ( Qt::CheckState(settings.value("pppStatic").toInt()) == Qt::Checked) {
|
---|
| 145 | _static = true;
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | _usePhase = false;
|
---|
| 149 | if ( Qt::CheckState(settings.value("pppUsePhase").toInt()) == Qt::Checked) {
|
---|
| 150 | _usePhase = true;
|
---|
| 151 | }
|
---|
| 152 |
|
---|
| 153 | _estTropo = false;
|
---|
| 154 | if ( Qt::CheckState(settings.value("pppEstTropo").toInt()) == Qt::Checked) {
|
---|
| 155 | _estTropo = true;
|
---|
| 156 | }
|
---|
| 157 |
|
---|
| 158 | _xcBanc.ReSize(4); _xcBanc = 0.0;
|
---|
| 159 | _ellBanc.ReSize(3); _ellBanc = 0.0;
|
---|
| 160 |
|
---|
[2265] | 161 | if (_usePhase &&
|
---|
| 162 | Qt::CheckState(settings.value("pppGLONASS").toInt()) == Qt::Checked) {
|
---|
[2239] | 163 | _useGlonass = true;
|
---|
| 164 | }
|
---|
| 165 | else {
|
---|
| 166 | _useGlonass = false;
|
---|
| 167 | }
|
---|
| 168 |
|
---|
| 169 | int nextPar = 0;
|
---|
[2265] | 170 | _params.push_back(new bncParam(bncParam::CRD_X, ++nextPar, ""));
|
---|
| 171 | _params.push_back(new bncParam(bncParam::CRD_Y, ++nextPar, ""));
|
---|
| 172 | _params.push_back(new bncParam(bncParam::CRD_Z, ++nextPar, ""));
|
---|
| 173 | _params.push_back(new bncParam(bncParam::RECCLK, ++nextPar, ""));
|
---|
[2084] | 174 | if (_estTropo) {
|
---|
[2239] | 175 | _params.push_back(new bncParam(bncParam::TROPO, ++nextPar, ""));
|
---|
[2084] | 176 | }
|
---|
[2073] | 177 |
|
---|
| 178 | unsigned nPar = _params.size();
|
---|
[2084] | 179 |
|
---|
[2073] | 180 | _QQ.ReSize(nPar);
|
---|
[2239] | 181 |
|
---|
[2073] | 182 | _QQ = 0.0;
|
---|
| 183 |
|
---|
[2239] | 184 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 185 | bncParam* pp = _params[iPar-1];
|
---|
| 186 | if (pp->isCrd()) {
|
---|
| 187 | _QQ(iPar,iPar) = sig_crd_0 * sig_crd_0;
|
---|
| 188 | }
|
---|
[2265] | 189 | else if (pp->type == bncParam::RECCLK) {
|
---|
[2239] | 190 | _QQ(iPar,iPar) = sig_clk_0 * sig_clk_0;
|
---|
| 191 | }
|
---|
| 192 | else if (pp->type == bncParam::TROPO) {
|
---|
| 193 | _QQ(iPar,iPar) = sig_trp_0 * sig_trp_0;
|
---|
| 194 | }
|
---|
[2077] | 195 | }
|
---|
[2125] | 196 |
|
---|
| 197 | // NMEA Output
|
---|
| 198 | // -----------
|
---|
| 199 | QString nmeaFileName = settings.value("nmeaFile").toString();
|
---|
| 200 | if (nmeaFileName.isEmpty()) {
|
---|
| 201 | _nmeaFile = 0;
|
---|
| 202 | _nmeaStream = 0;
|
---|
| 203 | }
|
---|
| 204 | else {
|
---|
| 205 | expandEnvVar(nmeaFileName);
|
---|
| 206 | _nmeaFile = new QFile(nmeaFileName);
|
---|
| 207 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
|
---|
| 208 | _nmeaFile->open(QIODevice::WriteOnly | QIODevice::Append);
|
---|
| 209 | }
|
---|
| 210 | else {
|
---|
| 211 | _nmeaFile->open(QIODevice::WriteOnly);
|
---|
| 212 | }
|
---|
| 213 | _nmeaStream = new QTextStream();
|
---|
| 214 | _nmeaStream->setDevice(_nmeaFile);
|
---|
[2130] | 215 | QDateTime dateTime = QDateTime::currentDateTime().toUTC();
|
---|
| 216 | QString nmStr = "GPRMC," + dateTime.time().toString("hhmmss")
|
---|
[2171] | 217 | + ",A,,,,,,,"
|
---|
[2130] | 218 | + dateTime.date().toString("ddMMyy")
|
---|
[2171] | 219 | + ",,";
|
---|
[2130] | 220 |
|
---|
| 221 | writeNMEAstr(nmStr);
|
---|
[2125] | 222 | }
|
---|
[2058] | 223 | }
|
---|
| 224 |
|
---|
| 225 | // Destructor
|
---|
| 226 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 227 | bncModel::~bncModel() {
|
---|
[2126] | 228 | delete _nmeaStream;
|
---|
| 229 | delete _nmeaFile;
|
---|
[2058] | 230 | }
|
---|
| 231 |
|
---|
| 232 | // Bancroft Solution
|
---|
| 233 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 234 | t_irc bncModel::cmpBancroft(t_epoData* epoData) {
|
---|
| 235 |
|
---|
[2231] | 236 | if (epoData->sizeGPS() < MINOBS) {
|
---|
[2547] | 237 | _log += "bncModel::cmpBancroft: not enough data\n";
|
---|
[2058] | 238 | return failure;
|
---|
| 239 | }
|
---|
| 240 |
|
---|
[2231] | 241 | Matrix BB(epoData->sizeGPS(), 4);
|
---|
[2058] | 242 |
|
---|
[2231] | 243 | QMapIterator<QString, t_satData*> it(epoData->satDataGPS);
|
---|
[2058] | 244 | int iObs = 0;
|
---|
| 245 | while (it.hasNext()) {
|
---|
[2060] | 246 | ++iObs;
|
---|
[2058] | 247 | it.next();
|
---|
| 248 | QString prn = it.key();
|
---|
| 249 | t_satData* satData = it.value();
|
---|
| 250 | BB(iObs, 1) = satData->xx(1);
|
---|
| 251 | BB(iObs, 2) = satData->xx(2);
|
---|
| 252 | BB(iObs, 3) = satData->xx(3);
|
---|
| 253 | BB(iObs, 4) = satData->P3 + satData->clk;
|
---|
| 254 | }
|
---|
| 255 |
|
---|
| 256 | bancroft(BB, _xcBanc);
|
---|
| 257 |
|
---|
[2064] | 258 | // Ellipsoidal Coordinates
|
---|
| 259 | // ------------------------
|
---|
| 260 | xyz2ell(_xcBanc.data(), _ellBanc.data());
|
---|
[2063] | 261 |
|
---|
[2064] | 262 | // Compute Satellite Elevations
|
---|
| 263 | // ----------------------------
|
---|
[2231] | 264 | QMutableMapIterator<QString, t_satData*> iGPS(epoData->satDataGPS);
|
---|
| 265 | while (iGPS.hasNext()) {
|
---|
| 266 | iGPS.next();
|
---|
| 267 | QString prn = iGPS.key();
|
---|
| 268 | t_satData* satData = iGPS.value();
|
---|
[2063] | 269 |
|
---|
[2109] | 270 | ColumnVector rr = satData->xx - _xcBanc.Rows(1,3);
|
---|
| 271 | double rho = rr.norm_Frobenius();
|
---|
[2064] | 272 |
|
---|
| 273 | double neu[3];
|
---|
[2109] | 274 | xyz2neu(_ellBanc.data(), rr.data(), neu);
|
---|
[2064] | 275 |
|
---|
| 276 | satData->eleSat = acos( sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / rho );
|
---|
| 277 | if (neu[2] < 0) {
|
---|
| 278 | satData->eleSat *= -1.0;
|
---|
| 279 | }
|
---|
| 280 | satData->azSat = atan2(neu[1], neu[0]);
|
---|
[2070] | 281 |
|
---|
[2287] | 282 | if (satData->eleSat < MINELE_GPS) {
|
---|
[2070] | 283 | delete satData;
|
---|
[2231] | 284 | iGPS.remove();
|
---|
[2070] | 285 | }
|
---|
[2064] | 286 | }
|
---|
| 287 |
|
---|
[2231] | 288 | QMutableMapIterator<QString, t_satData*> iGlo(epoData->satDataGlo);
|
---|
| 289 | while (iGlo.hasNext()) {
|
---|
| 290 | iGlo.next();
|
---|
| 291 | QString prn = iGlo.key();
|
---|
| 292 | t_satData* satData = iGlo.value();
|
---|
| 293 |
|
---|
| 294 | ColumnVector rr = satData->xx - _xcBanc.Rows(1,3);
|
---|
| 295 | double rho = rr.norm_Frobenius();
|
---|
| 296 |
|
---|
| 297 | double neu[3];
|
---|
| 298 | xyz2neu(_ellBanc.data(), rr.data(), neu);
|
---|
| 299 |
|
---|
| 300 | satData->eleSat = acos( sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / rho );
|
---|
| 301 | if (neu[2] < 0) {
|
---|
| 302 | satData->eleSat *= -1.0;
|
---|
| 303 | }
|
---|
| 304 | satData->azSat = atan2(neu[1], neu[0]);
|
---|
| 305 |
|
---|
[2287] | 306 | if (satData->eleSat < MINELE_GLO) {
|
---|
[2231] | 307 | delete satData;
|
---|
| 308 | iGlo.remove();
|
---|
| 309 | }
|
---|
| 310 | }
|
---|
| 311 |
|
---|
[2058] | 312 | return success;
|
---|
| 313 | }
|
---|
[2060] | 314 |
|
---|
| 315 | // Computed Value
|
---|
| 316 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2080] | 317 | double bncModel::cmpValue(t_satData* satData) {
|
---|
[2060] | 318 |
|
---|
[2073] | 319 | ColumnVector xRec(3);
|
---|
| 320 | xRec(1) = x();
|
---|
| 321 | xRec(2) = y();
|
---|
| 322 | xRec(3) = z();
|
---|
[2060] | 323 |
|
---|
[2073] | 324 | double rho0 = (satData->xx - xRec).norm_Frobenius();
|
---|
[2060] | 325 | double dPhi = t_CST::omega * rho0 / t_CST::c;
|
---|
| 326 |
|
---|
[2073] | 327 | xRec(1) = x() * cos(dPhi) - y() * sin(dPhi);
|
---|
| 328 | xRec(2) = y() * cos(dPhi) + x() * sin(dPhi);
|
---|
| 329 | xRec(3) = z();
|
---|
| 330 |
|
---|
[2060] | 331 | satData->rho = (satData->xx - xRec).norm_Frobenius();
|
---|
| 332 |
|
---|
[2084] | 333 | double tropDelay = delay_saast(satData->eleSat) +
|
---|
| 334 | trp() / sin(satData->eleSat);
|
---|
[2060] | 335 |
|
---|
[2265] | 336 | return satData->rho + clk() - satData->clk + tropDelay;
|
---|
[2060] | 337 | }
|
---|
| 338 |
|
---|
[2063] | 339 | // Tropospheric Model (Saastamoinen)
|
---|
| 340 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2065] | 341 | double bncModel::delay_saast(double Ele) {
|
---|
[2063] | 342 |
|
---|
[2064] | 343 | double height = _ellBanc(3);
|
---|
[2063] | 344 |
|
---|
[2064] | 345 | double pp = 1013.25 * pow(1.0 - 2.26e-5 * height, 5.225);
|
---|
| 346 | double TT = 18.0 - height * 0.0065 + 273.15;
|
---|
| 347 | double hh = 50.0 * exp(-6.396e-4 * height);
|
---|
[2063] | 348 | double ee = hh / 100.0 * exp(-37.2465 + 0.213166*TT - 0.000256908*TT*TT);
|
---|
| 349 |
|
---|
[2064] | 350 | double h_km = height / 1000.0;
|
---|
[2063] | 351 |
|
---|
| 352 | if (h_km < 0.0) h_km = 0.0;
|
---|
| 353 | if (h_km > 5.0) h_km = 5.0;
|
---|
| 354 | int ii = int(h_km + 1);
|
---|
| 355 | double href = ii - 1;
|
---|
| 356 |
|
---|
| 357 | double bCor[6];
|
---|
| 358 | bCor[0] = 1.156;
|
---|
| 359 | bCor[1] = 1.006;
|
---|
| 360 | bCor[2] = 0.874;
|
---|
| 361 | bCor[3] = 0.757;
|
---|
| 362 | bCor[4] = 0.654;
|
---|
| 363 | bCor[5] = 0.563;
|
---|
| 364 |
|
---|
| 365 | double BB = bCor[ii-1] + (bCor[ii]-bCor[ii-1]) * (h_km - href);
|
---|
| 366 |
|
---|
| 367 | double zen = M_PI/2.0 - Ele;
|
---|
| 368 |
|
---|
| 369 | return (0.002277/cos(zen)) * (pp + ((1255.0/TT)+0.05)*ee - BB*(tan(zen)*tan(zen)));
|
---|
| 370 | }
|
---|
| 371 |
|
---|
[2073] | 372 | // Prediction Step of the Filter
|
---|
| 373 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2080] | 374 | void bncModel::predict(t_epoData* epoData) {
|
---|
[2073] | 375 |
|
---|
[2244] | 376 | bool firstCrd = x() == 0.0 && y() == 0.0 && z() == 0.0;
|
---|
| 377 |
|
---|
| 378 | // Predict Parameter values, add white noise
|
---|
| 379 | // -----------------------------------------
|
---|
| 380 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 381 | bncParam* pp = _params[iPar-1];
|
---|
| 382 |
|
---|
| 383 | // Coordinates
|
---|
| 384 | // -----------
|
---|
| 385 | if (pp->type == bncParam::CRD_X) {
|
---|
| 386 | if (firstCrd || !_static) {
|
---|
| 387 | pp->xx = _xcBanc(1);
|
---|
| 388 | }
|
---|
| 389 | _QQ(iPar,iPar) += sig_crd_p * sig_crd_p;
|
---|
| 390 | }
|
---|
| 391 | else if (pp->type == bncParam::CRD_Y) {
|
---|
| 392 | if (firstCrd || !_static) {
|
---|
| 393 | pp->xx = _xcBanc(2);
|
---|
| 394 | }
|
---|
| 395 | _QQ(iPar,iPar) += sig_crd_p * sig_crd_p;
|
---|
| 396 | }
|
---|
| 397 | else if (pp->type == bncParam::CRD_Z) {
|
---|
| 398 | if (firstCrd || !_static) {
|
---|
| 399 | pp->xx = _xcBanc(3);
|
---|
| 400 | }
|
---|
| 401 | _QQ(iPar,iPar) += sig_crd_p * sig_crd_p;
|
---|
| 402 | }
|
---|
| 403 |
|
---|
| 404 | // Receiver Clocks
|
---|
| 405 | // ---------------
|
---|
[2265] | 406 | else if (pp->type == bncParam::RECCLK) {
|
---|
[2244] | 407 | pp->xx = _xcBanc(4);
|
---|
| 408 | for (int jj = 1; jj <= _params.size(); jj++) {
|
---|
| 409 | _QQ(iPar, jj) = 0.0;
|
---|
| 410 | }
|
---|
| 411 | _QQ(iPar,iPar) = sig_clk_0 * sig_clk_0;
|
---|
| 412 | }
|
---|
| 413 |
|
---|
| 414 | // Tropospheric Delay
|
---|
| 415 | // ------------------
|
---|
| 416 | else if (pp->type == bncParam::TROPO) {
|
---|
| 417 | _QQ(iPar,iPar) += sig_trp_p * sig_trp_p;
|
---|
| 418 | }
|
---|
| 419 | }
|
---|
| 420 |
|
---|
| 421 | // Add New Ambiguities if necessary
|
---|
| 422 | // --------------------------------
|
---|
[2083] | 423 | if (_usePhase) {
|
---|
[2080] | 424 |
|
---|
[2083] | 425 | // Make a copy of QQ and xx, set parameter indices
|
---|
| 426 | // -----------------------------------------------
|
---|
| 427 | SymmetricMatrix QQ_old = _QQ;
|
---|
| 428 |
|
---|
| 429 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 430 | _params[iPar-1]->index_old = _params[iPar-1]->index;
|
---|
| 431 | _params[iPar-1]->index = 0;
|
---|
| 432 | }
|
---|
| 433 |
|
---|
| 434 | // Remove Ambiguity Parameters without observations
|
---|
| 435 | // ------------------------------------------------
|
---|
| 436 | int iPar = 0;
|
---|
| 437 | QMutableVectorIterator<bncParam*> it(_params);
|
---|
| 438 | while (it.hasNext()) {
|
---|
| 439 | bncParam* par = it.next();
|
---|
| 440 | bool removed = false;
|
---|
| 441 | if (par->type == bncParam::AMB_L3) {
|
---|
[2231] | 442 | if (epoData->satDataGPS.find(par->prn) == epoData->satDataGPS.end() &&
|
---|
| 443 | epoData->satDataGlo.find(par->prn) == epoData->satDataGlo.end() ) {
|
---|
[2083] | 444 | removed = true;
|
---|
| 445 | delete par;
|
---|
| 446 | it.remove();
|
---|
| 447 | }
|
---|
[2080] | 448 | }
|
---|
[2083] | 449 | if (! removed) {
|
---|
| 450 | ++iPar;
|
---|
| 451 | par->index = iPar;
|
---|
| 452 | }
|
---|
[2080] | 453 | }
|
---|
[2083] | 454 |
|
---|
| 455 | // Add new ambiguity parameters
|
---|
| 456 | // ----------------------------
|
---|
[2231] | 457 | QMapIterator<QString, t_satData*> iGPS(epoData->satDataGPS);
|
---|
| 458 | while (iGPS.hasNext()) {
|
---|
| 459 | iGPS.next();
|
---|
[2233] | 460 | QString prn = iGPS.key();
|
---|
[2244] | 461 | t_satData* satData = iGPS.value();
|
---|
[2231] | 462 | bool found = false;
|
---|
[2083] | 463 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 464 | if (_params[iPar-1]->type == bncParam::AMB_L3 &&
|
---|
| 465 | _params[iPar-1]->prn == prn) {
|
---|
| 466 | found = true;
|
---|
| 467 | break;
|
---|
| 468 | }
|
---|
[2080] | 469 | }
|
---|
[2083] | 470 | if (!found) {
|
---|
| 471 | bncParam* par = new bncParam(bncParam::AMB_L3, _params.size()+1, prn);
|
---|
| 472 | _params.push_back(par);
|
---|
[2244] | 473 | par->xx = satData->L3 - cmpValue(satData);
|
---|
[2083] | 474 | }
|
---|
[2080] | 475 | }
|
---|
[2231] | 476 |
|
---|
| 477 | QMapIterator<QString, t_satData*> iGlo(epoData->satDataGlo);
|
---|
| 478 | while (iGlo.hasNext()) {
|
---|
| 479 | iGlo.next();
|
---|
[2233] | 480 | QString prn = iGlo.key();
|
---|
| 481 | t_satData* satData = iGlo.value();
|
---|
[2231] | 482 | bool found = false;
|
---|
| 483 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 484 | if (_params[iPar-1]->type == bncParam::AMB_L3 &&
|
---|
| 485 | _params[iPar-1]->prn == prn) {
|
---|
| 486 | found = true;
|
---|
| 487 | break;
|
---|
| 488 | }
|
---|
| 489 | }
|
---|
| 490 | if (!found) {
|
---|
| 491 | bncParam* par = new bncParam(bncParam::AMB_L3, _params.size()+1, prn);
|
---|
| 492 | _params.push_back(par);
|
---|
[2244] | 493 | par->xx = satData->L3 - cmpValue(satData);
|
---|
[2231] | 494 | }
|
---|
| 495 | }
|
---|
[2083] | 496 |
|
---|
| 497 | int nPar = _params.size();
|
---|
| 498 | _QQ.ReSize(nPar); _QQ = 0.0;
|
---|
| 499 | for (int i1 = 1; i1 <= nPar; i1++) {
|
---|
| 500 | bncParam* p1 = _params[i1-1];
|
---|
| 501 | if (p1->index_old != 0) {
|
---|
| 502 | _QQ(p1->index, p1->index) = QQ_old(p1->index_old, p1->index_old);
|
---|
| 503 | for (int i2 = 1; i2 <= nPar; i2++) {
|
---|
| 504 | bncParam* p2 = _params[i2-1];
|
---|
| 505 | if (p2->index_old != 0) {
|
---|
| 506 | _QQ(p1->index, p2->index) = QQ_old(p1->index_old, p2->index_old);
|
---|
| 507 | }
|
---|
[2080] | 508 | }
|
---|
| 509 | }
|
---|
| 510 | }
|
---|
[2083] | 511 |
|
---|
| 512 | for (int ii = 1; ii <= nPar; ii++) {
|
---|
| 513 | bncParam* par = _params[ii-1];
|
---|
| 514 | if (par->index_old == 0) {
|
---|
[2265] | 515 | if (par->prn[0] == 'R') {
|
---|
| 516 | _QQ(par->index, par->index) = sig_amb_0_GLO * sig_amb_0_GLO;
|
---|
| 517 | }
|
---|
| 518 | else {
|
---|
| 519 | _QQ(par->index, par->index) = sig_amb_0_GPS * sig_amb_0_GPS;
|
---|
| 520 | }
|
---|
[2083] | 521 | }
|
---|
| 522 | par->index_old = par->index;
|
---|
[2080] | 523 | }
|
---|
| 524 | }
|
---|
| 525 |
|
---|
[2073] | 526 | }
|
---|
| 527 |
|
---|
[2060] | 528 | // Update Step of the Filter (currently just a single-epoch solution)
|
---|
| 529 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 530 | t_irc bncModel::update(t_epoData* epoData) {
|
---|
| 531 |
|
---|
[2473] | 532 | bncSettings settings;
|
---|
| 533 | double sig_P3;
|
---|
| 534 | sig_P3 = 5.0;
|
---|
| 535 | if ( Qt::CheckState(settings.value("pppUsePhase").toInt()) == Qt::Checked ) {
|
---|
[2482] | 536 | sig_P3 = settings.value("pppSigmaCode").toDouble();
|
---|
[2473] | 537 | if (sig_P3 < 0.3 || sig_P3 > 50.0) {
|
---|
| 538 | sig_P3 = 5.0;
|
---|
| 539 | }
|
---|
| 540 | }
|
---|
| 541 |
|
---|
[2248] | 542 | _log.clear();
|
---|
[2124] | 543 |
|
---|
[2143] | 544 | _time = epoData->tt;
|
---|
| 545 |
|
---|
[2547] | 546 | _log += "Single Point Positioning of Epoch "
|
---|
| 547 | + QByteArray(_time.timestr(1).c_str()) +
|
---|
| 548 | "\n--------------------------------------------------------------\n";
|
---|
| 549 |
|
---|
[2112] | 550 | SymmetricMatrix QQsav;
|
---|
[2109] | 551 | ColumnVector dx;
|
---|
[2112] | 552 | ColumnVector vv;
|
---|
[2073] | 553 |
|
---|
[2113] | 554 | // Loop over all outliers
|
---|
| 555 | // ----------------------
|
---|
[2108] | 556 | do {
|
---|
| 557 |
|
---|
| 558 | // Bancroft Solution
|
---|
| 559 | // -----------------
|
---|
| 560 | if (cmpBancroft(epoData) != success) {
|
---|
[2124] | 561 | emit newMessage(_log, false);
|
---|
[2108] | 562 | return failure;
|
---|
| 563 | }
|
---|
[2080] | 564 |
|
---|
[2108] | 565 | // Status Prediction
|
---|
| 566 | // -----------------
|
---|
| 567 | predict(epoData);
|
---|
| 568 |
|
---|
[2109] | 569 | // Create First-Design Matrix
|
---|
| 570 | // --------------------------
|
---|
[2108] | 571 | unsigned nPar = _params.size();
|
---|
[2231] | 572 | unsigned nObs = 0;
|
---|
| 573 | if (_usePhase) {
|
---|
[2238] | 574 | nObs = 2 * epoData->sizeGPS() + epoData->sizeGlo();
|
---|
[2231] | 575 | }
|
---|
| 576 | else {
|
---|
| 577 | nObs = epoData->sizeGPS(); // Glonass pseudoranges are not used
|
---|
| 578 | }
|
---|
[2108] | 579 |
|
---|
[2540] | 580 | if (nObs < nPar) {
|
---|
[2547] | 581 | _log += "bncModel::update: nObs < nPar\n";
|
---|
[2540] | 582 | emit newMessage(_log, false);
|
---|
| 583 | return failure;
|
---|
| 584 | }
|
---|
| 585 |
|
---|
[2108] | 586 | Matrix AA(nObs, nPar); // first design matrix
|
---|
| 587 | ColumnVector ll(nObs); // tems observed-computed
|
---|
[2283] | 588 | DiagonalMatrix PP(nObs); PP = 0.0;
|
---|
[2108] | 589 |
|
---|
| 590 | unsigned iObs = 0;
|
---|
[2231] | 591 |
|
---|
| 592 | // GPS code and (optionally) phase observations
|
---|
| 593 | // --------------------------------------------
|
---|
| 594 | QMapIterator<QString, t_satData*> itGPS(epoData->satDataGPS);
|
---|
| 595 | while (itGPS.hasNext()) {
|
---|
[2083] | 596 | ++iObs;
|
---|
[2231] | 597 | itGPS.next();
|
---|
| 598 | QString prn = itGPS.key();
|
---|
| 599 | t_satData* satData = itGPS.value();
|
---|
[2108] | 600 |
|
---|
| 601 | double rhoCmp = cmpValue(satData);
|
---|
| 602 |
|
---|
| 603 | ll(iObs) = satData->P3 - rhoCmp;
|
---|
[2244] | 604 | PP(iObs,iObs) = 1.0 / (sig_P3 * sig_P3);
|
---|
[2083] | 605 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
[2239] | 606 | AA(iObs, iPar) = _params[iPar-1]->partial(satData, false);
|
---|
[2083] | 607 | }
|
---|
[2108] | 608 |
|
---|
| 609 | if (_usePhase) {
|
---|
| 610 | ++iObs;
|
---|
| 611 | ll(iObs) = satData->L3 - rhoCmp;
|
---|
[2244] | 612 | PP(iObs,iObs) = 1.0 / (sig_L3_GPS * sig_L3_GPS);
|
---|
[2108] | 613 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 614 | if (_params[iPar-1]->type == bncParam::AMB_L3 &&
|
---|
| 615 | _params[iPar-1]->prn == prn) {
|
---|
[2109] | 616 | ll(iObs) -= _params[iPar-1]->xx;
|
---|
[2108] | 617 | }
|
---|
[2239] | 618 | AA(iObs, iPar) = _params[iPar-1]->partial(satData, true);
|
---|
[2108] | 619 | }
|
---|
| 620 | }
|
---|
[2080] | 621 | }
|
---|
[2231] | 622 |
|
---|
| 623 | // Glonass phase observations
|
---|
| 624 | // --------------------------
|
---|
| 625 | if (_usePhase) {
|
---|
| 626 | QMapIterator<QString, t_satData*> itGlo(epoData->satDataGlo);
|
---|
| 627 | while (itGlo.hasNext()) {
|
---|
[2238] | 628 | ++iObs;
|
---|
[2231] | 629 | itGlo.next();
|
---|
| 630 | QString prn = itGlo.key();
|
---|
| 631 | t_satData* satData = itGlo.value();
|
---|
[2238] | 632 |
|
---|
| 633 | double rhoCmp = cmpValue(satData);
|
---|
| 634 |
|
---|
| 635 | ll(iObs) = satData->L3 - rhoCmp;
|
---|
[2242] | 636 |
|
---|
[2244] | 637 | PP(iObs,iObs) = 1.0 / (sig_L3_GLO * sig_L3_GLO);
|
---|
[2238] | 638 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 639 | if (_params[iPar-1]->type == bncParam::AMB_L3 &&
|
---|
| 640 | _params[iPar-1]->prn == prn) {
|
---|
| 641 | ll(iObs) -= _params[iPar-1]->xx;
|
---|
| 642 | }
|
---|
[2239] | 643 | AA(iObs, iPar) = _params[iPar-1]->partial(satData, true);
|
---|
[2238] | 644 | }
|
---|
[2231] | 645 | }
|
---|
| 646 | }
|
---|
| 647 |
|
---|
[2112] | 648 | // Compute Filter Update
|
---|
[2108] | 649 | // ---------------------
|
---|
[2112] | 650 | QQsav = _QQ;
|
---|
| 651 |
|
---|
[2283] | 652 | kalman(AA, ll, PP, _QQ, dx);
|
---|
| 653 |
|
---|
| 654 | vv = ll - AA * dx;
|
---|
| 655 |
|
---|
[2547] | 656 | ostringstream strA;
|
---|
| 657 | strA.setf(ios::fixed);
|
---|
[2265] | 658 | ColumnVector vv_code(epoData->sizeGPS());
|
---|
| 659 | ColumnVector vv_phase(epoData->sizeGPS());
|
---|
| 660 | ColumnVector vv_glo(epoData->sizeGlo());
|
---|
[2245] | 661 |
|
---|
[2265] | 662 | for (unsigned iobs = 1; iobs <= epoData->sizeGPS(); ++iobs) {
|
---|
| 663 | if (_usePhase) {
|
---|
[2246] | 664 | vv_code(iobs) = vv(2*iobs-1);
|
---|
| 665 | vv_phase(iobs) = vv(2*iobs);
|
---|
| 666 | }
|
---|
[2265] | 667 | else {
|
---|
| 668 | vv_code(iobs) = vv(iobs);
|
---|
| 669 | }
|
---|
| 670 | }
|
---|
| 671 | if (_useGlonass) {
|
---|
[2246] | 672 | for (unsigned iobs = 1; iobs <= epoData->sizeGlo(); ++iobs) {
|
---|
| 673 | vv_glo(iobs) = vv(2*epoData->sizeGPS()+iobs);
|
---|
| 674 | }
|
---|
[2265] | 675 | }
|
---|
[2246] | 676 |
|
---|
[2547] | 677 | strA << "residuals code " << setw(8) << setprecision(3) << vv_code.t();
|
---|
[2265] | 678 | if (_usePhase) {
|
---|
[2547] | 679 | strA << "residuals phase " << setw(8) << setprecision(3) << vv_phase.t();
|
---|
[2265] | 680 | }
|
---|
| 681 | if (_useGlonass) {
|
---|
[2547] | 682 | strA << "residuals glo " << setw(8) << setprecision(3) << vv_glo.t();
|
---|
[2246] | 683 | }
|
---|
[2547] | 684 | _log += strA.str().c_str();
|
---|
[2246] | 685 |
|
---|
[2231] | 686 | } while (outlierDetection(QQsav, vv, epoData->satDataGPS,
|
---|
[2233] | 687 | epoData->satDataGlo) != 0);
|
---|
[2111] | 688 |
|
---|
[2109] | 689 | // Set Solution Vector
|
---|
| 690 | // -------------------
|
---|
[2265] | 691 | ostringstream strB;
|
---|
| 692 | strB.setf(ios::fixed);
|
---|
[2073] | 693 | QVectorIterator<bncParam*> itPar(_params);
|
---|
[2060] | 694 | while (itPar.hasNext()) {
|
---|
| 695 | bncParam* par = itPar.next();
|
---|
[2109] | 696 | par->xx += dx(par->index);
|
---|
[2265] | 697 |
|
---|
| 698 | if (par->type == bncParam::RECCLK) {
|
---|
[2547] | 699 | strB << "\n clk = " << setw(6) << setprecision(3) << par->xx
|
---|
[2124] | 700 | << " +- " << setw(6) << setprecision(3)
|
---|
| 701 | << sqrt(_QQ(par->index,par->index));
|
---|
| 702 | }
|
---|
| 703 | else if (par->type == bncParam::AMB_L3) {
|
---|
[2265] | 704 | strB << "\n amb " << par->prn.toAscii().data() << " = "
|
---|
[2124] | 705 | << setw(6) << setprecision(3) << par->xx
|
---|
| 706 | << " +- " << setw(6) << setprecision(3)
|
---|
| 707 | << sqrt(_QQ(par->index,par->index));
|
---|
| 708 | }
|
---|
[2212] | 709 | else if (par->type == bncParam::TROPO) {
|
---|
[2547] | 710 | strB << "\n trp = " << par->prn.toAscii().data()
|
---|
[2212] | 711 | << setw(7) << setprecision(3) << delay_saast(M_PI/2.0) << " "
|
---|
[2213] | 712 | << setw(6) << setprecision(3) << showpos << par->xx << noshowpos
|
---|
[2212] | 713 | << " +- " << setw(6) << setprecision(3)
|
---|
| 714 | << sqrt(_QQ(par->index,par->index));
|
---|
| 715 | }
|
---|
[2060] | 716 | }
|
---|
[2265] | 717 | strB << '\n';
|
---|
[2547] | 718 | _log += strB.str().c_str();
|
---|
| 719 | emit newMessage(_log, false);
|
---|
[2060] | 720 |
|
---|
[2547] | 721 | // Final Message (both log file and screen)
|
---|
| 722 | // ----------------------------------------
|
---|
| 723 | ostringstream strC;
|
---|
| 724 | strC.setf(ios::fixed);
|
---|
| 725 | strC << _staID.data() << " PPP "
|
---|
[2231] | 726 | << epoData->tt.timestr(1) << " " << epoData->sizeAll() << " "
|
---|
| 727 | << setw(14) << setprecision(3) << x() << " +- "
|
---|
| 728 | << setw(6) << setprecision(3) << sqrt(_QQ(1,1)) << " "
|
---|
| 729 | << setw(14) << setprecision(3) << y() << " +- "
|
---|
| 730 | << setw(6) << setprecision(3) << sqrt(_QQ(2,2)) << " "
|
---|
| 731 | << setw(14) << setprecision(3) << z() << " +- "
|
---|
[2124] | 732 | << setw(6) << setprecision(3) << sqrt(_QQ(3,3));
|
---|
[2113] | 733 |
|
---|
[2370] | 734 | // NEU Output
|
---|
| 735 | // ----------
|
---|
[2372] | 736 | if (settings.value("pppOrigin").toString() == "X Y Z") {
|
---|
[2370] | 737 | double xyzRef[3];
|
---|
| 738 | double ellRef[3];
|
---|
| 739 | double _xyz[3];
|
---|
| 740 | double _neu[3];
|
---|
| 741 | xyzRef[0] = settings.value("pppRefCrdX").toDouble();
|
---|
| 742 | xyzRef[1] = settings.value("pppRefCrdY").toDouble();
|
---|
| 743 | xyzRef[2] = settings.value("pppRefCrdZ").toDouble();
|
---|
| 744 | _xyz[0] = x() - xyzRef[0];
|
---|
| 745 | _xyz[1] = y() - xyzRef[1];
|
---|
| 746 | _xyz[2] = z() - xyzRef[2];
|
---|
| 747 | xyz2ell(xyzRef, ellRef);
|
---|
| 748 | xyz2neu(ellRef, _xyz, _neu);
|
---|
[2547] | 749 | strC << " NEU "
|
---|
| 750 | << setw(8) << setprecision(3) << _neu[0] << " "
|
---|
| 751 | << setw(8) << setprecision(3) << _neu[1] << " "
|
---|
| 752 | << setw(8) << setprecision(3) << _neu[2];
|
---|
[2370] | 753 | }
|
---|
| 754 |
|
---|
[2547] | 755 | strC << endl;
|
---|
| 756 |
|
---|
| 757 | emit newMessage(QByteArray(strC.str().c_str()), true);
|
---|
| 758 |
|
---|
[2131] | 759 | // NMEA Output
|
---|
| 760 | // -----------
|
---|
[2181] | 761 | double xyz[3];
|
---|
| 762 | xyz[0] = x();
|
---|
| 763 | xyz[1] = y();
|
---|
| 764 | xyz[2] = z();
|
---|
| 765 | double ell[3];
|
---|
| 766 | xyz2ell(xyz, ell);
|
---|
| 767 | double phiDeg = ell[0] * 180 / M_PI;
|
---|
| 768 | double lamDeg = ell[1] * 180 / M_PI;
|
---|
[2132] | 769 |
|
---|
[2181] | 770 | char phiCh = 'N';
|
---|
| 771 | if (phiDeg < 0) {
|
---|
| 772 | phiDeg = -phiDeg;
|
---|
| 773 | phiCh = 'S';
|
---|
| 774 | }
|
---|
| 775 | char lamCh = 'E';
|
---|
| 776 | if (lamDeg < 0) {
|
---|
[2406] | 777 | // lamDeg = -lamDeg; // GW, reason: RTKPlot cant handle 'W'
|
---|
| 778 | // lamCh = 'W'; // GW, reason: RTKPlot cant handle 'W'
|
---|
| 779 | lamDeg = 360. +lamDeg; // GW, reason: RTKPlot cant handle 'W'
|
---|
[2181] | 780 | }
|
---|
[2132] | 781 |
|
---|
[2181] | 782 | double dop = 2.0; // TODO
|
---|
[2133] | 783 |
|
---|
[2181] | 784 | ostringstream str3;
|
---|
| 785 | str3.setf(ios::fixed);
|
---|
| 786 | str3 << "GPGGA,"
|
---|
| 787 | << epoData->tt.timestr(0,0) << ','
|
---|
| 788 | << setw(2) << setfill('0') << int(phiDeg)
|
---|
| 789 | << setw(10) << setprecision(7) << setfill('0')
|
---|
| 790 | << fmod(60*phiDeg,60) << ',' << phiCh << ','
|
---|
| 791 | << setw(2) << setfill('0') << int(lamDeg)
|
---|
| 792 | << setw(10) << setprecision(7) << setfill('0')
|
---|
| 793 | << fmod(60*lamDeg,60) << ',' << lamCh
|
---|
[2231] | 794 | << ",1," << setw(2) << setfill('0') << epoData->sizeAll() << ','
|
---|
[2181] | 795 | << setw(3) << setprecision(1) << dop << ','
|
---|
| 796 | << setprecision(3) << ell[2] << ",M,0.0,M,,,";
|
---|
| 797 |
|
---|
| 798 | writeNMEAstr(QString(str3.str().c_str()));
|
---|
[2131] | 799 |
|
---|
[2060] | 800 | return success;
|
---|
| 801 | }
|
---|
[2112] | 802 |
|
---|
| 803 | // Outlier Detection
|
---|
| 804 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 805 | int bncModel::outlierDetection(const SymmetricMatrix& QQsav,
|
---|
| 806 | const ColumnVector& vv,
|
---|
[2231] | 807 | QMap<QString, t_satData*>& satDataGPS,
|
---|
| 808 | QMap<QString, t_satData*>& satDataGlo) {
|
---|
[2112] | 809 |
|
---|
[2231] | 810 | double vvMaxCodeGPS = 0.0;
|
---|
| 811 | double vvMaxPhaseGPS = 0.0;
|
---|
| 812 | double vvMaxPhaseGlo = 0.0;
|
---|
| 813 | QMutableMapIterator<QString, t_satData*> itMaxCodeGPS(satDataGPS);
|
---|
| 814 | QMutableMapIterator<QString, t_satData*> itMaxPhaseGPS(satDataGPS);
|
---|
| 815 | QMutableMapIterator<QString, t_satData*> itMaxPhaseGlo(satDataGlo);
|
---|
[2112] | 816 |
|
---|
| 817 | int ii = 0;
|
---|
[2231] | 818 |
|
---|
| 819 | // GPS code and (optionally) phase residuals
|
---|
| 820 | // -----------------------------------------
|
---|
| 821 | QMutableMapIterator<QString, t_satData*> itGPS(satDataGPS);
|
---|
| 822 | while (itGPS.hasNext()) {
|
---|
| 823 | itGPS.next();
|
---|
[2112] | 824 | ++ii;
|
---|
| 825 |
|
---|
[2231] | 826 | if (vvMaxCodeGPS == 0.0 || fabs(vv(ii)) > vvMaxCodeGPS) {
|
---|
| 827 | vvMaxCodeGPS = fabs(vv(ii));
|
---|
| 828 | itMaxCodeGPS = itGPS;
|
---|
[2112] | 829 | }
|
---|
| 830 |
|
---|
| 831 | if (_usePhase) {
|
---|
| 832 | ++ii;
|
---|
[2231] | 833 | if (vvMaxPhaseGPS == 0.0 || fabs(vv(ii)) > vvMaxPhaseGPS) {
|
---|
| 834 | vvMaxPhaseGPS = fabs(vv(ii));
|
---|
| 835 | itMaxPhaseGPS = itGPS;
|
---|
[2112] | 836 | }
|
---|
| 837 | }
|
---|
| 838 | }
|
---|
[2231] | 839 |
|
---|
[2238] | 840 | // Glonass phase residuals
|
---|
| 841 | // -----------------------
|
---|
| 842 | if (_usePhase) {
|
---|
| 843 | QMutableMapIterator<QString, t_satData*> itGlo(satDataGlo);
|
---|
| 844 | while (itGlo.hasNext()) {
|
---|
| 845 | itGlo.next();
|
---|
| 846 | ++ii;
|
---|
| 847 | if (vvMaxPhaseGlo == 0.0 || fabs(vv(ii)) > vvMaxPhaseGlo) {
|
---|
| 848 | vvMaxPhaseGlo = fabs(vv(ii));
|
---|
| 849 | itMaxPhaseGlo = itGlo;
|
---|
| 850 | }
|
---|
| 851 | }
|
---|
| 852 | }
|
---|
[2112] | 853 |
|
---|
[2248] | 854 | if (vvMaxPhaseGlo > MAXRES_PHASE_GLO) {
|
---|
| 855 | QString prn = itMaxPhaseGlo.key();
|
---|
| 856 | t_satData* satData = itMaxPhaseGlo.value();
|
---|
| 857 | delete satData;
|
---|
| 858 | itMaxPhaseGlo.remove();
|
---|
| 859 | _QQ = QQsav;
|
---|
| 860 |
|
---|
[2547] | 861 | _log += "Outlier Phase " + prn.toAscii() + " "
|
---|
| 862 | + QByteArray::number(vvMaxPhaseGlo, 'f', 3) + "\n";
|
---|
[2248] | 863 |
|
---|
| 864 | return 1;
|
---|
| 865 | }
|
---|
| 866 |
|
---|
| 867 | else if (vvMaxCodeGPS > MAXRES_CODE_GPS) {
|
---|
[2231] | 868 | QString prn = itMaxCodeGPS.key();
|
---|
| 869 | t_satData* satData = itMaxCodeGPS.value();
|
---|
[2112] | 870 | delete satData;
|
---|
[2231] | 871 | itMaxCodeGPS.remove();
|
---|
[2112] | 872 | _QQ = QQsav;
|
---|
[2114] | 873 |
|
---|
[2547] | 874 | _log += "Outlier Code " + prn.toAscii() + " "
|
---|
| 875 | + QByteArray::number(vvMaxCodeGPS, 'f', 3) + "\n";
|
---|
[2114] | 876 |
|
---|
[2112] | 877 | return 1;
|
---|
| 878 | }
|
---|
[2243] | 879 | else if (vvMaxPhaseGPS > MAXRES_PHASE_GPS) {
|
---|
[2231] | 880 | QString prn = itMaxPhaseGPS.key();
|
---|
| 881 | t_satData* satData = itMaxPhaseGPS.value();
|
---|
[2112] | 882 | delete satData;
|
---|
[2231] | 883 | itMaxPhaseGPS.remove();
|
---|
[2112] | 884 | _QQ = QQsav;
|
---|
[2114] | 885 |
|
---|
[2547] | 886 | _log += "Outlier Phase " + prn.toAscii() + " "
|
---|
| 887 | + QByteArray::number(vvMaxPhaseGPS, 'f', 3) + "\n";
|
---|
[2114] | 888 |
|
---|
[2112] | 889 | return 1;
|
---|
| 890 | }
|
---|
[2231] | 891 |
|
---|
[2112] | 892 | return 0;
|
---|
| 893 | }
|
---|
[2130] | 894 |
|
---|
| 895 | //
|
---|
| 896 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 897 | void bncModel::writeNMEAstr(const QString& nmStr) {
|
---|
| 898 |
|
---|
| 899 | unsigned char XOR = 0;
|
---|
| 900 | for (int ii = 0; ii < nmStr.length(); ii++) {
|
---|
| 901 | XOR ^= (unsigned char) nmStr[ii].toAscii();
|
---|
| 902 | }
|
---|
[2181] | 903 |
|
---|
| 904 | QString outStr = '$' + nmStr
|
---|
| 905 | + QString("*%1\n").arg(int(XOR), 0, 16).toUpper();
|
---|
[2130] | 906 |
|
---|
[2178] | 907 | if (_nmeaStream) {
|
---|
[2181] | 908 | *_nmeaStream << outStr;
|
---|
[2178] | 909 | _nmeaStream->flush();
|
---|
| 910 | }
|
---|
[2130] | 911 |
|
---|
[2181] | 912 | emit newNMEAstr(outStr.toAscii());
|
---|
[2130] | 913 | }
|
---|
[2283] | 914 |
|
---|
| 915 |
|
---|
| 916 | ////
|
---|
| 917 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 918 | void bncModel::kalman(const Matrix& AA, const ColumnVector& ll,
|
---|
| 919 | const DiagonalMatrix& PP,
|
---|
| 920 | SymmetricMatrix& QQ, ColumnVector& dx) {
|
---|
| 921 |
|
---|
| 922 | int nObs = AA.Nrows();
|
---|
| 923 | int nPar = AA.Ncols();
|
---|
| 924 |
|
---|
| 925 | UpperTriangularMatrix SS = Cholesky(QQ).t();
|
---|
| 926 |
|
---|
| 927 | Matrix SA = SS*AA.t();
|
---|
| 928 | Matrix SRF(nObs+nPar, nObs+nPar); SRF = 0;
|
---|
| 929 | for (int ii = 1; ii <= nObs; ++ii) {
|
---|
| 930 | SRF(ii,ii) = 1.0 / sqrt(PP(ii,ii));
|
---|
| 931 | }
|
---|
| 932 |
|
---|
| 933 | SRF.SubMatrix (nObs+1, nObs+nPar, 1, nObs) = SA;
|
---|
| 934 | SRF.SymSubMatrix(nObs+1, nObs+nPar) = SS;
|
---|
| 935 |
|
---|
| 936 | UpperTriangularMatrix UU;
|
---|
| 937 | QRZ(SRF, UU);
|
---|
| 938 |
|
---|
| 939 | SS = UU.SymSubMatrix(nObs+1, nObs+nPar);
|
---|
| 940 | UpperTriangularMatrix SH_rt = UU.SymSubMatrix(1, nObs);
|
---|
| 941 | Matrix YY = UU.SubMatrix(1, nObs, nObs+1, nObs+nPar);
|
---|
| 942 |
|
---|
| 943 | UpperTriangularMatrix SHi = SH_rt.i();
|
---|
| 944 |
|
---|
| 945 | Matrix KT = SHi * YY;
|
---|
| 946 | SymmetricMatrix Hi; Hi << SHi * SHi.t();
|
---|
| 947 |
|
---|
| 948 | dx = KT.t() * ll;
|
---|
| 949 | QQ << (SS.t() * SS);
|
---|
| 950 | }
|
---|