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