- Timestamp:
- Aug 2, 2014, 4:22:22 PM (10 years ago)
- Location:
- trunk/BNC/src/PPP
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/PPP/pppClient.cpp
r5734 r5740 1 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 1 42 2 43 #include <iostream> … … 10 51 #include "obspool.h" 11 52 #include "satbias.h" 12 #include " genconst.h"13 #include " utils.h"53 #include "bncconst.h" 54 #include "bncutils.h" 14 55 #include "station.h" 15 #include " tides.h"16 #include " antex.h"56 #include "bnctides.h" 57 #include "bncantex.h" 17 58 #include "filter.h" 18 59 … … 33 74 _ephPool = new t_ephPool(); 34 75 _obsPool = new t_obsPool(); 35 _staRover = new t_station(e_rover); 36 _staBase = new t_station(e_base); 76 _staRover = new t_station(); 37 77 _filter = new t_filter(); 38 78 } … … 46 86 delete _obsPool; 47 87 delete _staRover; 48 delete _staBase;49 88 delete _antex; 50 89 delete _filter; … … 54 93 // 55 94 ////////////////////////////////////////////////////////////////////////////// 56 void t_pppClient::setOptions(const t_ pppOpt* opt) {95 void t_pppClient::setOptions(const t_options* opt) { 57 96 delete _opt; 58 _opt = new t_options( opt);97 _opt = new t_options(*opt); 59 98 60 99 delete _antex; _antex = 0; 61 if (!_opt->antexFileName().empty()) { 62 _antex = new t_antex(_opt->antexFileName()); 63 } 64 65 _opt->print(); 100 if (!_opt->_antexFile.empty()) { 101 _antex = new bncAntex(_opt->_antexFile.c_str()); 102 } 66 103 } 67 104 … … 80 117 // 81 118 ////////////////////////////////////////////////////////////////////////////// 82 void t_pppClient::putOrbCorrections(int numCorr, const t_ pppOrbCorr* corr) {119 void t_pppClient::putOrbCorrections(int numCorr, const t_orbCorr* corr) { 83 120 for (int ii = 0; ii < numCorr; ii++) { 84 121 _ephPool->putOrbCorrection(new t_orbCorr(corr[ii])); … … 88 125 // 89 126 ////////////////////////////////////////////////////////////////////////////// 90 void t_pppClient::putClkCorrections(int numCorr, const t_ pppClkCorr* corr) {127 void t_pppClient::putClkCorrections(int numCorr, const t_clkCorr* corr) { 91 128 for (int ii = 0; ii < numCorr; ii++) { 92 129 _ephPool->putClkCorrection(new t_clkCorr(corr[ii])); … … 96 133 // 97 134 ////////////////////////////////////////////////////////////////////////////// 98 void t_pppClient::putBiases(int numBiases, const t_ pppSatBiases* biases) {135 void t_pppClient::putBiases(int numBiases, const t_satBiases* biases) { 99 136 for (int ii = 0; ii < numBiases; ii++) { 100 137 _obsPool->putBiases(new t_satBias(biases[ii])); … … 104 141 // 105 142 ////////////////////////////////////////////////////////////////////////////// 106 t_irc ::irct_pppClient::prepareObs(int numSat, const t_pppSatObs* satObs,107 vector<t_satObs*>& obsVector, t_time& epoTime) {143 t_irc t_pppClient::prepareObs(int numSat, const t_pppSatObs* satObs, 144 vector<t_satObs*>& obsVector, bncTime& epoTime) { 108 145 // Default 109 146 // ------- … … 114 151 int numValidGPS = 0; 115 152 for (int ii = 0; ii < numSat; ii++) { 116 char system = satObs[ii]._ satellite._system;153 char system = satObs[ii]._prn.system(); 117 154 if (system == 'G' || (system == 'R' && OPT->useGlonass())) { 118 155 t_satObs* satObs = new t_satObs(satObs[ii]); … … 142 179 if (fabs(dt) > MAXSYNC) { 143 180 LOG << "t_pppClient::prepareObs asynchronous observations" << endl; 144 return t_irc::failure;181 return failure; 145 182 } 146 183 meanDt += dt; … … 149 186 epoTime += meanDt / obsVector.size(); 150 187 151 return t_irc::success;188 return success; 152 189 } 153 190 154 191 // Compute the Bancroft position, check for blunders 155 192 ////////////////////////////////////////////////////////////////////////////// 156 t_irc ::irc t_pppClient::cmpBancroft(const t_time& epoTime,193 t_irc t_pppClient::cmpBancroft(const bncTime& epoTime, 157 194 vector<t_satObs*>& obsVector, 158 195 ColumnVector& xyzc, bool print) { … … 166 203 const t_satObs* satObs = obsVector.at(ii); 167 204 if ( satObs->isValid() && satObs->prn().system() == 'G' && 168 (!satObs->modelSet() || satObs->eleSat() >= OPT-> minEle()) ) {205 (!satObs->modelSet() || satObs->eleSat() >= OPT->_minEle) ) { 169 206 ++iObs; 170 207 BB[iObs][0] = satObs->xc()[0]; … … 174 211 } 175 212 } 176 if (iObs + 1 < OPT-> minobs()) {213 if (iObs + 1 < OPT->_minObs) { 177 214 LOG << "t_pppClient::cmpBancroft not enough observations" << endl; 178 return t_irc::failure;215 return failure; 179 216 } 180 217 BB = BB.Rows(1,iObs+1); 181 218 bancroft(BB, xyzc); 182 219 183 xyzc[3] /= t_ genConst::c;220 xyzc[3] /= t_CST::c; 184 221 185 222 // Check Blunders … … 191 228 const t_satObs* satObs = obsVector.at(ii); 192 229 if ( satObs->isValid() && satObs->prn().system() == 'G' && 193 (!satObs->modelSet() || satObs->eleSat() >= OPT-> minEle()) ) {230 (!satObs->modelSet() || satObs->eleSat() >= OPT->_minEle) ) { 194 231 ColumnVector rr = satObs->xc().Rows(1,3) - xyzc.Rows(1,3); 195 232 double res = rr.norm_Frobenius() - satObs->obsValue(tLC) 196 - (satObs->xc()[3] - xyzc[3]) * t_ genConst::c;233 - (satObs->xc()[3] - xyzc[3]) * t_CST::c; 197 234 if (fabs(res) > maxRes) { 198 235 maxRes = fabs(res); … … 208 245 << setw(14) << setprecision(3) << xyzc[1] << ' ' 209 246 << setw(14) << setprecision(3) << xyzc[2] << ' ' 210 << setw(14) << setprecision(3) << xyzc[3] * t_ genConst::c << endl << endl;247 << setw(14) << setprecision(3) << xyzc[3] * t_CST::c << endl << endl; 211 248 } 212 249 break; … … 221 258 } 222 259 223 return t_irc::success;260 return success; 224 261 } 225 262 … … 239 276 t_satObs* satObs = obsVector.at(ii); 240 277 if ( !satObs->outlier() && satObs->isValid() && satObs->prn().system() == 'R' && 241 (!satObs->modelSet() || satObs->eleSat() >= OPT-> minEle()) ) {278 (!satObs->modelSet() || satObs->eleSat() >= OPT->_minEle) ) { 242 279 ++nObs; 243 280 double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC); … … 270 307 void t_pppClient::initOutput(t_pppOutput* output) { 271 308 _output = output; 272 _output->_epoTime._mjd = 0; 273 _output->_epoTime._sec = 0.0; 274 _output->_numSat = 0; 275 _output->_pDop = 0.0; 276 _output->_ambFixRate = 0.0; 277 _output->_log = 0; 278 _output->_error = false; 309 _output->_numSat = 0; 310 _output->_pDop = 0.0; 311 _output->_error = false; 279 312 } 280 313 … … 286 319 } 287 320 _obsRover.clear(); 288 for (unsigned ii = 0; ii < _obsBase.size(); ii++) { 289 delete _obsBase.at(ii); 290 } 291 _obsBase.clear(); 292 } 293 294 // 295 ////////////////////////////////////////////////////////////////////////////// 296 void t_pppClient::finish(t_irc::irc irc) { 321 } 322 323 // 324 ////////////////////////////////////////////////////////////////////////////// 325 void t_pppClient::finish(t_irc irc) { 297 326 298 327 clearObs(); 299 328 300 _output->_epoTime._mjd = _epoTimeRover.mjd(); 301 _output->_epoTime._sec = _epoTimeRover.daysec(); 302 303 if (irc == t_irc::success) { 329 _output->_epoTime = _epoTimeRover; 330 331 if (irc == success) { 304 332 _output->_xyzRover[0] = _staRover->xyzApr()[0] + _filter->x()[0]; 305 333 _output->_xyzRover[1] = _staRover->xyzApr()[1] + _filter->x()[1]; … … 308 336 _output->_numSat = _filter->numSat(); 309 337 _output->_pDop = _filter->PDOP(); 310 _output->_ambFixRate = _filter->ambFixRate();311 338 _output->_error = false; 312 339 } … … 314 341 _output->_error = true; 315 342 } 316 if (OPT->logLevel() > 0) { 317 _output->_log = strdup(_log->str().c_str()); 318 } 343 _output->_log = _log->str(); 319 344 delete _log; _log = new ostringstream(); 320 345 } … … 322 347 // 323 348 ////////////////////////////////////////////////////////////////////////////// 324 t_irc ::irct_pppClient::cmpModel(t_station* station, const ColumnVector& xyzc,349 t_irc t_pppClient::cmpModel(t_station* station, const ColumnVector& xyzc, 325 350 vector<t_satObs*>& obsVector) { 326 351 327 t_time time; 328 if (station->roverBase() == e_rover) { 329 time = _epoTimeRover; 330 station->setName(OPT->roverName()); 331 station->setAntName(OPT->antNameRover()); 332 if (OPT->xyzAprRoverSet()) { 333 station->setXyzApr(OPT->xyzAprRover()); 334 } 335 else { 336 station->setXyzApr(xyzc.Rows(1,3)); 337 } 338 station->setNeuEcc(OPT->neuEccRover()); 352 bncTime time; 353 time = _epoTimeRover; 354 station->setName(OPT->_roverName); 355 station->setAntName(OPT->_antNameRover); 356 if (OPT->xyzAprRoverSet()) { 357 station->setXyzApr(OPT->_xyzAprRover); 339 358 } 340 359 else { 341 time = _epoTimeBase; 342 station->setName(OPT->baseName()); 343 station->setAntName(OPT->antNameBase()); 344 station->setXyzApr(OPT->xyzAprBase()); 345 station->setNeuEcc(OPT->neuEccBase()); 346 } 360 station->setXyzApr(xyzc.Rows(1,3)); 361 } 362 station->setNeuEcc(OPT->_neuEccRover); 347 363 348 364 // Receiver Clock … … 356 372 // Tides 357 373 // ----- 358 station->setTideDspl(t_tides::displacement(time, station->xyzApr())); 374 ColumnVector hlp = station->xyzApr(); 375 tides(time, hlp); 376 station->setTideDspl(hlp - station->xyzApr()); 359 377 360 378 // Observation model … … 364 382 t_satObs* satObs = *it; 365 383 satObs->cmpModel(station); 366 if (satObs->isValid() && satObs->eleSat() >= OPT-> minEle()) {384 if (satObs->isValid() && satObs->eleSat() >= OPT->_minEle) { 367 385 ++it; 368 386 } … … 373 391 } 374 392 375 return t_irc::success; 376 } 377 378 // 379 ////////////////////////////////////////////////////////////////////////////// 380 t_irc::irc t_pppClient::createDifferences() { 381 382 vector<t_satObs*>::iterator it = _obsRover.begin(); 383 while (it != _obsRover.end()) { 384 t_satObs* obsR = *it; 385 t_satObs* obsB = 0; 386 for (unsigned ii = 0; ii < _obsBase.size(); ii++) { 387 if (_obsBase[ii]->prn() == obsR->prn()) { 388 obsB = _obsBase[ii]; 389 break; 390 } 391 } 392 if (obsB) { 393 obsR->createDifference(obsB); 394 ++it; 395 } 396 else { 397 delete obsR; 398 it = _obsRover.erase(it); 399 } 400 } 401 402 return t_irc::success; 393 return success; 403 394 } 404 395 … … 414 405 // --------------------------------- 415 406 if (prepareObs(numSatRover, satObsRover, _obsRover, 416 _epoTimeRover) != t_irc::success) {417 return finish( t_irc::failure);407 _epoTimeRover) != success) { 408 return finish(failure); 418 409 } 419 410 … … 425 416 ColumnVector xyzc(4); xyzc = 0.0; 426 417 bool print = (iter == 2); 427 if (cmpBancroft(_epoTimeRover, _obsRover, xyzc, print) != t_irc::success) {428 return finish( t_irc::failure);429 } 430 if (cmpModel(_staRover, xyzc, _obsRover) != t_irc::success) {431 return finish( t_irc::failure);418 if (cmpBancroft(_epoTimeRover, _obsRover, xyzc, print) != success) { 419 return finish(failure); 420 } 421 if (cmpModel(_staRover, xyzc, _obsRover) != success) { 422 return finish(failure); 432 423 } 433 424 } 434 425 435 426 _offGG = cmpOffGG(_obsRover); 436 437 // Prepare Observations of the Base438 // --------------------------------439 if (OPT->isDifferential()) {440 if (prepareObs(numSatBase, satObsBase, _obsBase,441 _epoTimeBase) != t_irc::success) {442 return finish(t_irc::failure);443 }444 ColumnVector xyzc(4); xyzc = 0.0;445 if (cmpModel(_staBase, xyzc, _obsBase) != t_irc::success) {446 return finish(t_irc::failure);447 }448 if (cmpBancroft(_epoTimeBase, _obsBase, xyzc, true) != t_irc::success) {449 return finish(t_irc::failure);450 }451 _staBase->setDClk(xyzc[3]);452 453 _offGG -= cmpOffGG(_obsBase);454 455 // Create single-differences of observations456 // -----------------------------------------457 if (createDifferences() != t_irc::success) {458 return finish(t_irc::failure);459 }460 for (unsigned ii = 0; ii < _obsBase.size(); ii++) {461 delete _obsBase[ii];462 }463 _obsBase.clear();464 }465 427 466 428 // Store last epoch of data … … 470 432 // Process Epoch in Filter 471 433 // ----------------------- 472 if (_filter->processEpoch(_obsPool) != t_irc::success) {473 return finish( t_irc::failure);434 if (_filter->processEpoch(_obsPool) != success) { 435 return finish(failure); 474 436 } 475 437 } 476 438 catch (Exception& exc) { 477 439 LOG << exc.what() << endl; 478 return finish( t_irc::failure);440 return finish(failure); 479 441 } 480 442 catch (string& msg) { 481 443 LOG << "Exception: " << msg << endl; 482 return finish( t_irc::failure);444 return finish(failure); 483 445 } 484 446 catch (logic_error exc) { 485 447 LOG << exc.what() << endl; 486 return finish( t_irc::failure);448 return finish(failure); 487 449 } 488 450 catch (const char* msg) { 489 451 LOG << msg << endl; 490 return finish( t_irc::failure);452 return finish(failure); 491 453 } 492 454 catch (...) { 493 455 LOG << "unknown exception" << endl; 494 return finish(t_irc::failure); 495 } 496 497 return finish(t_irc::success); 498 } 456 return finish(failure); 457 } 458 459 return finish(success); 460 } 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 -
trunk/BNC/src/PPP/pppClient.h
r5734 r5740 4 4 #include <sstream> 5 5 #include <vector> 6 #include "RTCM3/ephemeris.h" 6 #include "ppp.h" 7 #include "ephemeris.h" 8 #include "options.h" 9 10 class bncAntex; 7 11 8 12 namespace BNC { … … 12 16 class t_satObs; 13 17 class t_station; 14 class t_antex;15 18 class t_filter; 16 19 … … 19 22 t_pppClient(); 20 23 ~t_pppClient(); 21 void setOptions(const t_ pppOpt* opt);24 void setOptions(const t_options* opt); 22 25 void putGPSEphemeris(const t_ephGPS* eph); 23 26 void putGloEphemeris(const t_ephGlo* eph); 24 void putOrbCorrections(int numCorr, const t_ pppOrbCorr* corr);25 void putClkCorrections(int numCorr, const t_ pppClkCorr* corr);26 void putBiases(int numBiases, const t_ pppSatBiases* biases);27 void putOrbCorrections(int numCorr, const t_orbCorr* corr); 28 void putClkCorrections(int numCorr, const t_clkCorr* corr); 29 void putBiases(int numBiases, const t_satBiases* biases); 27 30 void processEpoch(int numSatRover, const t_pppSatObs* satObsRover, 28 31 t_pppOutput* output); 29 32 const t_ephPool* ephPool() const {return _ephPool;} 30 33 const t_obsPool* obsPool() const {return _obsPool;} 31 const t_antex*antex() const {return _antex;}34 const bncAntex* antex() const {return _antex;} 32 35 const t_station* staRover() const {return _staRover;} 33 36 double offGG() const {return _offGG;} 37 static void bancroft(const Matrix& BBpass, ColumnVector& pos); 34 38 35 39 std::ostringstream* _log; … … 38 42 private: 39 43 void initOutput(t_pppOutput* output); 40 void finish(t_irc ::ircirc);44 void finish(t_irc irc); 41 45 void clearObs(); 42 t_irc ::ircprepareObs(int numSat, const t_pppSatObs* satObs,43 std::vector<t_satObs*>& obsVector, t_time& epoTime);44 t_irc ::irccmpModel(t_station* station, const ColumnVector& xyzc,46 t_irc prepareObs(int numSat, const t_pppSatObs* satObs, 47 std::vector<t_satObs*>& obsVector, bncTime& epoTime); 48 t_irc cmpModel(t_station* station, const ColumnVector& xyzc, 45 49 std::vector<t_satObs*>& obsVector); 46 t_irc ::irc cmpBancroft(const t_time& epoTime,50 t_irc cmpBancroft(const bncTime& epoTime, 47 51 std::vector<t_satObs*>& obsVector, 48 52 ColumnVector& xyzc, bool print); 49 t_irc::irc createDifferences();50 53 double cmpOffGG(std::vector<t_satObs*>& obsVector); 51 54 … … 53 56 t_ephPool* _ephPool; 54 57 t_obsPool* _obsPool; 55 t_time _epoTimeRover; 56 t_time _epoTimeBase; 58 bncTime _epoTimeRover; 57 59 t_station* _staRover; 58 t_station* _staBase; 59 t_antex* _antex; 60 bncAntex* _antex; 60 61 t_filter* _filter; 61 62 double _offGG; 62 63 std::vector<t_satObs*> _obsRover; 63 std::vector<t_satObs*> _obsBase;64 64 65 65 };
Note:
See TracChangeset
for help on using the changeset viewer.