Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef NOVTEL_OEM628_NOVATEL_MESSAGE_PARSER_H_
00031 #define NOVTEL_OEM628_NOVATEL_MESSAGE_PARSER_H_
00032
00033 #include <limits>
00034 #include <sstream>
00035 #include <string>
00036 #include <vector>
00037
00038 #include <gps_common/GPSFix.h>
00039 #include <novatel_gps_msgs/Gpgga.h>
00040 #include <novatel_gps_msgs/Gpgsa.h>
00041 #include <novatel_gps_msgs/Gpgsv.h>
00042 #include <novatel_gps_msgs/Gprmc.h>
00043 #include <novatel_gps_msgs/NovatelCorrectedImuData.h>
00044 #include <novatel_gps_msgs/NovatelPosition.h>
00045 #include <novatel_gps_msgs/NovatelMessageHeader.h>
00046 #include <novatel_gps_msgs/NovatelReceiverStatus.h>
00047 #include <novatel_gps_msgs/NovatelVelocity.h>
00048 #include <novatel_gps_msgs/Range.h>
00049 #include <novatel_gps_msgs/Time.h>
00050 #include <novatel_gps_msgs/Trackstat.h>
00051
00052 #include <novatel_gps_driver/binary_message.h>
00053 #include <novatel_gps_driver/nmea_sentence.h>
00054 #include <novatel_gps_driver/novatel_sentence.h>
00055
00056 namespace novatel_gps_driver
00057 {
00058 class NovatelMessageExtractor
00059 {
00060 public:
00079 bool ExtractCompleteMessages(
00080 const std::string input,
00081 std::vector<NmeaSentence>& nmea_sentences,
00082 std::vector<NovatelSentence>& novatel_sentences,
00083 std::vector<BinaryMessage>& binary_messages,
00084 std::string& remaining,
00085 bool keep_nmea_container = false);
00086
00093 double GetMostRecentUtcTime(const std::vector<NmeaSentence>& sentences);
00094
00103 void GetGpsFixMessage(
00104 const novatel_gps_msgs::Gprmc& gprmc,
00105 const novatel_gps_msgs::Gpgga& gpgga,
00106 gps_common::GPSFixPtr gps_fix);
00107
00108 private:
00109
00111 static const std::string CHECKSUM_FLAG;
00113 static const std::string FIELD_SEPARATOR;
00115 static const std::string HEADER_SEPARATOR;
00117 static const std::string NMEA_SENTENCE_FLAG;
00119 static const std::string NOVATEL_SENTENCE_FLAG;
00121 static const std::string NOVATEL_ASCII_FLAGS;
00123 static const std::string NOVATEL_BINARY_SYNC_BYTES;
00125 static const std::string NOVATEL_ENDLINE;
00126
00127 static constexpr uint32_t NOVATEL_CRC32_POLYNOMIAL = 0xEDB88320L;
00128
00129
00136 uint32_t CalculateBlockCRC32(
00137 uint32_t ulCount,
00138 const uint8_t* ucBuffer);
00139
00145 uint32_t CRC32Value(int32_t i);
00146
00147
00167 void FindAsciiSentence(const std::string& sentence,
00168 size_t current_idx,
00169 size_t& start_idx,
00170 size_t& end_idx,
00171 size_t& invalid_char_idx);
00172
00182 int32_t GetBinaryMessage(const std::string& str,
00183 size_t start_idx,
00184 BinaryMessage& msg);
00185
00194 bool GetNovatelMessageParts(
00195 const std::string& sentence,
00196 std::string& message_id,
00197 std::vector<std::string>& header,
00198 std::vector<std::string>& body);
00199
00211 int32_t GetNmeaSentence(
00212 const std::string& str,
00213 size_t start_idx,
00214 std::string& sentence,
00215 bool keep_container = false);
00216
00226 int32_t GetNovatelSentence(
00227 const std::string& str,
00228 size_t start_idx,
00229 std::string& sentence);
00230
00237 size_t GetSentenceChecksumStart(
00238 const std::string& str,
00239 size_t start_idx);
00240
00246 uint8_t NmeaChecksum(const std::string& sentence);
00247
00255 bool VectorizeNovatelSentence(
00256 const std::string& data,
00257 NovatelSentence& sentence);
00258
00266 void VectorizeNmeaSentence(
00267 const std::string& sentence,
00268 NmeaSentence& vectorized_message);
00269
00277 void VectorizeString(
00278 const std::string& str,
00279 std::vector<std::string>& vectorized_message,
00280 const std::string& delimiters);
00281 };
00282 }
00283
00284 #endif // NOVATEL_OEM628_NOVATEL_MESSAGE_PARSER_H_