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

Last change on this file was 10397, checked in by stuerze, 5 weeks 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 char sys = satObs->prn().system();
304 if (satObs->isValid() &&
305 (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle) ) {
306 ColumnVector rr = satObs->xc().Rows(1,3) - xyzc.Rows(1,3);
307 double res = rr.NormFrobenius() - satObs->obsValue(tLC)
308 - (satObs->xc()[3] - xyzc[3]) * t_CST::c;
309 if (fabs(res) > maxRes) {
310 maxRes = fabs(res);
311 maxResIndex = ii;
312 }
313 }
314 }
315 if (maxRes < BLUNDER) {
316 if (print) {
317 LOG.setf(ios::fixed);
318 LOG << "\nPPP of Epoch ";
319 if (!_epoTimeRover.undef()) LOG << string(_epoTimeRover);
320 LOG << "\n---------------------------------------------------------------\n";
321 LOG << string(epoTime) << " BANCROFT: "
322 << setw(14) << setprecision(3) << xyzc[0] << ' '
323 << setw(14) << setprecision(3) << xyzc[1] << ' '
324 << setw(14) << setprecision(3) << xyzc[2] << ' '
325 << setw(14) << setprecision(3) << xyzc[3] * t_CST::c << endl << endl;
326 }
327 break;
328 }
329 else {
330 t_pppSatObs* satObs = obsVector.at(maxResIndex);
331 LOG << "t_pppClient::cmpBancroft Outlier " << satObs->prn().toString()
332 << " " << maxRes << endl;
333 delete satObs;
334 obsVector.erase(obsVector.begin() + maxResIndex);
335 }
336 }
337
338 return success;
339}
340
341// Compute A Priori Gps Clock Offset
342//////////////////////////////////////////////////////////////////////////////
343double t_pppClient::cmpOffGps(vector<t_pppSatObs*>& obsVector) {
344
345 t_lc::type tLC = t_lc::dummy;
346 double offGps = 0.0;
347
348 if (_opt->useSystem('G')) {
349 while (obsVector.size() > 0) {
350 offGps = 0.0;
351 double maxRes = 0.0;
352 int maxResIndex = -1;
353 unsigned nObs = 0;
354 t_prn maxResPrn;
355 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
356 const t_pppSatObs* satObs = obsVector.at(ii);
357 if (satObs->prn().system() == 'G') {
358 if (tLC == t_lc::dummy) {
359 tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
360 }
361 if (satObs->isValid(tLC) && (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle)) {
362 double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
363 ++nObs;
364 offGps += ll;
365 if (fabs(ll) > fabs(maxRes)) {
366 maxRes = ll;
367 maxResIndex = ii;
368 maxResPrn = satObs->prn();
369 }
370 }
371 }
372 }
373
374 if (nObs > 0) {
375 offGps = offGps / nObs;
376 }
377 else {
378 offGps = 0.0;
379 }
380
381 if (fabs(maxRes) > 150.0) {
382 LOG << "t_pppClient::cmpOffGps outlier " << maxResPrn.toString() << " " << maxRes << endl;
383 delete obsVector.at(maxResIndex);
384 obsVector.erase(obsVector.begin() + maxResIndex);
385 }
386 else {
387 break;
388 }
389 }
390 }
391 return offGps;
392}
393
394
395// Compute A Priori Glonass Clock Offset
396//////////////////////////////////////////////////////////////////////////////
397double t_pppClient::cmpOffGlo(vector<t_pppSatObs*>& obsVector) {
398
399 t_lc::type tLC = t_lc::dummy;
400 double offGlo = 0.0;
401
402 if (_opt->useSystem('R')) {
403 while (obsVector.size() > 0) {
404 offGlo = 0.0;
405 double maxRes = 0.0;
406 int maxResIndex = -1;
407 unsigned nObs = 0;
408 t_prn maxResPrn;
409 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
410 const t_pppSatObs* satObs = obsVector.at(ii);
411 if (satObs->prn().system() == 'R') {
412 if (tLC == t_lc::dummy) {
413 tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
414 }
415 if (satObs->isValid(tLC) &&
416 (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle)) {
417 double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
418 ++nObs;
419 offGlo += ll;
420 if (fabs(ll) > fabs(maxRes)) {
421 maxRes = ll;
422 maxResIndex = ii;
423 maxResPrn = satObs->prn();
424 }
425 }
426 }
427 }
428
429 if (nObs > 0) {
430 offGlo = offGlo / nObs;
431 }
432 else {
433 offGlo = 0.0;
434 }
435 if (fabs(maxRes) > 150.0) {
436 LOG << "t_pppClient::cmpOffGlo outlier " << maxResPrn.toString() << " " << maxRes << endl;
437 delete obsVector.at(maxResIndex);
438 obsVector.erase(obsVector.begin() + maxResIndex);
439 }
440 else {
441 break;
442 }
443 }
444 }
445 return offGlo;
446}
447
448// Compute A Priori Galileo Clock Offset
449//////////////////////////////////////////////////////////////////////////////
450double t_pppClient::cmpOffGal(vector<t_pppSatObs*>& obsVector) {
451
452 t_lc::type tLC = t_lc::dummy;
453 double offGal = 0.0;
454
455 if (_opt->useSystem('E')) {
456 while (obsVector.size() > 0) {
457 offGal = 0.0;
458 double maxRes = 0.0;
459 int maxResIndex = -1;
460 unsigned nObs = 0;
461 t_prn maxResPrn;
462 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
463 const t_pppSatObs* satObs = obsVector.at(ii);
464 if (satObs->prn().system() == 'E') {
465 if (tLC == t_lc::dummy) {
466 tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
467 }
468 if (satObs->isValid(tLC) && (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle)) {
469 double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
470 ++nObs;
471 offGal += ll;
472 if (fabs(ll) > fabs(maxRes)) {
473 maxRes = ll;
474 maxResIndex = ii;
475 maxResPrn = satObs->prn();
476 }
477 }
478 }
479 }
480
481 if (nObs > 0) {
482 offGal = offGal / nObs;
483 }
484 else {
485 offGal = 0.0;
486 }
487
488 if (fabs(maxRes) > 150.0) {
489 LOG << "t_pppClient::cmpOffGal outlier " << maxResPrn.toString() << " " << maxRes << endl;
490 delete obsVector.at(maxResIndex);
491 obsVector.erase(obsVector.begin() + maxResIndex);
492 }
493 else {
494 break;
495 }
496 }
497 }
498 return offGal;
499}
500// Compute A Priori BDS Clock Offset
501//////////////////////////////////////////////////////////////////////////////
502double t_pppClient::cmpOffBds(vector<t_pppSatObs*>& obsVector) {
503
504 t_lc::type tLC = t_lc::dummy;
505 double offBds = 0.0;
506
507 if (_opt->useSystem('C')) {
508 while (obsVector.size() > 0) {
509 offBds = 0.0;
510 double maxRes = 0.0;
511 int maxResIndex = -1;
512 unsigned nObs = 0;
513 t_prn maxResPrn;
514 for (unsigned ii = 0; ii < obsVector.size(); ii++) {
515 const t_pppSatObs* satObs = obsVector.at(ii);
516 if (satObs->prn().system() == 'C') {
517 if (tLC == t_lc::dummy) {
518 tLC = satObs->isValid(t_lc::cIF) ? t_lc::cIF : t_lc::c1;
519 }
520 if (satObs->isValid(tLC) &&
521 (!satObs->modelSet() || satObs->eleSat() >= _opt->_minEle)) {
522 double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
523 ++nObs;
524 offBds += ll;
525 if (fabs(ll) > fabs(maxRes)) {
526 maxRes = ll;
527 maxResIndex = ii;
528 maxResPrn = satObs->prn();
529 }
530 }
531 }
532 }
533
534 if (nObs > 0) {
535 offBds = offBds / nObs;
536 }
537 else {
538 offBds = 0.0;
539 }
540
541 if (fabs(maxRes) > 150.0) {
542 LOG << "t_pppClient::cmpOffBDS outlier " << maxResPrn.toString() << " " << maxRes << endl;
543 delete obsVector.at(maxResIndex);
544 obsVector.erase(obsVector.begin() + maxResIndex);
545 }
546 else {
547 break;
548 }
549 }
550 }
551 return offBds;
552}
553
554//
555//////////////////////////////////////////////////////////////////////////////
556void t_pppClient::initOutput(t_output* output) {
557 _output = output;
558 _output->_numSat = 0;
559 _output->_hDop = 0.0;
560 _output->_error = false;
561}
562
563//
564//////////////////////////////////////////////////////////////////////////////
565void t_pppClient::clearObs() {
566 for (unsigned ii = 0; ii < _obsRover.size(); ii++) {
567 delete _obsRover.at(ii);
568 }
569 _obsRover.clear();
570}
571
572//
573//////////////////////////////////////////////////////////////////////////////
574void t_pppClient::finish(t_irc irc, int ind) {
575#ifdef BNC_DEBUG_PPP
576 LOG << "t_pppClient::finish(" << ind << "): " << irc << endl;
577#endif
578
579 clearObs();
580
581 _output->_epoTime = _epoTimeRover;
582
583 if (irc == success) {
584 _output->_xyzRover[0] = _staRover->xyzApr()[0] + _filter->x()[0];
585 _output->_xyzRover[1] = _staRover->xyzApr()[1] + _filter->x()[1];
586 _output->_xyzRover[2] = _staRover->xyzApr()[2] + _filter->x()[2];
587
588 xyz2neu(_staRover->ellApr().data(), _filter->x().data(), _output->_neu);
589
590 copy(&_filter->Q().data()[0], &_filter->Q().data()[6], _output->_covMatrix);
591
592 _output->_trp0 = t_tropo::delay_saast(_staRover->xyzApr(), M_PI/2.0);
593 _output->_trp = _filter->trp();
594 _output->_trpStdev = _filter->trpStdev();
595
596 _output->_numSat = _filter->numSat();
597 _output->_hDop = _filter->HDOP();
598 _output->_error = false;
599 }
600 else {
601 _output->_error = true;
602 }
603
604 _output->_log = _log->str();
605 delete _log; _log = new ostringstream();
606
607 return;
608}
609
610//
611//////////////////////////////////////////////////////////////////////////////
612t_irc t_pppClient::cmpModel(t_pppStation* station, const ColumnVector& xyzc,
613 vector<t_pppSatObs*>& obsVector) {
614 bncTime time;
615 time = _epoTimeRover;
616 station->setName(_opt->_roverName);
617 station->setAntName(_opt->_antNameRover);
618 station->setEpochTime(time);
619
620 if (_opt->xyzAprRoverSet()) {
621 station->setXyzApr(_opt->_xyzAprRover);
622 }
623 else {
624 station->setXyzApr(xyzc.Rows(1,3));
625 }
626 station->setNeuEcc(_opt->_neuEccRover);
627
628 // Receiver Clock
629 // --------------
630 station->setDClk(xyzc[3]);
631
632 // Tides
633 // -----
634 station->setTideDsplEarth(_tides->earth(time, station->xyzApr()));
635 station->setTideDsplOcean(_tides->ocean(time, station->xyzApr(), station->name()));
636
637 // Observation model
638 // -----------------
639 vector<t_pppSatObs*>::iterator it = obsVector.begin();
640 while (it != obsVector.end()) {
641 t_pppSatObs* satObs = *it;
642 t_irc modelSetup;
643 if (satObs->isValid()) {
644 modelSetup = satObs->cmpModel(station);
645 }
646 if (satObs->isValid() &&
647 satObs->eleSat() >= _opt->_minEle &&
648 modelSetup == success) {
649 ++it;
650 }
651 else {
652 delete satObs;
653 it = obsVector.erase(it);
654 }
655 }
656
657 return success;
658}
659
660//
661//////////////////////////////////////////////////////////////////////////////
662void t_pppClient::processEpoch(const vector<t_satObs*>& satObs, t_output* output) {
663
664 try {
665 initOutput(output);
666
667 // Prepare Observations of the Rover
668 // ---------------------------------
669 if (prepareObs(satObs, _obsRover, _epoTimeRover) != success) {
670 return finish(failure, 1);
671 }
672
673 for (int iter = 1; iter <= 2; iter++) {
674 ColumnVector xyzc(4); xyzc = 0.0;
675 bool print = (iter == 2);
676 if (cmpBancroft(_epoTimeRover, _obsRover, xyzc, print) != success) {
677 return finish(failure, 2);
678 }
679 if (cmpModel(_staRover, xyzc, _obsRover) != success) {
680 return finish(failure, 3);
681 }
682 }
683 // use observations only if satellite code biases are available
684 /* ------------------------------------------------------------
685 if (!_opt->_corrMount.empty() {
686 useObsWithCodeBiasesOnly(_obsRover);
687 }*/
688
689 if (int(_obsRover.size()) < _opt->_minObs) {
690 LOG << "t_pppClient::processEpoch not enough observations" << endl;
691 return finish(failure, 4);
692 }
693
694 _offGps = cmpOffGps(_obsRover);
695 _offGlo = cmpOffGlo(_obsRover);
696 _offGal = cmpOffGal(_obsRover);
697 _offBds = cmpOffBds(_obsRover);
698
699 // Prepare Pseudo Observations of the Rover
700 // ----------------------------------------
701 _pseudoObsIono = preparePseudoObs(_obsRover);
702
703 // Store last epoch of data
704 // ------------------------
705 _obsPool->putEpoch(_epoTimeRover, _obsRover, _pseudoObsIono);
706
707 // Process Epoch in Filter
708 // -----------------------
709 if (_filter->processEpoch(_obsPool) != success) {
710 LOG << "t_pppFilter::processEpoch() != success" << endl;
711 return finish(failure, 5);
712 }
713 }
714 catch (Exception& exc) {
715 LOG << exc.what() << endl;
716 return finish(failure, 6);
717 }
718 catch (t_except msg) {
719 LOG << msg.what() << endl;
720 return finish(failure, 7);
721 }
722 catch (const char* msg) {
723 LOG << msg << endl;
724 return finish(failure, 8);
725 }
726 catch (...) {
727 LOG << "unknown exception" << endl;
728 return finish(failure, 9);
729 }
730 return finish(success, 0);
731}
732
733//
734////////////////////////////////////////////////////////////////////////////
735double lorentz(const ColumnVector& aa, const ColumnVector& bb) {
736 return aa[0]*bb[0] + aa[1]*bb[1] + aa[2]*bb[2] - aa[3]*bb[3];
737}
738
739//
740////////////////////////////////////////////////////////////////////////////
741t_irc t_pppClient::bancroft(const Matrix& BBpass, ColumnVector& pos) {
742
743 if (pos.Nrows() != 4) {
744 pos.ReSize(4);
745 }
746 pos = 0.0;
747
748 for (int iter = 1; iter <= 2; iter++) {
749 Matrix BB = BBpass;
750 int mm = BB.Nrows();
751 for (int ii = 1; ii <= mm; ii++) {
752 double xx = BB(ii,1);
753 double yy = BB(ii,2);
754 double traveltime = 0.072;
755 if (iter > 1) {
756 double zz = BB(ii,3);
757 double rho = sqrt( (xx-pos(1)) * (xx-pos(1)) +
758 (yy-pos(2)) * (yy-pos(2)) +
759 (zz-pos(3)) * (zz-pos(3)) );
760 traveltime = rho / t_CST::c;
761 }
762 double angle = traveltime * t_CST::omega;
763 double cosa = cos(angle);
764 double sina = sin(angle);
765 BB(ii,1) = cosa * xx + sina * yy;
766 BB(ii,2) = -sina * xx + cosa * yy;
767 }
768
769 Matrix BBB;
770 if (mm > 4) {
771 SymmetricMatrix hlp; hlp << BB.t() * BB;
772 BBB = hlp.i() * BB.t();
773 }
774 else {
775 BBB = BB.i();
776 }
777 ColumnVector ee(mm); ee = 1.0;
778 ColumnVector alpha(mm); alpha = 0.0;
779 for (int ii = 1; ii <= mm; ii++) {
780 alpha(ii) = lorentz(BB.Row(ii).t(),BB.Row(ii).t())/2.0;
781 }
782 ColumnVector BBBe = BBB * ee;
783 ColumnVector BBBalpha = BBB * alpha;
784 double aa = lorentz(BBBe, BBBe);
785 double bb = lorentz(BBBe, BBBalpha)-1;
786 double cc = lorentz(BBBalpha, BBBalpha);
787 double root = sqrt(bb*bb-aa*cc);
788
789 Matrix hlpPos(4,2);
790 hlpPos.Column(1) = (-bb-root)/aa * BBBe + BBBalpha;
791 hlpPos.Column(2) = (-bb+root)/aa * BBBe + BBBalpha;
792
793 ColumnVector omc(2);
794 for (int pp = 1; pp <= 2; pp++) {
795 hlpPos(4,pp) = -hlpPos(4,pp);
796 omc(pp) = BB(1,4) -
797 sqrt( (BB(1,1)-hlpPos(1,pp)) * (BB(1,1)-hlpPos(1,pp)) +
798 (BB(1,2)-hlpPos(2,pp)) * (BB(1,2)-hlpPos(2,pp)) +
799 (BB(1,3)-hlpPos(3,pp)) * (BB(1,3)-hlpPos(3,pp)) ) -
800 hlpPos(4,pp);
801 }
802 if ( fabs(omc(1)) > fabs(omc(2)) ) {
803 pos = hlpPos.Column(2);
804 }
805 else {
806 pos = hlpPos.Column(1);
807 }
808 }
809 if (pos.size() != 4 ||
810 std::isnan(pos(1)) ||
811 std::isnan(pos(2)) ||
812 std::isnan(pos(3)) ||
813 std::isnan(pos(4))) {
814 return failure;
815 }
816
817 return success;
818}
819
820//
821//////////////////////////////////////////////////////////////////////////////
822void t_pppClient::reset() {
823
824 // to delete old orbit and clock corrections
825 delete _ephPool;
826 _ephPool = new t_pppEphPool();
827
828 // to delete old code biases
829 delete _obsPool;
830 _obsPool = new t_pppObsPool();
831
832 // to delete all parameters
833 delete _filter;
834 _filter = new t_pppFilter();
835
836}
Note: See TracBrowser for help on using the repository browser.