Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <novatel_gps_driver/parsers/insstdev.h>
00031 #include <novatel_gps_driver/parsers/header.h>
00032 #include <boost/make_shared.hpp>
00033
00034 const std::string novatel_gps_driver::InsstdevParser::MESSAGE_NAME = "INSSTDEV";
00035
00036 uint32_t novatel_gps_driver::InsstdevParser::GetMessageId() const
00037 {
00038 return MESSAGE_ID;
00039 }
00040
00041 const std::string novatel_gps_driver::InsstdevParser::GetMessageName() const
00042 {
00043 return MESSAGE_NAME;
00044 }
00045
00046 novatel_gps_msgs::InsstdevPtr
00047 novatel_gps_driver::InsstdevParser::ParseBinary(const novatel_gps_driver::BinaryMessage& bin_msg) throw(ParseException)
00048 {
00049 if (bin_msg.data_.size() != BINARY_LENGTH)
00050 {
00051 std::stringstream error;
00052 error << "Unexpected INSSTDEV message size: " << bin_msg.data_.size();
00053 throw ParseException(error.str());
00054 }
00055 novatel_gps_msgs::InsstdevPtr ros_msg = boost::make_shared<novatel_gps_msgs::Insstdev>();
00056 HeaderParser h_parser;
00057 ros_msg->novatel_msg_header = h_parser.ParseBinary(bin_msg);
00058 ros_msg->novatel_msg_header.message_name = GetMessageName();
00059 ros_msg->latitude_dev = ParseFloat(&bin_msg.data_[0]);
00060 ros_msg->latitude_dev = ParseFloat(&bin_msg.data_[4]);
00061 ros_msg->height_dev = ParseFloat(&bin_msg.data_[8]);
00062 ros_msg->north_velocity_dev = ParseFloat(&bin_msg.data_[12]);
00063 ros_msg->east_velocity_dev = ParseFloat(&bin_msg.data_[16]);
00064 ros_msg->up_velocity_dev = ParseFloat(&bin_msg.data_[20]);
00065 ros_msg->roll_dev = ParseFloat(&bin_msg.data_[24]);
00066 ros_msg->pitch_dev = ParseFloat(&bin_msg.data_[28]);
00067 ros_msg->azimuth_dev = ParseFloat(&bin_msg.data_[32]);
00068 uint32_t status = ParseUInt32(&bin_msg.data_[36]);
00069 GetExtendedSolutionStatusMessage(status, ros_msg->extended_solution_status);
00070 ros_msg->time_since_update = ParseUInt16(&bin_msg.data_[40]);
00071
00072 return ros_msg;
00073 }
00074
00075 novatel_gps_msgs::InsstdevPtr
00076 novatel_gps_driver::InsstdevParser::ParseAscii(const novatel_gps_driver::NovatelSentence& sentence) throw(ParseException)
00077 {
00078 if (sentence.body.size() != ASCII_FIELDS)
00079 {
00080 std::stringstream error;
00081 error << "Unexpected number of fields in INSSTDEV log: " << sentence.body.size();
00082 throw ParseException(error.str());
00083 }
00084 novatel_gps_msgs::InsstdevPtr msg = boost::make_shared<novatel_gps_msgs::Insstdev>();
00085 HeaderParser h_parser;
00086 msg->novatel_msg_header = h_parser.ParseAscii(sentence);
00087
00088 bool valid = true;
00089
00090 valid &= ParseFloat(sentence.body[0], msg->latitude_dev);
00091 valid &= ParseFloat(sentence.body[1], msg->longitude_dev);
00092 valid &= ParseFloat(sentence.body[2], msg->height_dev);
00093 valid &= ParseFloat(sentence.body[3], msg->north_velocity_dev);
00094 valid &= ParseFloat(sentence.body[4], msg->east_velocity_dev);
00095 valid &= ParseFloat(sentence.body[5], msg->up_velocity_dev);
00096 valid &= ParseFloat(sentence.body[6], msg->roll_dev);
00097 valid &= ParseFloat(sentence.body[7], msg->pitch_dev);
00098 valid &= ParseFloat(sentence.body[8], msg->azimuth_dev);
00099 uint32_t status;
00100 valid &= ParseUInt32(sentence.body[9], status);
00101 GetExtendedSolutionStatusMessage(status, msg->extended_solution_status);
00102
00103 if (!valid)
00104 {
00105 throw ParseException("Error parsing INSSTDEV log.");
00106 }
00107
00108 return msg;
00109 }