[6054] | 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 | *
|
---|
[6093] | 29 | * Class: t_pppParam, t_pppFilter
|
---|
[6054] | 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>
|
---|
| 42 | #include <cmath>
|
---|
[6094] | 43 | #include <sstream>
|
---|
[6054] | 44 | #include <newmatio.h>
|
---|
[6094] | 45 | #include <newmatap.h>
|
---|
[6054] | 46 |
|
---|
[6093] | 47 | #include "pppFilter.h"
|
---|
[6061] | 48 | #include "pppClient.h"
|
---|
[6054] | 49 | #include "bncutils.h"
|
---|
| 50 | #include "bncantex.h"
|
---|
[6059] | 51 | #include "pppOptions.h"
|
---|
[6060] | 52 | #include "pppModel.h"
|
---|
[6054] | 53 |
|
---|
[6055] | 54 | using namespace BNC_PPP;
|
---|
[6054] | 55 | using namespace std;
|
---|
| 56 |
|
---|
| 57 | const unsigned MINOBS = 5;
|
---|
| 58 | const double MINELE = 10.0 * M_PI / 180.0;
|
---|
| 59 | const double MAXRES_CODE = 15.0;
|
---|
| 60 | const double MAXRES_PHASE_GPS = 0.04;
|
---|
| 61 | const double MAXRES_PHASE_GLONASS = 0.08;
|
---|
| 62 | const double GLONASS_WEIGHT_FACTOR = 5.0;
|
---|
| 63 |
|
---|
[6100] | 64 | #define LOG (_pppClient->log())
|
---|
| 65 | #define OPT (_pppClient->opt())
|
---|
| 66 |
|
---|
[6054] | 67 | // Constructor
|
---|
| 68 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 69 | t_pppParam::t_pppParam(t_pppParam::parType typeIn, int indexIn,
|
---|
[6054] | 70 | const QString& prnIn) {
|
---|
| 71 | type = typeIn;
|
---|
| 72 | index = indexIn;
|
---|
| 73 | prn = prnIn;
|
---|
| 74 | index_old = 0;
|
---|
| 75 | xx = 0.0;
|
---|
| 76 | numEpo = 0;
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | // Destructor
|
---|
| 80 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 81 | t_pppParam::~t_pppParam() {
|
---|
[6054] | 82 | }
|
---|
| 83 |
|
---|
| 84 | // Partial
|
---|
| 85 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 86 | double t_pppParam::partial(t_satData* satData, bool phase) {
|
---|
[6054] | 87 |
|
---|
[6093] | 88 | Tracer tracer("t_pppParam::partial");
|
---|
[6054] | 89 |
|
---|
| 90 | // Coordinates
|
---|
| 91 | // -----------
|
---|
| 92 | if (type == CRD_X) {
|
---|
| 93 | return (xx - satData->xx(1)) / satData->rho;
|
---|
| 94 | }
|
---|
| 95 | else if (type == CRD_Y) {
|
---|
| 96 | return (xx - satData->xx(2)) / satData->rho;
|
---|
| 97 | }
|
---|
| 98 | else if (type == CRD_Z) {
|
---|
| 99 | return (xx - satData->xx(3)) / satData->rho;
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | // Receiver Clocks
|
---|
| 103 | // ---------------
|
---|
| 104 | else if (type == RECCLK) {
|
---|
| 105 | return 1.0;
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | // Troposphere
|
---|
| 109 | // -----------
|
---|
| 110 | else if (type == TROPO) {
|
---|
| 111 | return 1.0 / sin(satData->eleSat);
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 | // Glonass Offset
|
---|
| 115 | // --------------
|
---|
| 116 | else if (type == GLONASS_OFFSET) {
|
---|
| 117 | if (satData->prn[0] == 'R') {
|
---|
| 118 | return 1.0;
|
---|
| 119 | }
|
---|
| 120 | else {
|
---|
| 121 | return 0.0;
|
---|
| 122 | }
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | // Galileo Offset
|
---|
| 126 | // --------------
|
---|
| 127 | else if (type == GALILEO_OFFSET) {
|
---|
| 128 | if (satData->prn[0] == 'E') {
|
---|
| 129 | return 1.0;
|
---|
| 130 | }
|
---|
| 131 | else {
|
---|
| 132 | return 0.0;
|
---|
| 133 | }
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | // Ambiguities
|
---|
| 137 | // -----------
|
---|
| 138 | else if (type == AMB_L3) {
|
---|
| 139 | if (phase && satData->prn == prn) {
|
---|
| 140 | return 1.0;
|
---|
| 141 | }
|
---|
| 142 | else {
|
---|
| 143 | return 0.0;
|
---|
| 144 | }
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 | // Default return
|
---|
| 148 | // --------------
|
---|
| 149 | return 0.0;
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 | // Constructor
|
---|
| 153 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 154 | t_pppFilter::t_pppFilter(t_pppClient* pppClient) {
|
---|
[6054] | 155 |
|
---|
| 156 | _pppClient = pppClient;
|
---|
[6060] | 157 | _tides = new t_tides();
|
---|
| 158 |
|
---|
[6054] | 159 | // Antenna Name, ANTEX File
|
---|
| 160 | // ------------------------
|
---|
| 161 | _antex = 0;
|
---|
[6100] | 162 | if (!OPT->_antexFileName.empty()) {
|
---|
| 163 | _antex = new bncAntex(OPT->_antexFileName.c_str());
|
---|
[6054] | 164 | }
|
---|
| 165 |
|
---|
| 166 | // Bancroft Coordinates
|
---|
| 167 | // --------------------
|
---|
| 168 | _xcBanc.ReSize(4); _xcBanc = 0.0;
|
---|
| 169 | _ellBanc.ReSize(3); _ellBanc = 0.0;
|
---|
| 170 |
|
---|
| 171 | // Save copy of data (used in outlier detection)
|
---|
| 172 | // ---------------------------------------------
|
---|
| 173 | _epoData_sav = new t_epoData();
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | // Destructor
|
---|
| 177 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 178 | t_pppFilter::~t_pppFilter() {
|
---|
[6060] | 179 | delete _tides;
|
---|
[6054] | 180 | delete _antex;
|
---|
| 181 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 182 | delete _params[iPar-1];
|
---|
| 183 | }
|
---|
| 184 | for (int iPar = 1; iPar <= _params_sav.size(); iPar++) {
|
---|
| 185 | delete _params_sav[iPar-1];
|
---|
| 186 | }
|
---|
| 187 | delete _epoData_sav;
|
---|
| 188 | }
|
---|
| 189 |
|
---|
| 190 | // Reset Parameters and Variance-Covariance Matrix
|
---|
| 191 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 192 | void t_pppFilter::reset() {
|
---|
[6054] | 193 |
|
---|
[6093] | 194 | Tracer tracer("t_pppFilter::reset");
|
---|
[6054] | 195 |
|
---|
| 196 | double lastTrp = 0.0;
|
---|
| 197 | for (int ii = 0; ii < _params.size(); ii++) {
|
---|
[6093] | 198 | t_pppParam* pp = _params[ii];
|
---|
| 199 | if (pp->type == t_pppParam::TROPO) {
|
---|
[6054] | 200 | lastTrp = pp->xx;
|
---|
| 201 | }
|
---|
| 202 | delete pp;
|
---|
| 203 | }
|
---|
| 204 | _params.clear();
|
---|
| 205 |
|
---|
| 206 | int nextPar = 0;
|
---|
[6093] | 207 | _params.push_back(new t_pppParam(t_pppParam::CRD_X, ++nextPar, ""));
|
---|
| 208 | _params.push_back(new t_pppParam(t_pppParam::CRD_Y, ++nextPar, ""));
|
---|
| 209 | _params.push_back(new t_pppParam(t_pppParam::CRD_Z, ++nextPar, ""));
|
---|
| 210 | _params.push_back(new t_pppParam(t_pppParam::RECCLK, ++nextPar, ""));
|
---|
[6100] | 211 | if (OPT->estTrp()) {
|
---|
[6093] | 212 | _params.push_back(new t_pppParam(t_pppParam::TROPO, ++nextPar, ""));
|
---|
[6054] | 213 | }
|
---|
[6100] | 214 | if (OPT->useSystem('R')) {
|
---|
[6093] | 215 | _params.push_back(new t_pppParam(t_pppParam::GLONASS_OFFSET, ++nextPar, ""));
|
---|
[6054] | 216 | }
|
---|
[6100] | 217 | if (OPT->useSystem('E')) {
|
---|
[6093] | 218 | _params.push_back(new t_pppParam(t_pppParam::GALILEO_OFFSET, ++nextPar, ""));
|
---|
[6054] | 219 | }
|
---|
| 220 |
|
---|
| 221 | _QQ.ReSize(_params.size());
|
---|
| 222 | _QQ = 0.0;
|
---|
| 223 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
[6093] | 224 | t_pppParam* pp = _params[iPar-1];
|
---|
[6054] | 225 | pp->xx = 0.0;
|
---|
| 226 | if (pp->isCrd()) {
|
---|
[6100] | 227 | _QQ(iPar,iPar) = OPT->_aprSigCrd(1) * OPT->_aprSigCrd(1);
|
---|
[6054] | 228 | }
|
---|
[6093] | 229 | else if (pp->type == t_pppParam::RECCLK) {
|
---|
[6100] | 230 | _QQ(iPar,iPar) = OPT->_noiseClk * OPT->_noiseClk;
|
---|
[6054] | 231 | }
|
---|
[6093] | 232 | else if (pp->type == t_pppParam::TROPO) {
|
---|
[6100] | 233 | _QQ(iPar,iPar) = OPT->_aprSigTrp * OPT->_aprSigTrp;
|
---|
[6054] | 234 | pp->xx = lastTrp;
|
---|
| 235 | }
|
---|
[6093] | 236 | else if (pp->type == t_pppParam::GLONASS_OFFSET) {
|
---|
[6060] | 237 | _QQ(iPar,iPar) = 1000.0 * 1000.0;
|
---|
[6054] | 238 | }
|
---|
[6093] | 239 | else if (pp->type == t_pppParam::GALILEO_OFFSET) {
|
---|
[6060] | 240 | _QQ(iPar,iPar) = 1000.0 * 1000.0;
|
---|
[6054] | 241 | }
|
---|
| 242 | }
|
---|
| 243 | }
|
---|
| 244 |
|
---|
| 245 | // Bancroft Solution
|
---|
| 246 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 247 | t_irc t_pppFilter::cmpBancroft(t_epoData* epoData) {
|
---|
[6054] | 248 |
|
---|
[6093] | 249 | Tracer tracer("t_pppFilter::cmpBancroft");
|
---|
[6054] | 250 |
|
---|
| 251 | if (epoData->sizeSys('G') < MINOBS) {
|
---|
[6100] | 252 | LOG << "t_pppFilter::cmpBancroft: not enough data\n";
|
---|
[6054] | 253 | return failure;
|
---|
| 254 | }
|
---|
| 255 |
|
---|
| 256 | Matrix BB(epoData->sizeSys('G'), 4);
|
---|
| 257 |
|
---|
| 258 | QMapIterator<QString, t_satData*> it(epoData->satData);
|
---|
| 259 | int iObsBanc = 0;
|
---|
| 260 | while (it.hasNext()) {
|
---|
| 261 | it.next();
|
---|
| 262 | t_satData* satData = it.value();
|
---|
| 263 | if (satData->system() == 'G') {
|
---|
| 264 | ++iObsBanc;
|
---|
| 265 | QString prn = it.key();
|
---|
| 266 | BB(iObsBanc, 1) = satData->xx(1);
|
---|
| 267 | BB(iObsBanc, 2) = satData->xx(2);
|
---|
| 268 | BB(iObsBanc, 3) = satData->xx(3);
|
---|
| 269 | BB(iObsBanc, 4) = satData->P3 + satData->clk;
|
---|
| 270 | }
|
---|
| 271 | }
|
---|
| 272 |
|
---|
| 273 | bancroft(BB, _xcBanc);
|
---|
| 274 |
|
---|
| 275 | // Ellipsoidal Coordinates
|
---|
| 276 | // ------------------------
|
---|
| 277 | xyz2ell(_xcBanc.data(), _ellBanc.data());
|
---|
| 278 |
|
---|
| 279 | // Compute Satellite Elevations
|
---|
| 280 | // ----------------------------
|
---|
| 281 | QMutableMapIterator<QString, t_satData*> im(epoData->satData);
|
---|
| 282 | while (im.hasNext()) {
|
---|
| 283 | im.next();
|
---|
| 284 | t_satData* satData = im.value();
|
---|
| 285 | cmpEle(satData);
|
---|
| 286 | if (satData->eleSat < MINELE) {
|
---|
| 287 | delete satData;
|
---|
| 288 | im.remove();
|
---|
| 289 | }
|
---|
| 290 | }
|
---|
| 291 |
|
---|
| 292 | return success;
|
---|
| 293 | }
|
---|
| 294 |
|
---|
| 295 | // Computed Value
|
---|
| 296 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 297 | double t_pppFilter::cmpValue(t_satData* satData, bool phase) {
|
---|
[6054] | 298 |
|
---|
[6093] | 299 | Tracer tracer("t_pppFilter::cmpValue");
|
---|
[6054] | 300 |
|
---|
| 301 | ColumnVector xRec(3);
|
---|
| 302 | xRec(1) = x();
|
---|
| 303 | xRec(2) = y();
|
---|
| 304 | xRec(3) = z();
|
---|
| 305 |
|
---|
| 306 | double rho0 = (satData->xx - xRec).norm_Frobenius();
|
---|
| 307 | double dPhi = t_CST::omega * rho0 / t_CST::c;
|
---|
| 308 |
|
---|
| 309 | xRec(1) = x() * cos(dPhi) - y() * sin(dPhi);
|
---|
| 310 | xRec(2) = y() * cos(dPhi) + x() * sin(dPhi);
|
---|
| 311 | xRec(3) = z();
|
---|
| 312 |
|
---|
[6060] | 313 | xRec += _tides->displacement(_time, xRec);
|
---|
[6054] | 314 |
|
---|
| 315 | satData->rho = (satData->xx - xRec).norm_Frobenius();
|
---|
| 316 |
|
---|
| 317 | double tropDelay = delay_saast(satData->eleSat) +
|
---|
| 318 | trp() / sin(satData->eleSat);
|
---|
| 319 |
|
---|
| 320 | double wind = 0.0;
|
---|
| 321 | if (phase) {
|
---|
| 322 | wind = windUp(satData->prn, satData->xx, xRec) * satData->lambda3;
|
---|
| 323 | }
|
---|
| 324 |
|
---|
| 325 | double offset = 0.0;
|
---|
| 326 | if (satData->prn[0] == 'R') {
|
---|
| 327 | offset = Glonass_offset();
|
---|
| 328 | }
|
---|
| 329 | else if (satData->prn[0] == 'E') {
|
---|
| 330 | offset = Galileo_offset();
|
---|
| 331 | }
|
---|
| 332 |
|
---|
| 333 | double phaseCenter = 0.0;
|
---|
| 334 | if (_antex) {
|
---|
| 335 | bool found;
|
---|
[6100] | 336 | phaseCenter = _antex->pco(QString(OPT->_antNameRover.c_str()), satData->eleSat, found);
|
---|
[6054] | 337 | if (!found) {
|
---|
[6100] | 338 | LOG << "ANTEX: antenna >" << OPT->_antNameRover << "< not found\n";
|
---|
[6054] | 339 | }
|
---|
| 340 | }
|
---|
| 341 |
|
---|
| 342 | double antennaOffset = 0.0;
|
---|
[6061] | 343 | double cosa = cos(satData->azSat);
|
---|
| 344 | double sina = sin(satData->azSat);
|
---|
| 345 | double cose = cos(satData->eleSat);
|
---|
| 346 | double sine = sin(satData->eleSat);
|
---|
[6100] | 347 | antennaOffset = -OPT->_neuEccRover(1) * cosa*cose
|
---|
| 348 | -OPT->_neuEccRover(2) * sina*cose
|
---|
| 349 | -OPT->_neuEccRover(3) * sine;
|
---|
[6054] | 350 |
|
---|
| 351 | return satData->rho + phaseCenter + antennaOffset + clk()
|
---|
| 352 | + offset - satData->clk + tropDelay + wind;
|
---|
| 353 | }
|
---|
| 354 |
|
---|
| 355 | // Tropospheric Model (Saastamoinen)
|
---|
| 356 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 357 | double t_pppFilter::delay_saast(double Ele) {
|
---|
[6054] | 358 |
|
---|
[6093] | 359 | Tracer tracer("t_pppFilter::delay_saast");
|
---|
[6054] | 360 |
|
---|
| 361 | double xyz[3];
|
---|
| 362 | xyz[0] = x();
|
---|
| 363 | xyz[1] = y();
|
---|
| 364 | xyz[2] = z();
|
---|
| 365 | double ell[3];
|
---|
| 366 | xyz2ell(xyz, ell);
|
---|
| 367 | double height = ell[2];
|
---|
| 368 |
|
---|
| 369 | double pp = 1013.25 * pow(1.0 - 2.26e-5 * height, 5.225);
|
---|
| 370 | double TT = 18.0 - height * 0.0065 + 273.15;
|
---|
| 371 | double hh = 50.0 * exp(-6.396e-4 * height);
|
---|
| 372 | double ee = hh / 100.0 * exp(-37.2465 + 0.213166*TT - 0.000256908*TT*TT);
|
---|
| 373 |
|
---|
| 374 | double h_km = height / 1000.0;
|
---|
| 375 |
|
---|
| 376 | if (h_km < 0.0) h_km = 0.0;
|
---|
| 377 | if (h_km > 5.0) h_km = 5.0;
|
---|
| 378 | int ii = int(h_km + 1);
|
---|
| 379 | double href = ii - 1;
|
---|
| 380 |
|
---|
| 381 | double bCor[6];
|
---|
| 382 | bCor[0] = 1.156;
|
---|
| 383 | bCor[1] = 1.006;
|
---|
| 384 | bCor[2] = 0.874;
|
---|
| 385 | bCor[3] = 0.757;
|
---|
| 386 | bCor[4] = 0.654;
|
---|
| 387 | bCor[5] = 0.563;
|
---|
| 388 |
|
---|
| 389 | double BB = bCor[ii-1] + (bCor[ii]-bCor[ii-1]) * (h_km - href);
|
---|
| 390 |
|
---|
| 391 | double zen = M_PI/2.0 - Ele;
|
---|
| 392 |
|
---|
| 393 | return (0.002277/cos(zen)) * (pp + ((1255.0/TT)+0.05)*ee - BB*(tan(zen)*tan(zen)));
|
---|
| 394 | }
|
---|
| 395 |
|
---|
| 396 | // Prediction Step of the Filter
|
---|
| 397 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 398 | void t_pppFilter::predict(int iPhase, t_epoData* epoData) {
|
---|
[6054] | 399 |
|
---|
[6093] | 400 | Tracer tracer("t_pppFilter::predict");
|
---|
[6054] | 401 |
|
---|
| 402 | if (iPhase == 0) {
|
---|
| 403 |
|
---|
[6061] | 404 | const double maxSolGap = 0.0;
|
---|
| 405 |
|
---|
[6054] | 406 | bool firstCrd = false;
|
---|
[6061] | 407 | if (!_lastTimeOK.valid() || (maxSolGap > 0.0 && _time - _lastTimeOK > maxSolGap)) {
|
---|
[6054] | 408 | firstCrd = true;
|
---|
| 409 | _startTime = epoData->tt;
|
---|
| 410 | reset();
|
---|
| 411 | }
|
---|
| 412 |
|
---|
| 413 | // Use different white noise for Quick-Start mode
|
---|
| 414 | // ----------------------------------------------
|
---|
[6100] | 415 | double sigCrdP_used = OPT->_noiseCrd(1);
|
---|
| 416 | if ( OPT->_seedingTime > 0.0 && OPT->_seedingTime > (epoData->tt - _startTime) ) {
|
---|
[6054] | 417 | sigCrdP_used = 0.0;
|
---|
| 418 | }
|
---|
| 419 |
|
---|
| 420 | // Predict Parameter values, add white noise
|
---|
| 421 | // -----------------------------------------
|
---|
| 422 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
[6093] | 423 | t_pppParam* pp = _params[iPar-1];
|
---|
[6054] | 424 |
|
---|
| 425 | // Coordinates
|
---|
| 426 | // -----------
|
---|
[6093] | 427 | if (pp->type == t_pppParam::CRD_X) {
|
---|
[6054] | 428 | if (firstCrd) {
|
---|
[6100] | 429 | if (OPT->xyzAprRoverSet()) {
|
---|
| 430 | pp->xx = OPT->_xyzAprRover[0];
|
---|
[6054] | 431 | }
|
---|
| 432 | else {
|
---|
| 433 | pp->xx = _xcBanc(1);
|
---|
| 434 | }
|
---|
| 435 | }
|
---|
| 436 | _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
|
---|
| 437 | }
|
---|
[6093] | 438 | else if (pp->type == t_pppParam::CRD_Y) {
|
---|
[6054] | 439 | if (firstCrd) {
|
---|
[6100] | 440 | if (OPT->xyzAprRoverSet()) {
|
---|
| 441 | pp->xx = OPT->_xyzAprRover[1];
|
---|
[6054] | 442 | }
|
---|
| 443 | else {
|
---|
| 444 | pp->xx = _xcBanc(2);
|
---|
| 445 | }
|
---|
| 446 | }
|
---|
| 447 | _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
|
---|
| 448 | }
|
---|
[6093] | 449 | else if (pp->type == t_pppParam::CRD_Z) {
|
---|
[6054] | 450 | if (firstCrd) {
|
---|
[6100] | 451 | if (OPT->xyzAprRoverSet()) {
|
---|
| 452 | pp->xx = OPT->_xyzAprRover[2];
|
---|
[6054] | 453 | }
|
---|
| 454 | else {
|
---|
| 455 | pp->xx = _xcBanc(3);
|
---|
| 456 | }
|
---|
| 457 | }
|
---|
| 458 | _QQ(iPar,iPar) += sigCrdP_used * sigCrdP_used;
|
---|
| 459 | }
|
---|
| 460 |
|
---|
| 461 | // Receiver Clocks
|
---|
| 462 | // ---------------
|
---|
[6093] | 463 | else if (pp->type == t_pppParam::RECCLK) {
|
---|
[6054] | 464 | pp->xx = _xcBanc(4);
|
---|
| 465 | for (int jj = 1; jj <= _params.size(); jj++) {
|
---|
| 466 | _QQ(iPar, jj) = 0.0;
|
---|
| 467 | }
|
---|
[6100] | 468 | _QQ(iPar,iPar) = OPT->_noiseClk * OPT->_noiseClk;
|
---|
[6054] | 469 | }
|
---|
| 470 |
|
---|
| 471 | // Tropospheric Delay
|
---|
| 472 | // ------------------
|
---|
[6093] | 473 | else if (pp->type == t_pppParam::TROPO) {
|
---|
[6100] | 474 | _QQ(iPar,iPar) += OPT->_noiseTrp * OPT->_noiseTrp;
|
---|
[6054] | 475 | }
|
---|
| 476 |
|
---|
| 477 | // Glonass Offset
|
---|
| 478 | // --------------
|
---|
[6093] | 479 | else if (pp->type == t_pppParam::GLONASS_OFFSET) {
|
---|
[6061] | 480 | pp->xx = 0.0;
|
---|
| 481 | for (int jj = 1; jj <= _params.size(); jj++) {
|
---|
| 482 | _QQ(iPar, jj) = 0.0;
|
---|
[6054] | 483 | }
|
---|
[6061] | 484 | _QQ(iPar,iPar) = 1000.0 * 1000.0;
|
---|
[6054] | 485 | }
|
---|
| 486 |
|
---|
| 487 | // Galileo Offset
|
---|
| 488 | // --------------
|
---|
[6093] | 489 | else if (pp->type == t_pppParam::GALILEO_OFFSET) {
|
---|
[6061] | 490 | _QQ(iPar,iPar) += 0.1 * 0.1;
|
---|
[6054] | 491 | }
|
---|
| 492 | }
|
---|
| 493 | }
|
---|
| 494 |
|
---|
| 495 | // Add New Ambiguities if necessary
|
---|
| 496 | // --------------------------------
|
---|
[6100] | 497 | if (OPT->ambLCs('G').size() || OPT->ambLCs('R').size() || OPT->ambLCs('E').size()) {
|
---|
[6054] | 498 |
|
---|
| 499 | // Make a copy of QQ and xx, set parameter indices
|
---|
| 500 | // -----------------------------------------------
|
---|
| 501 | SymmetricMatrix QQ_old = _QQ;
|
---|
| 502 |
|
---|
| 503 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 504 | _params[iPar-1]->index_old = _params[iPar-1]->index;
|
---|
| 505 | _params[iPar-1]->index = 0;
|
---|
| 506 | }
|
---|
| 507 |
|
---|
| 508 | // Remove Ambiguity Parameters without observations
|
---|
| 509 | // ------------------------------------------------
|
---|
| 510 | int iPar = 0;
|
---|
[6093] | 511 | QMutableVectorIterator<t_pppParam*> im(_params);
|
---|
[6054] | 512 | while (im.hasNext()) {
|
---|
[6093] | 513 | t_pppParam* par = im.next();
|
---|
[6054] | 514 | bool removed = false;
|
---|
[6093] | 515 | if (par->type == t_pppParam::AMB_L3) {
|
---|
[6054] | 516 | if (epoData->satData.find(par->prn) == epoData->satData.end()) {
|
---|
| 517 | removed = true;
|
---|
| 518 | delete par;
|
---|
| 519 | im.remove();
|
---|
| 520 | }
|
---|
| 521 | }
|
---|
| 522 | if (! removed) {
|
---|
| 523 | ++iPar;
|
---|
| 524 | par->index = iPar;
|
---|
| 525 | }
|
---|
| 526 | }
|
---|
| 527 |
|
---|
| 528 | // Add new ambiguity parameters
|
---|
| 529 | // ----------------------------
|
---|
| 530 | QMapIterator<QString, t_satData*> it(epoData->satData);
|
---|
| 531 | while (it.hasNext()) {
|
---|
| 532 | it.next();
|
---|
| 533 | t_satData* satData = it.value();
|
---|
| 534 | addAmb(satData);
|
---|
| 535 | }
|
---|
| 536 |
|
---|
| 537 | int nPar = _params.size();
|
---|
| 538 | _QQ.ReSize(nPar); _QQ = 0.0;
|
---|
| 539 | for (int i1 = 1; i1 <= nPar; i1++) {
|
---|
[6093] | 540 | t_pppParam* p1 = _params[i1-1];
|
---|
[6054] | 541 | if (p1->index_old != 0) {
|
---|
| 542 | _QQ(p1->index, p1->index) = QQ_old(p1->index_old, p1->index_old);
|
---|
| 543 | for (int i2 = 1; i2 <= nPar; i2++) {
|
---|
[6093] | 544 | t_pppParam* p2 = _params[i2-1];
|
---|
[6054] | 545 | if (p2->index_old != 0) {
|
---|
| 546 | _QQ(p1->index, p2->index) = QQ_old(p1->index_old, p2->index_old);
|
---|
| 547 | }
|
---|
| 548 | }
|
---|
| 549 | }
|
---|
| 550 | }
|
---|
| 551 |
|
---|
| 552 | for (int ii = 1; ii <= nPar; ii++) {
|
---|
[6093] | 553 | t_pppParam* par = _params[ii-1];
|
---|
[6054] | 554 | if (par->index_old == 0) {
|
---|
[6100] | 555 | _QQ(par->index, par->index) = OPT->_aprSigAmb * OPT->_aprSigAmb;
|
---|
[6054] | 556 | }
|
---|
| 557 | par->index_old = par->index;
|
---|
| 558 | }
|
---|
| 559 | }
|
---|
| 560 | }
|
---|
| 561 |
|
---|
| 562 | // Update Step of the Filter (currently just a single-epoch solution)
|
---|
| 563 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 564 | t_irc t_pppFilter::update(t_epoData* epoData) {
|
---|
[6054] | 565 |
|
---|
[6093] | 566 | Tracer tracer("t_pppFilter::update");
|
---|
[6054] | 567 |
|
---|
| 568 | _time = epoData->tt; // current epoch time
|
---|
| 569 |
|
---|
[6100] | 570 | if (OPT->useOrbClkCorr()) {
|
---|
| 571 | LOG << "Precise Point Positioning of Epoch " << _time.timestr(1)
|
---|
| 572 | << "\n---------------------------------------------------------------\n";
|
---|
[6054] | 573 | }
|
---|
| 574 | else {
|
---|
[6100] | 575 | LOG << "Single Point Positioning of Epoch " << _time.timestr(1)
|
---|
| 576 | << "\n--------------------------------------------------------------\n";
|
---|
[6054] | 577 | }
|
---|
| 578 |
|
---|
| 579 | // Outlier Detection Loop
|
---|
| 580 | // ----------------------
|
---|
| 581 | if (update_p(epoData) != success) {
|
---|
| 582 | return failure;
|
---|
| 583 | }
|
---|
| 584 |
|
---|
| 585 | // Set Solution Vector
|
---|
| 586 | // -------------------
|
---|
[6100] | 587 | LOG.setf(ios::fixed);
|
---|
[6093] | 588 | QVectorIterator<t_pppParam*> itPar(_params);
|
---|
[6054] | 589 | while (itPar.hasNext()) {
|
---|
[6093] | 590 | t_pppParam* par = itPar.next();
|
---|
| 591 | if (par->type == t_pppParam::RECCLK) {
|
---|
[6100] | 592 | LOG << "\n clk = " << setw(10) << setprecision(3) << par->xx
|
---|
| 593 | << " +- " << setw(6) << setprecision(3)
|
---|
| 594 | << sqrt(_QQ(par->index,par->index));
|
---|
[6054] | 595 | }
|
---|
[6093] | 596 | else if (par->type == t_pppParam::AMB_L3) {
|
---|
[6054] | 597 | ++par->numEpo;
|
---|
[6100] | 598 | LOG << "\n amb " << par->prn.toAscii().data() << " = "
|
---|
| 599 | << setw(10) << setprecision(3) << par->xx
|
---|
| 600 | << " +- " << setw(6) << setprecision(3)
|
---|
| 601 | << sqrt(_QQ(par->index,par->index))
|
---|
| 602 | << " nEpo = " << par->numEpo;
|
---|
[6054] | 603 | }
|
---|
[6093] | 604 | else if (par->type == t_pppParam::TROPO) {
|
---|
[6054] | 605 | double aprTrp = delay_saast(M_PI/2.0);
|
---|
[6100] | 606 | LOG << "\n trp = " << par->prn.toAscii().data()
|
---|
| 607 | << setw(7) << setprecision(3) << aprTrp << " "
|
---|
| 608 | << setw(6) << setprecision(3) << showpos << par->xx << noshowpos
|
---|
| 609 | << " +- " << setw(6) << setprecision(3)
|
---|
| 610 | << sqrt(_QQ(par->index,par->index));
|
---|
[6054] | 611 | }
|
---|
[6093] | 612 | else if (par->type == t_pppParam::GLONASS_OFFSET) {
|
---|
[6100] | 613 | LOG << "\n offGlo = " << setw(10) << setprecision(3) << par->xx
|
---|
| 614 | << " +- " << setw(6) << setprecision(3)
|
---|
| 615 | << sqrt(_QQ(par->index,par->index));
|
---|
[6054] | 616 | }
|
---|
[6093] | 617 | else if (par->type == t_pppParam::GALILEO_OFFSET) {
|
---|
[6100] | 618 | LOG << "\n offGal = " << setw(10) << setprecision(3) << par->xx
|
---|
| 619 | << " +- " << setw(6) << setprecision(3)
|
---|
| 620 | << sqrt(_QQ(par->index,par->index));
|
---|
[6054] | 621 | }
|
---|
| 622 | }
|
---|
| 623 |
|
---|
[6105] | 624 | LOG << endl << endl;
|
---|
[6100] | 625 |
|
---|
[6054] | 626 | // Final Message (both log file and screen)
|
---|
| 627 | // ----------------------------------------
|
---|
[6100] | 628 | LOG << OPT->_roverName << " PPP "
|
---|
| 629 | << epoData->tt.timestr(1) << " " << epoData->sizeAll() << " "
|
---|
| 630 | << setw(14) << setprecision(3) << x() << " +- "
|
---|
| 631 | << setw(6) << setprecision(3) << sqrt(_QQ(1,1)) << " "
|
---|
| 632 | << setw(14) << setprecision(3) << y() << " +- "
|
---|
| 633 | << setw(6) << setprecision(3) << sqrt(_QQ(2,2)) << " "
|
---|
| 634 | << setw(14) << setprecision(3) << z() << " +- "
|
---|
| 635 | << setw(6) << setprecision(3) << sqrt(_QQ(3,3));
|
---|
[6054] | 636 |
|
---|
| 637 | // NEU Output
|
---|
| 638 | // ----------
|
---|
[6100] | 639 | if (OPT->xyzAprRoverSet()) {
|
---|
| 640 | double xyz[3];
|
---|
| 641 | xyz[0] = x() - OPT->_xyzAprRover[0];
|
---|
| 642 | xyz[1] = y() - OPT->_xyzAprRover[1];
|
---|
| 643 | xyz[2] = z() - OPT->_xyzAprRover[2];
|
---|
[6054] | 644 |
|
---|
| 645 | double ellRef[3];
|
---|
[6100] | 646 | xyz2ell(OPT->_xyzAprRover.data(), ellRef);
|
---|
| 647 | double neu[3];
|
---|
| 648 | xyz2neu(ellRef, xyz, neu);
|
---|
[6054] | 649 |
|
---|
[6100] | 650 | LOG << " NEU "
|
---|
| 651 | << setw(8) << setprecision(3) << neu[0] << " "
|
---|
| 652 | << setw(8) << setprecision(3) << neu[1] << " "
|
---|
[6105] | 653 | << setw(8) << setprecision(3) << neu[2] << endl << endl;
|
---|
[6054] | 654 | }
|
---|
[6100] | 655 | else {
|
---|
[6105] | 656 | LOG << endl << endl;
|
---|
[6100] | 657 | }
|
---|
[6054] | 658 |
|
---|
| 659 | _lastTimeOK = _time; // remember time of last successful update
|
---|
| 660 | return success;
|
---|
| 661 | }
|
---|
| 662 |
|
---|
| 663 | // Outlier Detection
|
---|
| 664 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 665 | QString t_pppFilter::outlierDetection(int iPhase, const ColumnVector& vv,
|
---|
[6054] | 666 | QMap<QString, t_satData*>& satData) {
|
---|
| 667 |
|
---|
[6093] | 668 | Tracer tracer("t_pppFilter::outlierDetection");
|
---|
[6054] | 669 |
|
---|
| 670 | QString prnGPS;
|
---|
| 671 | QString prnGlo;
|
---|
| 672 | double maxResGPS = 0.0;
|
---|
| 673 | double maxResGlo = 0.0;
|
---|
| 674 | findMaxRes(vv, satData, prnGPS, prnGlo, maxResGPS, maxResGlo);
|
---|
| 675 |
|
---|
| 676 | if (iPhase == 1) {
|
---|
| 677 | if (maxResGlo > MAXRES_PHASE_GLONASS) {
|
---|
[6100] | 678 | LOG << "Outlier Phase " << prnGlo.toAscii().data() << ' ' << maxResGlo << endl;
|
---|
[6054] | 679 | return prnGlo;
|
---|
| 680 | }
|
---|
| 681 | else if (maxResGPS > MAXRES_PHASE_GPS) {
|
---|
[6100] | 682 | LOG << "Outlier Phase " << prnGPS.toAscii().data() << ' ' << maxResGPS << endl;
|
---|
[6054] | 683 | return prnGPS;
|
---|
| 684 | }
|
---|
| 685 | }
|
---|
| 686 | else if (iPhase == 0 && maxResGPS > MAXRES_CODE) {
|
---|
[6100] | 687 | LOG << "Outlier Code " << prnGPS.toAscii().data() << ' ' << maxResGPS << endl;
|
---|
[6054] | 688 | return prnGPS;
|
---|
| 689 | }
|
---|
| 690 |
|
---|
| 691 | return QString();
|
---|
| 692 | }
|
---|
| 693 |
|
---|
| 694 | //
|
---|
| 695 | //////////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 696 | void t_pppFilter::kalman(const Matrix& AA, const ColumnVector& ll,
|
---|
[6054] | 697 | const DiagonalMatrix& PP,
|
---|
| 698 | SymmetricMatrix& QQ, ColumnVector& dx) {
|
---|
| 699 |
|
---|
[6093] | 700 | Tracer tracer("t_pppFilter::kalman");
|
---|
[6054] | 701 |
|
---|
| 702 | int nPar = AA.Ncols();
|
---|
| 703 | int nObs = AA.Nrows();
|
---|
| 704 | UpperTriangularMatrix SS = Cholesky(QQ).t();
|
---|
| 705 |
|
---|
| 706 | Matrix SA = SS*AA.t();
|
---|
| 707 | Matrix SRF(nObs+nPar, nObs+nPar); SRF = 0;
|
---|
| 708 | for (int ii = 1; ii <= nObs; ++ii) {
|
---|
| 709 | SRF(ii,ii) = 1.0 / sqrt(PP(ii,ii));
|
---|
| 710 | }
|
---|
| 711 |
|
---|
| 712 | SRF.SubMatrix (nObs+1, nObs+nPar, 1, nObs) = SA;
|
---|
| 713 | SRF.SymSubMatrix(nObs+1, nObs+nPar) = SS;
|
---|
| 714 |
|
---|
| 715 | UpperTriangularMatrix UU;
|
---|
| 716 | QRZ(SRF, UU);
|
---|
| 717 |
|
---|
| 718 | SS = UU.SymSubMatrix(nObs+1, nObs+nPar);
|
---|
| 719 | UpperTriangularMatrix SH_rt = UU.SymSubMatrix(1, nObs);
|
---|
| 720 | Matrix YY = UU.SubMatrix(1, nObs, nObs+1, nObs+nPar);
|
---|
| 721 |
|
---|
| 722 | UpperTriangularMatrix SHi = SH_rt.i();
|
---|
| 723 |
|
---|
| 724 | Matrix KT = SHi * YY;
|
---|
| 725 | SymmetricMatrix Hi; Hi << SHi * SHi.t();
|
---|
| 726 |
|
---|
| 727 | dx = KT.t() * ll;
|
---|
| 728 | QQ << (SS.t() * SS);
|
---|
| 729 | }
|
---|
| 730 |
|
---|
| 731 | // Phase Wind-Up Correction
|
---|
| 732 | ///////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 733 | double t_pppFilter::windUp(const QString& prn, const ColumnVector& rSat,
|
---|
[6054] | 734 | const ColumnVector& rRec) {
|
---|
| 735 |
|
---|
[6093] | 736 | Tracer tracer("t_pppFilter::windUp");
|
---|
[6054] | 737 |
|
---|
| 738 | double Mjd = _time.mjd() + _time.daysec() / 86400.0;
|
---|
| 739 |
|
---|
| 740 | // First time - initialize to zero
|
---|
| 741 | // -------------------------------
|
---|
| 742 | if (!_windUpTime.contains(prn)) {
|
---|
| 743 | _windUpSum[prn] = 0.0;
|
---|
| 744 | }
|
---|
| 745 |
|
---|
| 746 | // Compute the correction for new time
|
---|
| 747 | // -----------------------------------
|
---|
| 748 | if (!_windUpTime.contains(prn) || _windUpTime[prn] != Mjd) {
|
---|
| 749 | _windUpTime[prn] = Mjd;
|
---|
| 750 |
|
---|
| 751 | // Unit Vector GPS Satellite --> Receiver
|
---|
| 752 | // --------------------------------------
|
---|
| 753 | ColumnVector rho = rRec - rSat;
|
---|
| 754 | rho /= rho.norm_Frobenius();
|
---|
| 755 |
|
---|
| 756 | // GPS Satellite unit Vectors sz, sy, sx
|
---|
| 757 | // -------------------------------------
|
---|
| 758 | ColumnVector sz = -rSat / rSat.norm_Frobenius();
|
---|
| 759 |
|
---|
[6063] | 760 | ColumnVector xSun = t_astro::Sun(Mjd);
|
---|
[6054] | 761 | xSun /= xSun.norm_Frobenius();
|
---|
| 762 |
|
---|
| 763 | ColumnVector sy = crossproduct(sz, xSun);
|
---|
| 764 | ColumnVector sx = crossproduct(sy, sz);
|
---|
| 765 |
|
---|
| 766 | // Effective Dipole of the GPS Satellite Antenna
|
---|
| 767 | // ---------------------------------------------
|
---|
| 768 | ColumnVector dipSat = sx - rho * DotProduct(rho,sx)
|
---|
| 769 | - crossproduct(rho, sy);
|
---|
| 770 |
|
---|
| 771 | // Receiver unit Vectors rx, ry
|
---|
| 772 | // ----------------------------
|
---|
| 773 | ColumnVector rx(3);
|
---|
| 774 | ColumnVector ry(3);
|
---|
| 775 |
|
---|
| 776 | double recEll[3]; xyz2ell(rRec.data(), recEll) ;
|
---|
| 777 | double neu[3];
|
---|
| 778 |
|
---|
| 779 | neu[0] = 1.0;
|
---|
| 780 | neu[1] = 0.0;
|
---|
| 781 | neu[2] = 0.0;
|
---|
| 782 | neu2xyz(recEll, neu, rx.data());
|
---|
| 783 |
|
---|
| 784 | neu[0] = 0.0;
|
---|
| 785 | neu[1] = -1.0;
|
---|
| 786 | neu[2] = 0.0;
|
---|
| 787 | neu2xyz(recEll, neu, ry.data());
|
---|
| 788 |
|
---|
| 789 | // Effective Dipole of the Receiver Antenna
|
---|
| 790 | // ----------------------------------------
|
---|
| 791 | ColumnVector dipRec = rx - rho * DotProduct(rho,rx)
|
---|
| 792 | + crossproduct(rho, ry);
|
---|
| 793 |
|
---|
| 794 | // Resulting Effect
|
---|
| 795 | // ----------------
|
---|
| 796 | double alpha = DotProduct(dipSat,dipRec) /
|
---|
| 797 | (dipSat.norm_Frobenius() * dipRec.norm_Frobenius());
|
---|
| 798 |
|
---|
| 799 | if (alpha > 1.0) alpha = 1.0;
|
---|
| 800 | if (alpha < -1.0) alpha = -1.0;
|
---|
| 801 |
|
---|
| 802 | double dphi = acos(alpha) / 2.0 / M_PI; // in cycles
|
---|
| 803 |
|
---|
| 804 | if ( DotProduct(rho, crossproduct(dipSat, dipRec)) < 0.0 ) {
|
---|
| 805 | dphi = -dphi;
|
---|
| 806 | }
|
---|
| 807 |
|
---|
| 808 | _windUpSum[prn] = floor(_windUpSum[prn] - dphi + 0.5) + dphi;
|
---|
| 809 | }
|
---|
| 810 |
|
---|
| 811 | return _windUpSum[prn];
|
---|
| 812 | }
|
---|
| 813 |
|
---|
| 814 | //
|
---|
| 815 | ///////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 816 | void t_pppFilter::cmpEle(t_satData* satData) {
|
---|
| 817 | Tracer tracer("t_pppFilter::cmpEle");
|
---|
[6054] | 818 | ColumnVector rr = satData->xx - _xcBanc.Rows(1,3);
|
---|
| 819 | double rho = rr.norm_Frobenius();
|
---|
| 820 |
|
---|
| 821 | double neu[3];
|
---|
| 822 | xyz2neu(_ellBanc.data(), rr.data(), neu);
|
---|
| 823 |
|
---|
| 824 | satData->eleSat = acos( sqrt(neu[0]*neu[0] + neu[1]*neu[1]) / rho );
|
---|
| 825 | if (neu[2] < 0) {
|
---|
| 826 | satData->eleSat *= -1.0;
|
---|
| 827 | }
|
---|
| 828 | satData->azSat = atan2(neu[1], neu[0]);
|
---|
| 829 | }
|
---|
| 830 |
|
---|
| 831 | //
|
---|
| 832 | ///////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 833 | void t_pppFilter::addAmb(t_satData* satData) {
|
---|
| 834 | Tracer tracer("t_pppFilter::addAmb");
|
---|
[6054] | 835 | bool found = false;
|
---|
| 836 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
[6093] | 837 | if (_params[iPar-1]->type == t_pppParam::AMB_L3 &&
|
---|
[6054] | 838 | _params[iPar-1]->prn == satData->prn) {
|
---|
| 839 | found = true;
|
---|
| 840 | break;
|
---|
| 841 | }
|
---|
| 842 | }
|
---|
| 843 | if (!found) {
|
---|
[6093] | 844 | t_pppParam* par = new t_pppParam(t_pppParam::AMB_L3,
|
---|
[6054] | 845 | _params.size()+1, satData->prn);
|
---|
| 846 | _params.push_back(par);
|
---|
| 847 | par->xx = satData->L3 - cmpValue(satData, true);
|
---|
| 848 | }
|
---|
| 849 | }
|
---|
| 850 |
|
---|
| 851 | //
|
---|
| 852 | ///////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 853 | void t_pppFilter::addObs(int iPhase, unsigned& iObs, t_satData* satData,
|
---|
[6054] | 854 | Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP) {
|
---|
| 855 |
|
---|
[6093] | 856 | Tracer tracer("t_pppFilter::addObs");
|
---|
[6054] | 857 |
|
---|
| 858 | const double ELEWGHT = 20.0;
|
---|
| 859 | double ellWgtCoef = 1.0;
|
---|
| 860 | double eleD = satData->eleSat * 180.0 / M_PI;
|
---|
| 861 | if (eleD < ELEWGHT) {
|
---|
| 862 | ellWgtCoef = 1.5 - 0.5 / (ELEWGHT - 10.0) * (eleD - 10.0);
|
---|
| 863 | }
|
---|
| 864 |
|
---|
| 865 | // Remember Observation Index
|
---|
| 866 | // --------------------------
|
---|
| 867 | ++iObs;
|
---|
| 868 | satData->obsIndex = iObs;
|
---|
| 869 |
|
---|
| 870 | // Phase Observations
|
---|
| 871 | // ------------------
|
---|
| 872 | if (iPhase == 1) {
|
---|
| 873 | ll(iObs) = satData->L3 - cmpValue(satData, true);
|
---|
[6100] | 874 | double sigL3 = 2.98 * OPT->_sigmaL1;
|
---|
[6054] | 875 | if (satData->system() == 'R') {
|
---|
| 876 | sigL3 *= GLONASS_WEIGHT_FACTOR;
|
---|
| 877 | }
|
---|
| 878 | PP(iObs,iObs) = 1.0 / (sigL3 * sigL3) / (ellWgtCoef * ellWgtCoef);
|
---|
| 879 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
[6093] | 880 | if (_params[iPar-1]->type == t_pppParam::AMB_L3 &&
|
---|
[6054] | 881 | _params[iPar-1]->prn == satData->prn) {
|
---|
| 882 | ll(iObs) -= _params[iPar-1]->xx;
|
---|
| 883 | }
|
---|
| 884 | AA(iObs, iPar) = _params[iPar-1]->partial(satData, true);
|
---|
| 885 | }
|
---|
| 886 | }
|
---|
| 887 |
|
---|
| 888 | // Code Observations
|
---|
| 889 | // -----------------
|
---|
| 890 | else {
|
---|
[6100] | 891 | double sigP3 = 2.98 * OPT->_sigmaC1;
|
---|
[6054] | 892 | ll(iObs) = satData->P3 - cmpValue(satData, false);
|
---|
[6064] | 893 | PP(iObs,iObs) = 1.0 / (sigP3 * sigP3) / (ellWgtCoef * ellWgtCoef);
|
---|
[6054] | 894 | for (int iPar = 1; iPar <= _params.size(); iPar++) {
|
---|
| 895 | AA(iObs, iPar) = _params[iPar-1]->partial(satData, false);
|
---|
| 896 | }
|
---|
| 897 | }
|
---|
| 898 | }
|
---|
| 899 |
|
---|
| 900 | //
|
---|
| 901 | ///////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 902 | QByteArray t_pppFilter::printRes(int iPhase, const ColumnVector& vv,
|
---|
[6054] | 903 | const QMap<QString, t_satData*>& satDataMap) {
|
---|
| 904 |
|
---|
[6093] | 905 | Tracer tracer("t_pppFilter::printRes");
|
---|
[6054] | 906 |
|
---|
| 907 | ostringstream str;
|
---|
| 908 | str.setf(ios::fixed);
|
---|
| 909 |
|
---|
| 910 | QMapIterator<QString, t_satData*> it(satDataMap);
|
---|
| 911 | while (it.hasNext()) {
|
---|
| 912 | it.next();
|
---|
| 913 | t_satData* satData = it.value();
|
---|
| 914 | if (satData->obsIndex != 0) {
|
---|
| 915 | str << _time.timestr(1)
|
---|
| 916 | << " RES " << satData->prn.toAscii().data()
|
---|
| 917 | << (iPhase ? " L3 " : " P3 ")
|
---|
| 918 | << setw(9) << setprecision(4) << vv(satData->obsIndex) << endl;
|
---|
| 919 | }
|
---|
| 920 | }
|
---|
| 921 |
|
---|
| 922 | return QByteArray(str.str().c_str());
|
---|
| 923 | }
|
---|
| 924 |
|
---|
| 925 | //
|
---|
| 926 | ///////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 927 | void t_pppFilter::findMaxRes(const ColumnVector& vv,
|
---|
[6054] | 928 | const QMap<QString, t_satData*>& satData,
|
---|
| 929 | QString& prnGPS, QString& prnGlo,
|
---|
| 930 | double& maxResGPS, double& maxResGlo) {
|
---|
| 931 |
|
---|
[6093] | 932 | Tracer tracer("t_pppFilter::findMaxRes");
|
---|
[6054] | 933 |
|
---|
| 934 | maxResGPS = 0.0;
|
---|
| 935 | maxResGlo = 0.0;
|
---|
| 936 |
|
---|
| 937 | QMapIterator<QString, t_satData*> it(satData);
|
---|
| 938 | while (it.hasNext()) {
|
---|
| 939 | it.next();
|
---|
| 940 | t_satData* satData = it.value();
|
---|
| 941 | if (satData->obsIndex != 0) {
|
---|
| 942 | QString prn = satData->prn;
|
---|
| 943 | if (prn[0] == 'R') {
|
---|
| 944 | if (fabs(vv(satData->obsIndex)) > maxResGlo) {
|
---|
| 945 | maxResGlo = fabs(vv(satData->obsIndex));
|
---|
| 946 | prnGlo = prn;
|
---|
| 947 | }
|
---|
| 948 | }
|
---|
| 949 | else {
|
---|
| 950 | if (fabs(vv(satData->obsIndex)) > maxResGPS) {
|
---|
| 951 | maxResGPS = fabs(vv(satData->obsIndex));
|
---|
| 952 | prnGPS = prn;
|
---|
| 953 | }
|
---|
| 954 | }
|
---|
| 955 | }
|
---|
| 956 | }
|
---|
| 957 | }
|
---|
| 958 |
|
---|
| 959 | // Update Step (private - loop over outliers)
|
---|
| 960 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 961 | t_irc t_pppFilter::update_p(t_epoData* epoData) {
|
---|
[6054] | 962 |
|
---|
[6093] | 963 | Tracer tracer("t_pppFilter::update_p");
|
---|
[6054] | 964 |
|
---|
| 965 | // Save Variance-Covariance Matrix, and Status Vector
|
---|
| 966 | // --------------------------------------------------
|
---|
| 967 | rememberState(epoData);
|
---|
| 968 |
|
---|
| 969 | QString lastOutlierPrn;
|
---|
| 970 |
|
---|
| 971 | // Try with all satellites, then with all minus one, etc.
|
---|
| 972 | // ------------------------------------------------------
|
---|
| 973 | while (selectSatellites(lastOutlierPrn, epoData->satData) == success) {
|
---|
| 974 |
|
---|
| 975 | QByteArray strResCode;
|
---|
| 976 | QByteArray strResPhase;
|
---|
| 977 |
|
---|
| 978 | // Bancroft Solution
|
---|
| 979 | // -----------------
|
---|
| 980 | if (cmpBancroft(epoData) != success) {
|
---|
| 981 | break;
|
---|
| 982 | }
|
---|
| 983 |
|
---|
| 984 | // First update using code observations, then phase observations
|
---|
| 985 | // -------------------------------------------------------------
|
---|
[6100] | 986 | bool usePhase = OPT->ambLCs('G').size() || OPT->ambLCs('R').size() ||
|
---|
| 987 | OPT->ambLCs('E').size();
|
---|
[6063] | 988 |
|
---|
| 989 | for (int iPhase = 0; iPhase <= (usePhase ? 1 : 0); iPhase++) {
|
---|
[6054] | 990 |
|
---|
| 991 | // Status Prediction
|
---|
| 992 | // -----------------
|
---|
| 993 | predict(iPhase, epoData);
|
---|
| 994 |
|
---|
| 995 | // Create First-Design Matrix
|
---|
| 996 | // --------------------------
|
---|
| 997 | unsigned nPar = _params.size();
|
---|
| 998 | unsigned nObs = 0;
|
---|
| 999 | if (iPhase == 0) {
|
---|
| 1000 | nObs = epoData->sizeAll() - epoData->sizeSys('R'); // Glonass code not used
|
---|
| 1001 | }
|
---|
| 1002 | else {
|
---|
| 1003 | nObs = epoData->sizeAll();
|
---|
| 1004 | }
|
---|
| 1005 |
|
---|
| 1006 | // Prepare first-design Matrix, vector observed-computed
|
---|
| 1007 | // -----------------------------------------------------
|
---|
| 1008 | Matrix AA(nObs, nPar); // first design matrix
|
---|
| 1009 | ColumnVector ll(nObs); // tems observed-computed
|
---|
| 1010 | DiagonalMatrix PP(nObs); PP = 0.0;
|
---|
| 1011 |
|
---|
| 1012 | unsigned iObs = 0;
|
---|
| 1013 | QMapIterator<QString, t_satData*> it(epoData->satData);
|
---|
| 1014 | while (it.hasNext()) {
|
---|
| 1015 | it.next();
|
---|
| 1016 | t_satData* satData = it.value();
|
---|
| 1017 | if (iPhase == 1 || satData->system() != 'R') {
|
---|
| 1018 | QString prn = satData->prn;
|
---|
| 1019 | addObs(iPhase, iObs, satData, AA, ll, PP);
|
---|
| 1020 | }
|
---|
| 1021 | }
|
---|
| 1022 |
|
---|
| 1023 | // Compute Filter Update
|
---|
| 1024 | // ---------------------
|
---|
| 1025 | ColumnVector dx;
|
---|
| 1026 | kalman(AA, ll, PP, _QQ, dx);
|
---|
| 1027 | ColumnVector vv = ll - AA * dx;
|
---|
| 1028 |
|
---|
| 1029 | // Print Residuals
|
---|
| 1030 | // ---------------
|
---|
| 1031 | if (iPhase == 0) {
|
---|
| 1032 | strResCode = printRes(iPhase, vv, epoData->satData);
|
---|
| 1033 | }
|
---|
| 1034 | else {
|
---|
| 1035 | strResPhase = printRes(iPhase, vv, epoData->satData);
|
---|
| 1036 | }
|
---|
| 1037 |
|
---|
| 1038 | // Check the residuals
|
---|
| 1039 | // -------------------
|
---|
| 1040 | lastOutlierPrn = outlierDetection(iPhase, vv, epoData->satData);
|
---|
| 1041 |
|
---|
| 1042 | // No Outlier Detected
|
---|
| 1043 | // -------------------
|
---|
| 1044 | if (lastOutlierPrn.isEmpty()) {
|
---|
| 1045 |
|
---|
[6093] | 1046 | QVectorIterator<t_pppParam*> itPar(_params);
|
---|
[6054] | 1047 | while (itPar.hasNext()) {
|
---|
[6093] | 1048 | t_pppParam* par = itPar.next();
|
---|
[6054] | 1049 | par->xx += dx(par->index);
|
---|
| 1050 | }
|
---|
| 1051 |
|
---|
[6063] | 1052 | if (!usePhase || iPhase == 1) {
|
---|
[6054] | 1053 | if (_outlierGPS.size() > 0 || _outlierGlo.size() > 0) {
|
---|
[6100] | 1054 | LOG << "Neglected PRNs: ";
|
---|
[6054] | 1055 | if (!_outlierGPS.isEmpty()) {
|
---|
[6100] | 1056 | LOG << _outlierGPS.last().toAscii().data() << ' ';
|
---|
[6054] | 1057 | }
|
---|
| 1058 | QStringListIterator itGlo(_outlierGlo);
|
---|
| 1059 | while (itGlo.hasNext()) {
|
---|
| 1060 | QString prn = itGlo.next();
|
---|
[6100] | 1061 | LOG << prn.toAscii().data() << ' ';
|
---|
[6054] | 1062 | }
|
---|
| 1063 | }
|
---|
[6106] | 1064 | LOG << strResCode.data() << strResPhase.data();
|
---|
[6054] | 1065 |
|
---|
| 1066 | return success;
|
---|
| 1067 | }
|
---|
| 1068 | }
|
---|
| 1069 |
|
---|
| 1070 | // Outlier Found
|
---|
| 1071 | // -------------
|
---|
| 1072 | else {
|
---|
| 1073 | restoreState(epoData);
|
---|
| 1074 | break;
|
---|
| 1075 | }
|
---|
| 1076 |
|
---|
| 1077 | } // for iPhase
|
---|
| 1078 |
|
---|
| 1079 | } // while selectSatellites
|
---|
| 1080 |
|
---|
| 1081 | restoreState(epoData);
|
---|
| 1082 | return failure;
|
---|
| 1083 | }
|
---|
| 1084 |
|
---|
| 1085 | // Remeber Original State Vector and Variance-Covariance Matrix
|
---|
| 1086 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 1087 | void t_pppFilter::rememberState(t_epoData* epoData) {
|
---|
[6054] | 1088 |
|
---|
| 1089 | _QQ_sav = _QQ;
|
---|
| 1090 |
|
---|
[6093] | 1091 | QVectorIterator<t_pppParam*> itSav(_params_sav);
|
---|
[6054] | 1092 | while (itSav.hasNext()) {
|
---|
[6093] | 1093 | t_pppParam* par = itSav.next();
|
---|
[6054] | 1094 | delete par;
|
---|
| 1095 | }
|
---|
| 1096 | _params_sav.clear();
|
---|
| 1097 |
|
---|
[6093] | 1098 | QVectorIterator<t_pppParam*> it(_params);
|
---|
[6054] | 1099 | while (it.hasNext()) {
|
---|
[6093] | 1100 | t_pppParam* par = it.next();
|
---|
| 1101 | _params_sav.push_back(new t_pppParam(*par));
|
---|
[6054] | 1102 | }
|
---|
| 1103 |
|
---|
| 1104 | _epoData_sav->deepCopy(epoData);
|
---|
| 1105 | }
|
---|
| 1106 |
|
---|
| 1107 | // Restore Original State Vector and Variance-Covariance Matrix
|
---|
| 1108 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 1109 | void t_pppFilter::restoreState(t_epoData* epoData) {
|
---|
[6054] | 1110 |
|
---|
| 1111 | _QQ = _QQ_sav;
|
---|
| 1112 |
|
---|
[6093] | 1113 | QVectorIterator<t_pppParam*> it(_params);
|
---|
[6054] | 1114 | while (it.hasNext()) {
|
---|
[6093] | 1115 | t_pppParam* par = it.next();
|
---|
[6054] | 1116 | delete par;
|
---|
| 1117 | }
|
---|
| 1118 | _params.clear();
|
---|
| 1119 |
|
---|
[6093] | 1120 | QVectorIterator<t_pppParam*> itSav(_params_sav);
|
---|
[6054] | 1121 | while (itSav.hasNext()) {
|
---|
[6093] | 1122 | t_pppParam* par = itSav.next();
|
---|
| 1123 | _params.push_back(new t_pppParam(*par));
|
---|
[6054] | 1124 | }
|
---|
| 1125 |
|
---|
| 1126 | epoData->deepCopy(_epoData_sav);
|
---|
| 1127 | }
|
---|
| 1128 |
|
---|
| 1129 | //
|
---|
| 1130 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 1131 | t_irc t_pppFilter::selectSatellites(const QString& lastOutlierPrn,
|
---|
[6054] | 1132 | QMap<QString, t_satData*>& satData) {
|
---|
| 1133 |
|
---|
| 1134 | // First Call
|
---|
| 1135 | // ----------
|
---|
| 1136 | if (lastOutlierPrn.isEmpty()) {
|
---|
| 1137 | _outlierGPS.clear();
|
---|
| 1138 | _outlierGlo.clear();
|
---|
| 1139 | return success;
|
---|
| 1140 | }
|
---|
| 1141 |
|
---|
| 1142 | // Second and next trials
|
---|
| 1143 | // ----------------------
|
---|
| 1144 | else {
|
---|
| 1145 |
|
---|
| 1146 | if (lastOutlierPrn[0] == 'R') {
|
---|
| 1147 | _outlierGlo << lastOutlierPrn;
|
---|
| 1148 | }
|
---|
| 1149 |
|
---|
| 1150 | // Remove all Glonass Outliers
|
---|
| 1151 | // ---------------------------
|
---|
| 1152 | QStringListIterator it(_outlierGlo);
|
---|
| 1153 | while (it.hasNext()) {
|
---|
| 1154 | QString prn = it.next();
|
---|
| 1155 | if (satData.contains(prn)) {
|
---|
| 1156 | delete satData.take(prn);
|
---|
| 1157 | }
|
---|
| 1158 | }
|
---|
| 1159 |
|
---|
| 1160 | if (lastOutlierPrn[0] == 'R') {
|
---|
| 1161 | _outlierGPS.clear();
|
---|
| 1162 | return success;
|
---|
| 1163 | }
|
---|
| 1164 |
|
---|
| 1165 | // GPS Outlier appeared for the first time - try to delete it
|
---|
| 1166 | // ----------------------------------------------------------
|
---|
| 1167 | if (_outlierGPS.indexOf(lastOutlierPrn) == -1) {
|
---|
| 1168 | _outlierGPS << lastOutlierPrn;
|
---|
| 1169 | if (satData.contains(lastOutlierPrn)) {
|
---|
| 1170 | delete satData.take(lastOutlierPrn);
|
---|
| 1171 | }
|
---|
| 1172 | return success;
|
---|
| 1173 | }
|
---|
| 1174 |
|
---|
| 1175 | }
|
---|
| 1176 |
|
---|
| 1177 | return failure;
|
---|
| 1178 | }
|
---|
[6089] | 1179 |
|
---|
| 1180 | //
|
---|
| 1181 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 1182 | double lorentz(const ColumnVector& aa, const ColumnVector& bb) {
|
---|
| 1183 | return aa(1)*bb(1) + aa(2)*bb(2) + aa(3)*bb(3) - aa(4)*bb(4);
|
---|
| 1184 | }
|
---|
| 1185 |
|
---|
| 1186 | //
|
---|
| 1187 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6093] | 1188 | void t_pppFilter::bancroft(const Matrix& BBpass, ColumnVector& pos) {
|
---|
[6089] | 1189 |
|
---|
| 1190 | if (pos.Nrows() != 4) {
|
---|
| 1191 | pos.ReSize(4);
|
---|
| 1192 | }
|
---|
| 1193 | pos = 0.0;
|
---|
| 1194 |
|
---|
| 1195 | for (int iter = 1; iter <= 2; iter++) {
|
---|
| 1196 | Matrix BB = BBpass;
|
---|
| 1197 | int mm = BB.Nrows();
|
---|
| 1198 | for (int ii = 1; ii <= mm; ii++) {
|
---|
| 1199 | double xx = BB(ii,1);
|
---|
| 1200 | double yy = BB(ii,2);
|
---|
| 1201 | double traveltime = 0.072;
|
---|
| 1202 | if (iter > 1) {
|
---|
| 1203 | double zz = BB(ii,3);
|
---|
| 1204 | double rho = sqrt( (xx-pos(1)) * (xx-pos(1)) +
|
---|
| 1205 | (yy-pos(2)) * (yy-pos(2)) +
|
---|
| 1206 | (zz-pos(3)) * (zz-pos(3)) );
|
---|
| 1207 | traveltime = rho / t_CST::c;
|
---|
| 1208 | }
|
---|
| 1209 | double angle = traveltime * t_CST::omega;
|
---|
| 1210 | double cosa = cos(angle);
|
---|
| 1211 | double sina = sin(angle);
|
---|
| 1212 | BB(ii,1) = cosa * xx + sina * yy;
|
---|
| 1213 | BB(ii,2) = -sina * xx + cosa * yy;
|
---|
| 1214 | }
|
---|
| 1215 |
|
---|
| 1216 | Matrix BBB;
|
---|
| 1217 | if (mm > 4) {
|
---|
| 1218 | SymmetricMatrix hlp; hlp << BB.t() * BB;
|
---|
| 1219 | BBB = hlp.i() * BB.t();
|
---|
| 1220 | }
|
---|
| 1221 | else {
|
---|
| 1222 | BBB = BB.i();
|
---|
| 1223 | }
|
---|
| 1224 | ColumnVector ee(mm); ee = 1.0;
|
---|
| 1225 | ColumnVector alpha(mm); alpha = 0.0;
|
---|
| 1226 | for (int ii = 1; ii <= mm; ii++) {
|
---|
| 1227 | alpha(ii) = lorentz(BB.Row(ii).t(),BB.Row(ii).t())/2.0;
|
---|
| 1228 | }
|
---|
| 1229 | ColumnVector BBBe = BBB * ee;
|
---|
| 1230 | ColumnVector BBBalpha = BBB * alpha;
|
---|
| 1231 | double aa = lorentz(BBBe, BBBe);
|
---|
| 1232 | double bb = lorentz(BBBe, BBBalpha)-1;
|
---|
| 1233 | double cc = lorentz(BBBalpha, BBBalpha);
|
---|
| 1234 | double root = sqrt(bb*bb-aa*cc);
|
---|
| 1235 |
|
---|
| 1236 | Matrix hlpPos(4,2);
|
---|
| 1237 | hlpPos.Column(1) = (-bb-root)/aa * BBBe + BBBalpha;
|
---|
| 1238 | hlpPos.Column(2) = (-bb+root)/aa * BBBe + BBBalpha;
|
---|
| 1239 |
|
---|
| 1240 | ColumnVector omc(2);
|
---|
| 1241 | for (int pp = 1; pp <= 2; pp++) {
|
---|
| 1242 | hlpPos(4,pp) = -hlpPos(4,pp);
|
---|
| 1243 | omc(pp) = BB(1,4) -
|
---|
| 1244 | sqrt( (BB(1,1)-hlpPos(1,pp)) * (BB(1,1)-hlpPos(1,pp)) +
|
---|
| 1245 | (BB(1,2)-hlpPos(2,pp)) * (BB(1,2)-hlpPos(2,pp)) +
|
---|
| 1246 | (BB(1,3)-hlpPos(3,pp)) * (BB(1,3)-hlpPos(3,pp)) ) -
|
---|
| 1247 | hlpPos(4,pp);
|
---|
| 1248 | }
|
---|
| 1249 | if ( fabs(omc(1)) > fabs(omc(2)) ) {
|
---|
| 1250 | pos = hlpPos.Column(2);
|
---|
| 1251 | }
|
---|
| 1252 | else {
|
---|
| 1253 | pos = hlpPos.Column(1);
|
---|
| 1254 | }
|
---|
| 1255 | }
|
---|
| 1256 | }
|
---|
| 1257 |
|
---|