55 const size_t LEN = 16;
56 if (sentence.get_body().size() > LEN || sentence.get_body().size() < LEN)
58 std::stringstream error;
59 error <<
"GGA parsing failed: Expected GPGGA length is " << LEN <<
", but actual length is " << sentence.get_body().size();
63 rosaic::GpggaPtr msg = boost::make_shared<rosaic::Gpgga>();
66 msg->message_id = sentence.get_body()[0];
68 if (sentence.get_body()[1].empty() || sentence.get_body()[1] ==
"0")
85 uint32_t unix_time_nanoseconds = (
static_cast<uint32_t
>(utc_double*100)%100)*10000;
86 msg->header.stamp.sec = unix_time_seconds;
87 msg->header.stamp.nsec = unix_time_nanoseconds;
92 time_obj = ros::Time::now();
93 msg->header.stamp.sec = time_obj.sec;
94 msg->header.stamp.nsec = time_obj.nsec;
105 double latitude = 0.0;
109 double longitude = 0.0;
113 msg->lat_dir = sentence.get_body()[3];
114 msg->lon_dir = sentence.get_body()[5];
121 msg->altitude_units = sentence.get_body()[10];
123 msg->undulation_units = sentence.get_body()[12];
124 double diff_age_temp;
126 msg->diff_age =
static_cast<uint32_t
>(round(diff_age_temp));
127 msg->station_id = sentence.get_body()[14];
std::string g_frame_id
The frame ID used in the header of every published ROS message.
rosaic::GpggaPtr parseASCII(const NMEASentence &sentence) noexcept(false) override
Parses one GGA message.
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.
static const std::string MESSAGE_ID
Declares the string MESSAGE_ID.
double convertUTCDoubleToSeconds(double utc_double)
Converts UTC time from the without-colon-delimiter format to the number-of-seconds-since-midnight for...
Derived class for parsing GGA messages.
bool wasLastGPGGAValid() const
Tells us whether the last GGA message was valid or not.
uint32_t parseUInt32(const uint8_t *buffer)
Converts a 4-byte-buffer into an unsigned 32-bit integer.
double convertDMSToDegrees(double dms)
Converts latitude or longitude from the DMS notation (in the without-colon-delimiter format)...
time_t convertUTCtoUnix(double utc_double)
Converts UTC time from the without-colon-delimiter format to Unix Epoch time (a number-of-seconds-sin...
Struct to split an NMEA sentence into its ID and its body, the latter tokenized into a vector of stri...
Class to declare error message format when parsing, derived from the public class "std::runtime_error...
const std::string getMessageID() const override
Returns the ASCII message ID, here "$GPGGA".
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.