31 #include <boost/make_shared.hpp> 50 const size_t MAX_LEN = 15;
51 const size_t MIN_LEN = 14;
52 if (sentence.body.size() > MAX_LEN || sentence.body.size() < MIN_LEN)
54 std::stringstream error;
55 error <<
"Expected GPGGA length " << MIN_LEN <<
" <= length <= " 56 << MAX_LEN <<
", actual length = " << sentence.body.size();
60 novatel_gps_msgs::GpggaPtr
msg = boost::make_shared<novatel_gps_msgs::Gpgga>();
62 msg->message_id = sentence.body[0];
64 if (sentence.body[1].empty() || sentence.body[1] ==
"0")
83 double latitude = 0.0;
84 valid = valid &&
ParseDouble(sentence.body[2], latitude);
87 double longitude = 0.0;
88 valid = valid &&
ParseDouble(sentence.body[4], longitude);
91 msg->lat_dir = sentence.body[3];
92 msg->lon_dir = sentence.body[5];
93 valid = valid &&
ParseUInt32(sentence.body[6], msg->gps_qual);
94 valid = valid &&
ParseUInt32(sentence.body[7], msg->num_sats);
96 valid = valid &&
ParseFloat(sentence.body[8], msg->hdop);
97 valid = valid &&
ParseFloat(sentence.body[9], msg->alt);
98 msg->altitude_units = sentence.body[10];
99 valid = valid &&
ParseFloat(sentence.body[11], msg->undulation);
100 msg->undulation_units = sentence.body[12];
101 valid = valid &&
ParseUInt32(sentence.body[13], msg->diff_age);
102 if (sentence.body.size() == MAX_LEN)
104 msg->station_id = sentence.body[14];
108 msg->station_id =
"";
117 if (sentence.body[2].empty() || sentence.body[4].empty())
const std::string GetMessageName() const override
static const std::string MESSAGE_NAME
bool WasLastGpsValid() const
double ParseDouble(const uint8_t *buffer)
Converts a buffer containing 8 bytes into a double.
novatel_gps_msgs::GpggaPtr ParseAscii(const NmeaSentence &sentence) override
Converts sentence into a ROS message pointer and returns it.
uint32_t ParseUInt32(const uint8_t *buffer)
Converts a buffer containing 4 bytes into an unsigned 32-bit int.
float ParseFloat(const uint8_t *buffer)
Converts a buffer containing 4 bytes into a float.
double UtcFloatToSeconds(double utc_float)
double ConvertDmsToDegrees(double dms)
uint32_t GetMessageId() const override
bool ToDouble(const std::string &string, double &value)