#include <novatel_message_extractor.h>
Public Member Functions | |
bool | ExtractCompleteMessages (const std::string input, std::vector< NmeaSentence > &nmea_sentences, std::vector< NovatelSentence > &novatel_sentences, std::vector< BinaryMessage > &binary_messages, std::string &remaining, bool keep_nmea_container=false) |
Extracts messages from a buffer of NovAtel data. More... | |
void | GetGpsFixMessage (const novatel_gps_msgs::Gprmc &gprmc, const novatel_gps_msgs::Gpgga &gpgga, gps_common::GPSFixPtr gps_fix) |
Combines data receives in GPRMC and GPGGA message to produce a gps_common/GPSFixPtr ROS message. More... | |
double | GetMostRecentUtcTime (const std::vector< NmeaSentence > &sentences) |
Iterates through the provided messages to find the first GPGGA or GPRMC message with a valid UTC time, then returns it. More... | |
Private Member Functions | |
uint32_t | CalculateBlockCRC32 (uint32_t ulCount, const uint8_t *ucBuffer) |
Calculates the CRC-32 of a block of data all at once. More... | |
uint32_t | CRC32Value (int32_t i) |
Calculates the CRC-32 of a single value. More... | |
void | FindAsciiSentence (const std::string &sentence, size_t current_idx, size_t &start_idx, size_t &end_idx, size_t &invalid_char_idx) |
Searches for a valid ASCII message within a string. More... | |
int32_t | GetBinaryMessage (const std::string &str, size_t start_idx, BinaryMessage &msg) |
Extracts a binary message from a data buffer. More... | |
int32_t | GetNmeaSentence (const std::string &str, size_t start_idx, std::string &sentence, bool keep_container=false) |
Extracts an NMEA sentence from an input string. More... | |
bool | GetNovatelMessageParts (const std::string &sentence, std::string &message_id, std::vector< std::string > &header, std::vector< std::string > &body) |
Splits an ASCII NovAtel message up into header and body parts. More... | |
int32_t | GetNovatelSentence (const std::string &str, size_t start_idx, std::string &sentence) |
Extracts a NovAtel sentence from an input string. More... | |
size_t | GetSentenceChecksumStart (const std::string &str, size_t start_idx) |
Finds the location of the next checksum in a valid ASCII sentence. More... | |
uint8_t | NmeaChecksum (const std::string &sentence) |
Calculates the checksum of a NMEA sentence. More... | |
void | VectorizeNmeaSentence (const std::string &sentence, NmeaSentence &vectorized_message) |
Takes a sentence extracted by GetNmeaSentence and converts it into a data structure. More... | |
bool | VectorizeNovatelSentence (const std::string &data, NovatelSentence &sentence) |
Takes a sentence extracted by GetNovatelSentence and converts it into a data structure. More... | |
void | VectorizeString (const std::string &str, std::vector< std::string > &vectorized_message, const std::string &delimiters) |
Static Private Attributes | |
static const std::string | CHECKSUM_FLAG = "*" |
Precedes checkums in ASCII messages. More... | |
static const std::string | FIELD_SEPARATOR = "," |
Separates data fields in ASCII messages. More... | |
static const std::string | HEADER_SEPARATOR = ";" |
Separates header from body in ASCII NovAtel messages. More... | |
static const std::string | NMEA_SENTENCE_FLAG = "$" |
Indicates the beginning of a NMEA sentence. More... | |
static const std::string | NOVATEL_ASCII_FLAGS = "$#" |
Used to search for both types of ASCII messages. More... | |
static const std::string | NOVATEL_BINARY_SYNC_BYTES = "\xAA\x44\x12" |
Indicates the beginning of a binary NovAtel message. More... | |
static constexpr uint32_t | NOVATEL_CRC32_POLYNOMIAL = 0xEDB88320L |
static const std::string | NOVATEL_ENDLINE = "\r\n" |
Indicates the end of an ASCII message. More... | |
static const std::string | NOVATEL_SENTENCE_FLAG = "#" |
Indicates the beginning of an ASCII NovAtel message. More... | |
Definition at line 58 of file novatel_message_extractor.h.
|
private |
Calculates the CRC-32 of a block of data all at once.
ulCount | Number of bytes in the data block |
ucBuffer | Data block |
Definition at line 71 of file novatel_message_extractor.cpp.
|
private |
Calculates the CRC-32 of a single value.
i | The value to process |
Definition at line 56 of file novatel_message_extractor.cpp.
bool novatel_gps_driver::NovatelMessageExtractor::ExtractCompleteMessages | ( | const std::string | input, |
std::vector< NmeaSentence > & | nmea_sentences, | ||
std::vector< NovatelSentence > & | novatel_sentences, | ||
std::vector< BinaryMessage > & | binary_messages, | ||
std::string & | remaining, | ||
bool | keep_nmea_container = false |
||
) |
Extracts messages from a buffer of NovAtel data.
This will search through the "input" string for any valid NMEA or NovAtel ASCII messages as well as any binary NovAtel messages, place them into the provided containers, and also provide any leftover bytes at the end of the buffer that were not part of a valid sentence.
[in] | input | A buffer of data to search for messages |
[out] | nmea_sentences | NMEA sentences found in the buffer |
[out] | novatel_sentences | ASCII NovAtel sentences found in the buffer |
[out] | binary_messages | Binary NovAtel message found in the buffer |
[out] | remaining | Any bytes left after the last complete sentence in the buffer |
[in] | keep_nmea_container | "true" to preserve message begin & end markers around parsed NMEA sentences |
Definition at line 359 of file novatel_message_extractor.cpp.
|
private |
Searches for a valid ASCII message within a string.
What constitutes a valid ASCII message is defined by: http://docs.novatel.com/OEM7/Content/Messages/ASCII.htm
We check whether a substring: 1) Starts with '#' or '$' 2) Ends with "\r\n" 3) Between those values, only contains characters with an ASCII value of 9, 10, 11, 13, or between 32 and 126 (inclusive)
[in] | sentence | The string to search within |
[in] | current_idx | The position in the string to search from |
[out] | start_idx | The position of the earliest '#' or '$', if found |
[out] | end_idx | The position of the first '' after the start, if "\r\n" was found |
[out] | invalid_char_idx | If an invalid character was found between the start and end, its index |
Definition at line 309 of file novatel_message_extractor.cpp.
|
private |
Extracts a binary message from a data buffer.
[in] | str | The data buffer to search through. |
[in] | start_idx | An index in the buffer to begin searching from. |
[out] | msg | The parsed message. |
Definition at line 144 of file novatel_message_extractor.cpp.
void novatel_gps_driver::NovatelMessageExtractor::GetGpsFixMessage | ( | const novatel_gps_msgs::Gprmc & | gprmc, |
const novatel_gps_msgs::Gpgga & | gpgga, | ||
gps_common::GPSFixPtr | gps_fix | ||
) |
Combines data receives in GPRMC and GPGGA message to produce a gps_common/GPSFixPtr ROS message.
[in] | gprmc | A valid GPRMC message. |
[in] | gpgga | A valid GPGGA message. |
[out] | gps_fix | An initialised GPSFixPtr message must be provided; it will be filled in based on the provided GPRMC/GPGGA messages. |
Definition at line 545 of file novatel_message_extractor.cpp.
double novatel_gps_driver::NovatelMessageExtractor::GetMostRecentUtcTime | ( | const std::vector< NmeaSentence > & | sentences | ) |
Iterates through the provided messages to find the first GPGGA or GPRMC message with a valid UTC time, then returns it.
[in] | sentences | A list of NMEA sentences to search for UTC times. |
Definition at line 516 of file novatel_message_extractor.cpp.
|
private |
Extracts an NMEA sentence from an input string.
[in] | str | The string to extract an NMEA sentence from. |
[in] | start_idx | The index to begin searching at. |
[out] | sentence | If a valid sentence was found, it will be placed here. |
[out] | keep_container | "true" to keep sentence & checksum position marks in the output sentence. |
Definition at line 256 of file novatel_message_extractor.cpp.
|
private |
Splits an ASCII NovAtel message up into header and body parts.
[in] | sentence | The NovAtel message to parse. |
[out] | message_id | The message's ID. |
[out] | header | All of the fields in the message's header. |
[out] | body | All of the fields in the message's body. |
Definition at line 111 of file novatel_message_extractor.cpp.
|
private |
Extracts a NovAtel sentence from an input string.
[in] | str | The string to search for a NovAtel sentence. |
[in] | start_idx | The index to begin searching from. |
[out] | sentence | The extracted sentence. |
Definition at line 210 of file novatel_message_extractor.cpp.
|
private |
Finds the location of the next checksum in a valid ASCII sentence.
str | A buffer to search for a checksum. |
start_idx | The location to begin searching from. |
Definition at line 98 of file novatel_message_extractor.cpp.
|
private |
Calculates the checksum of a NMEA sentence.
sentence | The sentence to check. |
Definition at line 87 of file novatel_message_extractor.cpp.
|
private |
Takes a sentence extracted by GetNmeaSentence and converts it into a data structure.
[in] | data | A valid, extracted ASCII NMEA sentence. |
[out] | sentence | A data structure containing the sentence. |
Definition at line 348 of file novatel_message_extractor.cpp.
|
private |
Takes a sentence extracted by GetNovatelSentence and converts it into a data structure.
[in] | data | A valid, extracted ASCII NovAtel sentence. |
[out] | sentence | A data structure containing the sentence. |
Definition at line 340 of file novatel_message_extractor.cpp.
|
private |
Splits a string into a vector using any of the provided characters as delimiters.
[in] | str | The string to parse. |
[out] | vectorized_message | The split results. |
[in] | delimiters | A set of characters to use as delimiters. |
Definition at line 103 of file novatel_message_extractor.cpp.
|
staticprivate |
Precedes checkums in ASCII messages.
Definition at line 111 of file novatel_message_extractor.h.
|
staticprivate |
Separates data fields in ASCII messages.
Definition at line 113 of file novatel_message_extractor.h.
|
staticprivate |
Separates header from body in ASCII NovAtel messages.
Definition at line 115 of file novatel_message_extractor.h.
|
staticprivate |
Indicates the beginning of a NMEA sentence.
Definition at line 117 of file novatel_message_extractor.h.
|
staticprivate |
Used to search for both types of ASCII messages.
Definition at line 121 of file novatel_message_extractor.h.
|
staticprivate |
Indicates the beginning of a binary NovAtel message.
Definition at line 123 of file novatel_message_extractor.h.
|
staticprivate |
Definition at line 127 of file novatel_message_extractor.h.
|
staticprivate |
Indicates the end of an ASCII message.
Definition at line 125 of file novatel_message_extractor.h.
|
staticprivate |
Indicates the beginning of an ASCII NovAtel message.
Definition at line 119 of file novatel_message_extractor.h.