void xCNAV2PNBgpsNavMsg::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 TransmitTime = g.convertToCommonTime(); SatID satSys(1, SatID::systemGPS); ObsID obsID( ObsID::otNavMsg, ObsID::cbL2, ObsID::tcC2LM ); // Test Data copied from RINEX file for PRN3, week 1638, day 153 2011 // Subframe 2 Data unsigned long TOWWeek = 1638; int n_TOWWeek = 13; int s_TOWWeek = 1; unsigned long ITOW = 53; int n_ITOW = 8; int s_ITOW = 1; unsigned long Top = 378000; int n_Top = 11; int s_Top = 300; unsigned long L1CHealth = 0; int n_L1CHealth = 1; int s_L1CHealth = 1; long URAoe = -16; int n_URAoe = 5; int s_URAoe = 1; unsigned long Toe = 388800; int n_Toe = 11; int s_Toe = 300; double Ahalf = 5.15365527534E+03; int n_Ahalf = 32; int s_Ahalf = -19; double deltaA = Ahalf*Ahalf - A_REF_GPS; int n_deltaA = 26; int s_deltaA = -9; double Adot = 0; int n_Adot = 25; int s_Adot = -21; double dn = 5.39093883996E-09; int n_dn = 17; int s_dn = -44; double dndot = 0; int n_dndot = 23; int s_dndot = -57; double M0 = 1.05539162795E+00; int n_M0 = 33; int s_M0 = -32; double ecc = 1.42575260252E-02; int n_ecc = 33; int s_ecc = -34; double w = 1.09154604931E+00; int n_w = 33; int s_w = -32; double OMEGA0 = -2.16947563164E+00; int n_OMEGA0 = 33; int s_OMEGA0 = -32; double i0 = 9.28692497530E-01; int n_i0 = 33; int s_i0 = -32; double OMEGAdot = -8.56285667735E-09; int n_OMEGAdot = 24; int s_OMEGAdot = -43; double deltaOMEGAdot = OMEGAdot - OMEGADOT_REF_GPS; int n_deltaOMEGAdot = 17; int s_deltaOMEGAdot = -44; double idot = 5.52880172536E-10; int n_idot = 15; int s_idot = -44; double Cis = 5.02914190292E-08; int n_Cis = 16; int s_Cis = -30; double Cic = -2.30967998505E-07; int n_Cic = 16; int s_Cic = -30; double Crs = 1.87812500000E+01; int n_Crs = 24; int s_Crs = -8; double Crc = 2.03562500000E+02; int n_Crc = 24; int s_Crc = -8; double Cus = 8.35768878460E-06; int n_Cus = 21; int s_Cus = -30; double Cuc = 9.57399606705E-07; int n_Cuc = 21; int s_Cuc = -30; long URAoc = 15; int n_URAoc = 5; int s_URAoc = 1; unsigned long URAoc1 = 1; int n_URAoc1 = 3; int s_URAoc1 = 1; unsigned long URAoc2 = 2; int n_URAoc2 = 3; int s_URAoc2 = 1; double af0 = 7.23189674318E-04; int n_af0 = 26; int s_af0 = -35; double af1 = 5.11590769747E-12; int n_af1 = 20; int s_af1 = -48; double af2 = 0.0; int n_af2 = 10; int s_af2 = -60; double Tgd = -4.65661287308E-09; int n_Tgd = 13; int s_Tgd = -35; double ISCL1cp = 1E-8; int n_ISCL1cp = 13; int s_ISCL1cp = -35; double ISCL1cd = -1E-8; int n_ISCL1cd = 13; int s_ISCL1cd = -35; unsigned long sflag = 0; int n_sflag = 1; int s_sflag = 1; unsigned long reservedBits = 0; int n_reservedBits = 10; int s_reservedBits = 1; unsigned long CRC = 0; int n_CRC = 24; int s_CRC = 1; ofstream outf("Logs/CNAV2PNB_Output", ios::out); // First Test Case. Create PNB object in which to store subframe 2 data // for the CNAV2 nav message. PackedNavBits pnb; /* Pack Subframe 2 data */ pnb.setSatID(satSys); pnb.setObsID(obsID); pnb.setTime(TransmitTime); pnb.addUnsignedLong(TOWWeek, n_TOWWeek, s_TOWWeek); pnb.addUnsignedLong(ITOW, n_ITOW, s_ITOW); pnb.addUnsignedLong(Top, n_Top, s_Top); pnb.addUnsignedLong(L1CHealth, n_L1CHealth, s_L1CHealth); pnb.addLong(URAoe, n_URAoe, s_URAoe); pnb.addUnsignedLong(Toe, n_Toe, s_Toe); pnb.addSignedDouble(deltaA, n_deltaA, s_deltaA); pnb.addSignedDouble(Adot, n_Adot, s_Adot); pnb.addDoubleSemiCircles(dn, n_dn, s_dn); pnb.addDoubleSemiCircles(dndot, n_dndot, s_dndot); pnb.addDoubleSemiCircles(M0, n_M0, s_M0); pnb.addUnsignedDouble(ecc, n_ecc, s_ecc); pnb.addDoubleSemiCircles(w, n_w, s_w); pnb.addDoubleSemiCircles(OMEGA0, n_OMEGA0, s_OMEGA0); pnb.addDoubleSemiCircles(i0, n_i0, s_i0); pnb.addDoubleSemiCircles(deltaOMEGAdot, n_deltaOMEGAdot, s_deltaOMEGAdot); pnb.addDoubleSemiCircles(idot, n_idot, s_idot); pnb.addSignedDouble(Cis, n_Cis, s_Cis); pnb.addSignedDouble(Cic, n_Cic, s_Cic); pnb.addSignedDouble(Crs, n_Crs, s_Crs); pnb.addSignedDouble(Crc, n_Crc, s_Crc); pnb.addSignedDouble(Cus, n_Cus, s_Cus); pnb.addSignedDouble(Cuc, n_Cuc, s_Cuc); pnb.addLong(URAoc, n_URAoc, s_URAoc); pnb.addUnsignedLong(URAoc1, n_URAoc1, s_URAoc1); pnb.addUnsignedLong(URAoc2, n_URAoc2, s_URAoc2); pnb.addSignedDouble(af0, n_af0, s_af0); pnb.addSignedDouble(af1, n_af1, s_af1); pnb.addSignedDouble(af2, n_af2, s_af2); pnb.addSignedDouble(Tgd, n_Tgd, s_Tgd); pnb.addSignedDouble(ISCL1cp, n_ISCL1cp, s_ISCL1cp); pnb.addSignedDouble(ISCL1cd, n_ISCL1cd, s_ISCL1cd); pnb.addUnsignedLong(sflag, n_sflag, s_sflag); pnb.addUnsignedLong(reservedBits, n_reservedBits, s_reservedBits); pnb.addUnsignedLong(CRC, n_CRC, s_CRC); outf << endl; outf << "Time of Transmission: " << pnb.getTransmitTime() << endl; outf << "Time of Transmission pnb: " << GPSWeekSecond(pnb.getTransmitTime()).printf("%F, %g") << endl; // Resize the vector holding the packed nav message data pnb.trimsize(); outf << "PNB Object Dump:" << endl; outf << pnb << endl; // Second test case. Create a CEC object with the packed data above, available from RINEX file. outf << endl << "Test Case 2: Creating CEC object with data from RINEX file." << endl; outf << "Time = " << g << endl; CommonTime dt = TransmitTime; short PRNIDArg = 3; int TOI = 50; // 9 bit word from subframe 1 CNAV2EphClk cec; cec.loadData( obsID, PRNIDArg, TOI, pnb); Xvt xvt = cec.svXvt( dt ); double ClkCorr = cec.svClockBias( dt ); double ClkDrift = cec.svClockDrift( dt ); outf << "Position cec: " << xvt.x<< endl; outf << "Velocity cec: " << xvt.v << endl; outf.setf(ios::scientific, ios::floatfield); outf.precision(11); outf << "RelCorr cec: " << cec.svRelativity(dt) << endl; outf << "Clock Bias cec: " << ClkCorr << endl; outf << "Clock Drift cec: " << ClkDrift << endl; outf << "Time of Prediction cec:" << GPSWeekSecond(cec.getTimeOfPrediction()).printf("%F, %g") << endl; outf << endl << "CEC Object Dump:" << endl; outf << cec << endl; CPPUNIT_ASSERT(fileEqualTest((char*)"Logs/CNAV2PNB_Truth",(char*)"Logs/CNAV2PNB_Output")); }
void xCNAV2gpsNavMsg::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 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; short raccflag = 0; short rhealth = 0; short riodc = 22; short rfitInt = 0; short rl2pdata = 0; short rcflags = 1; short riode = 22; long raodo = 10; 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 ridot = 5.52880172536E-10; double raf0 = 7.23189674318E-04; double raf1 = 5.11590769747E-12; double raf2 = 0.0; double rTgd = -4.65661287308E-09; double deltaA = rA - A_REF_GPS; long TOW = 382500; long Top = 378000; short URAoe = 1; short URAoc = 1; short URAoc1 = 2; short URAoc2 = 3; double ISCL1cp = 1E-8; // Synthetic, reasonable values double ISCL1cd = -1E-8; // Synthetic, reasonable values // 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 idot2 = 1.21433630E-10; double af0_2 = 1.32815912E-05; double af1_2 = 1.25055521E-12; double af2_2 = 0.0; double Tgd2 = -1.07102096E-08; short health = 0; double deltaA2 = A2 - A_REF_GPS; long TOW2 = 0; long Top2 = 601200; short URAoe2 = 1; short URAoc_2 = 1; short URAoc1_2 = 2; short URAoc2_2 = 3; double ISCL1cp2 = 1E-8; //Synthetic, reasonable values double ISCL1cd2 = -1E-8; //Synthetic, reasonable values // 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 idot3 = 1.36791412E-10; double af0_3 = 8.43554735E-05; double af1_3 = 2.38742359E-12; double af2_3 = 0.0; double Tgd3 = -5.58793545E-09; short health3 = 0; double deltaA3 = A3 - A_REF_GPS; long TOW3 = 597600; long Top3 = 594000; short URAoe3 = 1; short URAoc_3 = 1; short URAoc1_3 = 2; short URAoc2_3 = 3; double ISCL1cp3 = 1E-8; // Synthetic, reasonable values double ISCL1cd3 = -1E-8; // Synthetic, reasonable values 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/Output", ios::out); outf.precision(11); // First test case. Create an CEC object with data available from RINEX file. outf << endl << "Test Case 1: Creating CEC object with data from RINEX file." << endl; outf << "Time = " << g << endl; CNAV2EphClk cec; cec.loadData( SysID, obsID, PRNID, rTOWWeek, TOW, Top, rhealth, URAoe, rToe, deltaA, rAdot, rdn, rdnDot, rM0, recc, rw, rOMEGA0, ri0, rOMEGAdot, ridot, rCic, rCis, rCrc, rCrs, rCuc, rCus, URAoc, URAoc1, URAoc2, raf0, raf1, raf2, rTgd, ISCL1cp, ISCL1cd); Xvt xvt1 = cec.svXvt( dt ); outf << "Position cec: " << xvt1.x << endl; outf << "Velocity cec: " << xvt1.v << endl; outf << "Clock Bias cec: " << xvt1.clkbias << endl; outf << "Clock Drift cec: " << xvt1.clkdrift << endl; outf << "RelCorr cec: " << xvt1.relcorr << endl; outf << "Time of Prediction cec: " << GPSWeekSecond(cec.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 CEC object with data available from navdump. outf << endl << "Test Case 2: Creating CEC object with data from navdump." << endl; outf << "Time = " << ct2 << endl; CNAV2EphClk cec2; cec2.loadData( SysID, obsID, PRNID2, TOWWeek2, TOW2, Top2, health, URAoe2, Toe2, deltaA2, Adot2, dn2, dnDot2, M02, ecc2, w2, OMEGA02, i02, OMEGAdot2, idot2, Cic2, Cis2, Crc2, Crs2, Cuc2, Cus2, URAoc_2, URAoc1_2, URAoc2_2, af0_2, af1_2, af2_2, Tgd2, ISCL1cp2, ISCL1cd2); Xvt xvt2 = cec2.svXvt( dt2 ); outf << "Position cec2: " << xvt2.x << endl; outf << "Velocity cec2: " << xvt2.v << endl; outf << "Clock Bias cec2: " << xvt2.clkbias << endl; outf << "Clock Drift cec2: " << xvt2.clkdrift << endl; outf << "RelCorr cec2: " << xvt2.relcorr << endl; outf << "Time of Prediction cec2: " << GPSWeekSecond(cec2.getTimeOfPrediction()).printf("%F, %g") << endl; // Third test case. Create an CEC object with data available from navdump. outf << endl << "Test Case 3: Creating CEC object with data from navdump." << endl; outf << "Time = " << ct3 << endl; CNAV2EphClk cec3; cec3.loadData( SysID, obsID, PRNID3, TOWWeek3, TOW3, Top3, health, URAoe3, Toe3, deltaA3, Adot3, dn3, dnDot3, M03, ecc3, w3, OMEGA03, i03, OMEGAdot3, idot3, Cic3, Cis3, Crc3, Crs3, Cuc3, Cus3, URAoc_3, URAoc1_3, URAoc2_3, af0_3, af1_3, af2_3, Tgd3, ISCL1cp3, ISCL1cd3); Xvt xvt3 = cec3.svXvt( dt3 ); outf << "Position cec3: " << xvt3.x << endl; outf << "Velocity cec3: " << xvt3.v << endl; outf << "Clock Bias cec3: " << xvt3.clkbias << endl; outf << "Clock Drift cec3: " << xvt3.clkdrift << endl; outf << "RelCorr cec3: " << xvt3.relcorr << endl; outf << "Time of Prediction cec3: " << GPSWeekSecond(cec3.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<< "Clock Bias EE: " << xvt.clkbias << endl; outf<< "Clock Drift EE: " << xvt.clkdrift << endl; outf<< "RelCorr EE: " << EE.svRelativity(dt) << endl; outf << endl; outf << "CEC Object Dump:" << endl; outf << cec << endl; outf << endl; outf << "CEC2 Object Dump:" << endl; outf << cec2 << endl; outf << endl; outf << "CEC3 Object Dump:" << endl; outf << cec3 << endl; outf << endl; outf << "Fit Interval Tests" << endl; outf << "BeginFit cec: " << GPSWeekSecond(cec.getOrbit().getBeginningOfFitInterval()).printf("%F, %g") << endl; outf << "BeginFit EE: " << GPSWeekSecond(EE.getOrbit().getBeginningOfFitInterval()).printf("%F, %g") << endl; outf << endl; outf << "EndFit cec: " << GPSWeekSecond(cec.getOrbit().getEndOfFitInterval()).printf("%F, %g") << endl; outf << "EndFit EE : " << GPSWeekSecond(EE.getOrbit().getEndOfFitInterval()).printf("%F, %g") << endl; outf << endl; outf << "Within Fit Interval: " << cec.getOrbit().withinFitInterval(dt) << endl; outf << "Within Fit Interval: " << EE.getOrbit().withinFitInterval(dt) << endl; CPPUNIT_ASSERT(fileEqualTest((char*)"Logs/Truth",(char*)"Logs/Output")); }