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