parser_tests.cpp
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // Copyright (c) 2017, Southwest Research Institute® (SwRI®)
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of Southwest Research Institute® (SwRI®) nor the
14 // names of its contributors may be used to endorse or promote products
15 // derived from this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL SOUTHWEST RESEARCH INSTITUTE BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //
28 // *****************************************************************************
29 
38 
39 #include <gtest/gtest.h>
44 
45 TEST(ParserTestSuite, testBestposAsciiParsing)
46 {
48  std::string bestpos_str = "#BESTPOSA,ICOM1,0,87.5,FINESTEERING,1956,157432.000,00000800,7145,6938;"
49  "SOL_COMPUTED,SINGLE,29.44391220792,-98.61476921244,261.4344,-26.0000,WGS84,2.1382,"
50  "3.1092,4.0429,\"\",0.000,0.000,8,8,8,8,0,06,00,03*ecf2202b\r\n"
51  "#BESTPOSA,COM1,0,83.5,FINESTEERING,1419,336148.000,02000040,6145,2724;SOL_COMPUTED,SINGLE,"
52  "51.11636418888,-114.03832502118,1064.9520,-16.2712,WGS84,1.6961,1.3636,3.6449,\"\","
53  "0.000,0.000,8,8,8,8,0,0,0,06,0,03*f181ad10\r\n"
54  "#BESTPOSA,COM1,0,78.5,FINESTEERING,1419,336208.000,02000040,6145,2724;SOL_COMPUTED,"
55  "NARROW_INT,51.11635910984,-114.03833105168,1063.8416,-16.2712,WGS84,0.0135,0.0084,"
56  "0.0172,\"AAAA\",1.000,0.000,8,8,8,8,0,01,0,03*072421c0\r\n";
57  std::string extracted_str;
58 
60 
61  std::vector<novatel_gps_driver::NmeaSentence> nmea_sentences;
62  std::vector<novatel_gps_driver::NovatelSentence> novatel_sentences;
63  std::vector<novatel_gps_driver::BinaryMessage> binary_messages;
64  std::string remaining;
65 
66  extractor.ExtractCompleteMessages(bestpos_str, nmea_sentences, novatel_sentences,
67  binary_messages, remaining);
68 
69  ASSERT_EQ(0, nmea_sentences.size());
70  ASSERT_EQ(0, binary_messages.size());
71  ASSERT_EQ(3, novatel_sentences.size());
72 
73  novatel_gps_driver::NovatelSentence sentence = novatel_sentences.front();
74 
75  ASSERT_EQ(parser.GetMessageName() + "A", sentence.id);
76 
77  novatel_gps_msgs::NovatelPositionPtr msg = parser.ParseAscii(sentence);
78 
79 
80  ASSERT_NE(msg.get(), nullptr);
81 
82  ASSERT_EQ(0x800, msg->novatel_msg_header.receiver_status.original_status_code);
83 
84  ASSERT_EQ(true, msg->novatel_msg_header.receiver_status.usb_buffer_overrun);
85 
86  ASSERT_EQ("SOL_COMPUTED", msg->solution_status);
87  ASSERT_DOUBLE_EQ(29.44391220792, msg->lat);
88  ASSERT_DOUBLE_EQ(-98.61476921244, msg->lon);
89 }
90 
91 TEST(ParserTestSuite, testGpggaParsing)
92 {
94  std::string sentence_str = "$GPGGA,134658.00,5106.9792,N,11402.3003,W,2,09,1.0,"
95  "1048.47,M,-16.27,M,08,AAAA*60\r\n"
96  "$GPGGA,134658.00,5106.9792,N,11402.3003,W,0,09,1.0,"
97  "1048.47,M,-16.27,M,08,AAAA*62\r\n";
98  std::string extracted_str;
99 
101 
102  std::vector<novatel_gps_driver::NmeaSentence> nmea_sentences;
103  std::vector<novatel_gps_driver::NovatelSentence> novatel_sentences;
104  std::vector<novatel_gps_driver::BinaryMessage> binary_messages;
105  std::string remaining;
106 
107  extractor.ExtractCompleteMessages(sentence_str, nmea_sentences, novatel_sentences,
108  binary_messages, remaining);
109 
110  ASSERT_EQ(2, nmea_sentences.size());
111  ASSERT_EQ(0, binary_messages.size());
112  ASSERT_EQ(0, novatel_sentences.size());
113 
114  novatel_gps_driver::NmeaSentence sentence = nmea_sentences.front();
115 
116  ASSERT_EQ(parser.GetMessageName(), sentence.id);
117 
118  novatel_gps_msgs::GpggaPtr msg = parser.ParseAscii(sentence);
119 
120  ASSERT_NE(msg.get(), nullptr);
121  ASSERT_EQ(novatel_gps_msgs::Gpgga::GPS_QUAL_PSEUDORANGE_DIFFERENTIAL, msg->gps_qual);
122  ASSERT_DOUBLE_EQ(51.116319999999995, msg->lat);
123  ASSERT_STREQ("N", msg->lat_dir.c_str());
124  ASSERT_DOUBLE_EQ(114.03833833333334, msg->lon);
125  ASSERT_STREQ("W", msg->lon_dir.c_str());
126  ASSERT_EQ(9, msg->num_sats);
127  ASSERT_DOUBLE_EQ(1.0, msg->hdop);
128  ASSERT_DOUBLE_EQ(1048.469970703125, msg->alt);
129  ASSERT_STREQ("M", msg->altitude_units.c_str());
130  ASSERT_DOUBLE_EQ(-16.270000457763672, msg->undulation);
131  ASSERT_STREQ("M", msg->undulation_units.c_str());
132  ASSERT_EQ(8, msg->diff_age);
133  ASSERT_STREQ("AAAA", msg->station_id.c_str());
134 
135  sentence = nmea_sentences.at(1);
136  msg = parser.ParseAscii(sentence);
137 
138  ASSERT_EQ(novatel_gps_msgs::Gpgga::GPS_QUAL_INVALID, msg->gps_qual);
139 }
140 
141 TEST(ParserTestSuite, testCorrimudataAsciiParsing)
142 {
144  std::string sentence_str = "#CORRIMUDATAA,COM1,0,77.5,FINESTEERING,1769,237601.000,02000020,"
145  "bdba,12597;1769,237601.000000000,-0.000003356,0.000002872,0.000001398,0.000151593,"
146  "0.000038348,-0.000078820*e370e1d9\r\n";
147  std::string extracted_str;
148 
150 
151  std::vector<novatel_gps_driver::NmeaSentence> nmea_sentences;
152  std::vector<novatel_gps_driver::NovatelSentence> novatel_sentences;
153  std::vector<novatel_gps_driver::BinaryMessage> binary_messages;
154  std::string remaining;
155 
156  extractor.ExtractCompleteMessages(sentence_str, nmea_sentences, novatel_sentences,
157  binary_messages, remaining);
158 
159  ASSERT_EQ(0, nmea_sentences.size());
160  ASSERT_EQ(0, binary_messages.size());
161  ASSERT_EQ(1, novatel_sentences.size());
162 
163  novatel_gps_driver::NovatelSentence sentence = novatel_sentences.front();
164 
165  ASSERT_EQ(parser.GetMessageName() + "A", sentence.id);
166 
167  novatel_gps_msgs::NovatelCorrectedImuDataPtr msg = parser.ParseAscii(sentence);
168 
169  ASSERT_NE(msg.get(), nullptr);
170  ASSERT_EQ(1769, msg->gps_week_num);
171  ASSERT_DOUBLE_EQ(237601.0, msg->gps_seconds);
172  ASSERT_DOUBLE_EQ(-0.000003356, msg->pitch_rate);
173  ASSERT_DOUBLE_EQ(0.000002872, msg->roll_rate);
174  ASSERT_DOUBLE_EQ(0.000001398, msg->yaw_rate);
175  ASSERT_DOUBLE_EQ(0.000151593, msg->lateral_acceleration);
176  ASSERT_DOUBLE_EQ(0.000038348, msg->longitudinal_acceleration);
177  ASSERT_DOUBLE_EQ(-0.00007882, msg->vertical_acceleration);
178 }
179 
180 TEST(ParserTestSuite, testGpgsvParsing)
181 {
183  std::string sentence_str = "$GPGSV,3,3,11,12,07,00.,32,13,03,227,36,22,0.,041,*4A\r\n"
184  "$GPGSV,1,1,00,,,,*79\r\n";
185  std::string extracted_str;
186 
188 
189  std::vector<novatel_gps_driver::NmeaSentence> nmea_sentences;
190  std::vector<novatel_gps_driver::NovatelSentence> novatel_sentences;
191  std::vector<novatel_gps_driver::BinaryMessage> binary_messages;
192  std::string remaining;
193 
194  extractor.ExtractCompleteMessages(sentence_str, nmea_sentences, novatel_sentences,
195  binary_messages, remaining);
196 
197  ASSERT_EQ(2, nmea_sentences.size());
198  ASSERT_EQ(0, binary_messages.size());
199  ASSERT_EQ(0, novatel_sentences.size());
200 
201  novatel_gps_driver::NmeaSentence sentence = nmea_sentences.front();
202 
203  ASSERT_EQ(parser.GetMessageName(), sentence.id);
204  ASSERT_FALSE(sentence.body.empty());
205 
206  novatel_gps_msgs::GpgsvPtr msg = parser.ParseAscii(sentence);
207 
208  ASSERT_NE(msg.get(), nullptr);
209 
210  ASSERT_EQ(3, msg->n_msgs);
211  ASSERT_EQ(3, msg->msg_number);
212  ASSERT_EQ(3, msg->satellites.size());
213  ASSERT_EQ(11, msg->n_satellites);
214  ASSERT_EQ(12, msg->satellites[0].prn);
215  ASSERT_EQ(7, msg->satellites[0].elevation);
216  ASSERT_EQ(0, msg->satellites[0].azimuth);
217  ASSERT_EQ(32, msg->satellites[0].snr);
218  ASSERT_EQ(13, msg->satellites[1].prn);
219  ASSERT_EQ(3, msg->satellites[1].elevation);
220  ASSERT_EQ(227, msg->satellites[1].azimuth);
221  ASSERT_EQ(36, msg->satellites[1].snr);
222  ASSERT_EQ(22, msg->satellites[2].prn);
223  ASSERT_EQ(0, msg->satellites[2].elevation);
224  ASSERT_EQ(41, msg->satellites[2].azimuth);
225  ASSERT_EQ(-1, msg->satellites[2].snr);
226 
227  msg = parser.ParseAscii(nmea_sentences.at(1));
228 
229  ASSERT_NE(msg.get(), nullptr);
230  ASSERT_EQ(0, msg->satellites.size());
231 }
232 
233 TEST(ParserTestSuite, testGphdtParsing)
234 {
236  std::string sentence_str = "$GPHDT,275.432,T*30\r\n";
237  std::string extracted_str;
238 
240 
241  std::vector<novatel_gps_driver::NmeaSentence> nmea_sentences;
242  std::vector<novatel_gps_driver::NovatelSentence> novatel_sentences;
243  std::vector<novatel_gps_driver::BinaryMessage> binary_messages;
244  std::string remaining;
245 
246  extractor.ExtractCompleteMessages(sentence_str, nmea_sentences, novatel_sentences,
247  binary_messages, remaining);
248 
249  ASSERT_EQ(1, nmea_sentences.size());
250  ASSERT_EQ(0, binary_messages.size());
251  ASSERT_EQ(0, novatel_sentences.size());
252 
253  novatel_gps_driver::NmeaSentence sentence = nmea_sentences.front();
254 
255  ASSERT_EQ(parser.GetMessageName(), sentence.id);
256  ASSERT_FALSE(sentence.body.empty());
257 
258  novatel_gps_msgs::GphdtPtr msg = parser.ParseAscii(sentence);
259 
260  ASSERT_NE(msg.get(), nullptr);
261 
262  ASSERT_DOUBLE_EQ(275.432, msg->heading);
263  ASSERT_EQ("T", msg->t);
264 }
265 
266 TEST(ParserTestSuite, testInscovAsciiParsing)
267 {
269  std::string sentence_str = "#INSCOVA,COM1,0,66.5,FINESTEERING,1959,336623.000,00000000,"
270  "f078,13754;1959,336623.000000000,0.0211295047125775,-0.0018214277429204,-0.0016153828661881,"
271  "-0.0018214277429204,0.0174981375607521,0.0049878113409426,-0.0016153828661881,"
272  "0.0049878113409426,0.0285474196118174,0.0000332609098342,-0.0000003409117564,"
273  "0.0000018468158360,-0.0000003409117564,0.0000340563145112,-0.0000136598582783,"
274  "0.0000018468158360,-0.0000136598582783,0.1515644215075894,0.0000008850783906,"
275  "0.0000000006144488,-0.0000001633832672,0.0000000006144488,0.0000010749675168,"
276  "0.0000000004985751,-0.0000001633832672,0.0000000004985751,0.0000009343218169*bc5352ab\r\n";
277  std::string extracted_str;
278 
280 
281  std::vector<novatel_gps_driver::NmeaSentence> nmea_sentences;
282  std::vector<novatel_gps_driver::NovatelSentence> novatel_sentences;
283  std::vector<novatel_gps_driver::BinaryMessage> binary_messages;
284  std::string remaining;
285 
286  extractor.ExtractCompleteMessages(sentence_str, nmea_sentences, novatel_sentences,
287  binary_messages, remaining);
288 
289  ASSERT_EQ(0, nmea_sentences.size());
290  ASSERT_EQ(0, binary_messages.size());
291  ASSERT_EQ(1, novatel_sentences.size());
292 
293  novatel_gps_driver::NovatelSentence sentence = novatel_sentences.front();
294 
295  ASSERT_EQ(parser.GetMessageName() + "A", sentence.id);
296 
297  novatel_gps_msgs::InscovPtr msg = parser.ParseAscii(sentence);
298 
299  ASSERT_NE(msg.get(), nullptr);
300 
301  ASSERT_EQ(1959, msg->week);
302  ASSERT_DOUBLE_EQ(336623.0, msg->seconds);
303  ASSERT_DOUBLE_EQ(0.0211295047125775, msg->position_covariance[0]);
304  ASSERT_DOUBLE_EQ(0.0000009343218169, msg->velocity_covariance[8]);
305 }
306 
307 TEST(ParserTestSuite, testInspvaAsciiParsing)
308 {
310  std::string sentence_str = "#INSPVAA,COM1,0,31.0,FINESTEERING,1264,144088.000,02040000,"
311  "5615,1541;1264,144088.002284950,51.116827527,-114.037738908,401.191547167,354.846489850,"
312  "108.429407241,-10.837482850,1.116219952,-3.476059035,7.372686190,INS_ALIGNMENT_COMPLETE*a2913d36\r\n";
313  std::string extracted_str;
314 
316 
317  std::vector<novatel_gps_driver::NmeaSentence> nmea_sentences;
318  std::vector<novatel_gps_driver::NovatelSentence> novatel_sentences;
319  std::vector<novatel_gps_driver::BinaryMessage> binary_messages;
320  std::string remaining;
321 
322  extractor.ExtractCompleteMessages(sentence_str, nmea_sentences, novatel_sentences,
323  binary_messages, remaining);
324 
325  ASSERT_EQ(0, nmea_sentences.size());
326  ASSERT_EQ(0, binary_messages.size());
327  ASSERT_EQ(1, novatel_sentences.size());
328 
329  novatel_gps_driver::NovatelSentence sentence = novatel_sentences.front();
330 
331  ASSERT_EQ(parser.GetMessageName() + "A", sentence.id);
332 
333  novatel_gps_msgs::InspvaPtr msg = parser.ParseAscii(sentence);
334 
335  ASSERT_NE(msg.get(), nullptr);
336 
337  ASSERT_EQ(1264, msg->week);
338  ASSERT_DOUBLE_EQ(144088.002284950, msg->seconds);
339  ASSERT_DOUBLE_EQ(51.116827527, msg->latitude);
340  ASSERT_DOUBLE_EQ(-114.037738908, msg->longitude);
341  ASSERT_DOUBLE_EQ(401.191547167, msg->height);
342  ASSERT_DOUBLE_EQ(354.846489850, msg->north_velocity);
343  ASSERT_DOUBLE_EQ(108.429407241, msg->east_velocity);
344  ASSERT_DOUBLE_EQ(-10.837482850, msg->up_velocity);
345  ASSERT_DOUBLE_EQ(1.116219952, msg->roll);
346  ASSERT_DOUBLE_EQ(-3.476059035, msg->pitch);
347  ASSERT_DOUBLE_EQ(7.372686190, msg->azimuth);
348  ASSERT_EQ("INS_ALIGNMENT_COMPLETE", msg->status);
349 }
350 
351 TEST(ParserTestSuite, testInsstdevAsciiParsing)
352 {
354  std::string sentence_str = "#INSSTDEVA,COM1,0,78.0,FINESTEERING,1907,233990.000,02000020,"
355  "3e6d,32768;0.4372,0.3139,0.7547,0.0015,0.0015,0.0014,3.7503,3.7534,5.1857,26000005,"
356  "0,0,01ffd1bf,0*3deca7d2\r\n";
357  std::string extracted_str;
358 
360 
361  std::vector<novatel_gps_driver::NmeaSentence> nmea_sentences;
362  std::vector<novatel_gps_driver::NovatelSentence> novatel_sentences;
363  std::vector<novatel_gps_driver::BinaryMessage> binary_messages;
364  std::string remaining;
365 
366  extractor.ExtractCompleteMessages(sentence_str, nmea_sentences, novatel_sentences,
367  binary_messages, remaining);
368 
369  ASSERT_EQ(0, nmea_sentences.size());
370  ASSERT_EQ(0, binary_messages.size());
371  ASSERT_EQ(1, novatel_sentences.size());
372 
373  novatel_gps_driver::NovatelSentence sentence = novatel_sentences.front();
374 
375  ASSERT_EQ(parser.GetMessageName() + "A", sentence.id);
376 
377  novatel_gps_msgs::InsstdevPtr msg = parser.ParseAscii(sentence);
378 
379  ASSERT_NE(msg.get(), nullptr);
380 
381  ASSERT_FLOAT_EQ(0.4372, msg->latitude_dev);
382  ASSERT_FLOAT_EQ(0.3139, msg->longitude_dev);
383  ASSERT_FLOAT_EQ(0.7547, msg->height_dev);
384  ASSERT_FLOAT_EQ(0.0015, msg->north_velocity_dev);
385  ASSERT_FLOAT_EQ(0.0015, msg->east_velocity_dev);
386  ASSERT_FLOAT_EQ(0.0014, msg->up_velocity_dev);
387  ASSERT_FLOAT_EQ(3.7503, msg->roll_dev);
388  ASSERT_FLOAT_EQ(3.7534, msg->pitch_dev);
389  ASSERT_FLOAT_EQ(5.1857, msg->azimuth_dev);
390  ASSERT_EQ(26000005, msg->extended_solution_status.original_mask);
391 }
392 
393 TEST(ParserTestSuite, testBestxyzAsciiParsing)
394 {
396  std::string bestxyz_str = "#BESTXYZA,COM1,0,55.0,FINESTEERING,1419,340033.000,02000040,d821,2724;"
397  "SOL_COMPUTED,NARROW_INT,-1634531.5683,-3664618.0326,4942496.3270,0.0099,"
398  "0.0219,0.0115,SOL_COMPUTED,NARROW_INT,0.0011,-0.0049,-0.0001,0.0199,0.0439,"
399  "0.0230,\"AAAA\",0.250,1.000,0.000,12,11,11,11,0,01,0,33*1fe2f509\r\n";
400 
401  std::string extracted_str;
402 
404 
405  std::vector<novatel_gps_driver::NmeaSentence> nmea_sentences;
406  std::vector<novatel_gps_driver::NovatelSentence> novatel_sentences;
407  std::vector<novatel_gps_driver::BinaryMessage> binary_messages;
408  std::string remaining;
409 
410  extractor.ExtractCompleteMessages(bestxyz_str, nmea_sentences, novatel_sentences,
411  binary_messages, remaining);
412 
413  ASSERT_EQ(0, nmea_sentences.size());
414  ASSERT_EQ(0, binary_messages.size());
415  ASSERT_EQ(1, novatel_sentences.size());
416 
417  novatel_gps_driver::NovatelSentence sentence = novatel_sentences.front();
418 
419  ASSERT_EQ(parser.GetMessageName() + "A", sentence.id);
420 
421  novatel_gps_msgs::NovatelXYZPtr msg = parser.ParseAscii(sentence);
422 
423  ASSERT_NE(msg.get(), nullptr);
424 
425  ASSERT_EQ("SOL_COMPUTED", msg->solution_status);
426  ASSERT_EQ("NARROW_INT", msg->position_type);
427  ASSERT_DOUBLE_EQ(-1634531.5683, msg->x);
428  ASSERT_DOUBLE_EQ(-3664618.0326, msg->y);
429  ASSERT_DOUBLE_EQ(4942496.3270, msg->z);
430  ASSERT_FLOAT_EQ(0.0099, msg->x_sigma);
431  ASSERT_FLOAT_EQ(0.0219, msg->y_sigma);
432  ASSERT_FLOAT_EQ(0.0115, msg->z_sigma);
433  ASSERT_EQ("SOL_COMPUTED", msg->velocity_solution_status);
434  ASSERT_EQ("NARROW_INT", msg->velocity_type);
435  ASSERT_DOUBLE_EQ(0.0011, msg->x_vel);
436  ASSERT_DOUBLE_EQ(-0.0049, msg->y_vel);
437  ASSERT_DOUBLE_EQ(-0.0001, msg->z_vel);
438  ASSERT_FLOAT_EQ(0.0199, msg->x_vel_sigma);
439  ASSERT_FLOAT_EQ(0.0439, msg->y_vel_sigma);
440  ASSERT_FLOAT_EQ(0.0230, msg->z_vel_sigma);
441  ASSERT_EQ("\"AAAA\"", msg->base_station_id);
442  ASSERT_FLOAT_EQ(0.250, msg->velocity_latency);
443  ASSERT_FLOAT_EQ(1.000, msg->diff_age);
444  ASSERT_FLOAT_EQ(0.000, msg->solution_age);
445  ASSERT_EQ(12, msg->num_satellites_tracked);
446  ASSERT_EQ(11, msg->num_satellites_used_in_solution);
447  ASSERT_EQ(11, msg->num_gps_and_glonass_l1_used_in_solution);
448  ASSERT_EQ(11, msg->num_gps_and_glonass_l1_and_l2_used_in_solution);
449  ASSERT_EQ(1, msg->extended_solution_status.original_mask);
450 }
451 
452 TEST(ParserTestSuite, testHeading2AsciiParsing)
453 {
455  std::string heading2_str = "#HEADING2A,COM1,0,39.5,FINESTEERING,1622,422892.200,02040000,f9bf,6521;"
456  "SOL_COMPUTED,NARROW_INT,0.927607417,178.347869873,-1.3037414550,0,0.261901051,0.391376048,"
457  "\"R222\",\"AAAA\",18,17,17,16,0,01,0,33*8c48d77c\r\n"
458  "#HEADING2A,COM1,0,39.5,FINESTEERING,1622,422892.200,02040000,f9bf,6521;"
459  "SOL_COMPUTED,NARROW_INT,0.927607417,178.347869873,-1.3037414550,0,0.261901051,0.391376048,"
460  "\"R222\",\"AAAA\",18,17,17,16,4,01,0,33*d1a48670\r\n";
461 
462  std::string extracted_str;
463 
465 
466  std::vector<novatel_gps_driver::NmeaSentence> nmea_sentences;
467  std::vector<novatel_gps_driver::NovatelSentence> novatel_sentences;
468  std::vector<novatel_gps_driver::BinaryMessage> binary_messages;
469  std::string remaining;
470 
471  extractor.ExtractCompleteMessages(heading2_str, nmea_sentences, novatel_sentences,
472  binary_messages, remaining);
473 
474  ASSERT_EQ(0, nmea_sentences.size());
475  ASSERT_EQ(0, binary_messages.size());
476  ASSERT_EQ(2, novatel_sentences.size());
477 
478  novatel_gps_driver::NovatelSentence sentence = novatel_sentences.front();
479 
480  ASSERT_EQ(parser.GetMessageName() + "A", sentence.id);
481 
482  novatel_gps_msgs::NovatelHeading2Ptr msg = parser.ParseAscii(sentence);
483 
484  ASSERT_NE(msg.get(), nullptr);
485 
486  ASSERT_EQ("SOL_COMPUTED", msg->solution_status);
487  ASSERT_EQ("NARROW_INT", msg->position_type);
488  ASSERT_FLOAT_EQ(0.927607417, msg->baseline_length);
489  ASSERT_FLOAT_EQ(178.347869873, msg->heading);
490  ASSERT_FLOAT_EQ(-1.3037414550, msg->pitch);
491  ASSERT_FLOAT_EQ(0.261901051, msg->heading_sigma);
492  ASSERT_FLOAT_EQ(0.391376048, msg->pitch_sigma);
493  ASSERT_EQ("\"R222\"", msg->rover_station_id);
494  ASSERT_EQ("\"AAAA\"", msg->master_station_id);
495  ASSERT_EQ(18, msg->num_satellites_tracked);
496  ASSERT_EQ(17, msg->num_satellites_used_in_solution);
497  ASSERT_EQ(17, msg->num_satellites_above_elevation_mask_angle);
498  ASSERT_EQ(16, msg->num_satellites_above_elevation_mask_angle_l2);
499  ASSERT_EQ(novatel_gps_msgs::NovatelHeading2::SOURCE_PRIMARY_ANTENNA, msg->solution_source);
500  ASSERT_EQ(1, msg->extended_solution_status.original_mask);
501 
502  msg = parser.ParseAscii(novatel_sentences.at(1));
503 
504  ASSERT_NE(msg.get(), nullptr);
505  ASSERT_EQ(novatel_gps_msgs::NovatelHeading2::SOURCE_SECONDARY_ANTENNA, msg->solution_source);
506 }
507 
508 TEST(ParserTestSuite, testDualAntennaHeadingAsciiParsing)
509 {
511  std::string heading_str = "#DUALANTENNAHEADINGA,UNKNOWN,0,66.5,FINESTEERING,1949,575614.000,02000000,d426,32768;"
512  "SOL_COMPUTED,NARROW_INT,-1.000000000,255.538528442,0.006041416,0.0,0.043859947,0.052394450,"
513  "\"J56X\",24,18,18,17,04,01,00,33*1f082ec5\r\n"
514  "#DUALANTENNAHEADINGA,UNKNOWN,0,66.5,FINESTEERING,1949,575614.000,02000000,d426,32768;"
515  "SOL_COMPUTED,NARROW_INT,-1.000000000,255.538528442,0.006041416,0.0,0.043859947,0.052394450,"
516  "\"J56X\",24,18,18,17,0,01,00,33*8ae85b15\r\n";
517 
518  std::string extracted_str;
519 
521 
522  std::vector<novatel_gps_driver::NmeaSentence> nmea_sentences;
523  std::vector<novatel_gps_driver::NovatelSentence> novatel_sentences;
524  std::vector<novatel_gps_driver::BinaryMessage> binary_messages;
525  std::string remaining;
526 
527  extractor.ExtractCompleteMessages(heading_str, nmea_sentences, novatel_sentences,
528  binary_messages, remaining);
529 
530  ASSERT_EQ(0, nmea_sentences.size());
531  ASSERT_EQ(0, binary_messages.size());
532  ASSERT_EQ(2, novatel_sentences.size());
533 
534  novatel_gps_driver::NovatelSentence sentence = novatel_sentences.front();
535 
536  ASSERT_EQ(parser.GetMessageName() + "A", sentence.id);
537 
538  novatel_gps_msgs::NovatelDualAntennaHeadingPtr msg = parser.ParseAscii(sentence);
539 
540  ASSERT_NE(msg.get(), nullptr);
541 
542  ASSERT_EQ("SOL_COMPUTED", msg->solution_status);
543  ASSERT_EQ("NARROW_INT", msg->position_type);
544  ASSERT_FLOAT_EQ(-1.000000000, msg->baseline_length);
545  ASSERT_FLOAT_EQ(255.538528442, msg->heading);
546  ASSERT_FLOAT_EQ(0.006041416, msg->pitch);
547  ASSERT_FLOAT_EQ(0.043859947, msg->heading_sigma);
548  ASSERT_FLOAT_EQ(0.052394450, msg->pitch_sigma);
549  ASSERT_EQ("\"J56X\"", msg->station_id);
550  ASSERT_EQ(24, msg->num_satellites_tracked);
551  ASSERT_EQ(18, msg->num_satellites_used_in_solution);
552  ASSERT_EQ(18, msg->num_satellites_above_elevation_mask_angle);
553  ASSERT_EQ(17, msg->num_satellites_above_elevation_mask_angle_l2);
554  ASSERT_EQ(novatel_gps_msgs::NovatelDualAntennaHeading::SOURCE_SECONDARY_ANTENNA, msg->solution_source);
555  ASSERT_EQ(1, msg->extended_solution_status.original_mask);
556 
557  msg = parser.ParseAscii(novatel_sentences.at(1));
558 
559  ASSERT_NE(msg.get(), nullptr);
560  ASSERT_EQ(novatel_gps_msgs::NovatelDualAntennaHeading::SOURCE_PRIMARY_ANTENNA, msg->solution_source);
561 }
562 
563 int main(int argc, char **argv)
564 {
565  testing::InitGoogleTest(&argc, argv);
566 
567  return RUN_ALL_TESTS();
568 }
msg
const std::string GetMessageName() const override
Definition: gpgsv.cpp:40
const std::string GetMessageName() const override
Definition: bestxyz.cpp:45
novatel_gps_msgs::InscovPtr ParseAscii(const NovatelSentence &sentence) noexcept(false) override
Converts sentence into a ROS message pointer and returns it.
Definition: inscov.cpp:79
const std::string GetMessageName() const override
Definition: gpgga.cpp:42
const std::string GetMessageName() const override
Definition: heading2.cpp:45
const std::string GetMessageName() const override
Definition: inscov.cpp:41
novatel_gps_msgs::NovatelPositionPtr ParseAscii(const NovatelSentence &sentence) noexcept(false) override
Converts sentence into a ROS message pointer and returns it.
Definition: bestpos.cpp:110
novatel_gps_msgs::NovatelXYZPtr ParseAscii(const NovatelSentence &sentence) noexcept(false) override
Converts sentence into a ROS message pointer and returns it.
Definition: bestxyz.cpp:137
const std::string GetMessageName() const override
Definition: gphdt.cpp:12
novatel_gps_msgs::GpgsvPtr ParseAscii(const NmeaSentence &sentence) noexcept(false) override
Converts sentence into a ROS message pointer and returns it.
Definition: gpgsv.cpp:45
TEST(ParserTestSuite, testBestposAsciiParsing)
novatel_gps_msgs::InsstdevPtr ParseAscii(const NovatelSentence &sentence) noexcept(false) override
Converts sentence into a ROS message pointer and returns it.
Definition: insstdev.cpp:76
const std::string GetMessageName() const override
Definition: insstdev.cpp:41
const std::string GetMessageName() const override
Definition: corrimudata.cpp:41
novatel_gps_msgs::GphdtPtr ParseAscii(const NmeaSentence &sentence) noexcept(false) override
Converts sentence into a ROS message pointer and returns it.
Definition: gphdt.cpp:17
novatel_gps_msgs::NovatelDualAntennaHeadingPtr ParseAscii(const NovatelSentence &sentence) noexcept(false) override
Converts sentence into a ROS message pointer and returns it.
novatel_gps_msgs::NovatelCorrectedImuDataPtr ParseAscii(const NovatelSentence &sentence) noexcept(false) override
Converts sentence into a ROS message pointer and returns it.
Definition: corrimudata.cpp:73
const std::string GetMessageName() const override
Definition: inspva.cpp:41
bool ExtractCompleteMessages(const std::string &input, std::vector< NmeaSentence > &nmea_sentences, std::vector< NovatelSentence > &novatel_sentences, std::vector< BinaryMessage > &binary_messages, std::string &remaining, bool keep_nmea_container=false)
Extracts messages from a buffer of NovAtel data.
parser
int main(int argc, char **argv)
novatel_gps_msgs::InspvaPtr ParseAscii(const NovatelSentence &sentence) noexcept(false) override
Converts sentence into a ROS message pointer and returns it.
Definition: inspva.cpp:120
const std::string GetMessageName() const override
Definition: bestpos.cpp:45
const std::string GetMessageName() const override
novatel_gps_msgs::NovatelHeading2Ptr ParseAscii(const NovatelSentence &sentence) noexcept(false) override
Converts sentence into a ROS message pointer and returns it.
Definition: heading2.cpp:115
novatel_gps_msgs::GpggaPtr ParseAscii(const NmeaSentence &sentence) noexcept(false) override
Converts sentence into a ROS message pointer and returns it.
Definition: gpgga.cpp:47


novatel_gps_driver
Author(s):
autogenerated on Thu Jul 16 2020 03:17:30