[5683] | 1 |
|
---|
[5740] | 2 | // Part of BNC, a utility for retrieving decoding and
|
---|
| 3 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
| 4 | //
|
---|
| 5 | // Copyright (C) 2007
|
---|
| 6 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 7 | // http://www.bkg.bund.de
|
---|
| 8 | // Czech Technical University Prague, Department of Geodesy
|
---|
| 9 | // http://www.fsv.cvut.cz
|
---|
| 10 | //
|
---|
| 11 | // Email: euref-ip@bkg.bund.de
|
---|
| 12 | //
|
---|
| 13 | // This program is free software; you can redistribute it and/or
|
---|
| 14 | // modify it under the terms of the GNU General Public License
|
---|
| 15 | // as published by the Free Software Foundation, version 2.
|
---|
| 16 | //
|
---|
| 17 | // This program is distributed in the hope that it will be useful,
|
---|
| 18 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 20 | // GNU General Public License for more details.
|
---|
| 21 | //
|
---|
| 22 | // You should have received a copy of the GNU General Public License
|
---|
| 23 | // along with this program; if not, write to the Free Software
|
---|
| 24 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
| 25 |
|
---|
| 26 | /* -------------------------------------------------------------------------
|
---|
| 27 | * BKG NTRIP Client
|
---|
| 28 | * -------------------------------------------------------------------------
|
---|
| 29 | *
|
---|
| 30 | * Class: t_pppClient
|
---|
| 31 | *
|
---|
| 32 | * Purpose: PPP Client processing starts here
|
---|
| 33 | *
|
---|
| 34 | * Author: L. Mervart
|
---|
| 35 | *
|
---|
| 36 | * Created: 29-Jul-2014
|
---|
| 37 | *
|
---|
| 38 | * Changes:
|
---|
| 39 | *
|
---|
| 40 | * -----------------------------------------------------------------------*/
|
---|
| 41 |
|
---|
[5758] | 42 | #include <QThreadStorage>
|
---|
[5740] | 43 |
|
---|
[5683] | 44 | #include <iostream>
|
---|
| 45 | #include <iomanip>
|
---|
| 46 | #include <stdlib.h>
|
---|
| 47 | #include <string.h>
|
---|
| 48 | #include <stdexcept>
|
---|
| 49 |
|
---|
[5734] | 50 | #include "pppClient.h"
|
---|
[5810] | 51 | #include "pppEphPool.h"
|
---|
| 52 | #include "pppObsPool.h"
|
---|
| 53 | #include "pppSatBias.h"
|
---|
[5740] | 54 | #include "bncconst.h"
|
---|
| 55 | #include "bncutils.h"
|
---|
[5810] | 56 | #include "pppStation.h"
|
---|
[5740] | 57 | #include "bncantex.h"
|
---|
[5810] | 58 | #include "pppFilter.h"
|
---|
[5683] | 59 |
|
---|
[5814] | 60 | using namespace BNC_PPP;
|
---|
[5683] | 61 | using namespace std;
|
---|
| 62 |
|
---|
[5758] | 63 | // Global variable holding thread-specific pointers
|
---|
[5683] | 64 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5758] | 65 | QThreadStorage<t_pppClient*> CLIENTS;
|
---|
[5683] | 66 |
|
---|
[5758] | 67 | // Static function returning thread-specific pointer
|
---|
| 68 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 69 | t_pppClient* t_pppClient::instance() {
|
---|
| 70 | return CLIENTS.localData();
|
---|
| 71 | }
|
---|
| 72 |
|
---|
[5683] | 73 | // Constructor
|
---|
| 74 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5810] | 75 | t_pppClient::t_pppClient(const t_pppOptions* opt) {
|
---|
[5683] | 76 | _output = 0;
|
---|
[5810] | 77 | _opt = new t_pppOptions(*opt);
|
---|
[5683] | 78 | _log = new ostringstream();
|
---|
[5810] | 79 | _ephPool = new t_pppEphPool();
|
---|
[5819] | 80 | _obsPool = new t_frqObsPool();
|
---|
[5810] | 81 | _staRover = new t_pppStation();
|
---|
| 82 | _filter = new t_pppFilter();
|
---|
[5802] | 83 | _tides = new t_tides();
|
---|
[5761] | 84 |
|
---|
| 85 | if (!_opt->_antexFile.empty()) {
|
---|
| 86 | _antex = new bncAntex(_opt->_antexFile.c_str());
|
---|
| 87 | }
|
---|
| 88 | else {
|
---|
| 89 | _antex = 0;
|
---|
| 90 | }
|
---|
| 91 |
|
---|
[5759] | 92 | CLIENTS.setLocalData(this); // CLIENTS takes ownership over "this"
|
---|
[5683] | 93 | }
|
---|
| 94 |
|
---|
| 95 | // Destructor
|
---|
| 96 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5734] | 97 | t_pppClient::~t_pppClient() {
|
---|
[5683] | 98 | delete _log;
|
---|
| 99 | delete _opt;
|
---|
| 100 | delete _ephPool;
|
---|
| 101 | delete _obsPool;
|
---|
| 102 | delete _staRover;
|
---|
| 103 | delete _antex;
|
---|
| 104 | delete _filter;
|
---|
[5802] | 105 | delete _tides;
|
---|
[5683] | 106 | clearObs();
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | //
|
---|
| 110 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5772] | 111 | void t_pppClient::putEphemeris(const t_eph* eph) {
|
---|
| 112 | const t_ephGPS* ephGPS = dynamic_cast<const t_ephGPS*>(eph);
|
---|
| 113 | const t_ephGlo* ephGlo = dynamic_cast<const t_ephGlo*>(eph);
|
---|
| 114 | const t_ephGal* ephGal = dynamic_cast<const t_ephGal*>(eph);
|
---|
| 115 | if (ephGPS) {
|
---|
| 116 | _ephPool->putEphemeris(new t_ephGPS(*ephGPS));
|
---|
| 117 | }
|
---|
| 118 | else if (ephGlo) {
|
---|
| 119 | _ephPool->putEphemeris(new t_ephGlo(*ephGlo));
|
---|
| 120 | }
|
---|
| 121 | else if (ephGal) {
|
---|
| 122 | _ephPool->putEphemeris(new t_ephGal(*ephGal));
|
---|
| 123 | }
|
---|
[5683] | 124 | }
|
---|
| 125 |
|
---|
| 126 | //
|
---|
| 127 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5779] | 128 | void t_pppClient::putOrbCorrections(const vector<t_orbCorr*>& corr) {
|
---|
[5772] | 129 | for (unsigned ii = 0; ii < corr.size(); ii++) {
|
---|
[5779] | 130 | _ephPool->putOrbCorrection(new t_orbCorr(*corr[ii]));
|
---|
[5683] | 131 | }
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | //
|
---|
| 135 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5779] | 136 | void t_pppClient::putClkCorrections(const vector<t_clkCorr*>& corr) {
|
---|
[5772] | 137 | for (unsigned ii = 0; ii < corr.size(); ii++) {
|
---|
[5779] | 138 | _ephPool->putClkCorrection(new t_clkCorr(*corr[ii]));
|
---|
[5683] | 139 | }
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | //
|
---|
| 143 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5779] | 144 | void t_pppClient::putBiases(const vector<t_satBiases*>& biases) {
|
---|
[5772] | 145 | for (unsigned ii = 0; ii < biases.size(); ii++) {
|
---|
[5818] | 146 | _obsPool->putBiases(new t_pppSatBias(*biases[ii]));
|
---|
[5683] | 147 | }
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | //
|
---|
| 151 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5819] | 152 | t_irc t_pppClient::prepareObs(const vector<t_satObs*>& pppSatObs,
|
---|
| 153 | vector<t_pppSatObs*>& obsVector, bncTime& epoTime) {
|
---|
[5683] | 154 | // Default
|
---|
| 155 | // -------
|
---|
| 156 | epoTime.reset();
|
---|
| 157 |
|
---|
| 158 | // Create vector of valid observations
|
---|
| 159 | // -----------------------------------
|
---|
| 160 | int numValidGPS = 0;
|
---|
[5772] | 161 | for (unsigned ii = 0; ii < pppSatObs.size(); ii++) {
|
---|
[5778] | 162 | char system = pppSatObs[ii]->_prn.system();
|
---|
[5683] | 163 | if (system == 'G' || (system == 'R' && OPT->useGlonass())) {
|
---|
[5819] | 164 | t_pppSatObs* satObs = new t_pppSatObs(*pppSatObs[ii]);
|
---|
[5683] | 165 | if (satObs->isValid()) {
|
---|
| 166 | obsVector.push_back(satObs);
|
---|
| 167 | if (satObs->prn().system() == 'G') {
|
---|
| 168 | ++numValidGPS;
|
---|
| 169 | }
|
---|
| 170 | }
|
---|
| 171 | else {
|
---|
| 172 | delete satObs;
|
---|
| 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++) {
|
---|
[5819] | 182 | const t_pppSatObs* satObs = obsVector.at(ii);
|
---|
[5683] | 183 | if (epoTime.undef()) {
|
---|
| 184 | epoTime = satObs->time();
|
---|
| 185 | }
|
---|
| 186 | else {
|
---|
| 187 | double dt = satObs->time() - epoTime;
|
---|
| 188 | if (fabs(dt) > MAXSYNC) {
|
---|
[5734] | 189 | LOG << "t_pppClient::prepareObs asynchronous observations" << endl;
|
---|
[5740] | 190 | return failure;
|
---|
[5683] | 191 | }
|
---|
| 192 | meanDt += dt;
|
---|
| 193 | }
|
---|
| 194 | }
|
---|
| 195 |
|
---|
[5787] | 196 | if (obsVector.size() > 0) {
|
---|
| 197 | epoTime += meanDt / obsVector.size();
|
---|
| 198 | }
|
---|
| 199 |
|
---|
[5740] | 200 | return success;
|
---|
[5683] | 201 | }
|
---|
| 202 |
|
---|
| 203 | // Compute the Bancroft position, check for blunders
|
---|
| 204 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5740] | 205 | t_irc t_pppClient::cmpBancroft(const bncTime& epoTime,
|
---|
[5819] | 206 | vector<t_pppSatObs*>& obsVector,
|
---|
[5683] | 207 | ColumnVector& xyzc, bool print) {
|
---|
| 208 |
|
---|
| 209 | t_lc::type tLC = (OPT->dualFreqRequired() ? t_lc::cIF : t_lc::c1);
|
---|
| 210 |
|
---|
| 211 | while (true) {
|
---|
| 212 | Matrix BB(obsVector.size(), 4);
|
---|
| 213 | int iObs = -1;
|
---|
| 214 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
[5819] | 215 | const t_pppSatObs* satObs = obsVector.at(ii);
|
---|
[5683] | 216 | if ( satObs->isValid() && satObs->prn().system() == 'G' &&
|
---|
[5740] | 217 | (!satObs->modelSet() || satObs->eleSat() >= OPT->_minEle) ) {
|
---|
[5683] | 218 | ++iObs;
|
---|
| 219 | BB[iObs][0] = satObs->xc()[0];
|
---|
| 220 | BB[iObs][1] = satObs->xc()[1];
|
---|
| 221 | BB[iObs][2] = satObs->xc()[2];
|
---|
| 222 | BB[iObs][3] = satObs->obsValue(tLC) - satObs->cmpValueForBanc(tLC);
|
---|
| 223 | }
|
---|
| 224 | }
|
---|
[5740] | 225 | if (iObs + 1 < OPT->_minObs) {
|
---|
[5734] | 226 | LOG << "t_pppClient::cmpBancroft not enough observations" << endl;
|
---|
[5740] | 227 | return failure;
|
---|
[5683] | 228 | }
|
---|
| 229 | BB = BB.Rows(1,iObs+1);
|
---|
| 230 | bancroft(BB, xyzc);
|
---|
| 231 |
|
---|
[5740] | 232 | xyzc[3] /= t_CST::c;
|
---|
[5683] | 233 |
|
---|
| 234 | // Check Blunders
|
---|
| 235 | // --------------
|
---|
| 236 | const double BLUNDER = 100.0;
|
---|
| 237 | double maxRes = 0.0;
|
---|
| 238 | unsigned maxResIndex = 0;
|
---|
| 239 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
[5819] | 240 | const t_pppSatObs* satObs = obsVector.at(ii);
|
---|
[5683] | 241 | if ( satObs->isValid() && satObs->prn().system() == 'G' &&
|
---|
[5740] | 242 | (!satObs->modelSet() || satObs->eleSat() >= OPT->_minEle) ) {
|
---|
[5683] | 243 | ColumnVector rr = satObs->xc().Rows(1,3) - xyzc.Rows(1,3);
|
---|
| 244 | double res = rr.norm_Frobenius() - satObs->obsValue(tLC)
|
---|
[5740] | 245 | - (satObs->xc()[3] - xyzc[3]) * t_CST::c;
|
---|
[5683] | 246 | if (fabs(res) > maxRes) {
|
---|
| 247 | maxRes = fabs(res);
|
---|
| 248 | maxResIndex = ii;
|
---|
| 249 | }
|
---|
| 250 | }
|
---|
| 251 | }
|
---|
| 252 | if (maxRes < BLUNDER) {
|
---|
| 253 | if (print) {
|
---|
| 254 | LOG.setf(ios::fixed);
|
---|
| 255 | LOG << string(epoTime) << " BANCROFT:" << ' '
|
---|
| 256 | << setw(14) << setprecision(3) << xyzc[0] << ' '
|
---|
| 257 | << setw(14) << setprecision(3) << xyzc[1] << ' '
|
---|
| 258 | << setw(14) << setprecision(3) << xyzc[2] << ' '
|
---|
[5740] | 259 | << setw(14) << setprecision(3) << xyzc[3] * t_CST::c << endl << endl;
|
---|
[5683] | 260 | }
|
---|
| 261 | break;
|
---|
| 262 | }
|
---|
| 263 | else {
|
---|
[5819] | 264 | t_pppSatObs* satObs = obsVector.at(maxResIndex);
|
---|
[5734] | 265 | LOG << "t_pppClient::cmpBancroft outlier " << satObs->prn().toString()
|
---|
[5683] | 266 | << " " << maxRes << endl;
|
---|
| 267 | delete satObs;
|
---|
| 268 | obsVector.erase(obsVector.begin() + maxResIndex);
|
---|
| 269 | }
|
---|
| 270 | }
|
---|
| 271 |
|
---|
[5740] | 272 | return success;
|
---|
[5683] | 273 | }
|
---|
| 274 |
|
---|
| 275 | // Compute A Priori GPS-Glonass Offset
|
---|
| 276 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5819] | 277 | double t_pppClient::cmpOffGG(vector<t_pppSatObs*>& obsVector) {
|
---|
[5683] | 278 |
|
---|
| 279 | t_lc::type tLC = (OPT->dualFreqRequired() ? t_lc::cIF : t_lc::c1);
|
---|
| 280 | double offGG = 0.0;
|
---|
| 281 |
|
---|
| 282 | if (OPT->useGlonass()) {
|
---|
| 283 | while (true) {
|
---|
| 284 | offGG = 0.0;
|
---|
| 285 | bool outlierFound = false;
|
---|
| 286 | unsigned nObs = 0;
|
---|
| 287 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
[5819] | 288 | t_pppSatObs* satObs = obsVector.at(ii);
|
---|
[5683] | 289 | if ( !satObs->outlier() && satObs->isValid() && satObs->prn().system() == 'R' &&
|
---|
[5740] | 290 | (!satObs->modelSet() || satObs->eleSat() >= OPT->_minEle) ) {
|
---|
[5683] | 291 | ++nObs;
|
---|
| 292 | double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
|
---|
| 293 | if (fabs(ll) > 1000.0) {
|
---|
| 294 | satObs->setOutlier();
|
---|
| 295 | outlierFound = true;
|
---|
[5734] | 296 | LOG << "t_pppClient::cmpOffGG outlier " << satObs->prn().toString()
|
---|
[5683] | 297 | << " " << ll << endl;
|
---|
| 298 | }
|
---|
| 299 | offGG += ll;
|
---|
| 300 | }
|
---|
| 301 | }
|
---|
| 302 | if (nObs > 0) {
|
---|
| 303 | offGG = offGG / nObs;
|
---|
| 304 | }
|
---|
| 305 | else {
|
---|
| 306 | offGG = 0.0;
|
---|
| 307 | }
|
---|
| 308 | if (!outlierFound) {
|
---|
| 309 | break;
|
---|
| 310 | }
|
---|
| 311 | }
|
---|
| 312 | }
|
---|
| 313 |
|
---|
| 314 | return offGG;
|
---|
| 315 | }
|
---|
| 316 |
|
---|
| 317 | //
|
---|
| 318 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5744] | 319 | void t_pppClient::initOutput(t_output* output) {
|
---|
[5683] | 320 | _output = output;
|
---|
[5740] | 321 | _output->_numSat = 0;
|
---|
| 322 | _output->_pDop = 0.0;
|
---|
| 323 | _output->_error = false;
|
---|
[5683] | 324 | }
|
---|
| 325 |
|
---|
| 326 | //
|
---|
| 327 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5734] | 328 | void t_pppClient::clearObs() {
|
---|
[5683] | 329 | for (unsigned ii = 0; ii < _obsRover.size(); ii++) {
|
---|
| 330 | delete _obsRover.at(ii);
|
---|
| 331 | }
|
---|
| 332 | _obsRover.clear();
|
---|
| 333 | }
|
---|
| 334 |
|
---|
| 335 | //
|
---|
| 336 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5740] | 337 | void t_pppClient::finish(t_irc irc) {
|
---|
[5683] | 338 |
|
---|
| 339 | clearObs();
|
---|
| 340 |
|
---|
[5740] | 341 | _output->_epoTime = _epoTimeRover;
|
---|
[5683] | 342 |
|
---|
[5740] | 343 | if (irc == success) {
|
---|
[5683] | 344 | _output->_xyzRover[0] = _staRover->xyzApr()[0] + _filter->x()[0];
|
---|
| 345 | _output->_xyzRover[1] = _staRover->xyzApr()[1] + _filter->x()[1];
|
---|
| 346 | _output->_xyzRover[2] = _staRover->xyzApr()[2] + _filter->x()[2];
|
---|
| 347 | copy(&_filter->Q().data()[0], &_filter->Q().data()[6], _output->_covMatrix);
|
---|
| 348 | _output->_numSat = _filter->numSat();
|
---|
| 349 | _output->_pDop = _filter->PDOP();
|
---|
| 350 | _output->_error = false;
|
---|
| 351 | }
|
---|
| 352 | else {
|
---|
| 353 | _output->_error = true;
|
---|
| 354 | }
|
---|
[5740] | 355 | _output->_log = _log->str();
|
---|
[5683] | 356 | delete _log; _log = new ostringstream();
|
---|
| 357 | }
|
---|
| 358 |
|
---|
| 359 | //
|
---|
| 360 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5810] | 361 | t_irc t_pppClient::cmpModel(t_pppStation* station, const ColumnVector& xyzc,
|
---|
[5819] | 362 | vector<t_pppSatObs*>& obsVector) {
|
---|
[5683] | 363 |
|
---|
[5740] | 364 | bncTime time;
|
---|
| 365 | time = _epoTimeRover;
|
---|
| 366 | station->setName(OPT->_roverName);
|
---|
| 367 | station->setAntName(OPT->_antNameRover);
|
---|
| 368 | if (OPT->xyzAprRoverSet()) {
|
---|
| 369 | station->setXyzApr(OPT->_xyzAprRover);
|
---|
[5683] | 370 | }
|
---|
| 371 | else {
|
---|
[5740] | 372 | station->setXyzApr(xyzc.Rows(1,3));
|
---|
[5683] | 373 | }
|
---|
[5740] | 374 | station->setNeuEcc(OPT->_neuEccRover);
|
---|
[5683] | 375 |
|
---|
| 376 | // Receiver Clock
|
---|
| 377 | // --------------
|
---|
| 378 | station->setDClk(xyzc[3]);
|
---|
| 379 |
|
---|
| 380 | // Tides
|
---|
| 381 | // -----
|
---|
[5802] | 382 | station->setTideDspl( _tides->displacement(time, station->xyzApr()) );
|
---|
[5683] | 383 |
|
---|
| 384 | // Observation model
|
---|
| 385 | // -----------------
|
---|
[5819] | 386 | vector<t_pppSatObs*>::iterator it = obsVector.begin();
|
---|
[5683] | 387 | while (it != obsVector.end()) {
|
---|
[5819] | 388 | t_pppSatObs* satObs = *it;
|
---|
[5683] | 389 | satObs->cmpModel(station);
|
---|
[5740] | 390 | if (satObs->isValid() && satObs->eleSat() >= OPT->_minEle) {
|
---|
[5683] | 391 | ++it;
|
---|
| 392 | }
|
---|
| 393 | else {
|
---|
| 394 | delete satObs;
|
---|
| 395 | it = obsVector.erase(it);
|
---|
| 396 | }
|
---|
| 397 | }
|
---|
| 398 |
|
---|
[5740] | 399 | return success;
|
---|
[5683] | 400 | }
|
---|
| 401 |
|
---|
| 402 | //
|
---|
| 403 | //////////////////////////////////////////////////////////////////////////////
|
---|
[5819] | 404 | void t_pppClient::processEpoch(const vector<t_satObs*>& pppSatObs, t_output* output) {
|
---|
[5683] | 405 |
|
---|
| 406 | try {
|
---|
| 407 | initOutput(output);
|
---|
| 408 |
|
---|
| 409 | // Prepare Observations of the Rover
|
---|
| 410 | // ---------------------------------
|
---|
[5772] | 411 | if (prepareObs(pppSatObs, _obsRover, _epoTimeRover) != success) {
|
---|
[5740] | 412 | return finish(failure);
|
---|
[5683] | 413 | }
|
---|
| 414 |
|
---|
| 415 | LOG << "\nResults of Epoch ";
|
---|
| 416 | if (!_epoTimeRover.undef()) LOG << string(_epoTimeRover);
|
---|
| 417 | LOG << "\n--------------------------------------\n";
|
---|
| 418 |
|
---|
| 419 | for (int iter = 1; iter <= 2; iter++) {
|
---|
| 420 | ColumnVector xyzc(4); xyzc = 0.0;
|
---|
| 421 | bool print = (iter == 2);
|
---|
[5740] | 422 | if (cmpBancroft(_epoTimeRover, _obsRover, xyzc, print) != success) {
|
---|
| 423 | return finish(failure);
|
---|
[5683] | 424 | }
|
---|
[5740] | 425 | if (cmpModel(_staRover, xyzc, _obsRover) != success) {
|
---|
| 426 | return finish(failure);
|
---|
[5683] | 427 | }
|
---|
| 428 | }
|
---|
| 429 |
|
---|
| 430 | _offGG = cmpOffGG(_obsRover);
|
---|
| 431 |
|
---|
| 432 | // Store last epoch of data
|
---|
| 433 | // ------------------------
|
---|
| 434 | _obsPool->putEpoch(_epoTimeRover, _obsRover);
|
---|
| 435 |
|
---|
| 436 | // Process Epoch in Filter
|
---|
| 437 | // -----------------------
|
---|
[5740] | 438 | if (_filter->processEpoch(_obsPool) != success) {
|
---|
| 439 | return finish(failure);
|
---|
[5683] | 440 | }
|
---|
| 441 | }
|
---|
| 442 | catch (Exception& exc) {
|
---|
| 443 | LOG << exc.what() << endl;
|
---|
[5740] | 444 | return finish(failure);
|
---|
[5683] | 445 | }
|
---|
[5763] | 446 | catch (pppExcept msg) {
|
---|
| 447 | LOG << msg.what() << endl;
|
---|
[5740] | 448 | return finish(failure);
|
---|
[5683] | 449 | }
|
---|
[5786] | 450 | catch (const char* msg) {
|
---|
| 451 | LOG << msg << endl;
|
---|
| 452 | return finish(failure);
|
---|
| 453 | }
|
---|
[5683] | 454 | catch (...) {
|
---|
| 455 | LOG << "unknown exception" << endl;
|
---|
[5740] | 456 | return finish(failure);
|
---|
[5683] | 457 | }
|
---|
| 458 |
|
---|
[5740] | 459 | return finish(success);
|
---|
[5683] | 460 | }
|
---|
[5740] | 461 |
|
---|
| 462 | //
|
---|
| 463 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 464 | double lorentz(const ColumnVector& aa, const ColumnVector& bb) {
|
---|
| 465 | return aa[0]*bb[0] + aa[1]*bb[1] + aa[2]*bb[2] - aa[3]*bb[3];
|
---|
| 466 | }
|
---|
| 467 |
|
---|
| 468 | //
|
---|
| 469 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 470 | void t_pppClient::bancroft(const Matrix& BBpass, ColumnVector& pos) {
|
---|
| 471 |
|
---|
| 472 | if (pos.Nrows() != 4) {
|
---|
| 473 | pos.ReSize(4);
|
---|
| 474 | }
|
---|
| 475 | pos = 0.0;
|
---|
| 476 |
|
---|
| 477 | for (int iter = 1; iter <= 2; iter++) {
|
---|
| 478 | Matrix BB = BBpass;
|
---|
| 479 | int mm = BB.Nrows();
|
---|
| 480 | for (int ii = 1; ii <= mm; ii++) {
|
---|
| 481 | double xx = BB(ii,1);
|
---|
| 482 | double yy = BB(ii,2);
|
---|
| 483 | double traveltime = 0.072;
|
---|
| 484 | if (iter > 1) {
|
---|
| 485 | double zz = BB(ii,3);
|
---|
| 486 | double rho = sqrt( (xx-pos(1)) * (xx-pos(1)) +
|
---|
| 487 | (yy-pos(2)) * (yy-pos(2)) +
|
---|
| 488 | (zz-pos(3)) * (zz-pos(3)) );
|
---|
| 489 | traveltime = rho / t_CST::c;
|
---|
| 490 | }
|
---|
| 491 | double angle = traveltime * t_CST::omega;
|
---|
| 492 | double cosa = cos(angle);
|
---|
| 493 | double sina = sin(angle);
|
---|
| 494 | BB(ii,1) = cosa * xx + sina * yy;
|
---|
| 495 | BB(ii,2) = -sina * xx + cosa * yy;
|
---|
| 496 | }
|
---|
| 497 |
|
---|
| 498 | Matrix BBB;
|
---|
| 499 | if (mm > 4) {
|
---|
| 500 | SymmetricMatrix hlp; hlp << BB.t() * BB;
|
---|
| 501 | BBB = hlp.i() * BB.t();
|
---|
| 502 | }
|
---|
| 503 | else {
|
---|
| 504 | BBB = BB.i();
|
---|
| 505 | }
|
---|
| 506 | ColumnVector ee(mm); ee = 1.0;
|
---|
| 507 | ColumnVector alpha(mm); alpha = 0.0;
|
---|
| 508 | for (int ii = 1; ii <= mm; ii++) {
|
---|
| 509 | alpha(ii) = lorentz(BB.Row(ii).t(),BB.Row(ii).t())/2.0;
|
---|
| 510 | }
|
---|
| 511 | ColumnVector BBBe = BBB * ee;
|
---|
| 512 | ColumnVector BBBalpha = BBB * alpha;
|
---|
| 513 | double aa = lorentz(BBBe, BBBe);
|
---|
| 514 | double bb = lorentz(BBBe, BBBalpha)-1;
|
---|
| 515 | double cc = lorentz(BBBalpha, BBBalpha);
|
---|
| 516 | double root = sqrt(bb*bb-aa*cc);
|
---|
| 517 |
|
---|
| 518 | Matrix hlpPos(4,2);
|
---|
| 519 | hlpPos.Column(1) = (-bb-root)/aa * BBBe + BBBalpha;
|
---|
| 520 | hlpPos.Column(2) = (-bb+root)/aa * BBBe + BBBalpha;
|
---|
| 521 |
|
---|
| 522 | ColumnVector omc(2);
|
---|
| 523 | for (int pp = 1; pp <= 2; pp++) {
|
---|
| 524 | hlpPos(4,pp) = -hlpPos(4,pp);
|
---|
| 525 | omc(pp) = BB(1,4) -
|
---|
| 526 | sqrt( (BB(1,1)-hlpPos(1,pp)) * (BB(1,1)-hlpPos(1,pp)) +
|
---|
| 527 | (BB(1,2)-hlpPos(2,pp)) * (BB(1,2)-hlpPos(2,pp)) +
|
---|
| 528 | (BB(1,3)-hlpPos(3,pp)) * (BB(1,3)-hlpPos(3,pp)) ) -
|
---|
| 529 | hlpPos(4,pp);
|
---|
| 530 | }
|
---|
| 531 | if ( fabs(omc(1)) > fabs(omc(2)) ) {
|
---|
| 532 | pos = hlpPos.Column(2);
|
---|
| 533 | }
|
---|
| 534 | else {
|
---|
| 535 | pos = hlpPos.Column(1);
|
---|
| 536 | }
|
---|
| 537 | }
|
---|
| 538 | }
|
---|
| 539 |
|
---|