| 1 | //------------------------------------------------------------------------------
|
|---|
| 2 | //
|
|---|
| 3 | // RTCM2.h
|
|---|
| 4 | //
|
|---|
| 5 | // Purpose:
|
|---|
| 6 | //
|
|---|
| 7 | // Module for extraction of RTCM2 messages
|
|---|
| 8 | //
|
|---|
| 9 | // References:
|
|---|
| 10 | //
|
|---|
| 11 | // RTCM 10402.3 Recommended Standards for Differential GNSS (Global
|
|---|
| 12 | // Navigation Satellite Systems) Service; RTCM Paper 136-2001/SC104-STD,
|
|---|
| 13 | // Version 2.3, 20 Aug. 2001; Radio Technical Commission For Maritime
|
|---|
| 14 | // Services, Alexandria, Virgina (2001).
|
|---|
| 15 | // ICD-GPS-200; Navstar GPS Space Segment / Navigation User Interfaces;
|
|---|
| 16 | // Revison C; 25 Sept. 1997; Arinc Research Corp., El Segundo (1997).
|
|---|
| 17 | // Jensen M.; RTCM2ASC Documentation;
|
|---|
| 18 | // URL http://kom.aau.dk/~borre/masters/receiver/rtcm2asc.htm;
|
|---|
| 19 | // last accessed 17 Sep. 2006
|
|---|
| 20 | // Sager J.; Decoder for RTCM SC-104 data from a DGPS beacon receiver;
|
|---|
| 21 | // URL http://www.wsrcc.com/wolfgang/ftp/rtcm-0.3.tar.gz;
|
|---|
| 22 | // last accessed 17 Sep. 2006
|
|---|
| 23 | //
|
|---|
| 24 | // Last modified:
|
|---|
| 25 | //
|
|---|
| 26 | // 2006/09/17 OMO Created
|
|---|
| 27 | // 2006/10/05 OMO Specified const'ness of various member functions
|
|---|
| 28 | // 2006/10/17 OMO Removed obsolete check of multiple message indicator
|
|---|
| 29 | // 2006/11/25 OMO Revised check for presence of GLONASS data
|
|---|
| 30 | //
|
|---|
| 31 | // (c) DLR/GSOC
|
|---|
| 32 | //
|
|---|
| 33 | //------------------------------------------------------------------------------
|
|---|
| 34 |
|
|---|
| 35 | #ifndef INC_RTCM2_H
|
|---|
| 36 | #define INC_RTCM2_H
|
|---|
| 37 |
|
|---|
| 38 | #include <bitset>
|
|---|
| 39 | #include <fstream>
|
|---|
| 40 | #include <string>
|
|---|
| 41 | #include <vector>
|
|---|
| 42 |
|
|---|
| 43 | //
|
|---|
| 44 | // namespace rtcm2
|
|---|
| 45 | //
|
|---|
| 46 |
|
|---|
| 47 | namespace rtcm2 {
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 | //------------------------------------------------------------------------------
|
|---|
| 51 | //
|
|---|
| 52 | // class thirtyBitWord (specification)
|
|---|
| 53 | //
|
|---|
| 54 | // Purpose:
|
|---|
| 55 | //
|
|---|
| 56 | // Handling of RTCM2 30bit words
|
|---|
| 57 | //
|
|---|
| 58 | //------------------------------------------------------------------------------
|
|---|
| 59 |
|
|---|
| 60 | class ThirtyBitWord {
|
|---|
| 61 |
|
|---|
| 62 | public:
|
|---|
| 63 |
|
|---|
| 64 | // Constructor and initialization
|
|---|
| 65 |
|
|---|
| 66 | ThirtyBitWord();
|
|---|
| 67 |
|
|---|
| 68 | void clear();
|
|---|
| 69 |
|
|---|
| 70 | // Status queries
|
|---|
| 71 |
|
|---|
| 72 | bool fail() const;
|
|---|
| 73 | bool validParity() const;
|
|---|
| 74 | bool isHeader() const;
|
|---|
| 75 |
|
|---|
| 76 | // Access methods
|
|---|
| 77 |
|
|---|
| 78 | unsigned int all() const;
|
|---|
| 79 | unsigned int value() const;
|
|---|
| 80 |
|
|---|
| 81 | // Input
|
|---|
| 82 |
|
|---|
| 83 | void get(std::string& buf);
|
|---|
| 84 | void get(std::istream& inp);
|
|---|
| 85 | void getHeader(std::string& buf);
|
|---|
| 86 | void getHeader(std::istream& inp);
|
|---|
| 87 |
|
|---|
| 88 | private:
|
|---|
| 89 |
|
|---|
| 90 | // Input
|
|---|
| 91 |
|
|---|
| 92 | void append(unsigned char c);
|
|---|
| 93 |
|
|---|
| 94 | private:
|
|---|
| 95 |
|
|---|
| 96 | bool failure;
|
|---|
| 97 |
|
|---|
| 98 | //
|
|---|
| 99 | // A 32-bit integer is used to store the 30-bit RTCM word as well as 2
|
|---|
| 100 | // parity bits retained from the previous word
|
|---|
| 101 | //
|
|---|
| 102 | // Bits 31..30 (from left to right) hold the parity bits D29*..D30* of
|
|---|
| 103 | // the previous 30-bit word
|
|---|
| 104 | // Bits 29..06 (from left to right) hold the current data bits D01..D24
|
|---|
| 105 | // Bits 05..00 (from left to right) hold the current parity bits D25..D30
|
|---|
| 106 | //
|
|---|
| 107 |
|
|---|
| 108 | unsigned int W;
|
|---|
| 109 |
|
|---|
| 110 | };
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 | //------------------------------------------------------------------------------
|
|---|
| 115 | //
|
|---|
| 116 | // RTCM2packet (class definition)
|
|---|
| 117 | //
|
|---|
| 118 | // Purpose:
|
|---|
| 119 | //
|
|---|
| 120 | // A class for handling RTCM2 data packets
|
|---|
| 121 | //
|
|---|
| 122 | //------------------------------------------------------------------------------
|
|---|
| 123 |
|
|---|
| 124 | class RTCM2packet {
|
|---|
| 125 |
|
|---|
| 126 | public:
|
|---|
| 127 |
|
|---|
| 128 | // Constructor and initialization
|
|---|
| 129 |
|
|---|
| 130 | RTCM2packet();
|
|---|
| 131 |
|
|---|
| 132 | void clear();
|
|---|
| 133 |
|
|---|
| 134 | // Status queries
|
|---|
| 135 |
|
|---|
| 136 | bool valid() const;
|
|---|
| 137 |
|
|---|
| 138 | // Input
|
|---|
| 139 |
|
|---|
| 140 | void getPacket(std::string& buf);
|
|---|
| 141 | void getPacket(std::istream& inp);
|
|---|
| 142 | friend std::istream& operator >> (std::istream& is, RTCM2packet& p);
|
|---|
| 143 |
|
|---|
| 144 | //
|
|---|
| 145 | // Access methods
|
|---|
| 146 | //
|
|---|
| 147 |
|
|---|
| 148 | // Header and data words contents (parity corrected)
|
|---|
| 149 |
|
|---|
| 150 | unsigned int header1() const;
|
|---|
| 151 | unsigned int header2() const;
|
|---|
| 152 | unsigned int dataWord(int i) const;
|
|---|
| 153 |
|
|---|
| 154 | // Header information
|
|---|
| 155 |
|
|---|
| 156 | unsigned int msgType() const;
|
|---|
| 157 | unsigned int ID() const { return msgType(); };
|
|---|
| 158 | unsigned int stationID() const;
|
|---|
| 159 | unsigned int modZCount() const;
|
|---|
| 160 | unsigned int seqNumber() const;
|
|---|
| 161 | unsigned int nDataWords() const;
|
|---|
| 162 | unsigned int staHealth() const;
|
|---|
| 163 |
|
|---|
| 164 | // Data access
|
|---|
| 165 |
|
|---|
| 166 | unsigned int getUnsignedBits (unsigned int start,
|
|---|
| 167 | unsigned int n ) const;
|
|---|
| 168 | int getBits (unsigned int start,
|
|---|
| 169 | unsigned int n ) const;
|
|---|
| 170 |
|
|---|
| 171 | private:
|
|---|
| 172 |
|
|---|
| 173 | // All input of RTCM data uses a single instance, W, of a 30-bit word
|
|---|
| 174 | // to maintain parity bits between consecutive inputs.
|
|---|
| 175 |
|
|---|
| 176 | ThirtyBitWord W;
|
|---|
| 177 |
|
|---|
| 178 | // Two 30-bit words make up the header of an RTCM2 message
|
|---|
| 179 | // (parity corrected)
|
|---|
| 180 |
|
|---|
| 181 | unsigned int H1;
|
|---|
| 182 | unsigned int H2;
|
|---|
| 183 |
|
|---|
| 184 | // Data words (parity corrected)
|
|---|
| 185 |
|
|---|
| 186 | std::vector<unsigned int> DW;
|
|---|
| 187 |
|
|---|
| 188 | };
|
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 | //------------------------------------------------------------------------------
|
|---|
| 192 | //
|
|---|
| 193 | // RTCM2_03 (class definition)
|
|---|
| 194 | //
|
|---|
| 195 | // Purpose:
|
|---|
| 196 | //
|
|---|
| 197 | // A class for handling RTCM 2 GPS Reference Station Parameters messages
|
|---|
| 198 | //
|
|---|
| 199 | //------------------------------------------------------------------------------
|
|---|
| 200 |
|
|---|
| 201 | class RTCM2_03 {
|
|---|
| 202 |
|
|---|
| 203 | public:
|
|---|
| 204 |
|
|---|
| 205 | void extract(const RTCM2packet& P);
|
|---|
| 206 |
|
|---|
| 207 | public:
|
|---|
| 208 |
|
|---|
| 209 | bool validMsg; // Validity flag
|
|---|
| 210 | double x,y,z; // Station coordinates
|
|---|
| 211 |
|
|---|
| 212 | };
|
|---|
| 213 |
|
|---|
| 214 |
|
|---|
| 215 | //------------------------------------------------------------------------------
|
|---|
| 216 | //
|
|---|
| 217 | // RTCM2_23 (class definition)
|
|---|
| 218 | //
|
|---|
| 219 | // Purpose:
|
|---|
| 220 | //
|
|---|
| 221 | // A class for handling RTCM 2 Antenna Type Definition messages
|
|---|
| 222 | //
|
|---|
| 223 | //------------------------------------------------------------------------------
|
|---|
| 224 |
|
|---|
| 225 | class RTCM2_23 {
|
|---|
| 226 |
|
|---|
| 227 | public:
|
|---|
| 228 |
|
|---|
| 229 | void extract(const RTCM2packet& P);
|
|---|
| 230 |
|
|---|
| 231 | public:
|
|---|
| 232 |
|
|---|
| 233 | bool validMsg; // Validity flag
|
|---|
| 234 | std::string antType; // Antenna descriptor
|
|---|
| 235 | std::string antSN ; // Antenna Serial Number
|
|---|
| 236 |
|
|---|
| 237 | };
|
|---|
| 238 |
|
|---|
| 239 |
|
|---|
| 240 | //------------------------------------------------------------------------------
|
|---|
| 241 | //
|
|---|
| 242 | // RTCM2_24 (class definition)
|
|---|
| 243 | //
|
|---|
| 244 | // Purpose:
|
|---|
| 245 | //
|
|---|
| 246 | // A class for handling RTCM 2 Reference Station Antenna
|
|---|
| 247 | // Reference Point Parameter messages
|
|---|
| 248 | //
|
|---|
| 249 | //------------------------------------------------------------------------------
|
|---|
| 250 |
|
|---|
| 251 | class RTCM2_24 {
|
|---|
| 252 |
|
|---|
| 253 | public:
|
|---|
| 254 |
|
|---|
| 255 | void extract(const RTCM2packet& P);
|
|---|
| 256 |
|
|---|
| 257 | public:
|
|---|
| 258 |
|
|---|
| 259 | bool validMsg; // Validity flag
|
|---|
| 260 | bool isGPS; // Flag for GPS supporting station
|
|---|
| 261 | bool isGLONASS; // Flag for GLONASS supporting station
|
|---|
| 262 | double x,y,z; // Station coordinates (ECEF,[m])
|
|---|
| 263 | double h; // Antenna height [m]
|
|---|
| 264 |
|
|---|
| 265 | };
|
|---|
| 266 |
|
|---|
| 267 |
|
|---|
| 268 |
|
|---|
| 269 | //------------------------------------------------------------------------------
|
|---|
| 270 | //
|
|---|
| 271 | // RTCM2_Obs (class definition)
|
|---|
| 272 | //
|
|---|
| 273 | // Purpose:
|
|---|
| 274 | //
|
|---|
| 275 | // A class for handling blocks of RTCM2 18 & 19 packets that need to be
|
|---|
| 276 | // combined to get a complete set of measurements
|
|---|
| 277 | //
|
|---|
| 278 | //------------------------------------------------------------------------------
|
|---|
| 279 |
|
|---|
| 280 | class RTCM2_Obs {
|
|---|
| 281 |
|
|---|
| 282 | public:
|
|---|
| 283 |
|
|---|
| 284 | RTCM2_Obs(); // Constructor
|
|---|
| 285 |
|
|---|
| 286 | void extract(const RTCM2packet& P); // Packet handler
|
|---|
| 287 | void clear(); // Initialization
|
|---|
| 288 | bool valid() const; // Check for complete obs block
|
|---|
| 289 |
|
|---|
| 290 | double resolvedPhase_L1(int i) const; // L1 & L2 carrier phase of i-th sat
|
|---|
| 291 | double resolvedPhase_L2(int i) const; // with resolved 2^24 cy ambiguity
|
|---|
| 292 | // (based on rng_C1)
|
|---|
| 293 |
|
|---|
| 294 | void resolveEpoch (int refWeek, // Resolve epoch using reference
|
|---|
| 295 | double refSecs, // epoch (GPS week and secs)
|
|---|
| 296 | int& epochWeek,
|
|---|
| 297 | double& epochSecs ) const;
|
|---|
| 298 |
|
|---|
| 299 |
|
|---|
| 300 | public:
|
|---|
| 301 |
|
|---|
| 302 | double secs; // Seconds of hour (GPS time)
|
|---|
| 303 | int nSat; // Number of space vehicles
|
|---|
| 304 | std::vector<int> PRN; // PRN (satellite number)
|
|---|
| 305 | std::vector<double> rng_C1; // C/A code pseudorange on L1 [m]
|
|---|
| 306 | std::vector<double> rng_P1; // P(Y) code pseudorange on L1 [m]
|
|---|
| 307 | std::vector<double> rng_P2; // Pseudorange on L2 [m]
|
|---|
| 308 | std::vector<double> cph_L1; // Carrier phase on L1 [cy]
|
|---|
| 309 | std::vector<double> cph_L2; // Carrier phase on L2 [cy]
|
|---|
| 310 |
|
|---|
| 311 | private:
|
|---|
| 312 |
|
|---|
| 313 | bool anyGPS() const;
|
|---|
| 314 | bool anyGLONASS() const;
|
|---|
| 315 | bool allGPS() const;
|
|---|
| 316 | bool allGLONASS() const;
|
|---|
| 317 |
|
|---|
| 318 | private:
|
|---|
| 319 |
|
|---|
| 320 | typedef std::bitset<8> msgflags;
|
|---|
| 321 |
|
|---|
| 322 | msgflags availability; // Msg availability flags
|
|---|
| 323 | bool GPSonly; // Flag for GPS-only station
|
|---|
| 324 |
|
|---|
| 325 | };
|
|---|
| 326 |
|
|---|
| 327 |
|
|---|
| 328 | }; // End of namespace rtcm2
|
|---|
| 329 |
|
|---|
| 330 | #endif // include blocker
|
|---|