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