source: ntrip/trunk/BNC/src/PPP/pppClient.cpp@ 10576

Last change on this file since 10576 was 10576, checked in by stuerze, 44 hours ago

changes regarding PPP

  • Property svn:keywords set to Author Date Id Rev URL;svn:eol-style=native
  • Property svn:mime-type set to text/plain
File size: 23.5 KB
Line 
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 *
13 * Changes:
14 *
15 * -----------------------------------------------------------------------*/
16
17#include <QThreadStorage>
18
19#include <iostream>
20#include <iomanip>
21#include <cmath>
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
35using namespace BNC_PPP;
36using namespace std;
37
38// Global variable holding thread-specific pointers
39//////////////////////////////////////////////////////////////////////////////
40QThreadStorage<t_pppClient*> CLIENTS;
41
42// Static function returning thread-specific pointer
43//////////////////////////////////////////////////////////////////////////////
44t_pppClient* t_pppClient::instance() {
45 return CLIENTS.localData();
46}
47
48// Constructor
49//////////////////////////////////////////////////////////////////////////////
50t_pppClient::t_pppClient(const t_pppOptions* opt) {
51 _running = true;
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();
58 _filter = new t_pppFilter();
59 _tides = new t_tides();
60 _antex = 0;
61 if (!_opt->_antexFileName.empty()) {
62 _antex = new bncAntex(_opt->_antexFileName.c_str());
63 }
64 if (!_opt->_blqFileName.empty()) {
65 if (_tides->readBlqFile(_opt->_blqFileName.c_str()) == success) {
66 //_tides->printAllBlqSets();
67 }
68 }
69 _offGps = 0.0;
70 _offGlo = 0.0;
71 _offGal = 0.0;
72 _offBds = 0.0;
73 CLIENTS.setLocalData(this); // CLIENTS takes ownership over "this"
74}
75
76// Destructor
77//////////////////////////////////////////////////////////////////////////////
78t_pppClient::~t_pppClient() {
79 _running = false;
80 delete _log;
81 delete _opt;
82 delete _ephPool;
83 delete _obsPool;
84 delete _staRover;
85 if (_antex) {
86 delete _antex;
87 }
88 delete _filter;
89 delete _tides;
90 clearObs();
91}
92
93//
94//////////////////////////////////////////////////////////////////////////////
95void t_pppClient::putEphemeris(const t_eph* eph) {
96 const t_ephGPS* ephGPS = dynamic_cast<const t_ephGPS*>(eph);
97 const t_ephGlo* ephGlo = dynamic_cast<const t_ephGlo*>(eph);
98 const t_ephGal* ephGal = dynamic_cast<const t_ephGal*>(eph);
99 const t_ephBDS* ephBDS = dynamic_cast<const t_ephBDS*>(eph);
100 if (ephGPS) {
101 _ephPool->putEphemeris(new t_ephGPS(*ephGPS));
102 }
103 else if (ephGlo) {
104 _ephPool->putEphemeris(new t_ephGlo(*ephGlo));
105 }
106 else if (ephGal) {
107 _ephPool->putEphemeris(new t_ephGal(*ephGal));
108 }
109 else if (ephBDS) {
110 _ephPool->putEphemeris(new t_ephBDS(*ephBDS));
111 }
112}
113
114//
115//////////////////////////////////////////////////////////////////////////////
116void t_pppClient::putTec(const t_vTec* vTec) {
117 _obsPool->putTec(new t_vTec(*vTec));
118}
119
120//
121//////////////////////////////////////////////////////////////////////////////
122void t_pppClient::putOrbCorrections(const vector<t_orbCorr*>& corr) {
123 for (unsigned ii = 0; ii < corr.size(); ii++) {
124 _ephPool->putOrbCorrection(new t_orbCorr(*corr[ii]));
125 }
126}
127
128//
129//////////////////////////////////////////////////////////////////////////////
130void t_pppClient::putClkCorrections(const vector<t_clkCorr*>& corr) {
131 for (unsigned ii = 0; ii < corr.size(); ii++) {
132 _ephPool->putClkCorrection(new t_clkCorr(*corr[ii]));
133 }
134}
135
136//
137//////////////////////////////////////////////////////////////////////////////
138void t_pppClient::putCodeBiases(const vector<t_satCodeBias*>& biases) {
139 for (unsigned ii = 0; ii < biases.size(); ii++) {
140 _obsPool->putCodeBias(new t_satCodeBias(*biases[ii]));
141 }
142}
143
144//
145//////////////////////////////////////////////////////////////////////////////
146void t_pppClient::putPhaseBiases(const vector<t_satPhaseBias*>& biases) {
147 for (unsigned ii = 0; ii < biases.size(); ii++) {
148 _obsPool->putPhaseBias(new t_satPhaseBias(*biases[ii]));
149 }
150}
151
152//
153//////////////////////////////////////////////////////////////////////////////
154t_irc t_pppClient::prepareObs(const vector<t_satObs*>& satObs,
155 vector<t_pppSatObs*>& obsVector, bncTime& epoTime) {
156
157 // Default
158 // -------
159 epoTime.reset();
160 clearObs();
161
162 // Create vector of valid observations
163 // -----------------------------------
164 for (unsigned ii = 0; ii < satObs.size(); ii++) {
165 char sys = satObs[ii]->_prn.system();
166 if (_opt->useSystem(sys)) {
167 t_pppSatObs* pppSatObs = new t_pppSatObs(*satObs[ii]);
168 if (pppSatObs->isValid()) {
169 obsVector.push_back(pppSatObs);
170 }
171 else {
172 delete pppSatObs;
173 }
174 }
175 }
176
177 // Check whether data are synchronized, compute epoTime
178 // ----------------------------------------------------
179 const double MAXSYNC = 0.05; // synchronization limit
180 double meanDt = 0.0;
181 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
182 const t_pppSatObs* satObs = obsVector.at(ii);
183 if (epoTime.undef()) {
184 epoTime = satObs->time();
185 }
186 else {
187 double dt = satObs->time() - epoTime;
188 if (fabs(dt) > MAXSYNC) {
189 LOG << "t_pppClient::prepareObs asynchronous observations" << endl;
190 return failure;
191 }
192 meanDt += dt;
193 }
194 }
195
196 if (obsVector.size() > 0) {
197 epoTime += meanDt / obsVector.size();
198 }
199
200 return success;
201}
202
203//
204//////////////////////////////////////////////////////////////////////////////
205bool t_pppClient::preparePseudoObs(std::vector<t_pppSatObs*>& obsVector) {
206
207 bool pseudoObsIono = false;
208
209 if (_opt->_pseudoObsIono) {
210 vector<t_pppSatObs*>::iterator it = obsVector.begin();
211 while (it != obsVector.end()) {
212 t_pppSatObs* satObs = *it;
213 pseudoObsIono = satObs->setPseudoObsIono(t_frequency::G1);
214 it++;
215 }
216 }
217/*
218 vector<t_pppSatObs*>::iterator it = obsVector.begin();
219 while (it != obsVector.end()) {
220 t_pppSatObs* satObs = *it;
221 satObs->printObsMinusComputed();
222 it++;
223 }
224*/
225 return pseudoObsIono;
226}
227
228//
229//////////////////////////////////////////////////////////////////////////////
230void t_pppClient::useObsWithCodeBiasesOnly(std::vector<t_pppSatObs*>& obsVector) {
231
232 vector<t_pppSatObs*>::iterator it = obsVector.begin();
233 while (it != obsVector.end()) {
234 t_pppSatObs* pppSatObs = *it;
235 bool codeBiasesAvailable = false;
236 if (pppSatObs->getCodeBias(pppSatObs->fType1()) &&
237 pppSatObs->getCodeBias(pppSatObs->fType2())) {
238 codeBiasesAvailable = true;
239 }
240 if (codeBiasesAvailable) {
241 ++it;
242 }
243 else {
244 it = obsVector.erase(it);
245 delete pppSatObs;
246 }
247 }
248 return;
249}
250
251
252// Compute the Bancroft position, check for blunders
253//////////////////////////////////////////////////////////////////////////////
254t_irc t_pppClient::cmpBancroft(const bncTime& epoTime,
255 vector<t_pppSatObs*>& obsVector,
256 ColumnVector& xyzc, bool print) {
257 t_lc::type tLC = t_lc::dummy;
258 int numBancroft = obsVector.size();
259
260 while (_running) {
261 Matrix BB(numBancroft, 4);
262 int iObs = -1;
263 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
264 const t_pppSatObs* satObs = obsVector.at(ii);
265 if (tLC == t_lc::dummy) {
266 if (satObs->isValid(t_lc::cIF)) {
267 tLC = t_lc::cIF;
268 }
269 else if (satObs->isValid(t_lc::c1)) {
270 tLC = t_lc::c1;
271 }
272 else if (satObs->isValid(t_lc::c2)) {
273 tLC = t_lc::c2;
274 }
275 }
276 if ( satObs->isValid(tLC) &&
277 (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
278 ++iObs;
279 BB[iObs][0] = satObs->xc()[0];
280 BB[iObs][1] = satObs->xc()[1];
281 BB[iObs][2] = satObs->xc()[2];
282 BB[iObs][3] = satObs->obsValue(tLC) - satObs->cmpValueForBanc(tLC);
283 }
284 }
285 if (iObs + 1 < _opt->_minObs) {
286 LOG << "t_pppClient::cmpBancroft not enough observations: " << iObs + 1 << endl;
287 return failure;
288 }
289 BB = BB.Rows(1,iObs+1);
290 if (bancroft(BB, xyzc) != success) {
291 return failure;
292 }
293
294 xyzc[3] /= t_CST::c;
295
296 // Check Blunders
297 // --------------
298 const double BLUNDER = 150.0;
299 double maxRes = 0.0;
300 unsigned maxResIndex = 0;
301 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
302 const t_pppSatObs* satObs = obsVector.at(ii);
303 if (satObs->isValid() &&
304 (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
305 ColumnVector rr = satObs->xc().Rows(1,3) - xyzc.Rows(1,3);
306 double res = rr.NormFrobenius() - satObs->obsValue(tLC)
307 - (satObs->xc()[3] - xyzc[3]) * t_CST::c;
308 if (fabs(res) > maxRes) {
309 maxRes = fabs(res);
310 maxResIndex = ii;
311 }
312 }
313 }
314 if (maxRes < BLUNDER) {
315 if (print) {
316 LOG.setf(ios::fixed);
317 LOG << "\nPPP of Epoch ";
318 if (!_epoTimeRover.undef()) LOG << string(_epoTimeRover);
319 LOG << "\n---------------------------------------------------------------\n";
320 LOG << string(epoTime) << " BANCROFT: "
321 << setw(14) << setprecision(3) << xyzc[0] << ' '
322 << setw(14) << setprecision(3) << xyzc[1] << ' '
323 << setw(14) << setprecision(3) << xyzc[2] << ' '
324 << setw(14) << setprecision(3) << xyzc[3] * t_CST::c << endl << endl;
325 }
326 break;
327 }
328 else {
329 t_pppSatObs* satObs = obsVector.at(maxResIndex);
330 LOG << "t_pppClient::cmpBancroft Outlier " << satObs->prn().toString()
331 << " " << maxRes << endl;
332 delete satObs;
333 obsVector.erase(obsVector.begin() + maxResIndex);
334 }
335 }
336
337 return success;
338}
339
340// Compute A Priori Gps Clock Offset
341//////////////////////////////////////////////////////////////////////////////
342double t_pppClient::cmpOffGps(vector<t_pppSatObs*>& obsVector) {
343
344 t_lc::type tLC = t_lc::dummy;
345 double offGps = 0.0;
346
347 if (_opt->useSystem('G')) {
348 while (obsVector.size() > 0) {
349 offGps = 0.0;
350 double maxRes = 0.0;
351 int maxResIndex = -1;
352 unsigned nObs = 0;
353 t_prn maxResPrn;
354 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
355 const t_pppSatObs* satObs = obsVector.at(ii);
356 if (satObs->prn().system() == 'G') {
357 if (tLC == t_lc::dummy) {
358 tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
359 }
360 if (satObs->isValid(tLC) && (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle)) {
361 double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
362 ++nObs;
363 offGps += ll;
364 if (fabs(ll) > fabs(maxRes)) {
365 maxRes = ll;
366 maxResIndex = ii;
367 maxResPrn = satObs->prn();
368 }
369 }
370 }
371 }
372
373 if (nObs > 0) {
374 offGps = offGps / nObs;
375 }
376 else {
377 offGps = 0.0;
378 }
379
380 if (fabs(maxRes) > 150.0) {
381 LOG << "t_pppClient::cmpOffGps outlier " << maxResPrn.toString() << " " << maxRes << endl;
382 delete obsVector.at(maxResIndex);
383 obsVector.erase(obsVector.begin() + maxResIndex);
384 }
385 else {
386 break;
387 }
388 }
389 }
390 return offGps;
391}
392
393
394// Compute A Priori Glonass Clock Offset
395//////////////////////////////////////////////////////////////////////////////
396double t_pppClient::cmpOffGlo(vector<t_pppSatObs*>& obsVector) {
397
398 t_lc::type tLC = t_lc::dummy;
399 double offGlo = 0.0;
400
401 if (_opt->useSystem('R')) {
402 while (obsVector.size() > 0) {
403 offGlo = 0.0;
404 double maxRes = 0.0;
405 int maxResIndex = -1;
406 unsigned nObs = 0;
407 t_prn maxResPrn;
408 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
409 const t_pppSatObs* satObs = obsVector.at(ii);
410 if (satObs->prn().system() == 'R') {
411 if (tLC == t_lc::dummy) {
412 tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
413 }
414 if (satObs->isValid(tLC) &&
415 (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle)) {
416 double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
417 ++nObs;
418 offGlo += ll;
419 if (fabs(ll) > fabs(maxRes)) {
420 maxRes = ll;
421 maxResIndex = ii;
422 maxResPrn = satObs->prn();
423 }
424 }
425 }
426 }
427
428 if (nObs > 0) {
429 offGlo = offGlo / nObs;
430 }
431 else {
432 offGlo = 0.0;
433 }
434 if (fabs(maxRes) > 150.0) {
435 LOG << "t_pppClient::cmpOffGlo outlier " << maxResPrn.toString() << " " << maxRes << endl;
436 delete obsVector.at(maxResIndex);
437 obsVector.erase(obsVector.begin() + maxResIndex);
438 }
439 else {
440 break;
441 }
442 }
443 }
444 return offGlo;
445}
446
447// Compute A Priori Galileo Clock Offset
448//////////////////////////////////////////////////////////////////////////////
449double t_pppClient::cmpOffGal(vector<t_pppSatObs*>& obsVector) {
450
451 t_lc::type tLC = t_lc::dummy;
452 double offGal = 0.0;
453
454 if (_opt->useSystem('E')) {
455 while (obsVector.size() > 0) {
456 offGal = 0.0;
457 double maxRes = 0.0;
458 int maxResIndex = -1;
459 unsigned nObs = 0;
460 t_prn maxResPrn;
461 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
462 const t_pppSatObs* satObs = obsVector.at(ii);
463 if (satObs->prn().system() == 'E') {
464 if (tLC == t_lc::dummy) {
465 tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
466 }
467 if (satObs->isValid(tLC) && (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle)) {
468 double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
469 ++nObs;
470 offGal += ll;
471 if (fabs(ll) > fabs(maxRes)) {
472 maxRes = ll;
473 maxResIndex = ii;
474 maxResPrn = satObs->prn();
475 }
476 }
477 }
478 }
479
480 if (nObs > 0) {
481 offGal = offGal / nObs;
482 }
483 else {
484 offGal = 0.0;
485 }
486
487 if (fabs(maxRes) > 150.0) {
488 LOG << "t_pppClient::cmpOffGal outlier " << maxResPrn.toString() << " " << maxRes << endl;
489 delete obsVector.at(maxResIndex);
490 obsVector.erase(obsVector.begin() + maxResIndex);
491 }
492 else {
493 break;
494 }
495 }
496 }
497 return offGal;
498}
499// Compute A Priori BDS Clock Offset
500//////////////////////////////////////////////////////////////////////////////
501double t_pppClient::cmpOffBds(vector<t_pppSatObs*>& obsVector) {
502
503 t_lc::type tLC = t_lc::dummy;
504 double offBds = 0.0;
505
506 if (_opt->useSystem('C')) {
507 while (obsVector.size() > 0) {
508 offBds = 0.0;
509 double maxRes = 0.0;
510 int maxResIndex = -1;
511 unsigned nObs = 0;
512 t_prn maxResPrn;
513 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
514 const t_pppSatObs* satObs = obsVector.at(ii);
515 if (satObs->prn().system() == 'C') {
516 if (tLC == t_lc::dummy) {
517 tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
518 }
519 if (satObs->isValid(tLC) &&
520 (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle)) {
521 double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
522 ++nObs;
523 offBds += ll;
524 if (fabs(ll) > fabs(maxRes)) {
525 maxRes = ll;
526 maxResIndex = ii;
527 maxResPrn = satObs->prn();
528 }
529 }
530 }
531 }
532
533 if (nObs > 0) {
534 offBds = offBds / nObs;
535 }
536 else {
537 offBds = 0.0;
538 }
539
540 if (fabs(maxRes) > 150.0) {
541 LOG << "t_pppClient::cmpOffBDS outlier " << maxResPrn.toString() << " " << maxRes << endl;
542 delete obsVector.at(maxResIndex);
543 obsVector.erase(obsVector.begin() + maxResIndex);
544 }
545 else {
546 break;
547 }
548 }
549 }
550 return offBds;
551}
552
553//
554//////////////////////////////////////////////////////////////////////////////
555void t_pppClient::initOutput(t_output* output) {
556 _output = output;
557 _output->_numSat = 0;
558 _output->_hDop = 0.0;
559 _output->_error = false;
560}
561
562//
563//////////////////////////////////////////////////////////////////////////////
564void t_pppClient::clearObs() {
565 for (unsigned ii = 0; ii < _obsRover.size(); ii++) {
566 delete _obsRover.at(ii);
567 }
568 _obsRover.clear();
569}
570
571//
572//////////////////////////////////////////////////////////////////////////////
573void t_pppClient::finish(t_irc irc, int ind) {
574#ifdef BNC_DEBUG_PPP
575 LOG << "t_pppClient::finish(" << ind << "): " << irc << endl;
576#endif
577
578 clearObs();
579
580 _output->_epoTime = _epoTimeRover;
581
582 if (irc == success) {
583 _output->_xyzRover[0] = _staRover->xyzApr()[0] + _filter->x()[0];
584 _output->_xyzRover[1] = _staRover->xyzApr()[1] + _filter->x()[1];
585 _output->_xyzRover[2] = _staRover->xyzApr()[2] + _filter->x()[2];
586
587 xyz2neu(_staRover->ellApr().data(), _filter->x().data(), _output->_neu);
588
589 copy(&_filter->Q().data()[0], &_filter->Q().data()[6], _output->_covMatrix);
590
591 _output->_trp0 = t_tropo::delay_saast(_staRover->xyzApr(), M_PI/2.0);
592 _output->_trp = _filter->trp();
593 _output->_trpStdev = _filter->trpStdev();
594
595 _output->_numSat = _filter->numSat();
596 _output->_hDop = _filter->HDOP();
597 _output->_error = false;
598 }
599 else {
600 _output->_error = true;
601 }
602
603 _output->_log = _log->str();
604 delete _log; _log = new ostringstream();
605
606 return;
607}
608
609//
610//////////////////////////////////////////////////////////////////////////////
611t_irc t_pppClient::cmpModel(t_pppStation* station, const ColumnVector& xyzc,
612 vector<t_pppSatObs*>& obsVector) {
613 bncTime time;
614 time = _epoTimeRover;
615 station->setName(_opt->_roverName);
616 station->setAntName(_opt->_antNameRover);
617 station->setEpochTime(time);
618
619 if (_opt->xyzAprRoverSet()) {
620 station->setXyzApr(_opt->_xyzAprRover);
621 }
622 else {
623 station->setXyzApr(xyzc.Rows(1,3));
624 }
625 station->setNeuEcc(_opt->_neuEccRover);
626
627 // Receiver Clock
628 // --------------
629 station->setDClk(xyzc[3]);
630
631 // Tides
632 // -----
633 station->setTideDsplEarth(_tides->earth(time, station->xyzApr()));
634 station->setTideDsplOcean(_tides->ocean(time, station->xyzApr(), station->name()));
635
636 // Observation model
637 // -----------------
638 vector<t_pppSatObs*>::iterator it = obsVector.begin();
639 while (it != obsVector.end()) {
640 t_pppSatObs* satObs = *it;
641 t_irc modelSetup;
642 if (satObs->isValid()) {
643 modelSetup = satObs->cmpModel(station);
644 }
645 if (satObs->isValid() &&
646 satObs->eleSat() >= _opt->_minEle &&
647 modelSetup == success) {
648 ++it;
649 }
650 else {
651 delete satObs;
652 it = obsVector.erase(it);
653 }
654 }
655
656 return success;
657}
658
659//
660//////////////////////////////////////////////////////////////////////////////
661void t_pppClient::processEpoch(const vector<t_satObs*>& satObs, t_output* output) {
662
663 try {
664 initOutput(output);
665
666 // Prepare Observations of the Rover
667 // ---------------------------------
668 if (prepareObs(satObs, _obsRover, _epoTimeRover) != success) {
669 return finish(failure, 1);
670 }
671
672 for (int iter = 1; iter <= 2; iter++) {
673 ColumnVector xyzc(4); xyzc = 0.0;
674 bool print = (iter == 2);
675 if (cmpBancroft(_epoTimeRover, _obsRover, xyzc, print) != success) {
676 return finish(failure, 2);
677 }
678 if (cmpModel(_staRover, xyzc, _obsRover) != success) {
679 return finish(failure, 3);
680 }
681 }
682 // use observations only if satellite code biases are available
683 /* ------------------------------------------------------------
684 if (!_opt->_corrMount.empty() {
685 useObsWithCodeBiasesOnly(_obsRover);
686 }*/
687
688 if (int(_obsRover.size()) < _opt->_minObs) {
689 LOG << "t_pppClient::processEpoch not enough observations" << endl;
690 return finish(failure, 4);
691 }
692
693 _offGps = cmpOffGps(_obsRover);
694 _offGlo = cmpOffGlo(_obsRover);
695 _offGal = cmpOffGal(_obsRover);
696 _offBds = cmpOffBds(_obsRover);
697
698 // Prepare Pseudo Observations of the Rover
699 // ----------------------------------------
700 _pseudoObsIono = preparePseudoObs(_obsRover);
701
702 // Store last epoch of data
703 // ------------------------
704 _obsPool->putEpoch(_epoTimeRover, _obsRover, _pseudoObsIono);
705
706 // Process Epoch in Filter
707 // -----------------------
708 if (_filter->processEpoch(_obsPool) != success) {
709 LOG << "t_pppFilter::processEpoch() != success" << endl;
710 return finish(failure, 5);
711 }
712 }
713 catch (Exception& exc) {
714 LOG << exc.what() << endl;
715 return finish(failure, 6);
716 }
717 catch (t_except msg) {
718 LOG << msg.what() << endl;
719 return finish(failure, 7);
720 }
721 catch (const char* msg) {
722 LOG << msg << endl;
723 return finish(failure, 8);
724 }
725 catch (...) {
726 LOG << "unknown exception" << endl;
727 return finish(failure, 9);
728 }
729 return finish(success, 0);
730}
731
732//
733////////////////////////////////////////////////////////////////////////////
734double lorentz(const ColumnVector& aa, const ColumnVector& bb) {
735 return aa[0]*bb[0] + aa[1]*bb[1] + aa[2]*bb[2] - aa[3]*bb[3];
736}
737
738//
739////////////////////////////////////////////////////////////////////////////
740t_irc t_pppClient::bancroft(const Matrix& BBpass, ColumnVector& pos) {
741
742 if (pos.Nrows() != 4) {
743 pos.ReSize(4);
744 }
745 pos = 0.0;
746
747 for (int iter = 1; iter <= 2; iter++) {
748 Matrix BB = BBpass;
749 int mm = BB.Nrows();
750 for (int ii = 1; ii <= mm; ii++) {
751 double xx = BB(ii,1);
752 double yy = BB(ii,2);
753 double traveltime = 0.072;
754 if (iter > 1) {
755 double zz = BB(ii,3);
756 double rho = sqrt( (xx-pos(1)) * (xx-pos(1)) +
757 (yy-pos(2)) * (yy-pos(2)) +
758 (zz-pos(3)) * (zz-pos(3)) );
759 traveltime = rho / t_CST::c;
760 }
761 double angle = traveltime * t_CST::omega;
762 double cosa = cos(angle);
763 double sina = sin(angle);
764 BB(ii,1) = cosa * xx + sina * yy;
765 BB(ii,2) = -sina * xx + cosa * yy;
766 }
767
768 Matrix BBB;
769 if (mm > 4) {
770 SymmetricMatrix hlp; hlp << BB.t() * BB;
771 BBB = hlp.i() * BB.t();
772 }
773 else {
774 BBB = BB.i();
775 }
776 ColumnVector ee(mm); ee = 1.0;
777 ColumnVector alpha(mm); alpha = 0.0;
778 for (int ii = 1; ii <= mm; ii++) {
779 alpha(ii) = lorentz(BB.Row(ii).t(),BB.Row(ii).t())/2.0;
780 }
781 ColumnVector BBBe = BBB * ee;
782 ColumnVector BBBalpha = BBB * alpha;
783 double aa = lorentz(BBBe, BBBe);
784 double bb = lorentz(BBBe, BBBalpha)-1;
785 double cc = lorentz(BBBalpha, BBBalpha);
786 double root = sqrt(bb*bb-aa*cc);
787
788 Matrix hlpPos(4,2);
789 hlpPos.Column(1) = (-bb-root)/aa * BBBe + BBBalpha;
790 hlpPos.Column(2) = (-bb+root)/aa * BBBe + BBBalpha;
791
792 ColumnVector omc(2);
793 for (int pp = 1; pp <= 2; pp++) {
794 hlpPos(4,pp) = -hlpPos(4,pp);
795 omc(pp) = BB(1,4) -
796 sqrt( (BB(1,1)-hlpPos(1,pp)) * (BB(1,1)-hlpPos(1,pp)) +
797 (BB(1,2)-hlpPos(2,pp)) * (BB(1,2)-hlpPos(2,pp)) +
798 (BB(1,3)-hlpPos(3,pp)) * (BB(1,3)-hlpPos(3,pp)) ) -
799 hlpPos(4,pp);
800 }
801 if ( fabs(omc(1)) > fabs(omc(2)) ) {
802 pos = hlpPos.Column(2);
803 }
804 else {
805 pos = hlpPos.Column(1);
806 }
807 }
808 if (pos.size() != 4 ||
809 std::isnan(pos(1)) ||
810 std::isnan(pos(2)) ||
811 std::isnan(pos(3)) ||
812 std::isnan(pos(4))) {
813 return failure;
814 }
815
816 return success;
817}
818
819//
820//////////////////////////////////////////////////////////////////////////////
821void t_pppClient::reset() {
822
823 // to delete old orbit and clock corrections
824 delete _ephPool;
825 _ephPool = new t_pppEphPool();
826
827 // to delete old code biases
828 delete _obsPool;
829 _obsPool = new t_pppObsPool();
830
831 // to delete all parameters
832 delete _filter;
833 _filter = new t_pppFilter();
834
835}
Note: See TracBrowser for help on using the repository browser.