parser_tests.cpp
Go to the documentation of this file.
00001 // *****************************************************************************
00002 //
00003 // Copyright (c) 2017, Southwest Research Institute® (SwRI®)
00004 // All rights reserved.
00005 //
00006 // Redistribution and use in source and binary forms, with or without
00007 // modification, are permitted provided that the following conditions are met:
00008 //     * Redistributions of source code must retain the above copyright
00009 //       notice, this list of conditions and the following disclaimer.
00010 //     * Redistributions in binary form must reproduce the above copyright
00011 //       notice, this list of conditions and the following disclaimer in the
00012 //       documentation and/or other materials provided with the distribution.
00013 //     * Neither the name of Southwest Research Institute® (SwRI®) nor the
00014 //       names of its contributors may be used to endorse or promote products
00015 //       derived from this software without specific prior written permission.
00016 //
00017 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020 // ARE DISCLAIMED. IN NO EVENT SHALL SOUTHWEST RESEARCH INSTITUTE BE LIABLE FOR ANY
00021 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00022 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00023 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00024 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00026 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027 //
00028 // *****************************************************************************
00029 
00030 #include <novatel_gps_driver/parsers/bestpos.h>
00031 #include <novatel_gps_driver/parsers/gpgsv.h>
00032 #include <novatel_gps_driver/novatel_message_extractor.h>
00033 
00034 #include <gtest/gtest.h>
00035 #include <novatel_gps_driver/parsers/inspva.h>
00036 #include <novatel_gps_driver/parsers/insstdev.h>
00037 #include <novatel_gps_driver/parsers/corrimudata.h>
00038 #include <novatel_gps_driver/parsers/inscov.h>
00039 
00040 TEST(ParserTestSuite, testBestposAsciiParsing)
00041 {
00042   novatel_gps_driver::BestposParser parser;
00043   std::string bestpos_str = "#BESTPOSA,ICOM1,0,87.5,FINESTEERING,1956,157432.000,00000800,7145,6938;"
00044   "SOL_COMPUTED,SINGLE,29.44391220792,-98.61476921244,261.4344,-26.0000,WGS84,2.1382,"
00045   "3.1092,4.0429,\"\",0.000,0.000,8,8,8,8,0,06,00,03*ecf2202b\r\n"
00046   "#BESTPOSA,COM1,0,83.5,FINESTEERING,1419,336148.000,02000040,6145,2724;SOL_COMPUTED,SINGLE,"
00047   "51.11636418888,-114.03832502118,1064.9520,-16.2712,WGS84,1.6961,1.3636,3.6449,\"\","
00048   "0.000,0.000,8,8,8,8,0,0,0,06,0,03*f181ad10\r\n"
00049   "#BESTPOSA,COM1,0,78.5,FINESTEERING,1419,336208.000,02000040,6145,2724;SOL_COMPUTED,"
00050   "NARROW_INT,51.11635910984,-114.03833105168,1063.8416,-16.2712,WGS84,0.0135,0.0084,"
00051   "0.0172,\"AAAA\",1.000,0.000,8,8,8,8,0,01,0,03*072421c0\r\n";
00052   std::string extracted_str;
00053 
00054   novatel_gps_driver::NovatelMessageExtractor extractor;
00055 
00056   std::vector<novatel_gps_driver::NmeaSentence> nmea_sentences;
00057   std::vector<novatel_gps_driver::NovatelSentence> novatel_sentences;
00058   std::vector<novatel_gps_driver::BinaryMessage> binary_messages;
00059   std::string remaining;
00060 
00061   extractor.ExtractCompleteMessages(bestpos_str, nmea_sentences, novatel_sentences,
00062                                     binary_messages, remaining);
00063 
00064   ASSERT_EQ(0, nmea_sentences.size());
00065   ASSERT_EQ(0, binary_messages.size());
00066   ASSERT_EQ(3, novatel_sentences.size());
00067 
00068   novatel_gps_driver::NovatelSentence sentence = novatel_sentences.front();
00069 
00070   ASSERT_EQ(parser.GetMessageName() + "A", sentence.id);
00071 
00072   novatel_gps_msgs::NovatelPositionPtr msg = parser.ParseAscii(sentence);
00073 
00074   ASSERT_NE(msg.get(), nullptr);
00075 
00076   ASSERT_EQ("SOL_COMPUTED", msg->solution_status);
00077   ASSERT_DOUBLE_EQ(29.44391220792, msg->lat);
00078   ASSERT_DOUBLE_EQ(-98.61476921244, msg->lon);
00079 }
00080 
00081 TEST(ParserTestSuite, testCorrimudataAsciiParsing)
00082 {
00083   novatel_gps_driver::CorrImuDataParser parser;
00084   std::string sentence_str = "#CORRIMUDATAA,COM1,0,77.5,FINESTEERING,1769,237601.000,02000020,"
00085       "bdba,12597;1769,237601.000000000,-0.000003356,0.000002872,0.000001398,0.000151593,"
00086       "0.000038348,-0.000078820*e370e1d9\r\n";
00087   std::string extracted_str;
00088 
00089   novatel_gps_driver::NovatelMessageExtractor extractor;
00090 
00091   std::vector<novatel_gps_driver::NmeaSentence> nmea_sentences;
00092   std::vector<novatel_gps_driver::NovatelSentence> novatel_sentences;
00093   std::vector<novatel_gps_driver::BinaryMessage> binary_messages;
00094   std::string remaining;
00095 
00096   extractor.ExtractCompleteMessages(sentence_str, nmea_sentences, novatel_sentences,
00097                                     binary_messages, remaining);
00098 
00099   ASSERT_EQ(0, nmea_sentences.size());
00100   ASSERT_EQ(0, binary_messages.size());
00101   ASSERT_EQ(1, novatel_sentences.size());
00102 
00103   novatel_gps_driver::NovatelSentence sentence = novatel_sentences.front();
00104 
00105   ASSERT_EQ(parser.GetMessageName() + "A", sentence.id);
00106 
00107   novatel_gps_msgs::NovatelCorrectedImuDataPtr msg = parser.ParseAscii(sentence);
00108 
00109   ASSERT_NE(msg.get(), nullptr);
00110   ASSERT_EQ(1769, msg->gps_week_num);
00111   ASSERT_DOUBLE_EQ(237601.0, msg->gps_seconds);
00112   ASSERT_DOUBLE_EQ(-0.000003356, msg->pitch_rate);
00113   ASSERT_DOUBLE_EQ(0.000002872, msg->roll_rate);
00114   ASSERT_DOUBLE_EQ(0.000001398, msg->yaw_rate);
00115   ASSERT_DOUBLE_EQ(0.000151593, msg->lateral_acceleration);
00116   ASSERT_DOUBLE_EQ(0.000038348, msg->longitudinal_acceleration);
00117   ASSERT_DOUBLE_EQ(-0.00007882, msg->vertical_acceleration);
00118 }
00119 
00120 TEST(ParserTestSuite, testGpgsvParsing)
00121 {
00122   novatel_gps_driver::GpgsvParser parser;
00123   std::string sentence_str = "$GPGSV,3,3,11,12,07,00.,32,13,03,227,36,22,0.,041,*4A\r\n";
00124   std::string extracted_str;
00125 
00126   novatel_gps_driver::NovatelMessageExtractor extractor;
00127 
00128   std::vector<novatel_gps_driver::NmeaSentence> nmea_sentences;
00129   std::vector<novatel_gps_driver::NovatelSentence> novatel_sentences;
00130   std::vector<novatel_gps_driver::BinaryMessage> binary_messages;
00131   std::string remaining;
00132 
00133   extractor.ExtractCompleteMessages(sentence_str, nmea_sentences, novatel_sentences,
00134                                     binary_messages, remaining);
00135 
00136   ASSERT_EQ(1, nmea_sentences.size());
00137   ASSERT_EQ(0, binary_messages.size());
00138   ASSERT_EQ(0, novatel_sentences.size());
00139 
00140   novatel_gps_driver::NmeaSentence sentence = nmea_sentences.front();
00141 
00142   ASSERT_EQ(parser.GetMessageName(), sentence.id);
00143   ASSERT_FALSE(sentence.body.empty());
00144 
00145   novatel_gps_msgs::GpgsvPtr msg = parser.ParseAscii(sentence);
00146 
00147   ASSERT_NE(msg.get(), nullptr);
00148 
00149   ASSERT_EQ(3, msg->n_msgs);
00150   ASSERT_EQ(3, msg->msg_number);
00151   ASSERT_EQ(3, msg->satellites.size());
00152   ASSERT_EQ(11, msg->n_satellites);
00153   ASSERT_EQ(12, msg->satellites[0].prn);
00154   ASSERT_EQ(7, msg->satellites[0].elevation);
00155   ASSERT_EQ(0, msg->satellites[0].azimuth);
00156   ASSERT_EQ(32, msg->satellites[0].snr);
00157   ASSERT_EQ(13, msg->satellites[1].prn);
00158   ASSERT_EQ(3, msg->satellites[1].elevation);
00159   ASSERT_EQ(227, msg->satellites[1].azimuth);
00160   ASSERT_EQ(36, msg->satellites[1].snr);
00161   ASSERT_EQ(22, msg->satellites[2].prn);
00162   ASSERT_EQ(0, msg->satellites[2].elevation);
00163   ASSERT_EQ(41, msg->satellites[2].azimuth);
00164   ASSERT_EQ(-1, msg->satellites[2].snr);
00165 }
00166 
00167 TEST(ParserTestSuite, testInscovAsciiParsing)
00168 {
00169   novatel_gps_driver::InscovParser parser;
00170   std::string sentence_str = "#INSCOVA,COM1,0,66.5,FINESTEERING,1959,336623.000,00000000,"
00171       "f078,13754;1959,336623.000000000,0.0211295047125775,-0.0018214277429204,-0.0016153828661881,"
00172       "-0.0018214277429204,0.0174981375607521,0.0049878113409426,-0.0016153828661881,"
00173       "0.0049878113409426,0.0285474196118174,0.0000332609098342,-0.0000003409117564,"
00174       "0.0000018468158360,-0.0000003409117564,0.0000340563145112,-0.0000136598582783,"
00175       "0.0000018468158360,-0.0000136598582783,0.1515644215075894,0.0000008850783906,"
00176       "0.0000000006144488,-0.0000001633832672,0.0000000006144488,0.0000010749675168,"
00177       "0.0000000004985751,-0.0000001633832672,0.0000000004985751,0.0000009343218169*bc5352ab\r\n";
00178   std::string extracted_str;
00179 
00180   novatel_gps_driver::NovatelMessageExtractor extractor;
00181 
00182   std::vector<novatel_gps_driver::NmeaSentence> nmea_sentences;
00183   std::vector<novatel_gps_driver::NovatelSentence> novatel_sentences;
00184   std::vector<novatel_gps_driver::BinaryMessage> binary_messages;
00185   std::string remaining;
00186 
00187   extractor.ExtractCompleteMessages(sentence_str, nmea_sentences, novatel_sentences,
00188                                     binary_messages, remaining);
00189 
00190   ASSERT_EQ(0, nmea_sentences.size());
00191   ASSERT_EQ(0, binary_messages.size());
00192   ASSERT_EQ(1, novatel_sentences.size());
00193 
00194   novatel_gps_driver::NovatelSentence sentence = novatel_sentences.front();
00195 
00196   ASSERT_EQ(parser.GetMessageName() + "A", sentence.id);
00197 
00198   novatel_gps_msgs::InscovPtr msg = parser.ParseAscii(sentence);
00199 
00200   ASSERT_NE(msg.get(), nullptr);
00201 
00202   ASSERT_EQ(1959, msg->week);
00203   ASSERT_DOUBLE_EQ(336623.0, msg->seconds);
00204   ASSERT_DOUBLE_EQ(0.0211295047125775, msg->position_covariance[0]);
00205   ASSERT_DOUBLE_EQ(0.0000009343218169, msg->velocity_covariance[8]);
00206 }
00207 
00208 TEST(ParserTestSuite, testInspvaAsciiParsing)
00209 {
00210   novatel_gps_driver::InspvaParser parser;
00211   std::string sentence_str = "#INSPVAA,COM1,0,31.0,FINESTEERING,1264,144088.000,02040000,"
00212   "5615,1541;1264,144088.002284950,51.116827527,-114.037738908,401.191547167,354.846489850,"
00213   "108.429407241,-10.837482850,1.116219952,-3.476059035,7.372686190,INS_ALIGNMENT_COMPLETE*a2913d36\r\n";
00214   std::string extracted_str;
00215 
00216   novatel_gps_driver::NovatelMessageExtractor extractor;
00217 
00218   std::vector<novatel_gps_driver::NmeaSentence> nmea_sentences;
00219   std::vector<novatel_gps_driver::NovatelSentence> novatel_sentences;
00220   std::vector<novatel_gps_driver::BinaryMessage> binary_messages;
00221   std::string remaining;
00222 
00223   extractor.ExtractCompleteMessages(sentence_str, nmea_sentences, novatel_sentences,
00224                                     binary_messages, remaining);
00225 
00226   ASSERT_EQ(0, nmea_sentences.size());
00227   ASSERT_EQ(0, binary_messages.size());
00228   ASSERT_EQ(1, novatel_sentences.size());
00229 
00230   novatel_gps_driver::NovatelSentence sentence = novatel_sentences.front();
00231 
00232   ASSERT_EQ(parser.GetMessageName() + "A", sentence.id);
00233 
00234   novatel_gps_msgs::InspvaPtr msg = parser.ParseAscii(sentence);
00235 
00236   ASSERT_NE(msg.get(), nullptr);
00237 
00238   ASSERT_EQ(1264, msg->week);
00239   ASSERT_DOUBLE_EQ(144088.002284950, msg->seconds);
00240   ASSERT_DOUBLE_EQ(51.116827527, msg->latitude);
00241   ASSERT_DOUBLE_EQ(-114.037738908, msg->longitude);
00242   ASSERT_DOUBLE_EQ(401.191547167, msg->height);
00243   ASSERT_DOUBLE_EQ(354.846489850, msg->north_velocity);
00244   ASSERT_DOUBLE_EQ(108.429407241, msg->east_velocity);
00245   ASSERT_DOUBLE_EQ(-10.837482850, msg->up_velocity);
00246   ASSERT_DOUBLE_EQ(1.116219952, msg->roll);
00247   ASSERT_DOUBLE_EQ(-3.476059035, msg->pitch);
00248   ASSERT_DOUBLE_EQ(7.372686190, msg->azimuth);
00249   ASSERT_EQ("INS_ALIGNMENT_COMPLETE", msg->status);
00250 }
00251 
00252 TEST(ParserTestSuite, testInsstdevAsciiParsing)
00253 {
00254   novatel_gps_driver::InsstdevParser parser;
00255   std::string sentence_str = "#INSSTDEVA,COM1,0,78.0,FINESTEERING,1907,233990.000,02000020,"
00256       "3e6d,32768;0.4372,0.3139,0.7547,0.0015,0.0015,0.0014,3.7503,3.7534,5.1857,26000005,"
00257       "0,0,01ffd1bf,0*3deca7d2\r\n";
00258   std::string extracted_str;
00259 
00260   novatel_gps_driver::NovatelMessageExtractor extractor;
00261 
00262   std::vector<novatel_gps_driver::NmeaSentence> nmea_sentences;
00263   std::vector<novatel_gps_driver::NovatelSentence> novatel_sentences;
00264   std::vector<novatel_gps_driver::BinaryMessage> binary_messages;
00265   std::string remaining;
00266 
00267   extractor.ExtractCompleteMessages(sentence_str, nmea_sentences, novatel_sentences,
00268                                     binary_messages, remaining);
00269 
00270   ASSERT_EQ(0, nmea_sentences.size());
00271   ASSERT_EQ(0, binary_messages.size());
00272   ASSERT_EQ(1, novatel_sentences.size());
00273 
00274   novatel_gps_driver::NovatelSentence sentence = novatel_sentences.front();
00275 
00276   ASSERT_EQ(parser.GetMessageName() + "A", sentence.id);
00277 
00278   novatel_gps_msgs::InsstdevPtr msg = parser.ParseAscii(sentence);
00279 
00280   ASSERT_NE(msg.get(), nullptr);
00281 
00282   ASSERT_FLOAT_EQ(0.4372, msg->latitude_dev);
00283   ASSERT_FLOAT_EQ(0.3139, msg->longitude_dev);
00284   ASSERT_FLOAT_EQ(0.7547, msg->height_dev);
00285   ASSERT_FLOAT_EQ(0.0015, msg->north_velocity_dev);
00286   ASSERT_FLOAT_EQ(0.0015, msg->east_velocity_dev);
00287   ASSERT_FLOAT_EQ(0.0014, msg->up_velocity_dev);
00288   ASSERT_FLOAT_EQ(3.7503, msg->roll_dev);
00289   ASSERT_FLOAT_EQ(3.7534, msg->pitch_dev);
00290   ASSERT_FLOAT_EQ(5.1857, msg->azimuth_dev);
00291   ASSERT_EQ(26000005, msg->extended_solution_status.original_mask);
00292 }
00293 
00294 int main(int argc, char **argv)
00295 {
00296   testing::InitGoogleTest(&argc, argv);
00297 
00298   return RUN_ALL_TESTS();
00299 }


novatel_gps_driver
Author(s):
autogenerated on Sun Oct 8 2017 02:40:29