/* Method to really get the weight of a given satellite. * * @param sat Satellite * @param time Epoch * @param bcEph Broadcast EphemerisStore object to be used */ double ComputeIURAWeights::getWeight( const SatID& sat, const DayTime& time, const GPSEphemerisStore* bcEph ) throw(InvalidWeights) { // Set by default a very big value int iura(1000000); double sigma(1000000.0); EngEphemeris engEph; try { // Look if this satellite is present in ephemeris engEph = bcEph->findEphemeris(sat, time); // If so, get the IURA iura = engEph.getAccFlag(); } catch(...) { InvalidWeights eWeight("Satellite not found."); GPSTK_THROW(eWeight); } // Compute and return the weight sigma = gpstk::ura2nominalAccuracy(iura); return ( 1.0 / (sigma*sigma) ); } // End of method 'ComputeIURAWeights::getWeight()'
bool operator() (const EngEphemeris& l, const EngEphemeris& r) const { if ( (l.getPRNID() == r.getPRNID()) && (l.getIODC() == r.getIODC()) ) return true; return false; }
int main(int argc, char* argv[]) { // Set time to Day 153, 2011 (6/2/2011) at noon CivilTime g( 2011, 6, 2, 12, 14, 44.0, TimeSystem::GPS ); CommonTime dt = g.convertToCommonTime(); short weeknum = 1638; // By rules of Kepler Orbit, this must be week of Toe // Test data from 06/02/2011 long subframe1[10] = { 0x22C2663D, 0x1F0E29B8, 0x2664002B, 0x09FCC1B6, 0x0F60EB8A, 0x1299CE93, 0x29CD3DB6, 0x0597BB0F, 0x00000B68, 0x17B28E5C }; long subframe2[10] = { 0x22C2663D, 0x1F0E4A28, 0x05809675, 0x0EBD8AF1, 0x00089344, 0x008081F8, 0x1330CC2C, 0x0461E855, 0x034F8045, 0x17BB1E68 }; long subframe3[10] = { 0x22C2663D, 0x1F0E6BA0, 0x3FE129CD, 0x26E31837, 0x0006C96A, 0x35A74DFC, 0x065C8B0F, 0x1E4F400A, 0x3FE8966D, 0x05860C44 }; //The dump from ee.dump() and ee_copy.dump() should be the same // an EngEphemeris object is created, then used to create a Rinex3NavData EngEphemeris ee; ee.addSubframe(subframe1, weeknum, 3, 1); ee.addSubframe(subframe2, weeknum, 3, 1); ee.addSubframe(subframe3, weeknum, 3, 1); ee.dump(); Rinex3NavData rnd = Rinex3NavData(ee); //constructor EngEphemeris ee_copy; ee_copy = EngEphemeris(rnd); //cast ee_copy.dump(); }
// Try to convert the given pages into an EngEphemeris object. Returns true // upon success. bool makeEngEphemeris(EngEphemeris& eph, const EphemerisPages& pages) { EphemerisPages::const_iterator sf[4]; sf[1] = pages.find(1); if (sf[1] == pages.end()) return false; sf[2] = pages.find(2); if (sf[2] == pages.end()) return false; sf[3] = pages.find(3); if (sf[3] == pages.end()) return false; long t1 = sf[1]->second.getHOWTime(); long t2 = sf[2]->second.getHOWTime(); long t3 = sf[3]->second.getHOWTime(); if (t2 != t1+6 || t3 != t1+12) return false; int prn = sf[1]->second.prn; int week = sf[1]->second.time.GPSfullweek(); long sfa[10]; long long_sfa[10]; for (int i=1; i<=3; i++) { sf[i]->second.fillArray(sfa); for( int j = 0; j < 10; j++ ) long_sfa[j] = static_cast<long>( sfa[j] ); if (!eph.addSubframe(long_sfa, week, prn, 0)) return false; } if (eph.isData(1) && eph.isData(2) && eph.isData(3)) return true; return false; }
void processSubframes1to3(MDPNavSubframe& nav) { // For now, just look at L1 C/A navigation message if (nav.range != rcCA || nav.carrier != ccL1) return; NavIndex ni(RangeCarrierPair(nav.range, nav.carrier), nav.prn); ephData[ni] = nav; long sfa[10]; nav.fillArray(sfa); uint32_t uint_sfa[10]; for( int j = 0; j < 10; j++ ) uint_sfa[j] = static_cast<uint32_t>( sfa[j] ); numSubframesCollected++; if (gpstk::EngNav::checkParity(uint_sfa)) { paritySuccessCount++; ephPageStore[ni][nav.getSFID()] = nav; EngEphemeris engEph; if (makeEngEphemeris(engEph, ephPageStore[ni])) { currentPRN = engEph.getPRNID(); // debug if (firstNavSF) { earliestTime = engEph.getTransmitTime(); firstNavSF = false; } latestTime = engEph.getTransmitTime(); processEphemeris( engEph, ephPageStore[ni] ); } } else parityFailCount++; } // end of process(MDPNavSubframe)
RinexNavData::operator EngEphemeris() const throw() { EngEphemeris ee; // there's no TLM word in RinexNavData, so it's set to 0. // likewise, there's no AS alert or tracker. // Also, in Rinex, the accuracy is in meters, and setSF1 expects // the accuracy flag. We'll give it zero and pass the accuracy // separately via the setAccuracy() method. ee.setSF1(0, HOWtime, 0, weeknum, codeflgs, 0, health, short(IODC), L2Pdata, Tgd, Toc, af2, af1, af0, 0, PRNID); ee.setSF2(0, HOWtime, 0, short(IODE), Crs, dn, M0, Cuc, ecc, Cus, Ahalf, Toe, (fitint > 4) ? 1 : 0); ee.setSF3(0, HOWtime, 0, Cic, OMEGA0, Cis, i0, Crc, w, OMEGAdot, idot); ee.setFIC(false); ee.setAccuracy(accuracy); return ee; }
void xBrcClockCorrectiongpsNavMsg::firstTest(void) { // Set time to Day 153, 2011 (6/2/2011) at noon CivilTime g( 2011, 6, 2, 12, 14, 44.0, TimeSystem::GPS ); CommonTime dt = g.convertToCommonTime(); // Test data (copied from navdmp output for .....) // Generally, we'd load these data from the file std::string SysID = "G"; ObsID obsID( ObsID::otUndefined, ObsID::cbL1, ObsID::tcCA ); short PRNID = 3; double Toc = 388800.0; double Top = 345600.0; short weeknum = 1638; // By rules of Clock Correction, this must be week of Toc short URAoc = 5; short URAoc1 = 7; short URAoc2 = 7; bool healthy = true; double af0 = 7.23189674E-04; double af1 = 5.11590770E-12; double af2 = 0.00000000E+00; CommonTime TocCT = GPSWeekSecond(weeknum, Toc, TimeSystem::GPS); CommonTime TopCT = GPSWeekSecond(weeknum, Top, TimeSystem::GPS); // Test Data copied from RINEX file double rToc = 388800.0; double rTop = 345600.0; short rweeknum = 1638; // By rules of Clock Corection, this must be week of Toc short rURAoc = 5; short rURAoc1 = 7; short rURAoc2 = 7; bool rhealthy = true; double raf0 = 7.23189674318E-04; double raf1 = 5.11590769747E-12; double raf2 = 0.00000000000E+00; CommonTime rTocCT = GPSWeekSecond(rweeknum, rToc, TimeSystem::GPS); CommonTime rTopCT = GPSWeekSecond(rweeknum, rTop, TimeSystem::GPS); long subframe1[10] = { 0x22C2663D, 0x1F0E29B8, 0x2664002B, 0x09FCC1B6, 0x0F60EB8A, 0x1299CE93, 0x29CD3DB6, 0x0597BB0F, 0x00000B68, 0x17B28E5C }; long subframe2[10] = { 0x22C2663D, 0x1F0E4A28, 0x05809675, 0x0EBD8AF1, 0x00089344, 0x008081F8, 0x1330CC2C, 0x0461E855, 0x034F8045, 0x17BB1E68 }; long subframe3[10] = { 0x22C2663D, 0x1F0E6BA0, 0x3FE129CD, 0x26E31837, 0x0006C96A, 0x35A74DFC, 0x065C8B0F, 0x1E4F400A, 0x3FE8966D, 0x05860C44 }; ofstream outf("Logs/BrcClkCorr_Output", ios::out); // First test case. Create an empty CC object, then load the data. outf << "Test Case 1: Creating an empty CC object and loading the data." << endl; BrcClockCorrection co1; co1.loadData( SysID, obsID, PRNID, TocCT, TopCT, URAoc, URAoc1, URAoc2, healthy, af0, af1, af2 ); double ClkCorr1 = co1.svClockBias( dt ); outf.precision(11); outf << "Clock Correction co1: " << ClkCorr1 << endl << endl; // Second test case. Create an CC object with data available at time of construction. outf << "Test Case 2: Creating CC object with data." << endl; BrcClockCorrection co2( SysID, obsID, PRNID, TocCT, TopCT, URAoc, URAoc1, URAoc2, healthy, af0, af1, af2 ); double ClkCorr2 = co2.svClockBias( dt ); outf << "ClockCorrection co2: " << ClkCorr2 << endl << endl; // Third test case. Create a CC object using raw legacy navigation message data outf << "Test Case 3: Creating CC object with raw legacy nav message data." << endl; BrcClockCorrection co3(obsID, PRNID, weeknum, subframe1 ); double ClkCorr3 = co3.svClockBias( dt ); outf << "Clock Correction co3: " << ClkCorr3 << endl << endl; // Fourth test case. Create a CC object using raw legacy navigation message data outf << "Test Case 4: Creating CC object with raw legacy nav message data." << endl; BrcClockCorrection co4; co4.loadData(obsID, PRNID, weeknum, subframe1 ); double ClkCorr4 = co4.svClockBias( dt ); outf << "Clock Correction co4: " << ClkCorr4 << endl << endl; // Fifth test case. Create an CC object with data available from RINEX file. outf << "Test Case 5: Creating CC object with data from RINEX file." << endl; BrcClockCorrection co5( SysID, obsID, PRNID, rTocCT, TopCT, URAoc, URAoc1, URAoc2, rhealthy, raf0, raf1, raf2 ); double ClkCorr5 = co5.svClockBias( dt ); outf << "Clock Correction co5: " << ClkCorr5 << endl << endl; // Sixth test case. Compare against "classic" EngEphemeris outf << "Test Case 6: Calculated clock correction using 'classic' EngEphemeris." << endl; outf<< "Time= "<< g << endl; EngEphemeris EE; EE.addSubframe(subframe1, weeknum, 3, 1); EE.addSubframe(subframe2, weeknum, 3, 1); EE.addSubframe(subframe3, weeknum, 3, 1); Xvt xvt = EE.svXvt(dt); outf << "Clock Bias EE: " << xvt.clkbias << endl; outf << "Clock Drift EE: " << xvt.clkdrift << endl; // Test data (copied from navdmp output for PRN 6 Day 155, 2011) long subframeA1[10] = { 0x22C2663D, 0x30A2291C, 0x2664002B, 0x0DB9B68A, 0x12746316, 0x0BAC1EAA, 0x0DA73D35, 0x1A80002C, 0x00000574, 0x02C3A0F4 }; long subframeA2[10] = { 0x22C2663D, 0x30A24A8C, 0x1A80864C, 0x0C15B3B1, 0x0AD1AB66, 0x00B00201, 0x3A1D9937, 0x00F6A87A, 0x0353C6C1, 0x00001F0C }; long subframeA3[10] = { 0x22C2663D, 0x30A26B04, 0x3FDF944D, 0x2E5CB356, 0x002FCA3A, 0x040A9DDC, 0x0B45D00B, 0x03922318, 0x3FE905EF, 0x1A817FAC }; CivilTime ct2(2011, 6, 4, 11, 30, 0.0, TimeSystem::GPS ); dt = ct2.convertToCommonTime( ); outf << endl << "Test Case 7: Calculated clock corrections using 'classic' EngEphemeris." << endl; outf << "Time = " << ct2 << endl; EngEphemeris EEA; EEA.addSubframe(subframeA1, weeknum, 9, 1); EEA.addSubframe(subframeA2, weeknum, 9, 1); EEA.addSubframe(subframeA3, weeknum, 9, 1); xvt = EEA.svXvt(dt); outf << "Clock Bias EE: " << xvt.clkbias << endl; outf << "Clock Drift EE: " << xvt.clkdrift << endl; CivilTime ct3(2011, 6, 5, 1, 0, 0.0, TimeSystem::GPS ); dt = ct3.convertToCommonTime( ); outf << endl << "Test Case 8: Calculated clock corrections using 'classic' EngEphemeris." << endl; outf << "Time = " << ct3 << endl; xvt = EEA.svXvt(dt); outf << "Clock Bias EE: " << xvt.clkbias << endl; outf << "Clock Drift EE: " << xvt.clkdrift << endl << endl; outf << "Dump Output for Test Cases 4 and 6." << endl; outf << "dump EE:" << endl; outf << EE << endl; outf << "dump co4:" << endl; outf << co4 << endl; CPPUNIT_ASSERT(fileEqualTest((char*)"Logs/BrcClkCorr_Truth",(char*)"Logs/BrcClkCorr_Output")); }
bool operator() (const EngEphemeris& l, const EngEphemeris& r) const { if (l.getPRNID() < r.getPRNID()) return true; else if (l.getPRNID() > r.getPRNID()) return false; else if (l.getFullWeek() < r.getFullWeek()) return true; else if (l.getFullWeek() > r.getFullWeek()) return false; else if (l.getIODC() < r.getIODC()) return true; else if (l.getIODC() > r.getIODC()) return false; else if (l.getASAlert(1) < r.getASAlert(1)) return true; else if (l.getASAlert(1) > r.getASAlert(1)) return false; else if (l.getASAlert(2) < r.getASAlert(2)) return true; else if (l.getASAlert(2) > r.getASAlert(2)) return false; else if (l.getASAlert(3) < r.getASAlert(3)) return true; else if (l.getASAlert(3) > r.getASAlert(3)) return false; return false; }
bool operator() (const EngEphemeris& l) const { if ( (l.getPRNID() == PRN) && (l.getIODC() == IODC) ) return true; return false; }
EphDiffFinder(const EngEphemeris& e) : PRN(e.getPRNID()), IODC(e.getIODC()) {}
void xCNAVClockgpsNavMsg::firstTest(void) { // Set time to Day 153, 2011 (6/2/2011) at noon CivilTime g( 2011, 6, 2, 12, 14, 44.0, TimeSystem::GPS ); CommonTime dt = g.convertToCommonTime(); // Test data (copied from navdmp output for .....) // Generally, we'd load these data from the file std::string SysID = "G"; ObsID obsID( ObsID::otNavMsg, ObsID::cbL2, ObsID::tcC2LM ); ObsID obsID2( ObsID::otNavMsg, ObsID::cbL5, ObsID::tcIQ5 ); short PRNID = 3; double Toc = 388800.0; short TOWWeek = 1638; // By rules of Clock Correction, this must be week of Toc double accuracy = 10.61; // Test Data copied from RINEX file short rTOWWeek = 1638; // By rules of Clock Correction, this must be week of Toc double raccuracy = 10.61; double rToc = 388800.0; double raf0 = 7.23189674318E-04; double raf1 = 5.11590769747E-12; double raf2 = 0.0; long TOWMsg_1 = 382500; long Top = 378000; short AlertMsg = 0; short URAoc_1 = 4; short URAoc1_1 = 1; short URAoc2_1 = 2; // Set time to Day 156, 2011 (6/5/2011) at 1 am CivilTime ct2( 2011, 6, 5, 1, 0, 0.0, TimeSystem::GPS ); CommonTime dt2 = ct2.convertToCommonTime(); // Test data (copied from navdmp output for PRN 7 Day 156, 2011 at 00:00:00 Transmit Time) // Generally, we'd load these data from the file short PRNID2 = 7; double Toc2 = 7200.0; short TOWWeek2 = 1639; // By rules of Clock Correction, this must be week of Toc double accuracy2 = 10.61; double af0_2 = 1.32815912E-05; double af1_2 = 1.25055521E-12; double af2_2 = 0.0; long TOWMsg_2 = 0; long Top2 = 601200; short AlertMsg2 = 1; short URAoc_2 = 1; short URAoc1_2 = 2; short URAoc2_2 = 3; // Set time to Day 156, 2011 (6/5/2011) at midnight CivilTime ct3( 2011, 6, 5, 0, 0, 0.0, TimeSystem::GPS ); CommonTime dt3 = ct2.convertToCommonTime(); // Test data (copied from navdmp output for PRN 9 Day 155, 2011 at 22:00:00 Transmit Time) // Generally, we'd load these data from the file short PRNID3 = 9; double Toc3 = 0.0; short TOWWeek3 = 1638; // By rules of Clock Corection, this must be week of Toc double accuracy3 = 10.61; long TOWMsg_3 = 597600; long Top3 = 594000; double af0_3 = 8.43554735E-05; double af1_3 = 2.38742359E-12; double af2_3 = 0.0; short health3 = 0; long TOW3 = 597600; short URAoc_3 = 1; short URAoc1_3 = 2; short URAoc2_3 = 3; long subframe1[10] = { 0x22C2663D, 0x1F0E29B8, 0x2664002B, 0x09FCC1B6, 0x0F60EB8A, 0x1299CE93, 0x29CD3DB6, 0x0597BB0F, 0x00000B68, 0x17B28E5C }; long subframe2[10] = { 0x22C2663D, 0x1F0E4A28, 0x05809675, 0x0EBD8AF1, 0x00089344, 0x008081F8, 0x1330CC2C, 0x0461E855, 0x034F8045, 0x17BB1E68 }; long subframe3[10] = { 0x22C2663D, 0x1F0E6BA0, 0x3FE129CD, 0x26E31837, 0x0006C96A, 0x35A74DFC, 0x065C8B0F, 0x1E4F400A, 0x3FE8966D, 0x05860C44 }; ofstream outf("Logs/CNAVClock_Output", ios::out); outf.precision(11); // First test case. Create an CC object with data available from RINEX file. outf << endl << "Test Case 1: Creating CC object with data from RINEX file." << endl; outf << "Time = " << g << endl; CNAVClock cc1; cc1.loadData( SysID, obsID, PRNID, AlertMsg, TOWMsg_1, rTOWWeek, Top, rToc, raccuracy, URAoc_1, URAoc1_1, URAoc2_1, raf0, raf1, raf2 ); double ClkCorr1 = cc1.svClockBias( dt ); double ClkDrift1 = cc1.svClockDrift( dt ); outf << "Clock Bias cc1: " << ClkCorr1 << endl; outf << "Clock Drift cc1: " << ClkDrift1 << endl; outf << "Time of Prediction cc1: " << GPSWeekSecond(cc1.getTimeOfPrediction()).printf("%F, %g") << endl; outf << "CNAV Accuracy Test: " << SV_CNAV_ACCURACY_GPS_MAX_INDEX[URAoc_1+15] << endl; outf << "legacy Accuracy Test: " << SV_ACCURACY_GPS_MAX_INDEX[URAoc_1] << endl; // Second test case. Create an CC object with data available from navdump. outf << endl << "Test Case 2: Creating CC object with data from navdump." << endl; outf << "Time = " << ct2 << endl; CNAVClock cc2; cc2.loadData( SysID, obsID2, PRNID2, AlertMsg2, TOWMsg_2, TOWWeek2, Top2, Toc2, accuracy2, URAoc_2, URAoc1_2, URAoc2_2, af0_2, af1_2, af2_2 ); double ClkCorr2 = cc2.svClockBias( dt2 ); double ClkDrift2 = cc2.svClockDrift( dt2 ); outf << "Clock Bias cc2: " << ClkCorr2 << endl; outf << "Clock Drift cc2: " << ClkDrift2 << endl; outf << "Time of Prediction cc2: " << GPSWeekSecond(cc2.getTimeOfPrediction()).printf("%F, %g") << endl; // Third test case. Create an CC object with data available from navdump. outf << endl << "Test Case 3: Creating CC object with data from navdump." << endl; outf << "Time = " << ct3 << endl; CNAVClock cc3; cc3.loadData( SysID, obsID, PRNID3, AlertMsg, TOWMsg_3, TOWWeek3, Top3, Toc3, accuracy3, URAoc_3, URAoc1_3, URAoc2_3, af0_3, af1_3, af2_3 ); double ClkCorr3 = cc3.svClockBias( dt3 ); double ClkDrift3 = cc3.svClockDrift( dt3 ); outf << "Clock Bias cc3: " << ClkCorr3 << endl; outf << "Clock Drift cc3: " << ClkDrift3 << endl; outf << "Time of Prediction cc3: " << GPSWeekSecond(cc3.getTimeOfPrediction()).printf("%F, %g") << endl; // Fourth test case. Compare against "classic" EngEphemeris outf << endl << "Test Case 4: Calculated position using 'classic' EngEphemeris." << endl; outf<< "Time= "<< g << endl; EngEphemeris EE; EE.addSubframe(subframe1, TOWWeek, 3, 1); EE.addSubframe(subframe2, TOWWeek, 3, 1); EE.addSubframe(subframe3, TOWWeek, 3, 1); Xvt xvt = EE.svXvt(dt); outf<< "Clock Bias EE: " << xvt.clkbias << endl; outf<< "Clocl Drift EE: " << xvt.clkdrift << endl; outf << endl; outf << "CC1 Object Dump:" << endl; outf << cc1 << endl; outf << endl; outf << "CC2 Object Dump:" << endl; outf << cc2 << endl; outf << endl; outf << "CC3 Object Dump:" << endl; outf << cc3 << endl; CPPUNIT_ASSERT(fileEqualTest((char*)"Logs/CNAVClock_Truth",(char*)"Logs/CNAVClock_Output")); }
AlmOrbit ConvertEEtoAO(EngEphemeris& ee) { AlmOrbit ao( ee.getPRNID() , ee.getEcc() , ee.getI0()-0.3*PI, ee.getOmegaDot() , ee.getAhalf() , ee.getOmega0(), ee.getW() , ee.getM0() , ee.getAf0() , ee.getAf1() , long(ee.getToe()), long(ee.getHOWTime(1)), ee.getFullWeek(), ee.getHealth() ); return ao; }
void MinSfTest::process() { if (debugLevel) cout << "Setting up input file: " << inputOption.getValue().front() << endl; FileFilterFrame<FICStream, FICData> input(inputOption.getValue().front()); printf(" input.getDataCount() after init: %d\n", input.getDataCount()); if(debugLevel) cout << "Setting up output file: " << outputOption.getValue().front() << endl; fp.open( outputOption.getValue().front().c_str() ); if ( !fp.is_open() ) { printf(" Failed to open output file.\n"); exit(1); } // filter the FIC data for the requested vlock(s) std::list<long> blockList; blockList.push_back(109); input.filter(FICDataFilterBlock(blockList)); input.sort(FICDataOperatorLessThanBlock109()); input.unique(FICDataUniqueBlock109()); //some hand waving for the data conversion if(debugLevel) cout << "Reading the input data." << endl; list<FICData>& ficList = input.getData(); list<FICData>::iterator itr = ficList.begin(); DayTime earliest( DayTime::END_OF_TIME ); DayTime latest( DayTime::BEGINNING_OF_TIME ); int count = 0; int numMismatches = 0; int numMismatchEph = 0; while (itr != ficList.end()) { EngEphemeris ee(*itr); bc109.addEphemeris( ee ); DayTime ct = ee.getEpochTime(); if (ct>latest) latest = ct; if (ct<earliest) earliest = ct; // Following code simulates a situation where only words 3-10 // and the estimated time of receipt are available. DayTime timeOfReceipt = ee.getTransmitTime(); FICData& fic = *itr; long sf1min[8]; long sf2min[8]; long sf3min[8]; int wrdCnt = 8; int i; for (i=0; i<wrdCnt; ++i) sf1min[i] = fic.i[4+i]; for (i=0; i<wrdCnt; ++i) sf2min[i] = fic.i[14+i]; for (i=0; i<wrdCnt; ++i) sf3min[i] = fic.i[24+i]; EngEphemeris eeMin; short PRNID = (short) fic.i[1]; eeMin.addIncompleteSF1Thru3( sf1min, sf2min, sf3min, (long) timeOfReceipt.GPSsecond(), timeOfReceipt.GPSfullweek(), PRNID, 0 ); minRaw.addEphemeris( eeMin ); // Compare non-orbit portions of the two objects bool mismatch = false; for (int i=1; i<=3; ++i) { if (!ee.isData(i) || !eeMin.isData(i)) { mismatch = true; fp << "ERROR: not all subframes are claimed available."; } } if (ee.getIODC()!=eeMin.getIODC()) { mismatch = true; fp << "ERROR: IODCs do not match."; } if (ee.getIODE()!=eeMin.getIODE()) { mismatch = true; fp << "ERROR: IODCs do not match."; } if (ee.getFitInterval() != eeMin.getFitInterval() ) { mismatch = true; fp << "ERROR: fit intervals do not match."; } if (ee.getCodeFlags()!=eeMin.getCodeFlags() ) { mismatch = true; fp << "ERROR: code flags do not match."; } if (ee.getL2Pdata()!=eeMin.getL2Pdata() ) { mismatch = true; fp << "ERROR: L2P data flags do not match."; } if (ee.getAccuracy()!=eeMin.getAccuracy() ) { mismatch = true; fp << "ERROR: accuracy values do not match."; } if (ee.getAccFlag()!=eeMin.getAccFlag() ) { mismatch = true; fp << "ERROR: accuracy flags do not match."; } if (ee.getHealth()!=eeMin.getHealth() ) { mismatch = true; fp << "ERROR: health values do not match."; } if (ee.getFitInt()!=eeMin.getFitInt() ) { mismatch = true; fp << "ERROR: Fit interval values do not match."; } if (mismatch) { fp << " PRNID: " << PRNID << ", IODC: 0x " << hex << ee.getIODC() << dec << endl; numMismatches++; } itr++; count++; } cout << "Number of Block 109 records read: " << count << endl; if (numMismatches!=0) { printf("Errors detected. Some ephemerides did not match in both forms.\n"); printf("Number of mismatches: %d\n",numMismatches); } fp << "Number of mismatches detected: " << numMismatches << endl; if (debugLevel) cout << "done." << endl; // Generate test positions for PRN 1 and PRN 31 at // earliest epoch, latest epoch, and middle of the time span. try { double timeDuration = latest - earliest; DayTime middle( earliest ); middle += (timeDuration/2); short IODC109 = -1; short IODCMin = -1; short PRNID = 1; printf("--- PRN 1 Examples ---\n"); printf("\nEarliest time\n"); fp << "--- PRN 1 Examples ---" << endl; fp << endl << "Earliest time" << endl; testXvt( PRNID, earliest ); printf("\nMiddle time\n"); fp << endl << "Middle time" << endl; testXvt( PRNID, middle ); printf("\nLatest time\n"); fp << endl << "Latest time" << endl; testXvt( PRNID, latest ); PRNID = 31; printf("\n--- PRN 31 Examples ---\n"); printf("\nEarliest time\n"); fp << endl << "--- PRN 31 Examples ---" << endl; fp << endl << "Earliest time" << endl; testXvt( PRNID, earliest ); printf("\nMiddle time\n"); fp << endl << "Middle time" << endl; testXvt( PRNID, middle ); printf("\nLatest time\n"); fp << endl << "Latest time" << endl; testXvt( PRNID, latest ); } catch (gpstk::Exception& e) { cout << e << endl; } printf("\nBCEphemerisStore directly from existing FIC handlers.\n"); fp << endl << "BCEphemerisStore directly from existing FIC handlers." << endl; bc109.dump(1, fp); printf("BCEphemerisStore from new method.\n"); fp << endl << "BCEphemerisStore from new method." << endl; minRaw.dump(1, fp); // write the file data if (debugLevel) cout << "Conversion complete." << endl; }
void xCNAVEphemerisgpsNavMsg::firstTest(void) { // Set time to Day 153, 2011 (6/2/2011) at noon CivilTime g( 2011, 6, 2, 12, 14, 44.0, TimeSystem::GPS ); CommonTime dt = g.convertToCommonTime(); // Test data (copied from navdmp output for .....) // Generally, we'd load these data from the file std::string SysID = "G"; ObsID obsID( ObsID::otNavMsg, ObsID::cbL2, ObsID::tcC2LM ); ObsID obsID2( ObsID::otNavMsg, ObsID::cbL5, ObsID::tcIQ5 ); short PRNID = 3; double Toe = 388800.0; short TOWWeek = 1638; // By rules of Kepler Orbit, this must be week of Toe double accuracy = 10.61; double Cuc = 9.57399607E-07; double Cus = 8.35768878E-06; double Crc = 2.03562500E+02; double Crs = 1.87812500E+01; double Cic = -2.30967999E-07; double Cis = 5.02914190E-08; double M0 = 1.05539163E+00; double dn = 5.39093884E-09; double dnDot = 0.0; // Doesn't exist in legacy navigation message double ecc = 1.42575260E-02; double Ahalf = 5.15365528E+03; double A = Ahalf * Ahalf; // Changed from legacy navigation message double Adot = 0.0; // Doesn't exist in legacy navigation message double OMEGA0 = -2.16947563E+00; double i0 = 9.28692498E-01; double w = 1.09154605E+00; double OMEGAdot = -8.56285668E-09; double idot = 5.52880173E-10; // Test Data copied from RINEX file double rToe = 388800.0; short rTOWWeek = 1638; // By rules of Kepler Orbit, this must be week of Toe double raccuracy = 10.61; double rToc = 388800.0; short rTracker = 1; double rCuc = 9.57399606705E-07; double rCus = 8.35768878460E-06; double rCrc = 2.03562500000E+02; double rCrs = 1.87812500000E+01; double rCic = -2.30967998505E-07; double rCis = 5.02914190292E-08; double rM0 = 1.05539162795E+00; double rdn = 5.39093883996E-09; double rdnDot = 0.0; // Doesn't exist in legacy navigation message double recc = 1.42575260252E-02; double rAhalf = 5.15365527534E+03; double rA = rAhalf * rAhalf; // Changed from legacy navigation message double rAdot = 0.0; // Doesn't exist in legacy navigation message double rOMEGA0 = -2.16947563164E+00; double ri0 = 9.28692497530E-01; double rw = 1.09154604931E+00; double rOMEGAdot = -8.56285667735E-09; double deltaOMEGAdot1 = rOMEGAdot - OMEGADOT_REF_GPS; double ridot = 5.52880172536E-10; double deltaA = rA - A_REF_GPS; long TOWMsg10_1 = 382500; long TOWMsg11_1 = 382500; long Top = 378000; short URAoe = 1; short AlertMsg10 = 0; short AlertMsg11 = 0; short L1Health = 0; short L2Health = 0; short L5Health = 1; // Set time to Day 156, 2011 (6/5/2011) at 1 am CivilTime ct2( 2011, 6, 5, 1, 0, 0.0, TimeSystem::GPS ); CommonTime dt2 = ct2.convertToCommonTime(); // Test data (copied from navdmp output for PRN 7 Day 156, 2011 at 00:00:00 Transmit Time) // Generally, we'd load these data from the file short PRNID2 = 7; double Toe2 = 7200.0; short TOWWeek2 = 1639; // By rules of Kepler Orbit, this must be week of Toe double accuracy2 = 10.61; double Cuc2 = 6.33299351E-08; double Cus2 = 9.79751348E-07; double Crc2 = 3.67843750E+02; double Crs2 = 3.75000000E+01; double Cic2 = 1.13621354E-07; double Cis2 = 2.79396772E-08; double M02 = 5.40667729E-01; double dn2 = 4.46804325E-09; double dnDot2 = 0.0; // Doesn't exist in legacy navigation message double ecc2 = 4.48677479E-03; double Ahalf2 = 5.15365555E+03; double A2 = Ahalf2 * Ahalf2; // Changed from legacy navigation message double Adot2 = 0.0; // Doesn't exist in legacy navigation message double OMEGA02 = 2.03414883+00; double i02 = 9.74404003E-01; double w2 = -3.13294415E+00; double OMEGAdot2 = -8.35713382E-09; double deltaOMEGAdot2 = OMEGAdot2 - OMEGADOT_REF_GPS; double idot2 = 1.21433630E-10; double Tgd2 = -1.07102096E-08; double deltaA2 = A2 - A_REF_GPS; long TOWMsg10_2 = 0; long TOWMsg11_2 = 0; long Top2 = 601200; short URAoe2 = 1; // Set time to Day 156, 2011 (6/5/2011) at midnight CivilTime ct3( 2011, 6, 5, 0, 0, 0.0, TimeSystem::GPS ); CommonTime dt3 = ct2.convertToCommonTime(); // Test data (copied from navdmp output for PRN 9 Day 155, 2011 at 22:00:00 Transmit Time) // Generally, we'd load these data from the file short PRNID3 = 9; double Toe3 = 0.0; short TOWWeek3 = 1638; // By rules of Kepler Orbit, this must be week of Toe double accuracy3 = 10.61; double Cuc3 = 1.31130219E-06; double Cus3 = 1.83656812E-06; double Crc3 = 3.60718750E+02; double Crs3 = 1.67812500E+01; double Cic3 = -2.42143869E-07; double Cis3 = 3.55765224E-07; double M03 = -1.22303559E+00; double dn3 = 4.41946980E-09; double dnDot3 = 0.0; // Doesn't exist in legacy navigation message double ecc3 = 1.73985478E-02; double Ahalf3 = 5.15366363E+03; double A3 = Ahalf3 * Ahalf3; // Changed from legacy navigation message double Adot3 = 0.0; // Doesn't exist in legacy navigation message double OMEGA03 = 2.00581875E+00; double i03 = 9.83297588E-01; double w3 = 1.57216573E+00; double OMEGAdot3 = -8.40356433E-09; double deltaOMEGAdot3 = OMEGAdot3 - OMEGADOT_REF_GPS; double idot3 = 1.36791412E-10; double Tgd3 = -5.58793545E-09; double deltaA3 = A3 - A_REF_GPS; long TOWMsg10_3 = 597600; long TOWMsg11_3 = 597600; long Top3 = 594000; short URAoe3 = 1; long subframe1[10] = { 0x22C2663D, 0x1F0E29B8, 0x2664002B, 0x09FCC1B6, 0x0F60EB8A, 0x1299CE93, 0x29CD3DB6, 0x0597BB0F, 0x00000B68, 0x17B28E5C }; long subframe2[10] = { 0x22C2663D, 0x1F0E4A28, 0x05809675, 0x0EBD8AF1, 0x00089344, 0x008081F8, 0x1330CC2C, 0x0461E855, 0x034F8045, 0x17BB1E68 }; long subframe3[10] = { 0x22C2663D, 0x1F0E6BA0, 0x3FE129CD, 0x26E31837, 0x0006C96A, 0x35A74DFC, 0x065C8B0F, 0x1E4F400A, 0x3FE8966D, 0x05860C44 }; ofstream outf("Logs/CNAVEphemeris_Output", ios::out); outf.precision(11); // First test case. Create an CE object with data available from RINEX file. outf << endl << "Test Case 1: Creating CE object with data from RINEX file." << endl; outf << "Time = " << g << endl; CNAVEphemeris ce1; ce1.loadData(SysID, obsID, PRNID, AlertMsg10, TOWMsg10_1, AlertMsg11, TOWMsg11_1, rTOWWeek, Top, URAoe, L1Health, L2Health, L5Health, rToe, raccuracy, rCuc, rCus, rCrc, rCrs, rCic, rCis, rM0, rdn, rdnDot, recc, deltaA, rAdot, rOMEGA0, ri0, rw, deltaOMEGAdot1, ridot ); Xv xv1 = ce1.svXv( dt ); outf << "Position ce1: " << xv1.x << endl; outf << "Velocity ce1: " << xv1.v << endl; outf << "RelCorr ce1: " << ce1.svRelativity(dt) << endl; outf << "Time of Prediction ce1: " << GPSWeekSecond(ce1.getTimeOfPrediction()).printf("%F, %g") << endl; outf << "CNAV Accuracy Test: " << SV_CNAV_ACCURACY_GPS_MAX_INDEX[URAoe+15] << endl; outf << "legacy Accuracy Test: " << SV_ACCURACY_GPS_MAX_INDEX[URAoe] << endl; // Second test case. Create an CE object with data available from navdump. outf << endl << "Test Case 2: Creating CE object with data from navdump." << endl; outf << "Time = " << ct2 << endl; CNAVEphemeris ce2; ce2.loadData( SysID, obsID2, PRNID2, AlertMsg10, TOWMsg10_2, AlertMsg11, TOWMsg11_2, TOWWeek2, Top2, URAoe2, L1Health, L2Health, L5Health, Toe2, accuracy2, Cuc2, Cus2, Crc2, Crs2, Cic2, Cis2, M02, dn2, dnDot2, ecc2, deltaA2, Adot2, OMEGA02, i02, w2, deltaOMEGAdot2, idot2 ); Xv xv2 = ce2.svXv( dt2 ); outf << "Position ce2: " << xv2.x << endl; outf << "Velocity ce2: " << xv2.v << endl; outf << "RelCorr ce2: " << ce2.svRelativity(dt2) << endl; outf << "Time of Prediction ce2: " << GPSWeekSecond(ce2.getTimeOfPrediction()).printf("%F, %g") << endl; // Third test case. Create an CE object with data available from navdump. outf << endl << "Test Case 3: Creating CE object with data from navdump." << endl; outf << "Time = " << ct3 << endl; CNAVEphemeris ce3; ce3.loadData( SysID, obsID, PRNID3, AlertMsg10, TOWMsg10_3, AlertMsg11, TOWMsg11_3, TOWWeek3, Top3, URAoe3, L1Health, L2Health, L5Health, Toe3, accuracy3, Cuc3, Cus3, Crc3, Crs3, Cic3, Cis3, M03, dn3, dnDot3, ecc3, deltaA3, Adot3, OMEGA03, i03, w3, deltaOMEGAdot3, idot3 ); Xv xv3 = ce3.svXv( dt3 ); outf << "Position ce3: " << xv3.x << endl; outf << "Velocity ce3: " << xv3.v << endl; outf << "RelCorr ce3: " << ce3.svRelativity(dt3) << endl; outf << "Time of Prediction ce3: " << GPSWeekSecond(ce3.getTimeOfPrediction()).printf("%F, %g") << endl; // Fourth test case. Compare against "classic" EngEphemeris outf << endl << "Test Case 4: Calculated position using 'classic' EngEphemeris." << endl; outf<< "Time= "<< g << endl; EngEphemeris EE; EE.addSubframe(subframe1, TOWWeek, 3, 1); EE.addSubframe(subframe2, TOWWeek, 3, 1); EE.addSubframe(subframe3, TOWWeek, 3, 1); Xvt xvt = EE.svXvt(dt); outf<< "Position EE: " << xvt.x << endl; outf<< "Velocity EE: " << xvt.v << endl; outf<< "RelCorr EE: " << EE.svRelativity(dt) << endl; outf << endl; outf << "CE Object Dump:" << endl; outf << ce1 << endl; if ( ce1.getOrbit().isHealthy()) outf << "CE.orbit is healthy." << endl; else outf << "CE.orbit is NOT healthy." << endl; outf << endl; outf << "CE2 Object Dump:" << endl; outf << ce2 << endl; if ( ce2.getOrbit().isHealthy()) outf << "CE2.orbit is healthy." << endl; else outf << "CE2.orbit is NOT healthy." << endl; outf << endl; outf << "CE3 Object Dump:" << endl; outf << ce3 << endl; if ( ce3.getOrbit().isHealthy()) outf << "CE3.orbit is healthy." << endl; else outf << "CE3.orbit is NOT healthy." << endl; outf << endl; outf << "Fit Interval Tests" << endl; outf << "BeginFit ce1: " << GPSWeekSecond(ce1.getOrbit().getBeginningOfFitInterval()).printf("%F, %g") << endl; outf << "BeginFit EE: " << GPSWeekSecond(EE.getOrbit().getBeginningOfFitInterval()).printf("%F, %g") << endl; outf << endl; outf << "EndFit ce1: " << GPSWeekSecond(ce1.getOrbit().getEndOfFitInterval()).printf("%F, %g") << endl; outf << "EndFit EE : " << GPSWeekSecond(EE.getOrbit().getEndOfFitInterval()).printf("%F, %g") << endl; outf << endl; outf << "Within Fit Interval: " << ce1.getOrbit().withinFitInterval(dt) << endl; outf << "Within Fit Interval: " << EE.getOrbit().withinFitInterval(dt) << endl; CPPUNIT_ASSERT(fileEqualTest((char*)"Logs/CNAVEphemeris_Truth",(char*)"Logs/CNAVEphemeris_Output")); }
// Deprecated; use GPSEphemeris. // Converts this Rinex3NavData to an EngEphemeris object. Rinex3NavData::operator EngEphemeris() const throw() { EngEphemeris ee; // There's no TLM word in Rinex3NavData, so it's set to 0. // Likewise, there's no AS alert or tracker. // Also, in RINEX, the accuracy is in meters, and setSF1 expects // the accuracy flag. We'll give it zero and pass the accuracy // separately via the setAccuracy() method. ee.tlm_message[0] = 0; ee.tlm_message[1] = 0; ee.tlm_message[2] = 0; ee.HOWtime[0] = HOWtime; // RINEX does not actually specify ee.HOWtime[1] = HOWtime; // how the transmit time is derived. Therefore, ee.HOWtime[2] = HOWtime; // These values may be misleading. ee.ASalert[0] = 1; //AS and alert flags set to 1 (default) ee.ASalert[1] = 1; ee.ASalert[2] = 1; ee.weeknum = weeknum; ee.codeflags = codeflgs; ee.health = health; ee.IODC = short(IODC); ee.L2Pdata = L2Pdata; ee.Tgd = Tgd; ee.tracker = 0; ee.PRNID = PRNID; ee.satSys = satSys; bool healthy = false; if (health == 0) healthy = true; short accFlag = 0; //will be set later. //BrcClockCorrection takes a flag, while EngEphemeris takes a double. double toc = Toc; double timeDiff =toc - ee.HOWtime[0]; short epochWeek = ee.weeknum; if (timeDiff < -HALFWEEK) epochWeek++; else if (timeDiff > HALFWEEK) epochWeek--; CommonTime tocCT = GPSWeekSecond(epochWeek, Toc, TimeSystem::GPS); // The observation ID has a type of navigation, but the // carrier and code types are undefined. They could be // L1/L2 C/A, P, Y,..... ObsID obsID(ObsID::otNavMsg, ObsID::cbUndefined, ObsID::tcUndefined); ee.bcClock.loadData( satSys, obsID, PRNID, tocCT, accFlag, healthy, af0, af1, af2); ee.IODE = short(IODE); ee.fitint = (fitint > 4) ? 1 : 0; //double toe = Toe; //????? //Needed for modernized nav quatities double A = Ahalf * Ahalf; double dndot = 0.0; double Adot = 0.0; short fitHours = getLegacyFitInterval(ee.IODC, ee.fitint); long beginFitSOW = Toe - (fitHours/2)*3600.0; long endFitSOW = Toe + (fitHours/2)*3600.0; short beginFitWk = ee.weeknum; short endFitWk = ee.weeknum; if (beginFitSOW < 0) { beginFitSOW += FULLWEEK; beginFitWk--; } CommonTime beginFit = GPSWeekSecond(beginFitWk, beginFitSOW, TimeSystem::GPS); if (endFitSOW >= FULLWEEK) { endFitSOW += FULLWEEK; endFitWk++; } CommonTime endFit = GPSWeekSecond(endFitWk, endFitSOW, TimeSystem::GPS); CommonTime toeCT = GPSWeekSecond(epochWeek, Toe, TimeSystem::GPS); ee.orbit.loadData( satSys, obsID, PRNID, beginFit, endFit, toeCT, accFlag, healthy, Cuc, Cus, Crc, Crs, Cic, Cis, M0, dn, dndot, ecc, A, Ahalf, Adot, OMEGA0, i0, w, OMEGAdot, idot); ee.haveSubframe[0] = true; // need to be true to perform certain EngEphemeris functions ee.haveSubframe[1] = true; // examples: ee.dump(), ee.setAccuracy() ee.haveSubframe[2] = true; ee.setAccuracy(accuracy); return ee; } // End of 'Rinex3NavData::operator EngEphemeris()'
// Deprecated; used GPSEphemeris. // This routine uses EngEphemeris, so is for GPS data only. // The comments about GPS v. Galileo next to each elements are just notes // from sorting out the ICDs in the RINEX 3 documentation. Please leave // them there until we add a routine for handling GalRecord or similar. Rinex3NavData::Rinex3NavData(const EngEphemeris& ee) // GPS only { // epoch info satSys = ee.getSatSys(); PRNID = ee.getPRNID(); sat = RinexSatID(PRNID,SatID::systemGPS); time = ee.getEpochTime(); Toc = ee.getToc(); HOWtime = long(ee.getHOWTime(1)); weeknum = ee.getFullWeek(); accuracy = ee.getAccuracy(); health = ee.getHealth(); // GPS or Galileo data af0 = ee.getAf0(); // GPS and Galileo only af1 = ee.getAf1(); // GPS and Galileo only af2 = ee.getAf2(); // GPS and Galileo only Crs = ee.getCrs(); // GPS and Galileo only dn = ee.getDn(); // GPS and Galileo only M0 = ee.getM0(); // GPS and Galileo only Cuc = ee.getCuc(); // GPS and Galileo only ecc = ee.getEcc(); // GPS and Galileo only Cus = ee.getCus(); // GPS and Galileo only Ahalf = ee.getAhalf(); // GPS and Galileo only Toe = ee.getToe(); // GPS and Galileo only Cic = ee.getCic(); // GPS and Galileo only OMEGA0 = ee.getOmega0(); // GPS and Galileo only Cis = ee.getCis(); // GPS and Galileo only i0 = ee.getI0(); // GPS and Galileo only Crc = ee.getCrc(); // GPS and Galileo only w = ee.getW(); // GPS and Galileo only OMEGAdot = ee.getOmegaDot(); // GPS and Galileo only idot = ee.getIDot(); // GPS and Galileo only // GPS-only data IODE = ee.getIODE(); // GPS only codeflgs = ee.getCodeFlags(); // GPS only L2Pdata = ee.getL2Pdata(); // GPS only Tgd = ee.getTgd(); // GPS only IODC = ee.getIODC(); // GPS only fitint = ee.getFitInterval(); // GPS only } // End of 'Rinex3NavData::Rinex3NavData(const EngEphemeris& ee)'