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