[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>
|
---|
[2549] | 43 | #include <sstream>
|
---|
[2238] | 44 |
|
---|
[2035] | 45 | #include "bncpppclient.h"
|
---|
[2113] | 46 | #include "bncapp.h"
|
---|
[2043] | 47 | #include "bncutils.h"
|
---|
[2044] | 48 | #include "bncconst.h"
|
---|
[2058] | 49 | #include "bncmodel.h"
|
---|
[2226] | 50 | #include "bncsettings.h"
|
---|
[2035] | 51 |
|
---|
| 52 | extern "C" {
|
---|
| 53 | #include "clock_orbit_rtcm.h"
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | using namespace std;
|
---|
| 57 |
|
---|
| 58 | // Constructor
|
---|
| 59 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 60 | bncPPPclient::bncPPPclient(QByteArray staID) {
|
---|
[2113] | 61 |
|
---|
[2226] | 62 | bncSettings settings;
|
---|
| 63 |
|
---|
| 64 | if ( Qt::CheckState(settings.value("pppGLONASS").toInt()) == Qt::Checked) {
|
---|
| 65 | _useGlonass = true;
|
---|
| 66 | }
|
---|
| 67 | else {
|
---|
| 68 | _useGlonass = false;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
[2786] | 71 | if ( Qt::CheckState(settings.value("pppGalileo").toInt()) == Qt::Checked) {
|
---|
| 72 | _useGalileo = true;
|
---|
| 73 | }
|
---|
| 74 | else {
|
---|
| 75 | _useGalileo = false;
|
---|
| 76 | }
|
---|
[2776] | 77 |
|
---|
[2357] | 78 | if (settings.value("pppSPP").toString() == "PPP") {
|
---|
| 79 | _pppMode = true;
|
---|
| 80 | }
|
---|
| 81 | else {
|
---|
| 82 | _pppMode = false;
|
---|
| 83 | }
|
---|
| 84 |
|
---|
[2548] | 85 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
---|
| 86 | ((bncApp*)qApp), SLOT(slotMessage(const QByteArray,bool)));
|
---|
| 87 |
|
---|
[2113] | 88 | connect(((bncApp*)qApp), SIGNAL(newCorrections(QList<QString>)),
|
---|
[2585] | 89 | this, SLOT(slotNewCorrections(QList<QString>)));
|
---|
[2113] | 90 |
|
---|
[2039] | 91 | _staID = staID;
|
---|
[2113] | 92 | _model = new bncModel(staID);
|
---|
[2182] | 93 | connect(_model, SIGNAL(newNMEAstr(QByteArray)),
|
---|
| 94 | this, SIGNAL(newNMEAstr(QByteArray)));
|
---|
[2035] | 95 | }
|
---|
| 96 |
|
---|
| 97 | // Destructor
|
---|
| 98 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 99 | bncPPPclient::~bncPPPclient() {
|
---|
[2058] | 100 | delete _model;
|
---|
[2808] | 101 | while (!_epoData.empty()) {
|
---|
| 102 | delete _epoData.front();
|
---|
| 103 | _epoData.pop();
|
---|
| 104 | }
|
---|
[2035] | 105 | QMapIterator<QString, t_corr*> ic(_corr);
|
---|
| 106 | while (ic.hasNext()) {
|
---|
| 107 | ic.next();
|
---|
| 108 | delete ic.value();
|
---|
| 109 | }
|
---|
[2274] | 110 | QMapIterator<QString, t_bias*> ib(_bias);
|
---|
| 111 | while (ib.hasNext()) {
|
---|
| 112 | ib.next();
|
---|
| 113 | delete ib.value();
|
---|
| 114 | }
|
---|
[2035] | 115 | }
|
---|
| 116 |
|
---|
| 117 | //
|
---|
| 118 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2711] | 119 | void bncPPPclient::putNewObs(const t_obs& obs) {
|
---|
[2037] | 120 | QMutexLocker locker(&_mutex);
|
---|
[2051] | 121 |
|
---|
[2777] | 122 | if (obs.satSys == 'R') {
|
---|
| 123 | if (!_useGlonass) return;
|
---|
[2225] | 124 | }
|
---|
[2777] | 125 | else if (obs.satSys == 'E') {
|
---|
| 126 | if (!_useGalileo) return;
|
---|
[2776] | 127 | }
|
---|
| 128 | else if (obs.satSys != 'G') {
|
---|
| 129 | return;
|
---|
| 130 | }
|
---|
[2225] | 131 |
|
---|
[2051] | 132 | t_satData* satData = new t_satData();
|
---|
[2808] | 133 | satData->tt = bncTime(obs.GPSWeek, obs.GPSWeeks);
|
---|
[2051] | 134 |
|
---|
[2274] | 135 | // Satellite Number
|
---|
| 136 | // ----------------
|
---|
[2777] | 137 | satData->prn = QString("%1%2").arg(obs.satSys).arg(obs.satNum,2,10,QChar('0'));
|
---|
[2274] | 138 |
|
---|
[2505] | 139 | // Check Slips
|
---|
| 140 | // -----------
|
---|
| 141 | slipInfo& sInfo = _slips[satData->prn];
|
---|
[2711] | 142 | if ( sInfo.slipCntL1 == obs.slip_cnt_L1 &&
|
---|
[2778] | 143 | sInfo.slipCntL2 == obs.slip_cnt_L2 &&
|
---|
| 144 | sInfo.slipCntL5 == obs.slip_cnt_L5 ) {
|
---|
[2505] | 145 | satData->slipFlag = false;
|
---|
| 146 | }
|
---|
| 147 | else {
|
---|
| 148 | satData->slipFlag = true;
|
---|
| 149 | }
|
---|
[2711] | 150 | sInfo.slipCntL1 = obs.slip_cnt_L1;
|
---|
| 151 | sInfo.slipCntL2 = obs.slip_cnt_L2;
|
---|
[2505] | 152 |
|
---|
[2274] | 153 | // Handle Code Biases
|
---|
| 154 | // ------------------
|
---|
| 155 | t_bias* bb = 0;
|
---|
| 156 | if (_bias.contains(satData->prn)) {
|
---|
| 157 | bb = _bias.value(satData->prn);
|
---|
| 158 | }
|
---|
| 159 |
|
---|
[2808] | 160 | // Add new epoch, process the older ones
|
---|
| 161 | // -------------------------------------
|
---|
| 162 | if (_epoData.size() == 0) {
|
---|
| 163 | _epoData.push(new t_epoData());
|
---|
| 164 | _epoData.back()->tt = satData->tt;
|
---|
[2037] | 165 | }
|
---|
[2808] | 166 | else if (satData->tt != _epoData.back()->tt) {
|
---|
| 167 | processEpochs();
|
---|
| 168 | _epoData.push(new t_epoData());
|
---|
| 169 | _epoData.back()->tt = satData->tt;
|
---|
[2037] | 170 | }
|
---|
[2039] | 171 |
|
---|
[2786] | 172 | // Set Observations GPS
|
---|
| 173 | // --------------------
|
---|
[2711] | 174 | if (obs.satSys == 'G') {
|
---|
[2786] | 175 | if ( (obs.P1 || obs.C1) && (obs.P2 || obs.C2) && obs.L1() && obs.L2() ) {
|
---|
| 176 | double f1 = t_CST::freq1;
|
---|
| 177 | double f2 = t_CST::freq2;
|
---|
| 178 | double c1 = f1 * f1 / (f1 * f1 - f2 * f2);
|
---|
| 179 | double c2 = - f2 * f2 / (f1 * f1 - f2 * f2);
|
---|
| 180 | if (obs.P1) {
|
---|
| 181 | satData->P1 = obs.P1 + (bb ? bb->p1 : 0.0);
|
---|
| 182 | }
|
---|
| 183 | else {
|
---|
| 184 | satData->P1 = obs.C1 + (bb ? bb->c1 : 0.0);
|
---|
| 185 | }
|
---|
| 186 | if (obs.P2) {
|
---|
| 187 | satData->P2 = obs.P2 + (bb ? bb->p2 : 0.0);
|
---|
| 188 | }
|
---|
| 189 | else {
|
---|
| 190 | satData->P2 = obs.C2;
|
---|
| 191 | }
|
---|
| 192 | satData->L1 = obs.L1() * t_CST::c / f1;
|
---|
| 193 | satData->L2 = obs.L2() * t_CST::c / f2;
|
---|
| 194 | satData->P3 = c1 * satData->P1 + c2 * satData->P2;
|
---|
| 195 | satData->L3 = c1 * satData->L1 + c2 * satData->L2;
|
---|
| 196 | satData->lambda3 = c1 * t_CST::c / f1 + c2 * t_CST::c / f2;
|
---|
[2778] | 197 |
|
---|
[2808] | 198 | _epoData.back()->satDataGPS[satData->prn] = satData;
|
---|
[2778] | 199 | }
|
---|
| 200 | else {
|
---|
| 201 | delete satData;
|
---|
| 202 | }
|
---|
[2786] | 203 | }
|
---|
[2778] | 204 |
|
---|
[2786] | 205 | // Set Observations GLONASS
|
---|
| 206 | // ------------------------
|
---|
[2711] | 207 | else if (obs.satSys == 'R') {
|
---|
[2786] | 208 | if ( (obs.P1 || obs.C1) && (obs.P2 || obs.C2) && obs.L1() && obs.L2() ) {
|
---|
| 209 | double f1 = 1602000000.0 + 562500.0 * obs.slotNum;
|
---|
| 210 | double f2 = 1246000000.0 + 437500.0 * obs.slotNum;
|
---|
| 211 | double c1 = f1 * f1 / (f1 * f1 - f2 * f2);
|
---|
| 212 | double c2 = - f2 * f2 / (f1 * f1 - f2 * f2);
|
---|
| 213 | if (obs.P1) {
|
---|
| 214 | satData->P1 = obs.P1 + (bb ? bb->p1 : 0.0);
|
---|
| 215 | }
|
---|
| 216 | else {
|
---|
| 217 | satData->P1 = obs.C1 + (bb ? bb->c1 : 0.0);
|
---|
| 218 | }
|
---|
| 219 | if (obs.P2) {
|
---|
| 220 | satData->P2 = obs.P2 + (bb ? bb->p2 : 0.0);
|
---|
| 221 | }
|
---|
| 222 | else {
|
---|
| 223 | satData->P2 = obs.C2;
|
---|
| 224 | }
|
---|
| 225 | satData->L1 = obs.L1() * t_CST::c / f1;
|
---|
| 226 | satData->L2 = obs.L2() * t_CST::c / f2;
|
---|
| 227 | satData->P3 = c1 * satData->P1 + c2 * satData->P2;
|
---|
| 228 | satData->L3 = c1 * satData->L1 + c2 * satData->L2;
|
---|
| 229 | satData->lambda3 = c1 * t_CST::c / f1 + c2 * t_CST::c / f2;
|
---|
[2778] | 230 |
|
---|
[2808] | 231 | _epoData.back()->satDataGlo[satData->prn] = satData;
|
---|
[2778] | 232 | }
|
---|
| 233 | else {
|
---|
| 234 | delete satData;
|
---|
| 235 | }
|
---|
[2786] | 236 | }
|
---|
[2778] | 237 |
|
---|
[2786] | 238 | // Set Observations Galileo
|
---|
| 239 | // ------------------------
|
---|
[2778] | 240 | else if (obs.satSys == 'E') {
|
---|
[2787] | 241 | if ( obs.C1 && obs.C5 && obs.L1() && obs.L5) {
|
---|
[2786] | 242 | double f1 = t_CST::freq1;
|
---|
| 243 | double f5 = t_CST::freq5;
|
---|
| 244 | double c1 = f1 * f1 / (f1 * f1 - f5 * f5);
|
---|
| 245 | double c5 = - f5 * f5 / (f1 * f1 - f5 * f5);
|
---|
[2778] | 246 |
|
---|
[2786] | 247 | satData->P1 = obs.C1;
|
---|
| 248 | satData->P5 = obs.C5;
|
---|
| 249 | satData->L1 = obs.L1() * t_CST::c / f1;
|
---|
| 250 | satData->L5 = obs.L5 * t_CST::c / f5;
|
---|
| 251 | satData->P3 = c1 * satData->P1 + c5 * satData->P5;
|
---|
| 252 | satData->L3 = c1 * satData->L1 + c5 * satData->L5;
|
---|
| 253 | satData->lambda3 = c1 * t_CST::c / f1 + c5 * t_CST::c / f5;
|
---|
[2808] | 254 | _epoData.back()->satDataGal[satData->prn] = satData;
|
---|
[2778] | 255 | }
|
---|
| 256 | else {
|
---|
| 257 | delete satData;
|
---|
| 258 | }
|
---|
| 259 | }
|
---|
[2035] | 260 | }
|
---|
| 261 |
|
---|
| 262 | //
|
---|
| 263 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 264 | void bncPPPclient::slotNewCorrections(QList<QString> corrList) {
|
---|
| 265 | QMutexLocker locker(&_mutex);
|
---|
[2069] | 266 |
|
---|
| 267 | if (corrList.size() == 0) {
|
---|
| 268 | return;
|
---|
| 269 | }
|
---|
| 270 |
|
---|
| 271 | // Remove All Corrections
|
---|
| 272 | // ----------------------
|
---|
| 273 | QMapIterator<QString, t_corr*> ic(_corr);
|
---|
| 274 | while (ic.hasNext()) {
|
---|
| 275 | ic.next();
|
---|
| 276 | delete ic.value();
|
---|
| 277 | }
|
---|
| 278 | _corr.clear();
|
---|
| 279 |
|
---|
[2035] | 280 | QListIterator<QString> it(corrList);
|
---|
| 281 | while (it.hasNext()) {
|
---|
| 282 | QTextStream in(it.next().toAscii());
|
---|
| 283 | int messageType;
|
---|
| 284 | int updateInterval;
|
---|
| 285 | int GPSweek;
|
---|
| 286 | double GPSweeks;
|
---|
| 287 | QString prn;
|
---|
| 288 | in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
|
---|
[2809] | 289 |
|
---|
[2035] | 290 | if ( messageType == COTYPE_GPSCOMBINED ||
|
---|
[2207] | 291 | messageType == COTYPE_GLONASSCOMBINED ||
|
---|
| 292 | messageType == COTYPE_GPSORBIT ||
|
---|
| 293 | messageType == COTYPE_GPSCLOCK ||
|
---|
| 294 | messageType == COTYPE_GLONASSORBIT ||
|
---|
| 295 | messageType == COTYPE_GLONASSCLOCK ) {
|
---|
| 296 |
|
---|
[2035] | 297 | t_corr* cc = 0;
|
---|
| 298 | if (_corr.contains(prn)) {
|
---|
| 299 | cc = _corr.value(prn);
|
---|
| 300 | }
|
---|
| 301 | else {
|
---|
| 302 | cc = new t_corr();
|
---|
| 303 | _corr[prn] = cc;
|
---|
| 304 | }
|
---|
[2207] | 305 |
|
---|
[2035] | 306 | cc->tt.set(GPSweek, GPSweeks);
|
---|
[2809] | 307 | _corr_tt.set(GPSweek, GPSweeks);
|
---|
[2207] | 308 |
|
---|
| 309 | if ( messageType == COTYPE_GPSCOMBINED ||
|
---|
| 310 | messageType == COTYPE_GLONASSCOMBINED ) {
|
---|
[2366] | 311 | cc->rao.ReSize(3); cc->rao = 0.0;
|
---|
| 312 | cc->dotRao.ReSize(3); cc->dotRao = 0.0;
|
---|
| 313 | cc->dotDotRao.ReSize(3); cc->dotDotRao = 0.0;
|
---|
| 314 | cc->dClk = 0.0;
|
---|
| 315 | cc->dotDClk = 0.0;
|
---|
| 316 | cc->dotDotDClk = 0.0;
|
---|
| 317 | in >> cc->iod
|
---|
| 318 | >> cc->dClk >> cc->rao[0] >> cc->rao[1] >> cc->rao[2]
|
---|
| 319 | >> cc->dotDClk >> cc->dotRao[0] >> cc->dotRao[1] >> cc->dotRao[2]
|
---|
| 320 | >> cc->dotDotDClk >> cc->dotDotRao[0] >> cc->dotDotRao[1] >> cc->dotDotRao[2];
|
---|
| 321 | cc->dClk /= t_CST::c;
|
---|
| 322 | cc->dotDClk /= t_CST::c;
|
---|
| 323 | cc->dotDotDClk /= t_CST::c;
|
---|
[2208] | 324 | cc->raoSet = true;
|
---|
| 325 | cc->dClkSet = true;
|
---|
[2207] | 326 | }
|
---|
| 327 | else if ( messageType == COTYPE_GPSORBIT ||
|
---|
| 328 | messageType == COTYPE_GLONASSORBIT ) {
|
---|
[2366] | 329 | cc->rao.ReSize(3); cc->rao = 0.0;
|
---|
| 330 | cc->dotRao.ReSize(3); cc->dotRao = 0.0;
|
---|
| 331 | cc->dotDotRao.ReSize(3); cc->dotDotRao = 0.0;
|
---|
| 332 | in >> cc->iod
|
---|
| 333 | >> cc->rao[0] >> cc->rao[1] >> cc->rao[2]
|
---|
| 334 | >> cc->dotRao[0] >> cc->dotRao[1] >> cc->dotRao[2]
|
---|
| 335 | >> cc->dotDotRao[0] >> cc->dotDotRao[1] >> cc->dotDotRao[2];
|
---|
[2208] | 336 | cc->raoSet = true;
|
---|
[2207] | 337 | }
|
---|
| 338 | else if ( messageType == COTYPE_GPSCLOCK ||
|
---|
| 339 | messageType == COTYPE_GLONASSCLOCK ) {
|
---|
| 340 | int dummyIOD;
|
---|
[2366] | 341 | cc->dClk = 0.0;
|
---|
| 342 | cc->dotDClk = 0.0;
|
---|
| 343 | cc->dotDotDClk = 0.0;
|
---|
| 344 | in >> dummyIOD >> cc->dClk >> cc->dotDClk >> cc->dotDotDClk;
|
---|
| 345 | cc->dClk /= t_CST::c;
|
---|
| 346 | cc->dotDClk /= t_CST::c;
|
---|
| 347 | cc->dotDotDClk /= t_CST::c;
|
---|
[2208] | 348 | cc->dClkSet = true;
|
---|
[2207] | 349 | }
|
---|
[2035] | 350 | }
|
---|
[2317] | 351 | else if ( messageType == BTYPE_GPS ) {
|
---|
[2274] | 352 |
|
---|
| 353 | t_bias* bb = 0;
|
---|
| 354 | if (_bias.contains(prn)) {
|
---|
[2341] | 355 | bb = _bias.value(prn);
|
---|
[2274] | 356 | }
|
---|
| 357 | else {
|
---|
| 358 | bb = new t_bias();
|
---|
| 359 | _bias[prn] = bb;
|
---|
| 360 | }
|
---|
| 361 |
|
---|
| 362 | bb->tt.set(GPSweek, GPSweeks);
|
---|
| 363 |
|
---|
| 364 | int numBiases;
|
---|
| 365 | in >> numBiases;
|
---|
| 366 | for (int ii = 0; ii < numBiases; ++ii) {
|
---|
| 367 | int bType;
|
---|
| 368 | double bValue;
|
---|
| 369 | in >> bType >> bValue;
|
---|
[2426] | 370 | if (bType == CODETYPEGPS_L1_Z) {
|
---|
[2429] | 371 | bb->p1 = bValue;
|
---|
[2274] | 372 | }
|
---|
[2426] | 373 | else if (bType == CODETYPEGPS_L1_CA) {
|
---|
[2429] | 374 | bb->c1 = bValue;
|
---|
[2426] | 375 | }
|
---|
[2365] | 376 | else if (bType == CODETYPEGPS_L2_Z) {
|
---|
[2429] | 377 | bb->p2 = bValue;
|
---|
[2274] | 378 | }
|
---|
| 379 | }
|
---|
| 380 | }
|
---|
[2035] | 381 | }
|
---|
[2208] | 382 |
|
---|
| 383 | QMutableMapIterator<QString, t_corr*> im(_corr);
|
---|
| 384 | while (im.hasNext()) {
|
---|
| 385 | im.next();
|
---|
| 386 | t_corr* cc = im.value();
|
---|
| 387 | if (!cc->ready()) {
|
---|
| 388 | delete cc;
|
---|
| 389 | im.remove();
|
---|
| 390 | }
|
---|
| 391 | }
|
---|
[2035] | 392 | }
|
---|
| 393 |
|
---|
| 394 | // Satellite Position
|
---|
| 395 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2123] | 396 | t_irc bncPPPclient::getSatPos(const bncTime& tt, const QString& prn,
|
---|
[2357] | 397 | ColumnVector& xc, ColumnVector& vv) {
|
---|
[2035] | 398 |
|
---|
[2576] | 399 | const double MAXAGE = 120.0;
|
---|
[2041] | 400 |
|
---|
[2035] | 401 | if (_eph.contains(prn)) {
|
---|
[2040] | 402 |
|
---|
[2357] | 403 | if (_pppMode) {
|
---|
[2068] | 404 | if (_corr.contains(prn)) {
|
---|
| 405 | t_corr* cc = _corr.value(prn);
|
---|
[2576] | 406 | if (tt - cc->tt < MAXAGE) {
|
---|
| 407 | t_eph* eLast = _eph.value(prn)->last;
|
---|
| 408 | t_eph* ePrev = _eph.value(prn)->prev;
|
---|
| 409 | if (eLast && eLast->IOD() == cc->iod) {
|
---|
| 410 | eLast->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
|
---|
| 411 | applyCorr(tt, cc, xc, vv);
|
---|
| 412 | return success;
|
---|
| 413 | }
|
---|
| 414 | else if (ePrev && ePrev->IOD() == cc->iod) {
|
---|
| 415 | ePrev->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
|
---|
| 416 | applyCorr(tt, cc, xc, vv);
|
---|
| 417 | return success;
|
---|
| 418 | }
|
---|
| 419 | }
|
---|
[2041] | 420 | }
|
---|
[2040] | 421 | }
|
---|
[2576] | 422 |
|
---|
| 423 | else {
|
---|
| 424 | t_eph* ee = _eph.value(prn)->last;
|
---|
| 425 | ee->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
|
---|
| 426 | return success;
|
---|
| 427 | }
|
---|
[2035] | 428 | }
|
---|
| 429 |
|
---|
| 430 | return failure;
|
---|
| 431 | }
|
---|
| 432 |
|
---|
| 433 | //
|
---|
| 434 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2296] | 435 | void bncPPPclient::applyCorr(const bncTime& tt, const t_corr* cc,
|
---|
| 436 | ColumnVector& xc, ColumnVector& vv) {
|
---|
[2043] | 437 | ColumnVector dx(3);
|
---|
[2041] | 438 |
|
---|
[2367] | 439 | double dt = tt - cc->tt;
|
---|
| 440 | ColumnVector raoHlp = cc->rao + cc->dotRao * dt + cc->dotDotRao * dt * dt;
|
---|
[2296] | 441 |
|
---|
| 442 | RSW_to_XYZ(xc.Rows(1,3), vv, raoHlp, dx);
|
---|
| 443 |
|
---|
[2414] | 444 | xc[0] -= dx[0];
|
---|
| 445 | xc[1] -= dx[1];
|
---|
| 446 | xc[2] -= dx[2];
|
---|
[2417] | 447 | xc[3] += cc->dClk + cc->dotDClk * dt + cc->dotDotDClk * dt * dt;
|
---|
[2041] | 448 | }
|
---|
| 449 |
|
---|
[2049] | 450 | // Correct Time of Transmission
|
---|
| 451 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2240] | 452 | t_irc bncPPPclient::cmpToT(t_satData* satData) {
|
---|
[2049] | 453 |
|
---|
[2051] | 454 | double prange = satData->P3;
|
---|
[2049] | 455 | if (prange == 0.0) {
|
---|
| 456 | return failure;
|
---|
| 457 | }
|
---|
| 458 |
|
---|
| 459 | double clkSat = 0.0;
|
---|
| 460 | for (int ii = 1; ii <= 10; ii++) {
|
---|
| 461 |
|
---|
[2808] | 462 | bncTime ToT = satData->tt - prange / t_CST::c - clkSat;
|
---|
[2049] | 463 |
|
---|
| 464 | ColumnVector xc(4);
|
---|
| 465 | ColumnVector vv(3);
|
---|
[2357] | 466 | if (getSatPos(ToT, satData->prn, xc, vv) != success) {
|
---|
[2049] | 467 | return failure;
|
---|
| 468 | }
|
---|
| 469 |
|
---|
| 470 | double clkSatOld = clkSat;
|
---|
[2050] | 471 | clkSat = xc(4);
|
---|
[2049] | 472 |
|
---|
| 473 | if ( fabs(clkSat-clkSatOld) * t_CST::c < 1.e-4 ) {
|
---|
| 474 | satData->xx = xc.Rows(1,3);
|
---|
| 475 | satData->vv = vv;
|
---|
[2050] | 476 | satData->clk = clkSat * t_CST::c;
|
---|
[2049] | 477 | return success;
|
---|
| 478 | }
|
---|
| 479 | }
|
---|
| 480 |
|
---|
| 481 | return failure;
|
---|
| 482 | }
|
---|
| 483 |
|
---|
[2041] | 484 | //
|
---|
| 485 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2808] | 486 | void bncPPPclient::processFrontEpoch() {
|
---|
[2035] | 487 |
|
---|
[2053] | 488 | // Data Pre-Processing
|
---|
| 489 | // -------------------
|
---|
[2808] | 490 | QMutableMapIterator<QString, t_satData*> iGPS(_epoData.front()->satDataGPS);
|
---|
[2231] | 491 | while (iGPS.hasNext()) {
|
---|
| 492 | iGPS.next();
|
---|
| 493 | QString prn = iGPS.key();
|
---|
| 494 | t_satData* satData = iGPS.value();
|
---|
[2049] | 495 |
|
---|
[2240] | 496 | if (cmpToT(satData) != success) {
|
---|
[2049] | 497 | delete satData;
|
---|
[2231] | 498 | iGPS.remove();
|
---|
[2049] | 499 | continue;
|
---|
| 500 | }
|
---|
[2053] | 501 | }
|
---|
[2035] | 502 |
|
---|
[2808] | 503 | QMutableMapIterator<QString, t_satData*> iGlo(_epoData.front()->satDataGlo);
|
---|
[2231] | 504 | while (iGlo.hasNext()) {
|
---|
| 505 | iGlo.next();
|
---|
| 506 | QString prn = iGlo.key();
|
---|
| 507 | t_satData* satData = iGlo.value();
|
---|
| 508 |
|
---|
[2240] | 509 | if (cmpToT(satData) != success) {
|
---|
[2231] | 510 | delete satData;
|
---|
| 511 | iGlo.remove();
|
---|
| 512 | continue;
|
---|
| 513 | }
|
---|
| 514 | }
|
---|
| 515 |
|
---|
[2808] | 516 | QMutableMapIterator<QString, t_satData*> iGal(_epoData.front()->satDataGal);
|
---|
[2779] | 517 | while (iGal.hasNext()) {
|
---|
| 518 | iGal.next();
|
---|
| 519 | QString prn = iGal.key();
|
---|
| 520 | t_satData* satData = iGal.value();
|
---|
| 521 |
|
---|
| 522 | if (cmpToT(satData) != success) {
|
---|
| 523 | delete satData;
|
---|
| 524 | iGal.remove();
|
---|
| 525 | continue;
|
---|
| 526 | }
|
---|
| 527 | }
|
---|
| 528 |
|
---|
[2060] | 529 | // Filter Solution
|
---|
| 530 | // ---------------
|
---|
[2808] | 531 | if (_model->update(_epoData.front()) == success) {
|
---|
[2145] | 532 | emit newPosition(_model->time(), _model->x(), _model->y(), _model->z());
|
---|
[2060] | 533 | }
|
---|
[2035] | 534 | }
|
---|
[2808] | 535 |
|
---|
| 536 | //
|
---|
| 537 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 538 | void bncPPPclient::processEpochs() {
|
---|
[2809] | 539 |
|
---|
[2810] | 540 | // Synchronization threshold (not used in SPP mode)
|
---|
| 541 | // ------------------------------------------------
|
---|
[2812] | 542 | bncSettings settings;
|
---|
| 543 | double maxDt = settings.value("pppSync").toDouble();
|
---|
[2809] | 544 | if (!_pppMode) {
|
---|
| 545 | maxDt = 0.0;
|
---|
| 546 | }
|
---|
| 547 |
|
---|
[2810] | 548 | // Make sure the buffer does not grow beyond any limit
|
---|
| 549 | // ---------------------------------------------------
|
---|
| 550 | const unsigned MAX_EPODATA_SIZE = 120;
|
---|
| 551 | if (_epoData.size() > MAX_EPODATA_SIZE) {
|
---|
| 552 | delete _epoData.front();
|
---|
| 553 | _epoData.pop();
|
---|
| 554 | }
|
---|
| 555 |
|
---|
| 556 | // Loop over all unprocessed epochs
|
---|
| 557 | // --------------------------------
|
---|
[2809] | 558 | while (!_epoData.empty()) {
|
---|
[2810] | 559 |
|
---|
[2809] | 560 | t_epoData* frontEpoData = _epoData.front();
|
---|
| 561 |
|
---|
| 562 | // No corrections yet, skip the epoch
|
---|
| 563 | // ----------------------------------
|
---|
| 564 | if (maxDt != 0.0 && !_corr_tt.valid()) {
|
---|
[2810] | 565 | return;
|
---|
[2809] | 566 | }
|
---|
| 567 |
|
---|
[2810] | 568 | // Process the front epoch
|
---|
| 569 | // -----------------------
|
---|
| 570 | if (maxDt == 0 || frontEpoData->tt - _corr_tt < maxDt) {
|
---|
[2809] | 571 | processFrontEpoch();
|
---|
| 572 | delete _epoData.front();
|
---|
| 573 | _epoData.pop();
|
---|
| 574 | }
|
---|
| 575 | else {
|
---|
| 576 | return;
|
---|
| 577 | }
|
---|
| 578 | }
|
---|
[2808] | 579 | }
|
---|