.. _program_listing_file__tmp_ws_src_novatel_gps_driver_novatel_gps_driver_include_novatel_gps_driver_novatel_message_extractor.h: Program Listing for File novatel_message_extractor.h ==================================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/novatel_gps_driver/novatel_gps_driver/include/novatel_gps_driver/novatel_message_extractor.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // ***************************************************************************** // // Copyright (c) 2019, Southwest Research Institute® (SwRI®) // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of Southwest Research Institute® (SwRI®) nor the // names of its contributors may be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL SOUTHWEST RESEARCH INSTITUTE BE LIABLE FOR ANY // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // ***************************************************************************** #ifndef NOVTEL_OEM628_NOVATEL_MESSAGE_PARSER_H_ #define NOVTEL_OEM628_NOVATEL_MESSAGE_PARSER_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace novatel_gps_driver { class NovatelMessageExtractor { public: explicit NovatelMessageExtractor(rclcpp::Logger logger); bool ExtractCompleteMessages( const std::string& input, std::vector& nmea_sentences, std::vector& novatel_sentences, std::vector& binary_messages, std::string& remaining, bool keep_nmea_container = false); double GetMostRecentUtcTime(const std::vector& sentences); void GetGpsFixMessage( const novatel_gps_msgs::msg::Gprmc& gprmc, const novatel_gps_msgs::msg::Gpgga& gpgga, const gps_msgs::msg::GPSFix::UniquePtr& gps_fix); private: // Constants for parsing message structures static const std::string CHECKSUM_FLAG; static const std::string FIELD_SEPARATOR; static const std::string HEADER_SEPARATOR; static const std::string NMEA_SENTENCE_FLAG; static const std::string NOVATEL_SENTENCE_FLAG; static const std::string NOVATEL_ASCII_FLAGS; static const std::string NOVATEL_BINARY_SYNC_BYTES; static const std::string NOVATEL_ENDLINE; static constexpr uint32_t NOVATEL_CRC32_POLYNOMIAL = 0xEDB88320L; rclcpp::Logger logger_; // From Novatel OEMV® Family Firmware Reference Manual uint32_t CalculateBlockCRC32( uint32_t ulCount, const uint8_t* ucBuffer); uint32_t CRC32Value(int32_t i); void FindAsciiSentence(const std::string& sentence, size_t current_idx, size_t& start_idx, size_t& end_idx, size_t& invalid_char_idx); int32_t GetBinaryMessage(const std::string& str, size_t start_idx, BinaryMessage& msg); bool GetNovatelMessageParts( const std::string& sentence, std::string& message_id, std::vector& header, std::vector& body); int32_t GetNmeaSentence( const std::string& str, size_t start_idx, std::string& sentence, bool keep_container = false); int32_t GetNovatelSentence( const std::string& str, size_t start_idx, std::string& sentence); size_t GetSentenceChecksumStart( const std::string& str, size_t start_idx); uint8_t NmeaChecksum(const std::string& sentence); bool VectorizeNovatelSentence( const std::string& data, NovatelSentence& sentence); void VectorizeNmeaSentence( const std::string& sentence, NmeaSentence& vectorized_message); void VectorizeString( const std::string& str, std::vector& vectorized_message, const std::string& delimiters); }; } #endif // NOVATEL_GPS_DRIVER_NOVATEL_MESSAGE_PARSER_H_