Changeset 3375 in ntrip
- Timestamp:
- Aug 28, 2011, 3:54:10 PM (13 years ago)
- Location:
- trunk/BNC
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bnc.pro
r3374 r3375 2 2 # Switch to debug configuration 3 3 # ----------------------------- 4 CONFIG -= debug5 CONFIG += release4 CONFIG -= release 5 CONFIG += debug 6 6 7 7 -
trunk/BNC/bncmodel.cpp
r3331 r3375 52 52 #include "bnctides.h" 53 53 #include "bncantex.h" 54 #include "bnccomb.h" 54 55 55 56 using namespace std; … … 60 61 const double MINELE_GAL = 10.0 * M_PI / 180.0; 61 62 const double MAXRES_CODE_GPS = 10.0; 62 const double MAXRES_PHASE_GPS = 0.0 5;63 const double MAXRES_PHASE_GLO = 0.0 5;63 const double MAXRES_PHASE_GPS = 0.04; 64 const double MAXRES_PHASE_GLO = 0.04; 64 65 const double MAXRES_CODE_GAL = 10.0; 65 const double MAXRES_PHASE_GAL = 0.0 5;66 const double MAXRES_PHASE_GAL = 0.04; 66 67 67 68 // Constructor … … 257 258 _xcBanc.ReSize(4); _xcBanc = 0.0; 258 259 _ellBanc.ReSize(3); _ellBanc = 0.0; 260 261 // Save for Outlier Detection 262 // -------------------------- 263 _epoData_sav = 0; 259 264 } 260 265 … … 691 696 // ---------------------- 692 697 if (update_p(epoData) != success) { 698 emit newMessage(_log, false); 693 699 return failure; 694 700 } … … 936 942 // Outlier Detection 937 943 //////////////////////////////////////////////////////////////////////////// 938 int bncModel::outlierDetection(int iPhase, const SymmetricMatrix& QQsav, 939 const ColumnVector& vv, 944 bool bncModel::outlierDetection(int iPhase, const ColumnVector& vv, 940 945 QMap<QString, t_satData*>& satDataGPS, 941 946 QMap<QString, t_satData*>& satDataGlo, … … 952 957 double maxRes; 953 958 954 int irc = 0;959 bool irc = false; 955 960 956 961 if (iPhase == 0) { … … 958 963 // Check GPS Code 959 964 // -------------- 960 if ( irc == 0) {965 if (!irc) { 961 966 findMaxRes(iPhase, vv,satDataGPS, prnCode, maxResCode, prnPhase, maxResPhase); 962 967 if (maxResCode > MAXRES_CODE_GPS) { 963 satDataGPS.remove(prnCode);964 968 prnRemoved = prnCode; 965 969 maxRes = maxResCode; 966 irc = 1;970 irc = true; 967 971 } 968 972 } … … 970 974 // Check Galileo Code 971 975 // ------------------ 972 if ( irc == 0) {976 if (!irc) { 973 977 findMaxRes(iPhase, vv,satDataGal, prnCode, maxResCode, prnPhase, maxResPhase); 974 978 if (maxResCode > MAXRES_CODE_GAL) { 975 satDataGal.remove(prnCode);976 979 prnRemoved = prnCode; 977 980 maxRes = maxResCode; 978 irc = 1;981 irc = true; 979 982 } 980 983 } … … 985 988 // Check Glonass Phase 986 989 // ------------------- 987 if ( irc == 0) {990 if (!irc) { 988 991 findMaxRes(iPhase, vv,satDataGlo, prnCode, maxResCode, prnPhase, maxResPhase); 989 992 if (maxResPhase > MAXRES_PHASE_GLO) { 990 satDataGlo.remove(prnPhase);991 993 prnRemoved = prnPhase; 992 994 maxRes = maxResPhase; 993 irc = 1;995 irc = true; 994 996 } 995 997 } … … 997 999 // Check Galileo Phase 998 1000 // ------------------- 999 if ( irc == 0) {1001 if (!irc) { 1000 1002 findMaxRes(iPhase, vv,satDataGal, prnCode, maxResCode, prnPhase, maxResPhase); 1001 1003 if (maxResPhase > MAXRES_PHASE_GAL) { 1002 satDataGal.remove(prnPhase);1003 1004 prnRemoved = prnPhase; 1004 1005 maxRes = maxResPhase; 1005 irc = 1;1006 irc = true; 1006 1007 } 1007 1008 } … … 1009 1010 // Check GPS Phase 1010 1011 // --------------- 1011 if ( irc == 0) {1012 if (!irc) { 1012 1013 findMaxRes(iPhase, vv,satDataGPS, prnCode, maxResCode, prnPhase, maxResPhase); 1013 1014 if (maxResPhase > MAXRES_PHASE_GPS) { 1014 satDataGPS.remove(prnPhase);1015 1015 prnRemoved = prnPhase; 1016 1016 maxRes = maxResPhase; 1017 irc = 1;1017 irc = true; 1018 1018 } 1019 1019 } 1020 1020 } 1021 1021 1022 if (irc != 0) {1022 if (irc) { 1023 1023 _log += "Outlier " + prnRemoved.toAscii() + " " 1024 1024 + QByteArray::number(maxRes, 'f', 3) + "\n"; 1025 _QQ = QQsav;1026 QVectorIterator<bncParam*> itPar(_params);1027 while (itPar.hasNext()) {1028 bncParam* par = itPar.next();1029 if (par->type == bncParam::AMB_L3 && par->prn == prnRemoved) {1030 par->numEpo = 0;1031 }1032 }1033 1025 } 1034 1026 … … 1312 1304 } 1313 1305 1306 bool findInVector(const std::vector<QString>& vv, const QString& str) { 1307 std::vector<QString>::const_iterator it; 1308 for (it = vv.begin(); it != vv.end(); ++it) { 1309 if ( (*it) == str) { 1310 return true; 1311 } 1312 } 1313 return false; 1314 } 1315 1314 1316 // Update Step (private - loop over outliers) 1315 1317 //////////////////////////////////////////////////////////////////////////// … … 1318 1320 Tracer tracer("bncModel::update_p"); 1319 1321 1320 rememberState(); 1321 1322 for (int iPhase = 0; iPhase <= (_usePhase ? 1 : 0); iPhase++) { 1323 1324 SymmetricMatrix QQsav; 1325 ColumnVector vv; 1326 ColumnVector dx; 1327 1322 rememberState(epoData); 1323 1324 ColumnVector dx; 1325 1326 std::vector<QString> allPrns; 1327 getAllPrns(epoData, &allPrns); 1328 1329 std::vector<QString> usedPrns; 1330 1331 // Try with all satellites, then with all minus one, etc. 1332 // ------------------------------------------------------ 1333 for (unsigned nNeglected = 0; nNeglected < allPrns.size(); nNeglected++) { 1334 usedPrns = allPrns; 1335 1336 for (unsigned ii = 0; ii < nNeglected && usedPrns.size() > 0; ii++) { 1337 usedPrns.pop_back(); 1338 } 1339 1340 bool outlierDetected = false; 1341 1342 // Loop over all Combinations of "nUsed" Satellites 1343 // ------------------------------------------------ 1328 1344 do { 1329 1345 1330 // Bancroft Solution 1331 // ----------------- 1332 if (iPhase == 0) { 1333 if (cmpBancroft(epoData) != success) { 1334 restoreState(); 1335 emit newMessage(_log, false); 1336 return failure; 1337 } 1338 } 1339 else { 1340 if (epoData->sizeGPS() < MINOBS) { 1341 restoreState(); 1342 _log += "bncModel::update_p: not enough data\n"; 1343 emit newMessage(_log, false); 1344 return failure; 1345 } 1346 unsigned numSatNoSlip = 0; 1347 QVectorIterator<bncParam*> itPar(_params); 1348 while (itPar.hasNext()) { 1349 bncParam* par = itPar.next(); 1350 if (par->type == bncParam::AMB_L3 && par->prn[0] == 'G') { 1351 if (par->numEpo >= 1) { 1352 ++numSatNoSlip; 1346 if (outlierDetected) { 1347 _log += "TRY WITH PRNs: "; 1348 for (unsigned ip = 0; ip < usedPrns.size(); ip++) { 1349 _log += usedPrns[ip] + ' '; 1350 } 1351 _log += '\n'; 1352 } 1353 1354 for (unsigned ip = 0; ip < allPrns.size(); ip++) { 1355 QString prn = allPrns[ip]; 1356 if ( !findInVector(usedPrns, prn) ) { 1357 epoData->satDataGPS.remove(prn); 1358 epoData->satDataGlo.remove(prn); 1359 epoData->satDataGal.remove(prn); 1360 } 1361 } 1362 1363 // First update using code observations, then phase observations 1364 // ------------------------------------------------------------- 1365 for (int iPhase = 0; iPhase <= (_usePhase ? 1 : 0); iPhase++) { 1366 1367 // Bancroft Solution 1368 // ----------------- 1369 if (iPhase == 0) { 1370 if (cmpBancroft(epoData) != success) { 1371 restoreState(epoData); 1372 return failure; 1373 } 1374 } 1375 else { 1376 if (epoData->sizeGPS() < MINOBS) { 1377 restoreState(epoData); 1378 _log += "bncModel::update_p: not enough data\n"; 1379 return failure; 1380 } 1381 unsigned numSatNoSlip = 0; 1382 QVectorIterator<bncParam*> itPar(_params); 1383 while (itPar.hasNext()) { 1384 bncParam* par = itPar.next(); 1385 if (par->type == bncParam::AMB_L3 && par->prn[0] == 'G') { 1386 if (par->numEpo >= 1) { 1387 ++numSatNoSlip; 1388 } 1353 1389 } 1354 1390 } 1355 } 1356 if (numSatNoSlip > 0 && numSatNoSlip < MINOBS) { 1357 restoreState(); 1358 _log += "bncModel::update_p: not enough GPS satellites without cycle-slips\n"; 1359 emit newMessage(_log, false); 1360 return failure; 1361 } 1362 } 1363 1364 // Status Prediction 1365 // ----------------- 1366 predict(iPhase, epoData); 1367 1368 // Create First-Design Matrix 1369 // -------------------------- 1370 unsigned nPar = _params.size(); 1371 unsigned nObs = 0; 1372 if (iPhase == 0) { 1373 nObs = epoData->sizeGPS() + epoData->sizeGal(); // Glonass code not used 1374 } 1375 else { 1376 nObs = epoData->sizeGPS() + epoData->sizeGal() + epoData->sizeGlo(); 1377 } 1378 1379 Matrix AA(nObs, nPar); // first design matrix 1380 ColumnVector ll(nObs); // tems observed-computed 1381 DiagonalMatrix PP(nObs); PP = 0.0; 1382 1383 unsigned iObs = 0; 1384 1385 // GPS 1386 // --- 1387 QMapIterator<QString, t_satData*> itGPS(epoData->satDataGPS); 1388 while (itGPS.hasNext()) { 1389 itGPS.next(); 1390 t_satData* satData = itGPS.value(); 1391 addObs(iPhase, iObs, satData, AA, ll, PP); 1392 } 1393 1394 // Glonass 1395 // ------- 1396 if (iPhase == 1) { 1397 QMapIterator<QString, t_satData*> itGlo(epoData->satDataGlo); 1398 while (itGlo.hasNext()) { 1399 itGlo.next(); 1400 t_satData* satData = itGlo.value(); 1401 addObs(iPhase, iObs, satData, AA, ll, PP); 1402 } 1403 } 1404 1405 // Galileo 1406 // ------- 1407 QMapIterator<QString, t_satData*> itGal(epoData->satDataGal); 1408 while (itGal.hasNext()) { 1409 itGal.next(); 1410 t_satData* satData = itGal.value(); 1411 addObs(iPhase, iObs, satData, AA, ll, PP); 1412 } 1413 1414 // Compute Filter Update 1415 // --------------------- 1416 QQsav = _QQ; 1417 1418 kalman(AA, ll, PP, _QQ, dx); 1419 1420 vv = ll - AA * dx; 1421 1422 // Print Residuals 1423 // --------------- 1424 if (true) { 1425 ostringstream str; 1426 str.setf(ios::fixed); 1427 1391 if (numSatNoSlip > 0 && numSatNoSlip < MINOBS) { 1392 restoreState(epoData); 1393 _log += "bncModel::update_p: not enough GPS satellites without cycle-slips\n"; 1394 return failure; 1395 } 1396 } 1397 1398 // Status Prediction 1399 // ----------------- 1400 predict(iPhase, epoData); 1401 1402 // Create First-Design Matrix 1403 // -------------------------- 1404 unsigned nPar = _params.size(); 1405 unsigned nObs = 0; 1406 if (iPhase == 0) { 1407 nObs = epoData->sizeGPS() + epoData->sizeGal(); // Glonass code not used 1408 } 1409 else { 1410 nObs = epoData->sizeGPS() + epoData->sizeGal() + epoData->sizeGlo(); 1411 } 1412 1413 Matrix AA(nObs, nPar); // first design matrix 1414 ColumnVector ll(nObs); // tems observed-computed 1415 DiagonalMatrix PP(nObs); PP = 0.0; 1416 1417 unsigned iObs = 0; 1418 1419 // GPS 1420 // --- 1428 1421 QMapIterator<QString, t_satData*> itGPS(epoData->satDataGPS); 1429 1422 while (itGPS.hasNext()) { 1430 1423 itGPS.next(); 1431 1424 t_satData* satData = itGPS.value(); 1432 printRes(iPhase, vv, str, satData); 1433 } 1425 QString prn = satData->prn; 1426 if (findInVector(usedPrns, satData->prn)) { 1427 addObs(iPhase, iObs, satData, AA, ll, PP); 1428 } 1429 } 1430 1431 // Glonass 1432 // ------- 1434 1433 if (iPhase == 1) { 1435 1434 QMapIterator<QString, t_satData*> itGlo(epoData->satDataGlo); … … 1437 1436 itGlo.next(); 1438 1437 t_satData* satData = itGlo.value(); 1439 printRes(iPhase, vv, str, satData); 1440 } 1441 } 1438 if (findInVector(usedPrns, satData->prn)) { 1439 addObs(iPhase, iObs, satData, AA, ll, PP); 1440 } 1441 } 1442 } 1443 1444 // Galileo 1445 // ------- 1442 1446 QMapIterator<QString, t_satData*> itGal(epoData->satDataGal); 1443 1447 while (itGal.hasNext()) { 1444 1448 itGal.next(); 1445 1449 t_satData* satData = itGal.value(); 1446 printRes(iPhase, vv, str, satData); 1447 } 1448 _log += str.str().c_str(); 1449 } 1450 1451 } while (outlierDetection(iPhase, QQsav, vv, epoData->satDataGPS, 1452 epoData->satDataGlo, epoData->satDataGal) != 0); 1453 1454 // Update Parameters 1455 // ----------------- 1456 QVectorIterator<bncParam*> itPar(_params); 1457 while (itPar.hasNext()) { 1458 bncParam* par = itPar.next(); 1459 par->xx += dx(par->index); 1460 } 1461 } 1462 1463 return success; 1450 if (findInVector(usedPrns, satData->prn)) { 1451 addObs(iPhase, iObs, satData, AA, ll, PP); 1452 } 1453 } 1454 1455 // Compute Filter Update 1456 // --------------------- 1457 kalman(AA, ll, PP, _QQ, dx); 1458 1459 ColumnVector vv = ll - AA * dx; 1460 1461 // Print Residuals 1462 // --------------- 1463 if (true) { 1464 ostringstream str; 1465 str.setf(ios::fixed); 1466 1467 QMapIterator<QString, t_satData*> itGPS(epoData->satDataGPS); 1468 while (itGPS.hasNext()) { 1469 itGPS.next(); 1470 t_satData* satData = itGPS.value(); 1471 printRes(iPhase, vv, str, satData); 1472 } 1473 if (iPhase == 1) { 1474 QMapIterator<QString, t_satData*> itGlo(epoData->satDataGlo); 1475 while (itGlo.hasNext()) { 1476 itGlo.next(); 1477 t_satData* satData = itGlo.value(); 1478 printRes(iPhase, vv, str, satData); 1479 } 1480 } 1481 QMapIterator<QString, t_satData*> itGal(epoData->satDataGal); 1482 while (itGal.hasNext()) { 1483 itGal.next(); 1484 t_satData* satData = itGal.value(); 1485 printRes(iPhase, vv, str, satData); 1486 } 1487 _log += str.str().c_str(); 1488 } 1489 1490 // Check the residuals 1491 // ------------------- 1492 outlierDetected = outlierDetection(iPhase, vv, 1493 epoData->satDataGPS, 1494 epoData->satDataGlo, 1495 epoData->satDataGal); 1496 if (outlierDetected) { 1497 restoreState(epoData); 1498 break; 1499 } 1500 1501 } // for (int iPhase = 0; iPhase <= (_usePhase ? 1 : 0); iPhase++) 1502 1503 // Update Parameters 1504 // ----------------- 1505 if (!outlierDetected) { 1506 QVectorIterator<bncParam*> itPar(_params); 1507 while (itPar.hasNext()) { 1508 bncParam* par = itPar.next(); 1509 par->xx += dx(par->index); 1510 } 1511 return success; 1512 } 1513 1514 } while ( next_combination(allPrns.begin(), allPrns.end(), 1515 usedPrns.begin(), usedPrns.end()) ); 1516 1517 } // for (unsigned nUsed = allPrns.size(); nUsed >= MINOBS; nUsed--) 1518 1519 return failure; 1464 1520 } 1465 1521 1466 1522 // Remeber Original State Vector and Variance-Covariance Matrix 1467 1523 //////////////////////////////////////////////////////////////////////////// 1468 void bncModel::rememberState( ) {1524 void bncModel::rememberState(t_epoData* epoData) { 1469 1525 1470 1526 _QQ_sav = _QQ; … … 1482 1538 _params_sav.push_back(new bncParam(*par)); 1483 1539 } 1540 1541 delete _epoData_sav; 1542 _epoData_sav = new t_epoData(*epoData); 1484 1543 } 1485 1544 1486 1545 // Restore Original State Vector and Variance-Covariance Matrix 1487 1546 //////////////////////////////////////////////////////////////////////////// 1488 void bncModel::restoreState( ) {1547 void bncModel::restoreState(t_epoData* epoData) { 1489 1548 1490 1549 _QQ = _QQ_sav; … … 1502 1561 _params.push_back(new bncParam(*par)); 1503 1562 } 1504 } 1505 1563 1564 delete epoData; 1565 epoData = new t_epoData(*_epoData_sav); 1566 } 1567 1568 // 1569 //////////////////////////////////////////////////////////////////////////// 1570 void bncModel::getAllPrns(const t_epoData* epoData, 1571 std::vector<QString>* allPrns) { 1572 1573 QMapIterator<QString, t_satData*> itGPS(epoData->satDataGPS); 1574 while (itGPS.hasNext()) { 1575 itGPS.next(); 1576 t_satData* satData = itGPS.value(); 1577 allPrns->push_back(satData->prn); 1578 } 1579 1580 // Glonass 1581 // ------- 1582 QMapIterator<QString, t_satData*> itGlo(epoData->satDataGlo); 1583 while (itGlo.hasNext()) { 1584 itGlo.next(); 1585 t_satData* satData = itGlo.value(); 1586 allPrns->push_back(satData->prn); 1587 } 1588 1589 // Galileo 1590 // ------- 1591 QMapIterator<QString, t_satData*> itGal(epoData->satDataGal); 1592 while (itGal.hasNext()) { 1593 itGal.next(); 1594 t_satData* satData = itGal.value(); 1595 allPrns->push_back(satData->prn); 1596 } 1597 } 1598 -
trunk/BNC/bncmodel.h
r3330 r3375 29 29 #include <QtNetwork> 30 30 #include <newmat.h> 31 #include <vector> 31 32 32 33 #include "bncconst.h" … … 109 110 void predict(int iPhase, t_epoData* epoData); 110 111 t_irc update_p(t_epoData* epoData); 111 int outlierDetection(int iPhase, const SymmetricMatrix& QQsav, 112 const ColumnVector& vv, 112 bool outlierDetection(int iPhase, const ColumnVector& vv, 113 113 QMap<QString, t_satData*>& satDataGPS, 114 114 QMap<QString, t_satData*>& satDataGlo, … … 119 119 const ColumnVector& rRec); 120 120 121 void getAllPrns(const t_epoData* epoData, std::vector<QString>* allPrns); 122 121 123 bncTime _startTime; 122 124 123 void rememberState( );124 void restoreState( );125 void rememberState(t_epoData* epoData); 126 void restoreState(t_epoData* epoData); 125 127 126 128 class pppPos { … … 142 144 QVector<bncParam*> _params_sav; 143 145 SymmetricMatrix _QQ_sav; 146 t_epoData* _epoData_sav; 144 147 ColumnVector _xcBanc; 145 148 ColumnVector _ellBanc; -
trunk/BNC/bncpppclient.h
r3319 r3375 65 65 public: 66 66 t_epoData() {} 67 68 t_epoData(const t_epoData& ed) { 69 tt = ed.tt; 70 QMapIterator<QString, t_satData*> itGPS(ed.satDataGPS); 71 while (itGPS.hasNext()) { 72 itGPS.next(); 73 satDataGPS[itGPS.key()] = new t_satData(*itGPS.value()); 74 } 75 QMapIterator<QString, t_satData*> itGlo(ed.satDataGlo); 76 while (itGlo.hasNext()) { 77 itGlo.next(); 78 satDataGlo[itGPS.key()] = new t_satData(*itGlo.value()); 79 } 80 QMapIterator<QString, t_satData*> itGal(ed.satDataGal); 81 while (itGal.hasNext()) { 82 itGal.next(); 83 satDataGPS[itGal.key()] = new t_satData(*itGal.value()); 84 } 85 } 86 67 87 ~t_epoData() { 68 88 QMapIterator<QString, t_satData*> itGPS(satDataGPS); … … 87 107 unsigned sizeAll() const {return satDataGPS.size() + satDataGlo.size() + 88 108 satDataGal.size();} 89 bncTime 109 bncTime tt; 90 110 QMap<QString, t_satData*> satDataGPS; 91 111 QMap<QString, t_satData*> satDataGlo;
Note:
See TracChangeset
for help on using the changeset viewer.