54 const std::string& frame_id,
bool use_gnss_time,
60 const size_t LEN = 16;
61 if (sentence.get_body().size() > LEN || sentence.get_body().size() < LEN)
63 std::stringstream error;
64 error <<
"GGA parsing failed: Expected GPGGA length is " << LEN
65 <<
", but actual length is " << sentence.get_body().size();
72 msg.message_id = sentence.get_body()[0];
74 if (sentence.get_body()[1].empty() || sentence.get_body()[1] ==
"0")
89 time_t unix_time_seconds =
94 unix_time_seconds * 1000000000 +
95 (
static_cast<Timestamp>(utc_double * 100) % 100) * 10000;
104 "Error parsing UTC seconds in GPGGA");
112 double latitude = 0.0;
117 double longitude = 0.0;
122 msg.lat_dir = sentence.get_body()[3];
123 msg.lon_dir = sentence.get_body()[5];
133 msg.altitude_units = sentence.get_body()[10];
136 msg.undulation_units = sentence.get_body()[12];
137 double diff_age_temp;
140 msg.diff_age =
static_cast<uint32_t
>(round(diff_age_temp));
141 msg.station_id = sentence.get_body()[14];
Struct to split an NMEA sentence into its ID and its body, the latter tokenized into a vector of stri...
bool toDouble(const std::string &string, double &value)
Interprets the contents of "string" as a floating point number of type double It stores the "string"'...
float parseFloat(const uint8_t *buffer)
Converts a 4-byte-buffer into a float.
double convertUTCDoubleToSeconds(double utc_double)
Converts UTC time from the without-colon-delimiter format to the number-of-seconds-since-midnight for...
const std::string getMessageID() const override
Returns the ASCII message ID, here "$GPGGA".
Derived class for parsing GGA messages.
nmea_msgs::Gpgga GpggaMsg
static const std::string MESSAGE_ID
Declares the string MESSAGE_ID.
uint32_t parseUInt32(const uint8_t *buffer)
Converts a 4-byte-buffer into an unsigned 32-bit integer.
Class to declare error message format when parsing, derived from the public class "std::runtime_error...
double convertDMSToDegrees(double dms)
Converts latitude or longitude from the DMS notation (in the without-colon-delimiter format)...
TimestampRos timestampToRos(Timestamp ts)
Convert nsec timestamp to ROS timestamp.
bool wasLastGPGGAValid() const
Tells us whether the last GGA message was valid or not.
GpggaMsg parseASCII(const NMEASentence &sentence, const std::string &frame_id, bool use_gnss_time, Timestamp time_obj) noexcept(false) override
Parses one GGA message.
std::time_t convertUTCtoUnix(double utc_double)
Converts UTC time from the without-colon-delimiter format to Unix Epoch time (a number-of-seconds-sin...
double parseDouble(const uint8_t *buffer)
Converts an 8-byte-buffer into a double.
bool was_last_gpgga_valid_
Declares a boolean representing whether or not the last GPGGA message was valid.