[7237] | 1 | /* -------------------------------------------------------------------------
|
---|
| 2 | * BKG NTRIP Client
|
---|
| 3 | * -------------------------------------------------------------------------
|
---|
| 4 | *
|
---|
| 5 | * Class: t_pppClient
|
---|
| 6 | *
|
---|
| 7 | * Purpose: PPP Client processing starts here
|
---|
| 8 | *
|
---|
| 9 | * Author: L. Mervart
|
---|
| 10 | *
|
---|
| 11 | * Created: 29-Jul-2014
|
---|
| 12 | *
|
---|
[7271] | 13 | * Changes:
|
---|
[7237] | 14 | *
|
---|
| 15 | * -----------------------------------------------------------------------*/
|
---|
| 16 |
|
---|
| 17 | #include <QThreadStorage>
|
---|
| 18 |
|
---|
| 19 | #include <iostream>
|
---|
| 20 | #include <iomanip>
|
---|
[8451] | 21 | #include <cmath>
|
---|
[10034] | 22 | #include <stdlib.h>
|
---|
[7237] | 23 | #include <string.h>
|
---|
| 24 | #include <stdexcept>
|
---|
| 25 |
|
---|
| 26 | #include "pppClient.h"
|
---|
| 27 | #include "pppEphPool.h"
|
---|
| 28 | #include "pppObsPool.h"
|
---|
| 29 | #include "bncconst.h"
|
---|
| 30 | #include "bncutils.h"
|
---|
| 31 | #include "pppStation.h"
|
---|
| 32 | #include "bncantex.h"
|
---|
| 33 | #include "pppFilter.h"
|
---|
| 34 |
|
---|
| 35 | using namespace BNC_PPP;
|
---|
| 36 | using namespace std;
|
---|
| 37 |
|
---|
| 38 | // Global variable holding thread-specific pointers
|
---|
| 39 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 40 | QThreadStorage<t_pppClient*> CLIENTS;
|
---|
| 41 |
|
---|
| 42 | // Static function returning thread-specific pointer
|
---|
| 43 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 44 | t_pppClient* t_pppClient::instance() {
|
---|
| 45 | return CLIENTS.localData();
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | // Constructor
|
---|
| 49 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 50 | t_pppClient::t_pppClient(const t_pppOptions* opt) {
|
---|
[10259] | 51 | _running = true;
|
---|
[7237] | 52 | _output = 0;
|
---|
| 53 | _opt = new t_pppOptions(*opt);
|
---|
| 54 | _log = new ostringstream();
|
---|
| 55 | _ephPool = new t_pppEphPool();
|
---|
| 56 | _obsPool = new t_pppObsPool();
|
---|
| 57 | _staRover = new t_pppStation();
|
---|
[10034] | 58 | _filter = new t_pppFilter();
|
---|
[7237] | 59 | _tides = new t_tides();
|
---|
[8905] | 60 | _antex = 0;
|
---|
[7237] | 61 | if (!_opt->_antexFileName.empty()) {
|
---|
| 62 | _antex = new bncAntex(_opt->_antexFileName.c_str());
|
---|
| 63 | }
|
---|
[8905] | 64 | if (!_opt->_blqFileName.empty()) {
|
---|
| 65 | if (_tides->readBlqFile(_opt->_blqFileName.c_str()) == success) {
|
---|
| 66 | //_tides->printAllBlqSets();
|
---|
| 67 | }
|
---|
[7237] | 68 | }
|
---|
| 69 | CLIENTS.setLocalData(this); // CLIENTS takes ownership over "this"
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | // Destructor
|
---|
| 73 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 74 | t_pppClient::~t_pppClient() {
|
---|
[10259] | 75 | _running = false;
|
---|
[7237] | 76 | delete _log;
|
---|
| 77 | delete _opt;
|
---|
| 78 | delete _ephPool;
|
---|
| 79 | delete _obsPool;
|
---|
| 80 | delete _staRover;
|
---|
[7866] | 81 | if (_antex) {
|
---|
| 82 | delete _antex;
|
---|
| 83 | }
|
---|
[10034] | 84 | delete _filter;
|
---|
[7237] | 85 | delete _tides;
|
---|
| 86 | clearObs();
|
---|
| 87 | }
|
---|
| 88 |
|
---|
[7271] | 89 | //
|
---|
[7237] | 90 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 91 | void t_pppClient::putEphemeris(const t_eph* eph) {
|
---|
| 92 | const t_ephGPS* ephGPS = dynamic_cast<const t_ephGPS*>(eph);
|
---|
| 93 | const t_ephGlo* ephGlo = dynamic_cast<const t_ephGlo*>(eph);
|
---|
| 94 | const t_ephGal* ephGal = dynamic_cast<const t_ephGal*>(eph);
|
---|
[7271] | 95 | const t_ephBDS* ephBDS = dynamic_cast<const t_ephBDS*>(eph);
|
---|
[7237] | 96 | if (ephGPS) {
|
---|
| 97 | _ephPool->putEphemeris(new t_ephGPS(*ephGPS));
|
---|
| 98 | }
|
---|
| 99 | else if (ephGlo) {
|
---|
| 100 | _ephPool->putEphemeris(new t_ephGlo(*ephGlo));
|
---|
| 101 | }
|
---|
| 102 | else if (ephGal) {
|
---|
| 103 | _ephPool->putEphemeris(new t_ephGal(*ephGal));
|
---|
| 104 | }
|
---|
[7271] | 105 | else if (ephBDS) {
|
---|
| 106 | _ephPool->putEphemeris(new t_ephBDS(*ephBDS));
|
---|
| 107 | }
|
---|
[7237] | 108 | }
|
---|
| 109 |
|
---|
| 110 | //
|
---|
| 111 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 112 | void t_pppClient::putTec(const t_vTec* vTec) {
|
---|
[7248] | 113 | _obsPool->putTec(new t_vTec(*vTec));
|
---|
[7237] | 114 | }
|
---|
| 115 |
|
---|
[7271] | 116 | //
|
---|
[7237] | 117 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 118 | void t_pppClient::putOrbCorrections(const vector<t_orbCorr*>& corr) {
|
---|
| 119 | for (unsigned ii = 0; ii < corr.size(); ii++) {
|
---|
| 120 | _ephPool->putOrbCorrection(new t_orbCorr(*corr[ii]));
|
---|
| 121 | }
|
---|
| 122 | }
|
---|
| 123 |
|
---|
[7271] | 124 | //
|
---|
[7237] | 125 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 126 | void t_pppClient::putClkCorrections(const vector<t_clkCorr*>& corr) {
|
---|
| 127 | for (unsigned ii = 0; ii < corr.size(); ii++) {
|
---|
| 128 | _ephPool->putClkCorrection(new t_clkCorr(*corr[ii]));
|
---|
| 129 | }
|
---|
| 130 | }
|
---|
| 131 |
|
---|
[7271] | 132 | //
|
---|
[7237] | 133 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 134 | void t_pppClient::putCodeBiases(const vector<t_satCodeBias*>& biases) {
|
---|
| 135 | for (unsigned ii = 0; ii < biases.size(); ii++) {
|
---|
| 136 | _obsPool->putCodeBias(new t_satCodeBias(*biases[ii]));
|
---|
| 137 | }
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | //
|
---|
| 141 | //////////////////////////////////////////////////////////////////////////////
|
---|
[7288] | 142 | void t_pppClient::putPhaseBiases(const vector<t_satPhaseBias*>& biases) {
|
---|
| 143 | for (unsigned ii = 0; ii < biases.size(); ii++) {
|
---|
| 144 | _obsPool->putPhaseBias(new t_satPhaseBias(*biases[ii]));
|
---|
| 145 | }
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | //
|
---|
| 149 | //////////////////////////////////////////////////////////////////////////////
|
---|
[7237] | 150 | t_irc t_pppClient::prepareObs(const vector<t_satObs*>& satObs,
|
---|
| 151 | vector<t_pppSatObs*>& obsVector, bncTime& epoTime) {
|
---|
[8905] | 152 |
|
---|
[7271] | 153 | // Default
|
---|
[7237] | 154 | // -------
|
---|
| 155 | epoTime.reset();
|
---|
[10038] | 156 | clearObs();
|
---|
[7237] | 157 |
|
---|
| 158 | // Create vector of valid observations
|
---|
| 159 | // -----------------------------------
|
---|
| 160 | for (unsigned ii = 0; ii < satObs.size(); ii++) {
|
---|
[9567] | 161 | char sys = satObs[ii]->_prn.system();
|
---|
| 162 | if (_opt->useSystem(sys)) {
|
---|
[7237] | 163 | t_pppSatObs* pppSatObs = new t_pppSatObs(*satObs[ii]);
|
---|
| 164 | if (pppSatObs->isValid()) {
|
---|
| 165 | obsVector.push_back(pppSatObs);
|
---|
| 166 | }
|
---|
| 167 | else {
|
---|
| 168 | delete pppSatObs;
|
---|
| 169 | }
|
---|
| 170 | }
|
---|
| 171 | }
|
---|
| 172 |
|
---|
| 173 | // Check whether data are synchronized, compute epoTime
|
---|
| 174 | // ----------------------------------------------------
|
---|
| 175 | const double MAXSYNC = 0.05; // synchronization limit
|
---|
| 176 | double meanDt = 0.0;
|
---|
| 177 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
| 178 | const t_pppSatObs* satObs = obsVector.at(ii);
|
---|
| 179 | if (epoTime.undef()) {
|
---|
| 180 | epoTime = satObs->time();
|
---|
| 181 | }
|
---|
| 182 | else {
|
---|
| 183 | double dt = satObs->time() - epoTime;
|
---|
| 184 | if (fabs(dt) > MAXSYNC) {
|
---|
| 185 | LOG << "t_pppClient::prepareObs asynchronous observations" << endl;
|
---|
| 186 | return failure;
|
---|
| 187 | }
|
---|
| 188 | meanDt += dt;
|
---|
| 189 | }
|
---|
| 190 | }
|
---|
| 191 |
|
---|
| 192 | if (obsVector.size() > 0) {
|
---|
| 193 | epoTime += meanDt / obsVector.size();
|
---|
| 194 | }
|
---|
| 195 |
|
---|
| 196 | return success;
|
---|
| 197 | }
|
---|
| 198 |
|
---|
[8905] | 199 | //
|
---|
| 200 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 201 | bool t_pppClient::preparePseudoObs(std::vector<t_pppSatObs*>& obsVector) {
|
---|
| 202 |
|
---|
| 203 | bool pseudoObsIono = false;
|
---|
| 204 |
|
---|
[8912] | 205 | if (_opt->_pseudoObsIono) {
|
---|
[8905] | 206 | vector<t_pppSatObs*>::iterator it = obsVector.begin();
|
---|
| 207 | while (it != obsVector.end()) {
|
---|
| 208 | t_pppSatObs* satObs = *it;
|
---|
[10034] | 209 | pseudoObsIono = satObs->setPseudoObsIono(t_frequency::G1);
|
---|
[8905] | 210 | it++;
|
---|
| 211 | }
|
---|
| 212 | }
|
---|
[10256] | 213 | /*
|
---|
[10217] | 214 | vector<t_pppSatObs*>::iterator it = obsVector.begin();
|
---|
| 215 | while (it != obsVector.end()) {
|
---|
| 216 | t_pppSatObs* satObs = *it;
|
---|
| 217 | satObs->printObsMinusComputed();
|
---|
| 218 | it++;
|
---|
| 219 | }
|
---|
| 220 | */
|
---|
[8905] | 221 | return pseudoObsIono;
|
---|
| 222 | }
|
---|
| 223 |
|
---|
[9560] | 224 | //
|
---|
| 225 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 226 | void t_pppClient::useObsWithCodeBiasesOnly(std::vector<t_pppSatObs*>& obsVector) {
|
---|
| 227 |
|
---|
| 228 | vector<t_pppSatObs*>::iterator it = obsVector.begin();
|
---|
| 229 | while (it != obsVector.end()) {
|
---|
| 230 | t_pppSatObs* pppSatObs = *it;
|
---|
| 231 | bool codeBiasesAvailable = false;
|
---|
[10251] | 232 | if (pppSatObs->getCodeBias(pppSatObs->fType1()) &&
|
---|
| 233 | pppSatObs->getCodeBias(pppSatObs->fType2())) {
|
---|
| 234 | codeBiasesAvailable = true;
|
---|
[9560] | 235 | }
|
---|
| 236 | if (codeBiasesAvailable) {
|
---|
| 237 | ++it;
|
---|
| 238 | }
|
---|
| 239 | else {
|
---|
| 240 | it = obsVector.erase(it);
|
---|
| 241 | delete pppSatObs;
|
---|
| 242 | }
|
---|
| 243 | }
|
---|
[10251] | 244 | return;
|
---|
[9560] | 245 | }
|
---|
| 246 |
|
---|
| 247 |
|
---|
[7237] | 248 | // Compute the Bancroft position, check for blunders
|
---|
| 249 | //////////////////////////////////////////////////////////////////////////////
|
---|
[7271] | 250 | t_irc t_pppClient::cmpBancroft(const bncTime& epoTime,
|
---|
[7237] | 251 | vector<t_pppSatObs*>& obsVector,
|
---|
| 252 | ColumnVector& xyzc, bool print) {
|
---|
| 253 | t_lc::type tLC = t_lc::dummy;
|
---|
[10256] | 254 | int numBancroft = obsVector.size();
|
---|
[7237] | 255 |
|
---|
[10259] | 256 | while (_running) {
|
---|
[10256] | 257 | Matrix BB(numBancroft, 4);
|
---|
[7237] | 258 | int iObs = -1;
|
---|
| 259 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
| 260 | const t_pppSatObs* satObs = obsVector.at(ii);
|
---|
[10356] | 261 | if (tLC == t_lc::dummy) {
|
---|
| 262 | if (satObs->isValid(t_lc::cIF)) {
|
---|
| 263 | tLC = t_lc::cIF;
|
---|
[7237] | 264 | }
|
---|
[10356] | 265 | else if (satObs->isValid(t_lc::c1)) {
|
---|
| 266 | tLC = t_lc::c1;
|
---|
[7237] | 267 | }
|
---|
[10356] | 268 | else if (satObs->isValid(t_lc::c2)) {
|
---|
| 269 | tLC = t_lc::c2;
|
---|
| 270 | }
|
---|
[7237] | 271 | }
|
---|
[10356] | 272 | if ( satObs->isValid(tLC) &&
|
---|
| 273 | (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
|
---|
| 274 | ++iObs;
|
---|
| 275 | BB[iObs][0] = satObs->xc()[0];
|
---|
| 276 | BB[iObs][1] = satObs->xc()[1];
|
---|
| 277 | BB[iObs][2] = satObs->xc()[2];
|
---|
| 278 | BB[iObs][3] = satObs->obsValue(tLC) - satObs->cmpValueForBanc(tLC);
|
---|
| 279 | }
|
---|
[7237] | 280 | }
|
---|
[8912] | 281 | if (iObs + 1 < _opt->_minObs) {
|
---|
[9943] | 282 | LOG << "t_pppClient::cmpBancroft not enough observations: " << iObs + 1 << endl;
|
---|
[7237] | 283 | return failure;
|
---|
| 284 | }
|
---|
| 285 | BB = BB.Rows(1,iObs+1);
|
---|
[9600] | 286 | if (bancroft(BB, xyzc) != success) {
|
---|
| 287 | return failure;
|
---|
| 288 | }
|
---|
[7237] | 289 |
|
---|
| 290 | xyzc[3] /= t_CST::c;
|
---|
| 291 |
|
---|
| 292 | // Check Blunders
|
---|
| 293 | // --------------
|
---|
[10397] | 294 | const double BLUNDER = 150.0;
|
---|
[7237] | 295 | double maxRes = 0.0;
|
---|
| 296 | unsigned maxResIndex = 0;
|
---|
| 297 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
| 298 | const t_pppSatObs* satObs = obsVector.at(ii);
|
---|
[10388] | 299 | if (satObs->isValid() &&
|
---|
[10373] | 300 | (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
|
---|
[7237] | 301 | ColumnVector rr = satObs->xc().Rows(1,3) - xyzc.Rows(1,3);
|
---|
[8905] | 302 | double res = rr.NormFrobenius() - satObs->obsValue(tLC)
|
---|
[8453] | 303 | - (satObs->xc()[3] - xyzc[3]) * t_CST::c;
|
---|
[9600] | 304 | if (fabs(res) > maxRes) {
|
---|
| 305 | maxRes = fabs(res);
|
---|
[7237] | 306 | maxResIndex = ii;
|
---|
| 307 | }
|
---|
| 308 | }
|
---|
| 309 | }
|
---|
[9600] | 310 | if (maxRes < BLUNDER) {
|
---|
[10034] | 311 | if (print) {
|
---|
[7237] | 312 | LOG.setf(ios::fixed);
|
---|
[9783] | 313 | LOG << "\nPPP of Epoch ";
|
---|
| 314 | if (!_epoTimeRover.undef()) LOG << string(_epoTimeRover);
|
---|
| 315 | LOG << "\n---------------------------------------------------------------\n";
|
---|
[10384] | 316 | LOG << string(epoTime) << " BANCROFT: "
|
---|
[7237] | 317 | << setw(14) << setprecision(3) << xyzc[0] << ' '
|
---|
| 318 | << setw(14) << setprecision(3) << xyzc[1] << ' '
|
---|
| 319 | << setw(14) << setprecision(3) << xyzc[2] << ' '
|
---|
| 320 | << setw(14) << setprecision(3) << xyzc[3] * t_CST::c << endl << endl;
|
---|
| 321 | }
|
---|
| 322 | break;
|
---|
| 323 | }
|
---|
| 324 | else {
|
---|
| 325 | t_pppSatObs* satObs = obsVector.at(maxResIndex);
|
---|
[10165] | 326 | LOG << "t_pppClient::cmpBancroft Outlier " << satObs->prn().toString()
|
---|
[7237] | 327 | << " " << maxRes << endl;
|
---|
| 328 | delete satObs;
|
---|
| 329 | obsVector.erase(obsVector.begin() + maxResIndex);
|
---|
| 330 | }
|
---|
| 331 | }
|
---|
| 332 |
|
---|
| 333 | return success;
|
---|
| 334 | }
|
---|
| 335 |
|
---|
[7271] | 336 | //
|
---|
[7237] | 337 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 338 | void t_pppClient::initOutput(t_output* output) {
|
---|
| 339 | _output = output;
|
---|
| 340 | _output->_numSat = 0;
|
---|
[7927] | 341 | _output->_hDop = 0.0;
|
---|
[7237] | 342 | _output->_error = false;
|
---|
| 343 | }
|
---|
| 344 |
|
---|
[7271] | 345 | //
|
---|
[7237] | 346 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 347 | void t_pppClient::clearObs() {
|
---|
| 348 | for (unsigned ii = 0; ii < _obsRover.size(); ii++) {
|
---|
| 349 | delete _obsRover.at(ii);
|
---|
| 350 | }
|
---|
| 351 | _obsRover.clear();
|
---|
| 352 | }
|
---|
| 353 |
|
---|
[7271] | 354 | //
|
---|
[7237] | 355 | //////////////////////////////////////////////////////////////////////////////
|
---|
[9585] | 356 | void t_pppClient::finish(t_irc irc, int ind) {
|
---|
[9783] | 357 | #ifdef BNC_DEBUG_PPP
|
---|
[9585] | 358 | LOG << "t_pppClient::finish(" << ind << "): " << irc << endl;
|
---|
[9783] | 359 | #endif
|
---|
[9585] | 360 |
|
---|
[7237] | 361 | clearObs();
|
---|
| 362 |
|
---|
| 363 | _output->_epoTime = _epoTimeRover;
|
---|
| 364 |
|
---|
| 365 | if (irc == success) {
|
---|
| 366 | _output->_xyzRover[0] = _staRover->xyzApr()[0] + _filter->x()[0];
|
---|
| 367 | _output->_xyzRover[1] = _staRover->xyzApr()[1] + _filter->x()[1];
|
---|
| 368 | _output->_xyzRover[2] = _staRover->xyzApr()[2] + _filter->x()[2];
|
---|
| 369 |
|
---|
| 370 | xyz2neu(_staRover->ellApr().data(), _filter->x().data(), _output->_neu);
|
---|
| 371 |
|
---|
| 372 | copy(&_filter->Q().data()[0], &_filter->Q().data()[6], _output->_covMatrix);
|
---|
| 373 |
|
---|
| 374 | _output->_trp0 = t_tropo::delay_saast(_staRover->xyzApr(), M_PI/2.0);
|
---|
| 375 | _output->_trp = _filter->trp();
|
---|
| 376 | _output->_trpStdev = _filter->trpStdev();
|
---|
| 377 |
|
---|
[9386] | 378 | _output->_numSat = _filter->numSat();
|
---|
| 379 | _output->_hDop = _filter->HDOP();
|
---|
[7237] | 380 | _output->_error = false;
|
---|
| 381 | }
|
---|
| 382 | else {
|
---|
| 383 | _output->_error = true;
|
---|
| 384 | }
|
---|
[10034] | 385 |
|
---|
[7237] | 386 | _output->_log = _log->str();
|
---|
| 387 | delete _log; _log = new ostringstream();
|
---|
[9545] | 388 |
|
---|
| 389 | return;
|
---|
[7237] | 390 | }
|
---|
| 391 |
|
---|
[7271] | 392 | //
|
---|
[7237] | 393 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 394 | t_irc t_pppClient::cmpModel(t_pppStation* station, const ColumnVector& xyzc,
|
---|
| 395 | vector<t_pppSatObs*>& obsVector) {
|
---|
| 396 | bncTime time;
|
---|
| 397 | time = _epoTimeRover;
|
---|
[8912] | 398 | station->setName(_opt->_roverName);
|
---|
| 399 | station->setAntName(_opt->_antNameRover);
|
---|
[8905] | 400 | station->setEpochTime(time);
|
---|
[10034] | 401 |
|
---|
[8912] | 402 | if (_opt->xyzAprRoverSet()) {
|
---|
| 403 | station->setXyzApr(_opt->_xyzAprRover);
|
---|
[7237] | 404 | }
|
---|
| 405 | else {
|
---|
| 406 | station->setXyzApr(xyzc.Rows(1,3));
|
---|
| 407 | }
|
---|
[8912] | 408 | station->setNeuEcc(_opt->_neuEccRover);
|
---|
[7237] | 409 |
|
---|
| 410 | // Receiver Clock
|
---|
| 411 | // --------------
|
---|
| 412 | station->setDClk(xyzc[3]);
|
---|
| 413 |
|
---|
| 414 | // Tides
|
---|
| 415 | // -----
|
---|
[8905] | 416 | station->setTideDsplEarth(_tides->earth(time, station->xyzApr()));
|
---|
| 417 | station->setTideDsplOcean(_tides->ocean(time, station->xyzApr(), station->name()));
|
---|
[7271] | 418 |
|
---|
[7237] | 419 | // Observation model
|
---|
| 420 | // -----------------
|
---|
| 421 | vector<t_pppSatObs*>::iterator it = obsVector.begin();
|
---|
| 422 | while (it != obsVector.end()) {
|
---|
| 423 | t_pppSatObs* satObs = *it;
|
---|
[7254] | 424 | t_irc modelSetup;
|
---|
[7237] | 425 | if (satObs->isValid()) {
|
---|
[7254] | 426 | modelSetup = satObs->cmpModel(station);
|
---|
[7237] | 427 | }
|
---|
[7254] | 428 | if (satObs->isValid() &&
|
---|
[8912] | 429 | satObs->eleSat() >= _opt->_minEle &&
|
---|
[7254] | 430 | modelSetup == success) {
|
---|
[7237] | 431 | ++it;
|
---|
| 432 | }
|
---|
| 433 | else {
|
---|
| 434 | delete satObs;
|
---|
| 435 | it = obsVector.erase(it);
|
---|
| 436 | }
|
---|
| 437 | }
|
---|
| 438 |
|
---|
| 439 | return success;
|
---|
| 440 | }
|
---|
| 441 |
|
---|
[7271] | 442 | //
|
---|
[7237] | 443 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 444 | void t_pppClient::processEpoch(const vector<t_satObs*>& satObs, t_output* output) {
|
---|
| 445 |
|
---|
| 446 | try {
|
---|
| 447 | initOutput(output);
|
---|
[10034] | 448 |
|
---|
| 449 | // Prepare Observations of the Rover
|
---|
| 450 | // ---------------------------------
|
---|
| 451 | if (prepareObs(satObs, _obsRover, _epoTimeRover) != success) {
|
---|
| 452 | return finish(failure, 1);
|
---|
[10031] | 453 | }
|
---|
[9419] | 454 |
|
---|
[10034] | 455 | for (int iter = 1; iter <= 2; iter++) {
|
---|
| 456 | ColumnVector xyzc(4); xyzc = 0.0;
|
---|
| 457 | bool print = (iter == 2);
|
---|
| 458 | if (cmpBancroft(_epoTimeRover, _obsRover, xyzc, print) != success) {
|
---|
| 459 | return finish(failure, 2);
|
---|
[10031] | 460 | }
|
---|
[10034] | 461 | if (cmpModel(_staRover, xyzc, _obsRover) != success) {
|
---|
| 462 | return finish(failure, 3);
|
---|
[8956] | 463 | }
|
---|
[10034] | 464 | }
|
---|
| 465 | // use observations only if satellite code biases are available
|
---|
| 466 | /* ------------------------------------------------------------
|
---|
| 467 | if (!_opt->_corrMount.empty() {
|
---|
[10015] | 468 | useObsWithCodeBiasesOnly(_obsRover);
|
---|
[10034] | 469 | }*/
|
---|
[8905] | 470 |
|
---|
[10034] | 471 | if (int(_obsRover.size()) < _opt->_minObs) {
|
---|
| 472 | LOG << "t_pppClient::processEpoch not enough observations" << endl;
|
---|
| 473 | return finish(failure, 4);
|
---|
| 474 | }
|
---|
[10038] | 475 |
|
---|
[10034] | 476 | // Prepare Pseudo Observations of the Rover
|
---|
| 477 | // ----------------------------------------
|
---|
| 478 | _pseudoObsIono = preparePseudoObs(_obsRover);
|
---|
[10018] | 479 |
|
---|
[10034] | 480 | // Store last epoch of data
|
---|
| 481 | // ------------------------
|
---|
| 482 | _obsPool->putEpoch(_epoTimeRover, _obsRover, _pseudoObsIono);
|
---|
[7237] | 483 |
|
---|
[10034] | 484 | // Process Epoch in Filter
|
---|
| 485 | // -----------------------
|
---|
| 486 | if (_filter->processEpoch(_obsPool) != success) {
|
---|
[10220] | 487 | LOG << "t_pppFilter::processEpoch() != success" << endl;
|
---|
[10034] | 488 | return finish(failure, 5);
|
---|
| 489 | }
|
---|
[7237] | 490 | }
|
---|
| 491 | catch (Exception& exc) {
|
---|
| 492 | LOG << exc.what() << endl;
|
---|
[10034] | 493 | return finish(failure, 6);
|
---|
[7237] | 494 | }
|
---|
| 495 | catch (t_except msg) {
|
---|
| 496 | LOG << msg.what() << endl;
|
---|
[10034] | 497 | return finish(failure, 7);
|
---|
[7237] | 498 | }
|
---|
| 499 | catch (const char* msg) {
|
---|
| 500 | LOG << msg << endl;
|
---|
[10034] | 501 | return finish(failure, 8);
|
---|
[7237] | 502 | }
|
---|
| 503 | catch (...) {
|
---|
| 504 | LOG << "unknown exception" << endl;
|
---|
[10034] | 505 | return finish(failure, 9);
|
---|
[7237] | 506 | }
|
---|
[10034] | 507 | return finish(success, 0);
|
---|
[7237] | 508 | }
|
---|
| 509 |
|
---|
[7271] | 510 | //
|
---|
[7237] | 511 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 512 | double lorentz(const ColumnVector& aa, const ColumnVector& bb) {
|
---|
| 513 | return aa[0]*bb[0] + aa[1]*bb[1] + aa[2]*bb[2] - aa[3]*bb[3];
|
---|
| 514 | }
|
---|
| 515 |
|
---|
[7271] | 516 | //
|
---|
[7237] | 517 | ////////////////////////////////////////////////////////////////////////////
|
---|
[9600] | 518 | t_irc t_pppClient::bancroft(const Matrix& BBpass, ColumnVector& pos) {
|
---|
[7237] | 519 |
|
---|
| 520 | if (pos.Nrows() != 4) {
|
---|
| 521 | pos.ReSize(4);
|
---|
| 522 | }
|
---|
| 523 | pos = 0.0;
|
---|
| 524 |
|
---|
| 525 | for (int iter = 1; iter <= 2; iter++) {
|
---|
| 526 | Matrix BB = BBpass;
|
---|
| 527 | int mm = BB.Nrows();
|
---|
| 528 | for (int ii = 1; ii <= mm; ii++) {
|
---|
| 529 | double xx = BB(ii,1);
|
---|
| 530 | double yy = BB(ii,2);
|
---|
| 531 | double traveltime = 0.072;
|
---|
| 532 | if (iter > 1) {
|
---|
| 533 | double zz = BB(ii,3);
|
---|
[7271] | 534 | double rho = sqrt( (xx-pos(1)) * (xx-pos(1)) +
|
---|
| 535 | (yy-pos(2)) * (yy-pos(2)) +
|
---|
[7237] | 536 | (zz-pos(3)) * (zz-pos(3)) );
|
---|
| 537 | traveltime = rho / t_CST::c;
|
---|
| 538 | }
|
---|
| 539 | double angle = traveltime * t_CST::omega;
|
---|
| 540 | double cosa = cos(angle);
|
---|
| 541 | double sina = sin(angle);
|
---|
| 542 | BB(ii,1) = cosa * xx + sina * yy;
|
---|
| 543 | BB(ii,2) = -sina * xx + cosa * yy;
|
---|
| 544 | }
|
---|
[7271] | 545 |
|
---|
[7237] | 546 | Matrix BBB;
|
---|
| 547 | if (mm > 4) {
|
---|
| 548 | SymmetricMatrix hlp; hlp << BB.t() * BB;
|
---|
| 549 | BBB = hlp.i() * BB.t();
|
---|
| 550 | }
|
---|
| 551 | else {
|
---|
| 552 | BBB = BB.i();
|
---|
| 553 | }
|
---|
| 554 | ColumnVector ee(mm); ee = 1.0;
|
---|
| 555 | ColumnVector alpha(mm); alpha = 0.0;
|
---|
| 556 | for (int ii = 1; ii <= mm; ii++) {
|
---|
[7271] | 557 | alpha(ii) = lorentz(BB.Row(ii).t(),BB.Row(ii).t())/2.0;
|
---|
[7237] | 558 | }
|
---|
| 559 | ColumnVector BBBe = BBB * ee;
|
---|
| 560 | ColumnVector BBBalpha = BBB * alpha;
|
---|
| 561 | double aa = lorentz(BBBe, BBBe);
|
---|
| 562 | double bb = lorentz(BBBe, BBBalpha)-1;
|
---|
| 563 | double cc = lorentz(BBBalpha, BBBalpha);
|
---|
| 564 | double root = sqrt(bb*bb-aa*cc);
|
---|
| 565 |
|
---|
[7271] | 566 | Matrix hlpPos(4,2);
|
---|
[7237] | 567 | hlpPos.Column(1) = (-bb-root)/aa * BBBe + BBBalpha;
|
---|
| 568 | hlpPos.Column(2) = (-bb+root)/aa * BBBe + BBBalpha;
|
---|
| 569 |
|
---|
| 570 | ColumnVector omc(2);
|
---|
| 571 | for (int pp = 1; pp <= 2; pp++) {
|
---|
| 572 | hlpPos(4,pp) = -hlpPos(4,pp);
|
---|
[7271] | 573 | omc(pp) = BB(1,4) -
|
---|
[7237] | 574 | sqrt( (BB(1,1)-hlpPos(1,pp)) * (BB(1,1)-hlpPos(1,pp)) +
|
---|
| 575 | (BB(1,2)-hlpPos(2,pp)) * (BB(1,2)-hlpPos(2,pp)) +
|
---|
[7271] | 576 | (BB(1,3)-hlpPos(3,pp)) * (BB(1,3)-hlpPos(3,pp)) ) -
|
---|
[7237] | 577 | hlpPos(4,pp);
|
---|
| 578 | }
|
---|
| 579 | if ( fabs(omc(1)) > fabs(omc(2)) ) {
|
---|
| 580 | pos = hlpPos.Column(2);
|
---|
| 581 | }
|
---|
| 582 | else {
|
---|
| 583 | pos = hlpPos.Column(1);
|
---|
| 584 | }
|
---|
| 585 | }
|
---|
[9600] | 586 | if (pos.size() != 4 ||
|
---|
| 587 | std::isnan(pos(1)) ||
|
---|
| 588 | std::isnan(pos(2)) ||
|
---|
| 589 | std::isnan(pos(3)) ||
|
---|
| 590 | std::isnan(pos(4))) {
|
---|
| 591 | return failure;
|
---|
| 592 | }
|
---|
| 593 |
|
---|
| 594 | return success;
|
---|
[7237] | 595 | }
|
---|
| 596 |
|
---|
[7972] | 597 | //
|
---|
| 598 | //////////////////////////////////////////////////////////////////////////////
|
---|
[10256] | 599 | void t_pppClient::reset() {
|
---|
[9490] | 600 |
|
---|
[7972] | 601 | // to delete old orbit and clock corrections
|
---|
| 602 | delete _ephPool;
|
---|
| 603 | _ephPool = new t_pppEphPool();
|
---|
| 604 |
|
---|
| 605 | // to delete old code biases
|
---|
| 606 | delete _obsPool;
|
---|
| 607 | _obsPool = new t_pppObsPool();
|
---|
[8905] | 608 |
|
---|
| 609 | // to delete all parameters
|
---|
| 610 | delete _filter;
|
---|
[10034] | 611 | _filter = new t_pppFilter();
|
---|
[8905] | 612 |
|
---|
[7996] | 613 | }
|
---|