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/inspva.h>
00031 #include <boost/make_shared.hpp>
00032 #include <novatel_gps_driver/parsers/header.h>
00033
00034 const std::string novatel_gps_driver::InspvaParser::MESSAGE_NAME = "INSPVA";
00035
00036 uint32_t novatel_gps_driver::InspvaParser::GetMessageId() const
00037 {
00038 return MESSAGE_ID;
00039 }
00040
00041 const std::string novatel_gps_driver::InspvaParser::GetMessageName() const
00042 {
00043 return MESSAGE_NAME;
00044 }
00045
00046 novatel_gps_msgs::InspvaPtr
00047 novatel_gps_driver::InspvaParser::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 inspva message size: " << bin_msg.data_.size();
00053 throw ParseException(error.str());
00054 }
00055 novatel_gps_msgs::InspvaPtr ros_msg = boost::make_shared<novatel_gps_msgs::Inspva>();
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
00060 ros_msg->week = ParseUInt32(&bin_msg.data_[0]);
00061 ros_msg->seconds = ParseDouble(&bin_msg.data_[4]);
00062 ros_msg->latitude = ParseDouble(&bin_msg.data_[12]);
00063 ros_msg->longitude = ParseDouble(&bin_msg.data_[20]);
00064 ros_msg->height = ParseDouble(&bin_msg.data_[28]);
00065 ros_msg->north_velocity = ParseDouble(&bin_msg.data_[36]);
00066 ros_msg->east_velocity = ParseDouble(&bin_msg.data_[44]);
00067 ros_msg->up_velocity = ParseDouble(&bin_msg.data_[52]);
00068 ros_msg->roll = ParseDouble(&bin_msg.data_[60]);
00069 ros_msg->pitch = ParseDouble(&bin_msg.data_[68]);
00070 ros_msg->azimuth = ParseDouble(&bin_msg.data_[76]);
00071 uint32_t status = ParseUInt32(&bin_msg.data_[84]);
00072
00073 switch (status)
00074 {
00075 case 0:
00076 ros_msg->status = "INS_INACTIVE";
00077 break;
00078 case 1:
00079 ros_msg->status = "INS_ALIGNING";
00080 break;
00081 case 2:
00082 ros_msg->status = "INS_HIGH_VARIANCE";
00083 break;
00084 case 3:
00085 ros_msg->status = "INS_SOLUTION_GOOD";
00086 break;
00087 case 6:
00088 ros_msg->status = "INS_SOLUTION_FREE";
00089 break;
00090 case 7:
00091 ros_msg->status = "INS_ALIGNMENT_COMPLETE";
00092 break;
00093 case 8:
00094 ros_msg->status = "DETERMINING_ORIENTATION";
00095 break;
00096 case 9:
00097 ros_msg->status = "WAITING_INITIALPOS";
00098 break;
00099 case 10:
00100 ros_msg->status = "WAITING_AZIMUTH";
00101 break;
00102 case 11:
00103 ros_msg->status = "INITIALIZING_BASES";
00104 break;
00105 case 12:
00106 ros_msg->status = "MOTION_DETECT";
00107 break;
00108 default:
00109 {
00110 std::stringstream error;
00111 error << "Unexpected inertial solution status: " << status;
00112 throw ParseException(error.str());
00113 }
00114 }
00115
00116 return ros_msg;
00117 }
00118
00119 novatel_gps_msgs::InspvaPtr
00120 novatel_gps_driver::InspvaParser::ParseAscii(const novatel_gps_driver::NovatelSentence& sentence) throw(ParseException)
00121 {
00122 if (sentence.body.size() != ASCII_FIELDS)
00123 {
00124 std::stringstream error;
00125 error << "Unexpected number of fields in INSPVA log: " << sentence.body.size();
00126 throw ParseException(error.str());
00127 }
00128 novatel_gps_msgs::InspvaPtr msg = boost::make_shared<novatel_gps_msgs::Inspva>();
00129 HeaderParser h_parser;
00130 msg->novatel_msg_header = h_parser.ParseAscii(sentence);
00131
00132 bool valid = true;
00133
00134 valid &= ParseUInt32(sentence.body[0], msg->week);
00135 valid &= ParseDouble(sentence.body[1], msg->seconds);
00136 valid &= ParseDouble(sentence.body[2], msg->latitude);
00137 valid &= ParseDouble(sentence.body[3], msg->longitude);
00138 valid &= ParseDouble(sentence.body[4], msg->height);
00139 valid &= ParseDouble(sentence.body[5], msg->north_velocity);
00140 valid &= ParseDouble(sentence.body[6], msg->east_velocity);
00141 valid &= ParseDouble(sentence.body[7], msg->up_velocity);
00142 valid &= ParseDouble(sentence.body[8], msg->roll);
00143 valid &= ParseDouble(sentence.body[9], msg->pitch);
00144 valid &= ParseDouble(sentence.body[10], msg->azimuth);
00145 msg->status = sentence.body[11];
00146
00147 if (!valid)
00148 {
00149 throw ParseException("Error parsing INSPVA log.");
00150 }
00151
00152 return msg;
00153 }