[2035] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
| 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
| 3 | //
|
---|
| 4 | // Copyright (C) 2007
|
---|
| 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
| 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
| 8 | // http://www.fsv.cvut.cz
|
---|
| 9 | //
|
---|
| 10 | // Email: euref-ip@bkg.bund.de
|
---|
| 11 | //
|
---|
| 12 | // This program is free software; you can redistribute it and/or
|
---|
| 13 | // modify it under the terms of the GNU General Public License
|
---|
| 14 | // as published by the Free Software Foundation, version 2.
|
---|
| 15 | //
|
---|
| 16 | // This program is distributed in the hope that it will be useful,
|
---|
| 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | // GNU General Public License for more details.
|
---|
| 20 | //
|
---|
| 21 | // You should have received a copy of the GNU General Public License
|
---|
| 22 | // along with this program; if not, write to the Free Software
|
---|
| 23 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
| 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
| 26 | * BKG NTRIP Client
|
---|
| 27 | * -------------------------------------------------------------------------
|
---|
| 28 | *
|
---|
| 29 | * Class: bncPPPclient
|
---|
| 30 | *
|
---|
| 31 | * Purpose: Precise Point Positioning
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 21-Nov-2009
|
---|
| 36 | *
|
---|
| 37 | * Changes:
|
---|
| 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
[2249] | 41 | #include <newmatio.h>
|
---|
[2238] | 42 | #include <iomanip>
|
---|
| 43 |
|
---|
[2035] | 44 | #include "bncpppclient.h"
|
---|
[2113] | 45 | #include "bncapp.h"
|
---|
[2043] | 46 | #include "bncutils.h"
|
---|
[2044] | 47 | #include "bncconst.h"
|
---|
[2058] | 48 | #include "bncmodel.h"
|
---|
[2226] | 49 | #include "bncsettings.h"
|
---|
[2035] | 50 |
|
---|
| 51 | extern "C" {
|
---|
| 52 | #include "clock_orbit_rtcm.h"
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | using namespace std;
|
---|
| 56 |
|
---|
| 57 | // Constructor
|
---|
| 58 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 59 | bncPPPclient::bncPPPclient(QByteArray staID) {
|
---|
[2113] | 60 |
|
---|
[2226] | 61 | bncSettings settings;
|
---|
| 62 |
|
---|
| 63 | if ( Qt::CheckState(settings.value("pppGLONASS").toInt()) == Qt::Checked) {
|
---|
| 64 | _useGlonass = true;
|
---|
| 65 | }
|
---|
| 66 | else {
|
---|
| 67 | _useGlonass = false;
|
---|
| 68 | }
|
---|
| 69 |
|
---|
[2357] | 70 | if (settings.value("pppSPP").toString() == "PPP") {
|
---|
| 71 | _pppMode = true;
|
---|
| 72 | }
|
---|
| 73 | else {
|
---|
| 74 | _pppMode = false;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
[2113] | 77 | connect(((bncApp*)qApp), SIGNAL(newEphGPS(gpsephemeris)),
|
---|
| 78 | this, SLOT(slotNewEphGPS(gpsephemeris)));
|
---|
[2224] | 79 | connect(((bncApp*)qApp), SIGNAL(newEphGlonass(glonassephemeris)),
|
---|
| 80 | this, SLOT(slotNewEphGlonass(glonassephemeris)));
|
---|
[2113] | 81 | connect(((bncApp*)qApp), SIGNAL(newCorrections(QList<QString>)),
|
---|
| 82 | this, SLOT(slotNewCorrections(QList<QString>)));
|
---|
| 83 |
|
---|
[2039] | 84 | _staID = staID;
|
---|
| 85 | _epoData = 0;
|
---|
[2113] | 86 | _model = new bncModel(staID);
|
---|
[2182] | 87 | connect(_model, SIGNAL(newNMEAstr(QByteArray)),
|
---|
| 88 | this, SIGNAL(newNMEAstr(QByteArray)));
|
---|
[2035] | 89 | }
|
---|
| 90 |
|
---|
| 91 | // Destructor
|
---|
| 92 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 93 | bncPPPclient::~bncPPPclient() {
|
---|
[2058] | 94 | delete _model;
|
---|
[2039] | 95 | delete _epoData;
|
---|
[2035] | 96 | QMapIterator<QString, t_eph*> it(_eph);
|
---|
| 97 | while (it.hasNext()) {
|
---|
| 98 | it.next();
|
---|
| 99 | delete it.value();
|
---|
| 100 | }
|
---|
| 101 | QMapIterator<QString, t_corr*> ic(_corr);
|
---|
| 102 | while (ic.hasNext()) {
|
---|
| 103 | ic.next();
|
---|
| 104 | delete ic.value();
|
---|
| 105 | }
|
---|
[2274] | 106 | QMapIterator<QString, t_bias*> ib(_bias);
|
---|
| 107 | while (ib.hasNext()) {
|
---|
| 108 | ib.next();
|
---|
| 109 | delete ib.value();
|
---|
| 110 | }
|
---|
[2035] | 111 | }
|
---|
| 112 |
|
---|
| 113 | //
|
---|
| 114 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 115 | void bncPPPclient::putNewObs(p_obs pp) {
|
---|
[2037] | 116 | QMutexLocker locker(&_mutex);
|
---|
[2051] | 117 |
|
---|
[2037] | 118 | t_obsInternal* obs = &(pp->_o);
|
---|
[2051] | 119 |
|
---|
[2226] | 120 | if (obs->satSys != 'G' && !_useGlonass) {
|
---|
[2225] | 121 | return;
|
---|
| 122 | }
|
---|
| 123 |
|
---|
[2051] | 124 | t_satData* satData = new t_satData();
|
---|
| 125 |
|
---|
[2274] | 126 | // Satellite Number
|
---|
| 127 | // ----------------
|
---|
| 128 | if (obs->satSys == 'G') {
|
---|
| 129 | QString prn = QString("G%1").arg(obs->satNum, 2, 10, QChar('0'));
|
---|
| 130 | satData->prn = prn;
|
---|
| 131 | }
|
---|
| 132 | else if (obs->satSys == 'R') {
|
---|
| 133 | QString prn = QString("R%1").arg(obs->satNum, 2, 10, QChar('0'));
|
---|
| 134 | satData->prn = prn;
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | // Handle Code Biases
|
---|
| 138 | // ------------------
|
---|
| 139 | t_bias* bb = 0;
|
---|
| 140 | if (_bias.contains(satData->prn)) {
|
---|
| 141 | bb = _bias.value(satData->prn);
|
---|
| 142 | }
|
---|
| 143 |
|
---|
[2051] | 144 | // Set Code Observations
|
---|
| 145 | // ---------------------
|
---|
| 146 | if (obs->P1) {
|
---|
[2317] | 147 | satData->P1 = obs->P1;
|
---|
[2051] | 148 | satData->codeTypeF1 = t_satData::P_CODE;
|
---|
| 149 | }
|
---|
| 150 | else if (obs->C1) {
|
---|
[2317] | 151 | satData->P1 = obs->C1 + (bb ? bb->p1c1 : 0.0);
|
---|
[2051] | 152 | satData->codeTypeF1 = t_satData::C_CODE;
|
---|
| 153 | }
|
---|
| 154 | else {
|
---|
| 155 | delete satData;
|
---|
| 156 | return;
|
---|
| 157 | }
|
---|
| 158 |
|
---|
| 159 | if (obs->P2) {
|
---|
[2317] | 160 | satData->P2 = obs->P2 + (bb ? bb->p1p2 : 0.0);
|
---|
[2051] | 161 | satData->codeTypeF2 = t_satData::P_CODE;
|
---|
| 162 | }
|
---|
| 163 | else if (obs->C2) {
|
---|
[2317] | 164 | satData->P2 = obs->C2;
|
---|
[2051] | 165 | satData->codeTypeF2 = t_satData::C_CODE;
|
---|
| 166 | }
|
---|
| 167 | else {
|
---|
| 168 | delete satData;
|
---|
| 169 | return;
|
---|
| 170 | }
|
---|
| 171 |
|
---|
[2228] | 172 | double f1 = t_CST::freq1;
|
---|
| 173 | double f2 = t_CST::freq2;
|
---|
| 174 |
|
---|
[2229] | 175 | if (obs->satSys == 'R') {
|
---|
| 176 | f1 = 1602000000.0 + 562500.0 * obs->slot;
|
---|
| 177 | f2 = 1246000000.0 + 437500.0 * obs->slot;
|
---|
| 178 | }
|
---|
| 179 |
|
---|
[2228] | 180 | // Ionosphere-Free Combination
|
---|
| 181 | // ---------------------------
|
---|
| 182 | double c1 = f1 * f1 / (f1 * f1 - f2 * f2);
|
---|
| 183 | double c2 = - f2 * f2 / (f1 * f1 - f2 * f2);
|
---|
| 184 |
|
---|
[2051] | 185 | satData->P3 = c1 * satData->P1 + c2 * satData->P2;
|
---|
| 186 |
|
---|
| 187 | // Set Phase Observations
|
---|
| 188 | // ----------------------
|
---|
| 189 | if (obs->L1 && obs->L2) {
|
---|
[2228] | 190 | satData->L1 = obs->L1 * t_CST::c / f1;
|
---|
| 191 | satData->L2 = obs->L2 * t_CST::c / f2;
|
---|
[2051] | 192 | }
|
---|
| 193 | else {
|
---|
| 194 | delete satData;
|
---|
| 195 | return;
|
---|
| 196 | }
|
---|
| 197 | satData->L3 = c1 * satData->L1 + c2 * satData->L2;
|
---|
| 198 |
|
---|
| 199 | // Add new Satellite to the epoch
|
---|
| 200 | // ------------------------------
|
---|
[2123] | 201 | bncTime tt(obs->GPSWeek, obs->GPSWeeks);
|
---|
[2037] | 202 |
|
---|
[2039] | 203 | if (!_epoData) {
|
---|
| 204 | _epoData = new t_epoData();
|
---|
| 205 | _epoData->tt = tt;
|
---|
[2037] | 206 | }
|
---|
[2039] | 207 | else if (tt != _epoData->tt) {
|
---|
[2037] | 208 | processEpoch();
|
---|
[2039] | 209 | delete _epoData;
|
---|
| 210 | _epoData = new t_epoData();
|
---|
| 211 | _epoData->tt = tt;
|
---|
[2037] | 212 | }
|
---|
[2039] | 213 |
|
---|
[2231] | 214 | if (obs->satSys == 'G') {
|
---|
[2274] | 215 | _epoData->satDataGPS[satData->prn] = satData;
|
---|
[2231] | 216 | }
|
---|
| 217 | else if (obs->satSys == 'R') {
|
---|
[2274] | 218 | _epoData->satDataGlo[satData->prn] = satData;
|
---|
[2231] | 219 | }
|
---|
[2233] | 220 |
|
---|
[2035] | 221 | }
|
---|
| 222 |
|
---|
| 223 | //
|
---|
| 224 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 225 | void bncPPPclient::slotNewEphGPS(gpsephemeris gpseph) {
|
---|
| 226 | QMutexLocker locker(&_mutex);
|
---|
| 227 |
|
---|
| 228 | QString prn = QString("G%1").arg(gpseph.satellite, 2, 10, QChar('0'));
|
---|
| 229 |
|
---|
| 230 | if (_eph.contains(prn)) {
|
---|
[2040] | 231 | t_ephGPS* ee = static_cast<t_ephGPS*>(_eph.value(prn));
|
---|
| 232 | if ( (ee->GPSweek() < gpseph.GPSweek) ||
|
---|
| 233 | (ee->GPSweek() == gpseph.GPSweek &&
|
---|
| 234 | ee->TOC() < gpseph.TOC) ) {
|
---|
| 235 | ee->set(&gpseph);
|
---|
| 236 | }
|
---|
[2035] | 237 | }
|
---|
| 238 | else {
|
---|
| 239 | t_ephGPS* ee = new t_ephGPS();
|
---|
| 240 | ee->set(&gpseph);
|
---|
| 241 | _eph[prn] = ee;
|
---|
| 242 | }
|
---|
| 243 | }
|
---|
| 244 |
|
---|
| 245 | //
|
---|
| 246 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2224] | 247 | void bncPPPclient::slotNewEphGlonass(glonassephemeris gloeph) {
|
---|
| 248 | QMutexLocker locker(&_mutex);
|
---|
| 249 |
|
---|
| 250 | QString prn = QString("R%1").arg(gloeph.almanac_number, 2, 10, QChar('0'));
|
---|
| 251 |
|
---|
| 252 | if (_eph.contains(prn)) {
|
---|
[2268] | 253 | int ww = gloeph.GPSWeek;
|
---|
| 254 | int tow = gloeph.GPSTOW;
|
---|
| 255 | updatetime(&ww, &tow, gloeph.tb*1000, 0); // Moscow -> GPS
|
---|
[2224] | 256 | t_ephGlo* ee = static_cast<t_ephGlo*>(_eph.value(prn));
|
---|
[2268] | 257 | if (ee->GPSweek() < ww ||
|
---|
| 258 | (ee->GPSweek() == ww && ee->GPSweeks() < tow)) {
|
---|
[2224] | 259 | ee->set(&gloeph);
|
---|
| 260 | }
|
---|
| 261 | }
|
---|
| 262 | else {
|
---|
| 263 | t_ephGlo* ee = new t_ephGlo();
|
---|
| 264 | ee->set(&gloeph);
|
---|
| 265 | _eph[prn] = ee;
|
---|
| 266 | }
|
---|
| 267 | }
|
---|
| 268 |
|
---|
| 269 | //
|
---|
| 270 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2035] | 271 | void bncPPPclient::slotNewCorrections(QList<QString> corrList) {
|
---|
| 272 | QMutexLocker locker(&_mutex);
|
---|
[2069] | 273 |
|
---|
| 274 | if (corrList.size() == 0) {
|
---|
| 275 | return;
|
---|
| 276 | }
|
---|
| 277 |
|
---|
| 278 | // Remove All Corrections
|
---|
| 279 | // ----------------------
|
---|
| 280 | QMapIterator<QString, t_corr*> ic(_corr);
|
---|
| 281 | while (ic.hasNext()) {
|
---|
| 282 | ic.next();
|
---|
| 283 | delete ic.value();
|
---|
| 284 | }
|
---|
| 285 | _corr.clear();
|
---|
| 286 |
|
---|
[2035] | 287 | QListIterator<QString> it(corrList);
|
---|
| 288 | while (it.hasNext()) {
|
---|
| 289 | QTextStream in(it.next().toAscii());
|
---|
| 290 | int messageType;
|
---|
| 291 | int updateInterval;
|
---|
| 292 | int GPSweek;
|
---|
| 293 | double GPSweeks;
|
---|
| 294 | QString prn;
|
---|
| 295 | in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
|
---|
| 296 | if ( messageType == COTYPE_GPSCOMBINED ||
|
---|
[2207] | 297 | messageType == COTYPE_GLONASSCOMBINED ||
|
---|
| 298 | messageType == COTYPE_GPSORBIT ||
|
---|
| 299 | messageType == COTYPE_GPSCLOCK ||
|
---|
| 300 | messageType == COTYPE_GLONASSORBIT ||
|
---|
| 301 | messageType == COTYPE_GLONASSCLOCK ) {
|
---|
| 302 |
|
---|
[2035] | 303 | t_corr* cc = 0;
|
---|
| 304 | if (_corr.contains(prn)) {
|
---|
| 305 | cc = _corr.value(prn);
|
---|
| 306 | }
|
---|
| 307 | else {
|
---|
| 308 | cc = new t_corr();
|
---|
| 309 | _corr[prn] = cc;
|
---|
| 310 | }
|
---|
[2207] | 311 |
|
---|
[2035] | 312 | cc->tt.set(GPSweek, GPSweeks);
|
---|
[2207] | 313 |
|
---|
| 314 | if ( messageType == COTYPE_GPSCOMBINED ||
|
---|
| 315 | messageType == COTYPE_GLONASSCOMBINED ) {
|
---|
[2366] | 316 | cc->rao.ReSize(3); cc->rao = 0.0;
|
---|
| 317 | cc->dotRao.ReSize(3); cc->dotRao = 0.0;
|
---|
| 318 | cc->dotDotRao.ReSize(3); cc->dotDotRao = 0.0;
|
---|
| 319 | cc->dClk = 0.0;
|
---|
| 320 | cc->dotDClk = 0.0;
|
---|
| 321 | cc->dotDotDClk = 0.0;
|
---|
| 322 | in >> cc->iod
|
---|
| 323 | >> cc->dClk >> cc->rao[0] >> cc->rao[1] >> cc->rao[2]
|
---|
| 324 | >> cc->dotDClk >> cc->dotRao[0] >> cc->dotRao[1] >> cc->dotRao[2]
|
---|
| 325 | >> cc->dotDotDClk >> cc->dotDotRao[0] >> cc->dotDotRao[1] >> cc->dotDotRao[2];
|
---|
| 326 | cc->dClk /= t_CST::c;
|
---|
| 327 | cc->dotDClk /= t_CST::c;
|
---|
| 328 | cc->dotDotDClk /= t_CST::c;
|
---|
[2208] | 329 | cc->raoSet = true;
|
---|
| 330 | cc->dClkSet = true;
|
---|
[2207] | 331 | }
|
---|
| 332 | else if ( messageType == COTYPE_GPSORBIT ||
|
---|
| 333 | messageType == COTYPE_GLONASSORBIT ) {
|
---|
[2366] | 334 | cc->rao.ReSize(3); cc->rao = 0.0;
|
---|
| 335 | cc->dotRao.ReSize(3); cc->dotRao = 0.0;
|
---|
| 336 | cc->dotDotRao.ReSize(3); cc->dotDotRao = 0.0;
|
---|
| 337 | in >> cc->iod
|
---|
| 338 | >> cc->rao[0] >> cc->rao[1] >> cc->rao[2]
|
---|
| 339 | >> cc->dotRao[0] >> cc->dotRao[1] >> cc->dotRao[2]
|
---|
| 340 | >> cc->dotDotRao[0] >> cc->dotDotRao[1] >> cc->dotDotRao[2];
|
---|
[2208] | 341 | cc->raoSet = true;
|
---|
[2207] | 342 | }
|
---|
| 343 | else if ( messageType == COTYPE_GPSCLOCK ||
|
---|
| 344 | messageType == COTYPE_GLONASSCLOCK ) {
|
---|
| 345 | int dummyIOD;
|
---|
[2366] | 346 | cc->dClk = 0.0;
|
---|
| 347 | cc->dotDClk = 0.0;
|
---|
| 348 | cc->dotDotDClk = 0.0;
|
---|
| 349 | in >> dummyIOD >> cc->dClk >> cc->dotDClk >> cc->dotDotDClk;
|
---|
| 350 | cc->dClk /= t_CST::c;
|
---|
| 351 | cc->dotDClk /= t_CST::c;
|
---|
| 352 | cc->dotDotDClk /= t_CST::c;
|
---|
[2208] | 353 | cc->dClkSet = true;
|
---|
[2207] | 354 | }
|
---|
[2035] | 355 | }
|
---|
[2317] | 356 | else if ( messageType == BTYPE_GPS ) {
|
---|
[2274] | 357 |
|
---|
| 358 | t_bias* bb = 0;
|
---|
| 359 | if (_bias.contains(prn)) {
|
---|
[2341] | 360 | bb = _bias.value(prn);
|
---|
[2274] | 361 | }
|
---|
| 362 | else {
|
---|
| 363 | bb = new t_bias();
|
---|
| 364 | _bias[prn] = bb;
|
---|
| 365 | }
|
---|
| 366 |
|
---|
| 367 | bb->tt.set(GPSweek, GPSweeks);
|
---|
| 368 |
|
---|
| 369 | int numBiases;
|
---|
| 370 | in >> numBiases;
|
---|
| 371 | for (int ii = 0; ii < numBiases; ++ii) {
|
---|
| 372 | int bType;
|
---|
| 373 | double bValue;
|
---|
| 374 | in >> bType >> bValue;
|
---|
[2365] | 375 |
|
---|
| 376 | #define CODETYPEGPS_L1_CA 0
|
---|
| 377 | #define CODETYPEGPS_L1_P 1
|
---|
| 378 | #define CODETYPEGPS_L1_Z 2
|
---|
| 379 | #define CODETYPEGPS_L2_P 10
|
---|
| 380 | #define CODETYPEGPS_L2_Z 11
|
---|
| 381 |
|
---|
| 382 | if (bType == CODETYPEGPS_L1_CA) {
|
---|
| 383 | bb->p1c1 = bValue;
|
---|
[2274] | 384 | }
|
---|
[2365] | 385 | else if (bType == CODETYPEGPS_L2_Z) {
|
---|
| 386 | bb->p1p2 = bValue;
|
---|
[2274] | 387 | }
|
---|
| 388 | }
|
---|
| 389 | }
|
---|
[2035] | 390 | }
|
---|
[2208] | 391 |
|
---|
| 392 | QMutableMapIterator<QString, t_corr*> im(_corr);
|
---|
| 393 | while (im.hasNext()) {
|
---|
| 394 | im.next();
|
---|
| 395 | t_corr* cc = im.value();
|
---|
| 396 | if (!cc->ready()) {
|
---|
| 397 | delete cc;
|
---|
| 398 | im.remove();
|
---|
| 399 | }
|
---|
| 400 | }
|
---|
[2035] | 401 | }
|
---|
| 402 |
|
---|
| 403 | // Satellite Position
|
---|
| 404 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2123] | 405 | t_irc bncPPPclient::getSatPos(const bncTime& tt, const QString& prn,
|
---|
[2357] | 406 | ColumnVector& xc, ColumnVector& vv) {
|
---|
[2035] | 407 |
|
---|
[2067] | 408 | const double MAXAGE = 120.0;
|
---|
[2041] | 409 |
|
---|
[2035] | 410 | if (_eph.contains(prn)) {
|
---|
[2040] | 411 | t_eph* ee = _eph.value(prn);
|
---|
| 412 | ee->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
|
---|
| 413 |
|
---|
[2357] | 414 | if (_pppMode) {
|
---|
[2068] | 415 | if (_corr.contains(prn)) {
|
---|
| 416 | t_corr* cc = _corr.value(prn);
|
---|
| 417 | if (ee->IOD() == cc->iod && (tt - cc->tt) < MAXAGE) {
|
---|
[2296] | 418 | applyCorr(tt, cc, xc, vv);
|
---|
[2068] | 419 | return success;
|
---|
| 420 | }
|
---|
[2041] | 421 | }
|
---|
[2068] | 422 | return failure;
|
---|
[2040] | 423 | }
|
---|
[2068] | 424 |
|
---|
[2035] | 425 | return success;
|
---|
| 426 | }
|
---|
| 427 |
|
---|
| 428 | return failure;
|
---|
| 429 | }
|
---|
| 430 |
|
---|
| 431 | //
|
---|
| 432 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2296] | 433 | void bncPPPclient::applyCorr(const bncTime& tt, const t_corr* cc,
|
---|
| 434 | ColumnVector& xc, ColumnVector& vv) {
|
---|
[2043] | 435 | ColumnVector dx(3);
|
---|
[2041] | 436 |
|
---|
[2367] | 437 | double dt = tt - cc->tt;
|
---|
| 438 | ColumnVector raoHlp = cc->rao + cc->dotRao * dt + cc->dotDotRao * dt * dt;
|
---|
[2296] | 439 |
|
---|
| 440 | RSW_to_XYZ(xc.Rows(1,3), vv, raoHlp, dx);
|
---|
| 441 |
|
---|
[2414] | 442 | xc[0] -= dx[0];
|
---|
| 443 | xc[1] -= dx[1];
|
---|
| 444 | xc[2] -= dx[2];
|
---|
[2417] | 445 | xc[3] += cc->dClk + cc->dotDClk * dt + cc->dotDotDClk * dt * dt;
|
---|
[2041] | 446 | }
|
---|
| 447 |
|
---|
[2049] | 448 | // Correct Time of Transmission
|
---|
| 449 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2240] | 450 | t_irc bncPPPclient::cmpToT(t_satData* satData) {
|
---|
[2049] | 451 |
|
---|
[2051] | 452 | double prange = satData->P3;
|
---|
[2049] | 453 | if (prange == 0.0) {
|
---|
| 454 | return failure;
|
---|
| 455 | }
|
---|
| 456 |
|
---|
| 457 | double clkSat = 0.0;
|
---|
| 458 | for (int ii = 1; ii <= 10; ii++) {
|
---|
| 459 |
|
---|
[2123] | 460 | bncTime ToT = _epoData->tt - prange / t_CST::c - clkSat;
|
---|
[2049] | 461 |
|
---|
| 462 | ColumnVector xc(4);
|
---|
| 463 | ColumnVector vv(3);
|
---|
[2357] | 464 | if (getSatPos(ToT, satData->prn, xc, vv) != success) {
|
---|
[2049] | 465 | return failure;
|
---|
| 466 | }
|
---|
| 467 |
|
---|
| 468 | double clkSatOld = clkSat;
|
---|
[2050] | 469 | clkSat = xc(4);
|
---|
[2049] | 470 |
|
---|
| 471 | if ( fabs(clkSat-clkSatOld) * t_CST::c < 1.e-4 ) {
|
---|
| 472 | satData->xx = xc.Rows(1,3);
|
---|
| 473 | satData->vv = vv;
|
---|
[2050] | 474 | satData->clk = clkSat * t_CST::c;
|
---|
[2049] | 475 | return success;
|
---|
| 476 | }
|
---|
| 477 | }
|
---|
| 478 |
|
---|
| 479 | return failure;
|
---|
| 480 | }
|
---|
| 481 |
|
---|
[2041] | 482 | //
|
---|
| 483 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2035] | 484 | void bncPPPclient::processEpoch() {
|
---|
| 485 |
|
---|
[2053] | 486 | // Data Pre-Processing
|
---|
| 487 | // -------------------
|
---|
[2231] | 488 | QMutableMapIterator<QString, t_satData*> iGPS(_epoData->satDataGPS);
|
---|
| 489 | while (iGPS.hasNext()) {
|
---|
| 490 | iGPS.next();
|
---|
| 491 | QString prn = iGPS.key();
|
---|
| 492 | t_satData* satData = iGPS.value();
|
---|
[2049] | 493 |
|
---|
[2240] | 494 | if (cmpToT(satData) != success) {
|
---|
[2049] | 495 | delete satData;
|
---|
[2231] | 496 | iGPS.remove();
|
---|
[2049] | 497 | continue;
|
---|
| 498 | }
|
---|
[2053] | 499 | }
|
---|
[2035] | 500 |
|
---|
[2231] | 501 | QMutableMapIterator<QString, t_satData*> iGlo(_epoData->satDataGlo);
|
---|
| 502 | while (iGlo.hasNext()) {
|
---|
| 503 | iGlo.next();
|
---|
| 504 | QString prn = iGlo.key();
|
---|
| 505 | t_satData* satData = iGlo.value();
|
---|
| 506 |
|
---|
[2240] | 507 | if (cmpToT(satData) != success) {
|
---|
[2231] | 508 | delete satData;
|
---|
| 509 | iGlo.remove();
|
---|
| 510 | continue;
|
---|
| 511 | }
|
---|
| 512 | }
|
---|
| 513 |
|
---|
[2060] | 514 | // Filter Solution
|
---|
| 515 | // ---------------
|
---|
[2143] | 516 | if (_model->update(_epoData) == success) {
|
---|
[2145] | 517 | emit newPosition(_model->time(), _model->x(), _model->y(), _model->z());
|
---|
[2060] | 518 | }
|
---|
[2035] | 519 | }
|
---|
[2049] | 520 |
|
---|