Public Member Functions | Private Member Functions | Static Private Attributes
novatel_gps_driver::NovatelMessageExtractor Class Reference

#include <novatel_message_extractor.h>

List of all members.

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.
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.
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.

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.
uint32_t CRC32Value (int32_t i)
 Calculates the CRC-32 of a single value.
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.
int32_t GetBinaryMessage (const std::string &str, size_t start_idx, BinaryMessage &msg)
 Extracts a binary message from a data buffer.
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.
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.
int32_t GetNovatelSentence (const std::string &str, size_t start_idx, std::string &sentence)
 Extracts a NovAtel sentence from an input string.
size_t GetSentenceChecksumStart (const std::string &str, size_t start_idx)
 Finds the location of the next checksum in a valid ASCII sentence.
uint8_t NmeaChecksum (const std::string &sentence)
 Calculates the checksum of a NMEA sentence.
void VectorizeNmeaSentence (const std::string &sentence, NmeaSentence &vectorized_message)
 Takes a sentence extracted by GetNmeaSentence and converts it into a data structure.
bool VectorizeNovatelSentence (const std::string &data, NovatelSentence &sentence)
 Takes a sentence extracted by GetNovatelSentence and converts it into a data structure.
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.
static const std::string FIELD_SEPARATOR = ","
 Separates data fields in ASCII messages.
static const std::string HEADER_SEPARATOR = ";"
 Separates header from body in ASCII NovAtel messages.
static const std::string NMEA_SENTENCE_FLAG = "$"
 Indicates the beginning of a NMEA sentence.
static const std::string NOVATEL_ASCII_FLAGS = "$#"
 Used to search for both types of ASCII messages.
static const std::string NOVATEL_BINARY_SYNC_BYTES = "\xAA\x44\x12"
 Indicates the beginning of a binary NovAtel message.
static constexpr uint32_t NOVATEL_CRC32_POLYNOMIAL = 0xEDB88320L
static const std::string NOVATEL_ENDLINE = "\r\n"
 Indicates the end of an ASCII message.
static const std::string NOVATEL_SENTENCE_FLAG = "#"
 Indicates the beginning of an ASCII NovAtel message.

Detailed Description

Definition at line 58 of file novatel_message_extractor.h.


Member Function Documentation

uint32_t novatel_gps_driver::NovatelMessageExtractor::CalculateBlockCRC32 ( uint32_t  ulCount,
const uint8_t *  ucBuffer 
) [private]

Calculates the CRC-32 of a block of data all at once.

Parameters:
ulCountNumber of bytes in the data block
ucBufferData block
Returns:
CRC-32 of the data block

Definition at line 71 of file novatel_message_extractor.cpp.

Calculates the CRC-32 of a single value.

Parameters:
iThe value to process
Returns:
That value's CRC-32

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.

Parameters:
[in]inputA buffer of data to search for messages
[out]nmea_sentencesNMEA sentences found in the buffer
[out]novatel_sentencesASCII NovAtel sentences found in the buffer
[out]binary_messagesBinary NovAtel message found in the buffer
[out]remainingAny 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
Returns:
false if there were any errors parsing sentences

Definition at line 359 of file novatel_message_extractor.cpp.

void novatel_gps_driver::NovatelMessageExtractor::FindAsciiSentence ( const std::string &  sentence,
size_t  current_idx,
size_t &  start_idx,
size_t &  end_idx,
size_t &  invalid_char_idx 
) [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)

Parameters:
[in]sentenceThe string to search within
[in]current_idxThe position in the string to search from
[out]start_idxThe position of the earliest '#' or '$', if found
[out]end_idxThe position of the first '' after the start, if "\r\n" was found
[out]invalid_char_idxIf an invalid character was found between the start and end, its index

Definition at line 309 of file novatel_message_extractor.cpp.

int32_t novatel_gps_driver::NovatelMessageExtractor::GetBinaryMessage ( const std::string &  str,
size_t  start_idx,
BinaryMessage msg 
) [private]

Extracts a binary message from a data buffer.

Parameters:
[in]strThe data buffer to search through.
[in]start_idxAn index in the buffer to begin searching from.
[out]msgThe parsed message.
Returns:
>0: the number of bytes parsed into the message -1: Not enough data was available to parse the whole message -2: The message's checksum was invalid

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.

Parameters:
[in]gprmcA valid GPRMC message.
[in]gpggaA valid GPGGA message.
[out]gps_fixAn 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.

Iterates through the provided messages to find the first GPGGA or GPRMC message with a valid UTC time, then returns it.

Parameters:
[in]sentencesA list of NMEA sentences to search for UTC times.
Returns:
The UTC time in seconds, if found; 0 if not found.

Definition at line 516 of file novatel_message_extractor.cpp.

int32_t novatel_gps_driver::NovatelMessageExtractor::GetNmeaSentence ( const std::string &  str,
size_t  start_idx,
std::string &  sentence,
bool  keep_container = false 
) [private]

Extracts an NMEA sentence from an input string.

Parameters:
[in]strThe string to extract an NMEA sentence from.
[in]start_idxThe index to begin searching at.
[out]sentenceIf a valid sentence was found, it will be placed here.
[out]keep_container"true" to keep sentence & checksum position marks in the output sentence.
Returns:
0: Success -1: Not enough data to parse a complete sentence 1: Sentence's checksum was invalid

Definition at line 256 of file novatel_message_extractor.cpp.

bool novatel_gps_driver::NovatelMessageExtractor::GetNovatelMessageParts ( const std::string &  sentence,
std::string &  message_id,
std::vector< std::string > &  header,
std::vector< std::string > &  body 
) [private]

Splits an ASCII NovAtel message up into header and body parts.

Parameters:
[in]sentenceThe NovAtel message to parse.
[out]message_idThe message's ID.
[out]headerAll of the fields in the message's header.
[out]bodyAll of the fields in the message's body.
Returns:
false if there were errors parsing the message, true otherwise.

Definition at line 111 of file novatel_message_extractor.cpp.

int32_t novatel_gps_driver::NovatelMessageExtractor::GetNovatelSentence ( const std::string &  str,
size_t  start_idx,
std::string &  sentence 
) [private]

Extracts a NovAtel sentence from an input string.

Parameters:
[in]strThe string to search for a NovAtel sentence.
[in]start_idxThe index to begin searching from.
[out]sentenceThe extracted sentence.
Returns:
0: Success -1: Not eenough data to parse a complete sentence 1: Checksum was invalid

Definition at line 210 of file novatel_message_extractor.cpp.

size_t novatel_gps_driver::NovatelMessageExtractor::GetSentenceChecksumStart ( const std::string &  str,
size_t  start_idx 
) [private]

Finds the location of the next checksum in a valid ASCII sentence.

Parameters:
strA buffer to search for a checksum.
start_idxThe location to begin searching from.
Returns:
The index of that sentence's checksum.

Definition at line 98 of file novatel_message_extractor.cpp.

uint8_t novatel_gps_driver::NovatelMessageExtractor::NmeaChecksum ( const std::string &  sentence) [private]

Calculates the checksum of a NMEA sentence.

Parameters:
sentenceThe sentence to check.
Returns:
That sentence's checksum.

Definition at line 87 of file novatel_message_extractor.cpp.

void novatel_gps_driver::NovatelMessageExtractor::VectorizeNmeaSentence ( const std::string &  sentence,
NmeaSentence vectorized_message 
) [private]

Takes a sentence extracted by GetNmeaSentence and converts it into a data structure.

Parameters:
[in]dataA valid, extracted ASCII NMEA sentence.
[out]sentenceA data structure containing the sentence.
Returns:
false if it failed to parse the sentence, true otherwise.

Definition at line 348 of file novatel_message_extractor.cpp.

bool novatel_gps_driver::NovatelMessageExtractor::VectorizeNovatelSentence ( const std::string &  data,
NovatelSentence sentence 
) [private]

Takes a sentence extracted by GetNovatelSentence and converts it into a data structure.

Parameters:
[in]dataA valid, extracted ASCII NovAtel sentence.
[out]sentenceA data structure containing the sentence.
Returns:
false if it failed to parse the sentence, true otherwise.

Definition at line 340 of file novatel_message_extractor.cpp.

void novatel_gps_driver::NovatelMessageExtractor::VectorizeString ( const std::string &  str,
std::vector< std::string > &  vectorized_message,
const std::string &  delimiters 
) [private]

Splits a string into a vector using any of the provided characters as delimiters.

Parameters:
[in]strThe string to parse.
[out]vectorized_messageThe split results.
[in]delimitersA set of characters to use as delimiters.

Definition at line 103 of file novatel_message_extractor.cpp.


Member Data Documentation

const std::string novatel_gps_driver::NovatelMessageExtractor::CHECKSUM_FLAG = "*" [static, private]

Precedes checkums in ASCII messages.

Definition at line 111 of file novatel_message_extractor.h.

const std::string novatel_gps_driver::NovatelMessageExtractor::FIELD_SEPARATOR = "," [static, private]

Separates data fields in ASCII messages.

Definition at line 113 of file novatel_message_extractor.h.

const std::string novatel_gps_driver::NovatelMessageExtractor::HEADER_SEPARATOR = ";" [static, private]

Separates header from body in ASCII NovAtel messages.

Definition at line 115 of file novatel_message_extractor.h.

const std::string novatel_gps_driver::NovatelMessageExtractor::NMEA_SENTENCE_FLAG = "$" [static, private]

Indicates the beginning of a NMEA sentence.

Definition at line 117 of file novatel_message_extractor.h.

const std::string novatel_gps_driver::NovatelMessageExtractor::NOVATEL_ASCII_FLAGS = "$#" [static, private]

Used to search for both types of ASCII messages.

Definition at line 121 of file novatel_message_extractor.h.

const std::string novatel_gps_driver::NovatelMessageExtractor::NOVATEL_BINARY_SYNC_BYTES = "\xAA\x44\x12" [static, private]

Indicates the beginning of a binary NovAtel message.

Definition at line 123 of file novatel_message_extractor.h.

constexpr uint32_t novatel_gps_driver::NovatelMessageExtractor::NOVATEL_CRC32_POLYNOMIAL = 0xEDB88320L [static, private]

Definition at line 127 of file novatel_message_extractor.h.

const std::string novatel_gps_driver::NovatelMessageExtractor::NOVATEL_ENDLINE = "\r\n" [static, private]

Indicates the end of an ASCII message.

Definition at line 125 of file novatel_message_extractor.h.

const std::string novatel_gps_driver::NovatelMessageExtractor::NOVATEL_SENTENCE_FLAG = "#" [static, private]

Indicates the beginning of an ASCII NovAtel message.

Definition at line 119 of file novatel_message_extractor.h.


The documentation for this class was generated from the following files:


novatel_gps_driver
Author(s):
autogenerated on Wed Jul 3 2019 19:40:37