Changeset 1044 in ntrip for trunk/BNC/RTCM
- Timestamp:
- Aug 19, 2008, 11:36:54 AM (16 years ago)
- Location:
- trunk/BNC/RTCM
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/RTCM/GPSDecoder.h
r1035 r1044 34 34 class t_obsInternal { 35 35 public: 36 37 t_obsInternal() : 38 flags(0), 39 satSys(' '), 40 satNum(0), 41 slot(0), 42 GPSWeek(0), 43 GPSWeeks(0.0), 44 C1(0.0), 45 C2(0.0), 46 P1(0.0), 47 P2(0.0), 48 L1(0.0), 49 L2(0.0), 50 slip_cnt_L1(-1), 51 slip_cnt_L2(-1), 52 lock_timei_L1(-1), 53 lock_timei_L2(-1), 54 S1(0.0), 55 S2(0.0), 56 SNR1(0), 57 SNR2(0) { 58 StatID[0] = '\x0'; 59 } 36 60 int flags; 37 char StatID[20+1];// Station ID 38 char satSys; // Satellite System ('G' or 'R') 39 int satNum; // Satellite Number (PRN for GPS NAVSTAR) 40 int slot; // Slot Number (for Glonass) 41 int GPSWeek; // Week of GPS-Time 42 double GPSWeeks; // Second of Week (GPS-Time) 43 double C1; // CA-code pseudorange (meters) 44 double C2; // CA-code pseudorange (meters) 45 double P1; // P1-code pseudorange (meters) 46 double P2; // P2-code pseudorange (meters) 47 double L1; // L1 carrier phase (cycles) 48 double L2; // L2 carrier phase (cycles) 49 double S1; // L1 signal-to noise ratio 50 double S2; // L2 signal-to noise ratio 51 int SNR1; // L1 signal-to noise ratio (mapped to integer) 52 int SNR2; // L2 signal-to noise ratio (mapped to integer) 61 char StatID[20+1]; // Station ID 62 char satSys; // Satellite System ('G' or 'R') 63 int satNum; // Satellite Number (PRN for GPS NAVSTAR) 64 int slot; // Slot Number (for Glonass) 65 int GPSWeek; // Week of GPS-Time 66 double GPSWeeks; // Second of Week (GPS-Time) 67 double C1; // CA-code pseudorange (meters) 68 double C2; // CA-code pseudorange (meters) 69 double P1; // P1-code pseudorange (meters) 70 double P2; // P2-code pseudorange (meters) 71 double L1; // L1 carrier phase (cycles) 72 double L2; // L2 carrier phase (cycles) 73 int slip_cnt_L1; // L1 cumulative loss of continuity indicator (negative value = undefined) 74 int slip_cnt_L2; // L2 cumulative loss of continuity indicator (negative value = undefined) 75 int lock_timei_L1; // L1 last lock time indicator (negative value = undefined) 76 int lock_timei_L2; // L2 last lock time indicator (negative value = undefined) 77 double S1; // L1 signal-to noise ratio 78 double S2; // L2 signal-to noise ratio 79 int SNR1; // L1 signal-to noise ratio (mapped to integer) 80 int SNR2; // L2 signal-to noise ratio (mapped to integer) 53 81 }; 54 82 … … 60 88 _status = initial; 61 89 62 _o.flags = 0; 63 _o.StatID[0] = '\0'; 64 _o.satSys = 'G'; 65 _o.satNum = 0; 66 _o.slot = 0; 67 _o.GPSWeek = 0; 68 _o.GPSWeeks = 0.0; 69 _o.C1 = 0.0; 70 _o.C2 = 0.0; 71 _o.P1 = 0.0; 72 _o.P2 = 0.0; 73 _o.L1 = 0.0; 74 _o.L2 = 0.0; 75 _o.S1 = 0.0; 76 _o.S2 = 0.0; 77 _o.SNR1 = 0; 78 _o.SNR2 = 0; 90 _o.flags = 0; 91 _o.StatID[0] = '\0'; 92 _o.satSys = 'G'; 93 _o.satNum = 0; 94 _o.slot = 0; 95 _o.GPSWeek = 0; 96 _o.GPSWeeks = 0.0; 97 _o.C1 = 0.0; 98 _o.C2 = 0.0; 99 _o.P1 = 0.0; 100 _o.P2 = 0.0; 101 _o.L1 = 0.0; 102 _o.L2 = 0.0; 103 _o.S1 = 0.0; 104 _o.S2 = 0.0; 105 _o.slip_cnt_L1 = -1; 106 _o.slip_cnt_L2 = -1; 107 _o.lock_timei_L1 = -1; 108 _o.lock_timei_L2 = -1; 109 _o.SNR1 = 0; 110 _o.SNR2 = 0; 79 111 } 80 112 -
trunk/BNC/RTCM/RTCM2.cpp
r1029 r1044 945 945 cph_L1.resize(0); // Carrier phase [m] 946 946 cph_L2.resize(0); // Carrier phase [m] 947 slip_L1.resize(0); // Slip counter 948 slip_L2.resize(0); // Slip counter 947 949 948 950 availability.reset(); // Message status flags … … 1005 1007 bool isGPS,isCAcode,isL1,isOth; 1006 1008 int NSat,idx; 1007 int sid,prn ;1009 int sid,prn,slip_cnt; 1008 1010 double t,rng,cph; 1009 1011 … … 1114 1116 1115 1117 prn = (isGPS? sid : sid+200 ); 1116 1118 1117 1119 // Carrier phase measurement (mod 2^23 [cy]; sign matched to range) 1118 1120 cph = -P.getBits(iSat*48+40,32)/256.0; 1121 1122 // Slip counter 1123 slip_cnt = P.getUnsignedBits(iSat*48+35,5); 1119 1124 1120 1125 // Is this a new PRN? … … 1132 1137 cph_L1.push_back(0.0); 1133 1138 cph_L2.push_back(0.0); 1139 slip_L1.push_back(-1); 1140 slip_L2.push_back(-1); 1134 1141 }; 1135 1142 1136 1143 // Store measurement 1137 1144 if (isL1) { 1138 cph_L1[idx] = cph; 1145 cph_L1 [idx] = cph; 1146 slip_L1[idx] = slip_cnt; 1139 1147 } 1140 1148 else { 1141 cph_L2[idx] = cph; 1149 cph_L2 [idx] = cph; 1150 slip_L2[idx] = slip_cnt; 1142 1151 }; 1143 1152 … … 1251 1260 cph_L1.push_back(0.0); 1252 1261 cph_L2.push_back(0.0); 1262 slip_L1.push_back(-1); 1263 slip_L2.push_back(-1); 1253 1264 }; 1254 1265 … … 1339 1350 1340 1351 }; // End of namespace rtcm2 1352 1353 1354 -
trunk/BNC/RTCM/RTCM2.h
r1029 r1044 201 201 202 202 class RTCM2_03 { 203 204 public: 205 206 void extract(const RTCM2packet& P); 207 208 public: 209 210 bool validMsg; // Validity flag 211 double x,y,z; // Station coordinates 212 203 public: 204 205 RTCM2_03() : validMsg(false), x(0.0), y(0.0), z(0.0) { } 206 207 void extract(const RTCM2packet& P); 208 209 public: 210 bool validMsg; // Validity flag 211 double x,y,z; // Station coordinates 213 212 }; 214 213 … … 309 308 std::vector<double> cph_L1; // Carrier phase on L1 [cy] 310 309 std::vector<double> cph_L2; // Carrier phase on L2 [cy] 310 std::vector<int> slip_L1; // Carrier phase slip counter, L1 311 std::vector<int> slip_L2; // Carrier phase slip counter, L1 311 312 312 313 private: -
trunk/BNC/RTCM/RTCM2Decoder.cpp
r1029 r1044 39 39 * -----------------------------------------------------------------------*/ 40 40 41 #include <math.h> 42 #include <sstream> 43 #include <iomanip> 44 41 45 #include "../bncutils.h" 46 #include "rtcm_utils.h" 42 47 #include "GPSDecoder.h" 43 48 #include "RTCM2Decoder.h" 44 49 45 50 using namespace std; 51 using namespace rtcm2; 46 52 47 53 // … … 49 55 // 50 56 51 RTCM2Decoder::RTCM2Decoder( ) {52 57 RTCM2Decoder::RTCM2Decoder(const std::string& ID) { 58 _ID = ID; 53 59 } 54 60 … … 58 64 59 65 RTCM2Decoder::~RTCM2Decoder() { 60 } 61 62 // 63 66 for (t_pairMap::iterator ii = _ephPair.begin(); ii != _ephPair.end(); ii++) { 67 delete ii->second; 68 } 69 } 70 71 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 // 64 87 t_irc RTCM2Decoder::Decode(char* buffer, int bufLen) { 65 88 … … 95 118 _obsList.push_back(obs); 96 119 if (_ObsBlock.PRN[iSat] > 100) { 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); 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]; 136 obs->_o.lock_timei_L1 = -1; 137 obs->_o.lock_timei_L2 = -1; 111 138 } 112 139 _ObsBlock.clear(); 113 140 } 114 141 } 142 143 else if ( _PP.ID() == 20 || _PP.ID() == 21 ) { 144 _msg2021.extract(_PP); 145 146 if (_msg2021.valid()) { 147 translateCorr2Obs(); 148 } 149 } 150 151 else if ( _PP.ID() == 3 ) { 152 _msg03.extract(_PP); 153 } 154 155 else if ( _PP.ID() == 22 ) { 156 _msg22.extract(_PP); 157 } 115 158 } 116 159 return success; 117 160 } 118 161 162 163 164 void RTCM2Decoder::storeEph(const gpsephemeris& gpseph) { 165 t_ephGPS eph; eph.set(&gpseph); 166 167 storeEph(eph); 168 } 169 170 171 void RTCM2Decoder::storeEph(const t_ephGPS& gpseph) { 172 t_ephGPS* eph = new t_ephGPS(gpseph); 173 174 string prn = eph->prn(); 175 176 t_pairMap::iterator ip = _ephPair.find(prn); 177 if (ip == _ephPair.end() ) { 178 ip = _ephPair.insert(pair<string, t_ephPair*>(prn, new t_ephPair)).first; 179 } 180 t_ephPair* pair = ip->second; 181 182 if ( !pair->eph || eph->isNewerThan(pair->eph) ) { 183 delete pair->oldEph; 184 pair->oldEph = pair->eph; 185 pair->eph = eph; 186 187 return; 188 } 189 190 delete eph; 191 } 192 193 194 void RTCM2Decoder::translateCorr2Obs() { 195 196 if ( !_msg03.validMsg || !_msg2021.valid() ) { 197 return; 198 } 199 200 double stax = _msg03.x + (_msg22.validMsg ? _msg22.dL1[0] : 0.0); 201 double stay = _msg03.y + (_msg22.validMsg ? _msg22.dL1[1] : 0.0); 202 double staz = _msg03.z + (_msg22.validMsg ? _msg22.dL1[2] : 0.0); 203 204 int refWeek; 205 double refSecs; 206 currentGPSWeeks(refWeek, refSecs); 207 208 // Resolve receiver time of measurement (see RTCM 2.3, page 4-42, Message 18, Note 1) 209 // ---------------------------------------------------------------------------------- 210 double hoursec_est = _msg2021.hoursec(); // estimated time of measurement 211 double hoursec_rcv = rint(hoursec_est * 1e2) / 1e2; // receiver clock reading at hoursec_est 212 double rcv_clk_bias = (hoursec_est - hoursec_rcv) * c_light; 213 214 int GPSWeek; 215 double GPSWeeks; 216 resolveEpoch(hoursec_est, refWeek, refSecs, 217 GPSWeek, GPSWeeks); 218 219 int GPSWeek_rcv; 220 double GPSWeeks_rcv; 221 resolveEpoch(hoursec_rcv, refWeek, refSecs, 222 GPSWeek_rcv, GPSWeeks_rcv); 223 224 // Loop over all satellites 225 // ------------------------ 226 for (RTCM2_2021::data_iterator icorr = _msg2021.data.begin(); 227 icorr != _msg2021.data.end(); icorr++) { 228 const RTCM2_2021::HiResCorr* corr = icorr->second; 229 230 ostringstream oPRN; oPRN.fill('0'); 231 232 oPRN << (corr->PRN < 200 ? 'G' : 'R') 233 << setw(2) << (corr->PRN < 200 ? corr->PRN : corr->PRN - 200); 234 235 string PRN(oPRN.str()); 236 237 t_pairMap::const_iterator ieph = _ephPair.find(PRN); 238 const t_eph* eph0 = 0; 239 const t_eph* eph1 = 0; 240 241 if ( ieph != _ephPair.end() ) { 242 eph0 = ieph->second->eph; 243 eph1 = ieph->second->oldEph; 244 } 245 246 if ( !eph0 && !eph1 ) { 247 continue; 248 } 249 250 double L1 = 0; 251 double L2 = 0; 252 double P1 = 0; 253 double P2 = 0; 254 string obsT = ""; 255 256 // new observation 257 p_obs new_obs = 0; 258 259 for (unsigned ii = 0; ii < 4; ii++) { 260 int IODcorr = 0; 261 double corrVal = 0; 262 const t_eph* eph = 0; 263 double* obsVal = 0; 264 265 switch (ii) { 266 case 0: // --- L1 --- 267 IODcorr = corr->IODp1; 268 corrVal = corr->phase1 * LAMBDA_1; 269 obsVal = &L1; 270 obsT = "L1"; 271 break; 272 case 1: // --- L2 --- 273 IODcorr = corr->IODp2; 274 corrVal = corr->phase2 * LAMBDA_2; 275 obsVal = &L2; 276 obsT = "L2"; 277 break; 278 case 2: // --- P1 --- 279 IODcorr = corr->IODr1; 280 corrVal = corr->range1; 281 obsVal = &P1; 282 obsT = "P1"; 283 break; 284 case 3: // --- P2 --- 285 IODcorr = corr->IODr2; 286 corrVal = corr->range2; 287 obsVal = &P2; 288 obsT = "P2"; 289 break; 290 default: 291 continue; 292 } 293 294 eph = 0; 295 if ( eph0 && eph0->IOD() == IODcorr ) 296 eph = eph0; 297 else if ( eph1 && eph1->IOD() == IODcorr ) 298 eph = eph1; 299 if ( eph && corr ) { 300 int GPSWeek_tot; 301 double GPSWeeks_tot; 302 double rho, xSat, ySat, zSat, clkSat; 303 cmpRho(eph, stax, stay, staz, 304 GPSWeek, GPSWeeks, 305 rho, GPSWeek_tot, GPSWeeks_tot, 306 xSat, ySat, zSat, clkSat); 307 308 *obsVal = rho - corrVal + rcv_clk_bias - clkSat; 309 310 if ( *obsVal == 0 ) *obsVal = ZEROVALUE; 311 312 // Allocate new memory 313 // ------------------- 314 if ( !new_obs ) { 315 new_obs = new t_obs(); 316 317 new_obs->_o.StatID[0] = '\x0'; 318 new_obs->_o.satSys = (corr->PRN < 200 ? 'G' : 'R'); 319 new_obs->_o.satNum = (corr->PRN < 200 ? corr->PRN : corr->PRN - 200); 320 321 new_obs->_o.GPSWeek = GPSWeek_rcv; 322 new_obs->_o.GPSWeeks = GPSWeeks_rcv; 323 } 324 325 // Store estimated measurements 326 // ---------------------------- 327 switch (ii) { 328 case 0: // --- L1 --- 329 new_obs->_o.L1 = *obsVal / LAMBDA_1; 330 new_obs->_o.slip_cnt_L1 = corr->lock1; 331 new_obs->_o.lock_timei_L1 = -1; 332 break; 333 case 1: // --- L2 --- 334 new_obs->_o.L2 = *obsVal / LAMBDA_2; 335 new_obs->_o.slip_cnt_L2 = corr->lock2; 336 new_obs->_o.lock_timei_L2 = -1; 337 break; 338 case 2: // --- C1 / P1 --- 339 if ( corr->Pind1 ) 340 new_obs->_o.P1 = *obsVal; 341 else 342 new_obs->_o.C1 = *obsVal; 343 break; 344 case 3: // --- C2 / P2 --- 345 if ( corr->Pind2 ) 346 new_obs->_o.P2 = *obsVal; 347 else 348 new_obs->_o.C2 = *obsVal; 349 break; 350 default: 351 continue; 352 } 353 } 354 } // loop over frequencies 355 356 if ( new_obs ) { 357 _obsList.push_back( new_obs ); 358 } 359 } 360 } -
trunk/BNC/RTCM/RTCM2Decoder.h
r1029 r1044 26 26 #define INC_RTCM2DECODER_H 27 27 28 #include <map> 29 28 30 #include "GPSDecoder.h" 29 31 #include "RTCM2.h" 32 #include "RTCM2_2021.h" 33 #include "../RTCM3/rtcm3torinex.h" 34 #include "../RTCM3/ephemeris.h" 30 35 31 36 class RTCM2Decoder: public GPSDecoder { 32 37 33 38 public: 34 RTCM2Decoder( );39 RTCM2Decoder(const std::string& ID); 35 40 virtual ~RTCM2Decoder(); 36 41 virtual t_irc Decode(char* buffer, int bufLen); 37 42 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 std::string ID() const { return _ID; } 51 38 52 private: 39 53 40 std::string _buffer; 41 rtcm2::RTCM2_Obs _ObsBlock; 42 rtcm2::RTCM2packet _PP; 54 class t_ephPair { 55 public: 56 t_ephPair() { 57 eph = 0; 58 oldEph = 0; 59 } 60 61 ~t_ephPair() { 62 delete eph; 63 delete oldEph; 64 } 65 66 t_eph* eph; 67 t_eph* oldEph; 68 }; 43 69 70 void translateCorr2Obs(); 71 72 std::string _ID; 73 74 std::string _buffer; 75 rtcm2::RTCM2packet _PP; 76 77 // for messages 18, 19 decoding 78 rtcm2::RTCM2_Obs _ObsBlock; 79 80 // for messages 20, 21 decoding 81 rtcm2::RTCM2_03 _msg03; 82 rtcm2::RTCM2_22 _msg22; 83 rtcm2::RTCM2_2021 _msg2021; 84 std::map<std::string, t_ephPair*> _ephPair; 85 86 typedef std::map<std::string, t_ephPair*> t_pairMap; 44 87 }; 45 88 -
trunk/BNC/RTCM/rtcm_utils.cpp
r1027 r1044 38 38 eph->position(GPSWeek, GPSWeeks, xSat, ySat, zSat, clkSat); 39 39 40 cout << "----- cmpRho -----\n";41 eph->print(cout);42 cout << " pos " << setw(4) << GPSWeek43 << " " << setw(14) << setprecision(6) << GPSWeeks44 << " " << setw(13) << setprecision(3) << xSat45 << " " << setw(13) << setprecision(3) << ySat46 << " " << setw(13) << setprecision(3) << zSat47 << endl;40 ////cout << "----- cmpRho -----\n"; 41 ////eph->print(cout); 42 ////cout << " pos " << setw(4) << GPSWeek 43 //// << " " << setw(14) << setprecision(6) << GPSWeeks 44 //// << " " << setw(13) << setprecision(3) << xSat 45 //// << " " << setw(13) << setprecision(3) << ySat 46 //// << " " << setw(13) << setprecision(3) << zSat 47 //// << endl; 48 48 49 49 // Loop until the correct Time Of Transmission is found … … 85 85 rho = sqrt(dx*dx + dy*dy + dz*dz); 86 86 87 cout << " scrd " << setw(4) << GPSWeek_tot88 << " " << setw(15) << setprecision(8) << GPSWeeks_tot89 << " " << setw(13) << setprecision(3) << xSat90 << " " << setw(13) << setprecision(3) << ySat91 << " " << setw(13) << setprecision(3) << zSat92 << " rcv0 " << setw(12) << setprecision(3) << stax93 << " " << setw(12) << setprecision(3) << stay94 << " " << setw(12) << setprecision(3) << staz95 << " rcv " << setw(12) << setprecision(3) << xRec96 << " " << setw(12) << setprecision(3) << yRec97 << " " << setw(12) << setprecision(3) << zRec98 << " dPhi " << scientific << setw(13) << setprecision(10) << dPhi << fixed99 << " rho " << setw(13) << setprecision(3) << rho100 << endl;87 ////cout << " scrd " << setw(4) << GPSWeek_tot 88 //// << " " << setw(15) << setprecision(8) << GPSWeeks_tot 89 //// << " " << setw(13) << setprecision(3) << xSat 90 //// << " " << setw(13) << setprecision(3) << ySat 91 //// << " " << setw(13) << setprecision(3) << zSat 92 //// << " rcv0 " << setw(12) << setprecision(3) << stax 93 //// << " " << setw(12) << setprecision(3) << stay 94 //// << " " << setw(12) << setprecision(3) << staz 95 //// << " rcv " << setw(12) << setprecision(3) << xRec 96 //// << " " << setw(12) << setprecision(3) << yRec 97 //// << " " << setw(12) << setprecision(3) << zRec 98 //// << " dPhi " << scientific << setw(13) << setprecision(10) << dPhi << fixed 99 //// << " rho " << setw(13) << setprecision(3) << rho 100 //// << endl; 101 101 102 102 … … 112 112 clkSat *= c_light; // satellite clock correction in meters 113 113 114 cout << "***** cmpRho *****\n";115 116 114 return 0; 117 115 }
Note:
See TracChangeset
for help on using the changeset viewer.