Changeset 1029 in ntrip for trunk/BNC/RTCM
- Timestamp:
- Aug 8, 2008, 8:02:33 PM (17 years ago)
- Location:
- trunk/BNC/RTCM
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/BNC/RTCM/GPSDecoder.h ¶
r1024 r1029 47 47 double L1; // L1 carrier phase (cycles) 48 48 double L2; // L2 carrier phase (cycles) 49 int slip_cnt_L1; // L1 cumulative loss of continuity indicator50 int slip_cnt_L2; // L2 cumulative loss of continuity indicator51 49 double S1; // L1 signal-to noise ratio 52 50 double S2; // L2 signal-to noise ratio -
TabularUnified trunk/BNC/RTCM/RTCM2.cpp ¶
r1024 r1029 945 945 cph_L1.resize(0); // Carrier phase [m] 946 946 cph_L2.resize(0); // Carrier phase [m] 947 slip_L1.resize(0); // Slip counter948 slip_L2.resize(0); // Slip counter949 947 950 948 availability.reset(); // Message status flags … … 1007 1005 bool isGPS,isCAcode,isL1,isOth; 1008 1006 int NSat,idx; 1009 int sid,prn ,slip_cnt;1007 int sid,prn; 1010 1008 double t,rng,cph; 1011 1009 … … 1119 1117 // Carrier phase measurement (mod 2^23 [cy]; sign matched to range) 1120 1118 cph = -P.getBits(iSat*48+40,32)/256.0; 1121 1122 // Slip counter1123 slip_cnt = P.getUnsignedBits(iSat*48+35,5);1124 1119 1125 1120 // Is this a new PRN? … … 1137 1132 cph_L1.push_back(0.0); 1138 1133 cph_L2.push_back(0.0); 1139 slip_L1.push_back(-1);1140 slip_L2.push_back(-1);1141 1134 }; 1142 1135 1143 1136 // Store measurement 1144 1137 if (isL1) { 1145 cph_L1 [idx] = cph; 1146 slip_L1[idx] = slip_cnt; 1138 cph_L1[idx] = cph; 1147 1139 } 1148 1140 else { 1149 cph_L2 [idx] = cph; 1150 slip_L2[idx] = slip_cnt; 1141 cph_L2[idx] = cph; 1151 1142 }; 1152 1143 … … 1348 1339 1349 1340 }; // End of namespace rtcm2 1350 1351 1352 -
TabularUnified trunk/BNC/RTCM/RTCM2.h ¶
r1024 r1029 309 309 std::vector<double> cph_L1; // Carrier phase on L1 [cy] 310 310 std::vector<double> cph_L2; // Carrier phase on L2 [cy] 311 std::vector<int> slip_L1; // Carrier phase slip counter, L1312 std::vector<int> slip_L2; // Carrier phase slip counter, L1313 311 314 312 private: -
TabularUnified trunk/BNC/RTCM/RTCM2Decoder.cpp ¶
r1027 r1029 39 39 * -----------------------------------------------------------------------*/ 40 40 41 #include <math.h>42 #include <sstream>43 #include <iomanip>44 45 41 #include "../bncutils.h" 46 #include "rtcm_utils.h"47 42 #include "GPSDecoder.h" 48 43 #include "RTCM2Decoder.h" 49 44 50 45 using namespace std; 51 using namespace rtcm2;52 46 53 47 // … … 55 49 // 56 50 57 RTCM2Decoder::RTCM2Decoder( const std::string& ID) {58 _ID = ID; 51 RTCM2Decoder::RTCM2Decoder() { 52 59 53 } 60 54 … … 64 58 65 59 RTCM2Decoder::~RTCM2Decoder() { 66 for (t_pairMap::iterator ii = _ephPair.begin(); ii != _ephPair.end(); ii++) {67 delete ii->second;68 }69 60 } 70 61 62 // 71 63 72 //73 t_irc RTCM2Decoder::getStaCrd(double& xx, double& yy, double& zz) {74 if ( !_msg03.validMsg ) {75 return failure;76 }77 78 xx = _msg03.x + (_msg22.validMsg ? _msg22.dL1[0] : 0.0);79 yy = _msg03.y + (_msg22.validMsg ? _msg22.dL1[1] : 0.0);80 zz = _msg03.z + (_msg22.validMsg ? _msg22.dL1[2] : 0.0);81 82 return success;83 }84 85 86 //87 64 t_irc RTCM2Decoder::Decode(char* buffer, int bufLen) { 88 65 … … 118 95 _obsList.push_back(obs); 119 96 if (_ObsBlock.PRN[iSat] > 100) { 120 obs->_o.satNum = _ObsBlock.PRN[iSat] % 100; 121 obs->_o.satSys = 'R'; 122 } 123 else { 124 obs->_o.satNum = _ObsBlock.PRN[iSat]; 125 obs->_o.satSys = 'G'; 126 } 127 obs->_o.GPSWeek = epochWeek; 128 obs->_o.GPSWeeks = epochSecs; 129 obs->_o.C1 = _ObsBlock.rng_C1[iSat]; 130 obs->_o.P1 = _ObsBlock.rng_P1[iSat]; 131 obs->_o.P2 = _ObsBlock.rng_P2[iSat]; 132 obs->_o.L1 = _ObsBlock.resolvedPhase_L1(iSat); 133 obs->_o.L2 = _ObsBlock.resolvedPhase_L2(iSat); 134 obs->_o.slip_cnt_L1 = _ObsBlock.slip_L1[iSat]; 135 obs->_o.slip_cnt_L2 = _ObsBlock.slip_L2[iSat]; 97 obs->_o.satNum = _ObsBlock.PRN[iSat] % 100; 98 obs->_o.satSys = 'R'; 99 } 100 else { 101 obs->_o.satNum = _ObsBlock.PRN[iSat]; 102 obs->_o.satSys = 'G'; 103 } 104 obs->_o.GPSWeek = epochWeek; 105 obs->_o.GPSWeeks = epochSecs; 106 obs->_o.C1 = _ObsBlock.rng_C1[iSat]; 107 obs->_o.P1 = _ObsBlock.rng_P1[iSat]; 108 obs->_o.P2 = _ObsBlock.rng_P2[iSat]; 109 obs->_o.L1 = _ObsBlock.resolvedPhase_L1(iSat); 110 obs->_o.L2 = _ObsBlock.resolvedPhase_L2(iSat); 136 111 } 137 112 _ObsBlock.clear(); 138 113 } 139 }140 141 else if ( _PP.ID() == 20 || _PP.ID() == 21 ) {142 _msg2021.extract(_PP);143 144 if (_msg2021.valid()) {145 translateCorr2Obs();146 }147 }148 149 else if ( _PP.ID() == 3 ) {150 _msg03.extract(_PP);151 }152 153 else if ( _PP.ID() == 22 ) {154 _msg22.extract(_PP);155 114 } 156 115 } … … 158 117 } 159 118 160 161 162 void RTCM2Decoder::storeEph(const gpsephemeris& gpseph) {163 t_ephGPS* eph = new t_ephGPS; eph->set(&gpseph);164 165 string prn = eph->prn();166 167 t_pairMap::iterator ip = _ephPair.find(prn);168 if (ip == _ephPair.end() ) {169 ip = _ephPair.insert(pair<string, t_ephPair*>(prn, new t_ephPair)).first;170 }171 t_ephPair* pair = ip->second;172 173 if ( !pair->eph || eph->isNewerThan(pair->eph) ) {174 delete pair->oldEph;175 pair->oldEph = pair->eph;176 pair->eph = eph;177 178 return;179 }180 181 delete eph;182 }183 184 185 void RTCM2Decoder::storeEph(const t_ephGPS& gpseph) {186 t_ephGPS* eph = new t_ephGPS(gpseph);187 188 string prn = eph->prn();189 190 t_pairMap::iterator ip = _ephPair.find(prn);191 if (ip == _ephPair.end() ) {192 ip = _ephPair.insert(pair<string, t_ephPair*>(prn, new t_ephPair)).first;193 }194 t_ephPair* pair = ip->second;195 196 if ( !pair->eph || eph->isNewerThan(pair->eph) ) {197 delete pair->oldEph;198 pair->oldEph = pair->eph;199 pair->eph = eph;200 201 return;202 }203 204 delete eph;205 }206 207 208 void RTCM2Decoder::translateCorr2Obs() {209 210 if ( !_msg03.validMsg || !_msg2021.valid() ) {211 return;212 }213 214 double stax = _msg03.x + (_msg22.validMsg ? _msg22.dL1[0] : 0.0);215 double stay = _msg03.y + (_msg22.validMsg ? _msg22.dL1[1] : 0.0);216 double staz = _msg03.z + (_msg22.validMsg ? _msg22.dL1[2] : 0.0);217 218 int refWeek;219 double refSecs;220 currentGPSWeeks(refWeek, refSecs);221 222 // Resolve receiver time of measurement (see RTCM 2.3, page 4-42, Message 18, Note 1)223 // ----------------------------------------------------------------------------------224 double hoursec_est = _msg2021.hoursec(); // estimated time of measurement225 double hoursec_rcv = rint(hoursec_est * 1e2) / 1e2; // receiver clock reading at hoursec_est226 double rcv_clk_bias = (hoursec_est - hoursec_rcv) * c_light;227 228 int GPSWeek;229 double GPSWeeks;230 resolveEpoch(hoursec_est, refWeek, refSecs,231 GPSWeek, GPSWeeks);232 233 int GPSWeek_rcv;234 double GPSWeeks_rcv;235 resolveEpoch(hoursec_rcv, refWeek, refSecs,236 GPSWeek_rcv, GPSWeeks_rcv);237 238 // Loop over all satellites239 // ------------------------240 for (RTCM2_2021::data_iterator icorr = _msg2021.data.begin();241 icorr != _msg2021.data.end(); icorr++) {242 const RTCM2_2021::HiResCorr* corr = icorr->second;243 244 ostringstream oPRN; oPRN.fill('0');245 246 oPRN << (corr->PRN < 200 ? 'G' : 'R')247 << setw(2) << (corr->PRN < 200 ? corr->PRN : corr->PRN - 200);248 249 string PRN(oPRN.str());250 251 t_pairMap::const_iterator ieph = _ephPair.find(PRN);252 const t_eph* eph0 = 0;253 const t_eph* eph1 = 0;254 255 if ( ieph != _ephPair.end() ) {256 eph0 = ieph->second->eph;257 eph1 = ieph->second->oldEph;258 }259 260 261 if ( !eph0 && !eph1 ) {262 continue;263 }264 265 double L1 = 0;266 double L2 = 0;267 double P1 = 0;268 double P2 = 0;269 string obsT = "";270 271 // new observation272 p_obs new_obs = 0;273 274 for (unsigned ii = 0; ii < 4; ii++) {275 int IODcorr = 0;276 double corrVal = 0;277 const t_eph* eph = 0;278 double* obsVal = 0;279 280 switch (ii) {281 case 0: // --- L1 ---282 IODcorr = corr->IODp1;283 corrVal = corr->phase1 * LAMBDA_1;284 obsVal = &L1;285 obsT = "L1";286 break;287 case 1: // --- L2 ---288 IODcorr = corr->IODp2;289 corrVal = corr->phase2 * LAMBDA_2;290 obsVal = &L2;291 obsT = "L2";292 break;293 case 2: // --- P1 ---294 IODcorr = corr->IODr1;295 corrVal = corr->range1;296 obsVal = &P1;297 obsT = "P1";298 break;299 case 3: // --- P2 ---300 IODcorr = corr->IODr2;301 corrVal = corr->range2;302 obsVal = &P2;303 obsT = "P2";304 break;305 default:306 continue;307 }308 309 eph = 0;310 if ( eph0 && eph0->IOD() == IODcorr )311 eph = eph0;312 else if ( eph1 && eph1->IOD() == IODcorr )313 eph = eph1;314 if ( eph && corr ) {315 int GPSWeek_tot;316 double GPSWeeks_tot;317 double rho, xSat, ySat, zSat, clkSat;318 cmpRho(eph, stax, stay, staz,319 GPSWeek, GPSWeeks,320 rho, GPSWeek_tot, GPSWeeks_tot,321 xSat, ySat, zSat, clkSat);322 323 *obsVal = rho - corrVal + rcv_clk_bias - clkSat;324 325 if ( *obsVal == 0 ) *obsVal = ZEROVALUE;326 327 // Allocate new memory328 // -------------------329 if ( !new_obs ) {330 new_obs = new t_obs();331 332 new_obs->_o.StatID[0] = '\x0';333 new_obs->_o.satSys = (corr->PRN < 200 ? 'G' : 'R');334 new_obs->_o.satNum = (corr->PRN < 200 ? corr->PRN : corr->PRN - 200);335 336 new_obs->_o.GPSWeek = GPSWeek_rcv;337 new_obs->_o.GPSWeeks = GPSWeeks_rcv;338 }339 340 // Store estimated measurements341 // ----------------------------342 switch (ii) {343 case 0: // --- L1 ---344 new_obs->_o.L1 = *obsVal / LAMBDA_1;345 new_obs->_o.slip_cnt_L1 = corr->lock1;346 break;347 case 1: // --- L2 ---348 new_obs->_o.L2 = *obsVal / LAMBDA_2;349 new_obs->_o.slip_cnt_L2 = corr->lock2;350 break;351 case 2: // --- C1 / P1 ---352 if ( corr->Pind1 )353 new_obs->_o.P1 = *obsVal;354 else355 new_obs->_o.C1 = *obsVal;356 break;357 case 3: // --- C2 / P2 ---358 if ( corr->Pind2 )359 new_obs->_o.P2 = *obsVal;360 else361 new_obs->_o.C2 = *obsVal;362 break;363 default:364 continue;365 }366 }367 } // loop over frequencies368 369 if ( new_obs ) {370 _obsList.push_back( new_obs );371 }372 }373 } -
TabularUnified trunk/BNC/RTCM/RTCM2Decoder.h ¶
r1024 r1029 26 26 #define INC_RTCM2DECODER_H 27 27 28 #include <list>29 30 28 #include "GPSDecoder.h" 31 29 #include "RTCM2.h" 32 #include "RTCM2_2021.h"33 #include "../RTCM3/rtcm3torinex.h"34 #include "../RTCM3/ephemeris.h"35 30 36 31 class RTCM2Decoder: public GPSDecoder { 37 32 38 33 public: 39 RTCM2Decoder( const std::string& ID);34 RTCM2Decoder(); 40 35 virtual ~RTCM2Decoder(); 41 36 virtual t_irc Decode(char* buffer, int bufLen); 42 37 43 void storeEph(const gpsephemeris& gpseph);44 void storeEph(const t_ephGPS& gpseph);45 46 t_irc getStaCrd(double& xx, double& yy, double& zz);47 48 const rtcm2::RTCM2_2021& msg2021() const { return _msg2021; }49 50 38 private: 51 39 52 class t_ephPair { 53 public: 54 t_ephPair() { 55 eph = 0; 56 oldEph = 0; 57 } 58 59 ~t_ephPair() { 60 delete eph; 61 delete oldEph; 62 } 63 64 t_eph* eph; 65 t_eph* oldEph; 66 }; 40 std::string _buffer; 41 rtcm2::RTCM2_Obs _ObsBlock; 42 rtcm2::RTCM2packet _PP; 67 43 68 void translateCorr2Obs();69 70 std::string _ID;71 72 std::string _buffer;73 rtcm2::RTCM2packet _PP;74 75 // for messages 18, 19 decoding76 rtcm2::RTCM2_Obs _ObsBlock;77 78 // for messages 20, 21 decoding79 rtcm2::RTCM2_03 _msg03;80 rtcm2::RTCM2_22 _msg22;81 rtcm2::RTCM2_2021 _msg2021;82 std::map<std::string, t_ephPair*> _ephPair;83 84 typedef std::map<std::string, t_ephPair*> t_pairMap;85 44 }; 86 45
Note:
See TracChangeset
for help on using the changeset viewer.