TEST(CGPSInterface, parse_NMEA_ZDA_stream) { mrpt::io::CMemoryStream buf; { const std::string s("$GPZDA,181813,14,10,2003,00,00*4F\n"); buf.Write(s.c_str(), s.size()); buf.Seek(0); } CGPSInterface gps; gps.bindStream(&buf); gps.initialize(); gps.doProcess(); mrpt::hwdrivers::CGenericSensor::TListObservations obss; gps.getObservations(obss); EXPECT_EQ(obss.size(), 1U); auto obsGPS = mrpt::ptr_cast<CObservationGPS>::from(obss.begin()->second); const gnss::Message_NMEA_ZDA* msg = obsGPS->getMsgByClassPtr<gnss::Message_NMEA_ZDA>(); EXPECT_TRUE(msg != nullptr); if (!msg) return; EXPECT_TRUE(msg->fields.date_day == 14); EXPECT_TRUE(msg->fields.date_month == 10); EXPECT_TRUE(msg->fields.date_year == 2003); EXPECT_TRUE(msg->fields.UTCTime.hour == 18); EXPECT_TRUE(msg->fields.UTCTime.minute == 18); EXPECT_TRUE(msg->fields.UTCTime.sec == 13.0); // Replaced from EXPECT_EQ() to avoid a "bus error" in a gtest template // under armhf. }
TEST(CGPSInterface, parse_NOVATEL6_stream) { mrpt::io::CMemoryStream buf; { const unsigned char sample_novatel6_gps[] = { 0xaa, 0x44, 0x12, 0x1c, 0x2a, 0x00, 0x00, 0xa0, 0x48, 0x00, 0x00, 0x00, 0x5a, 0xb4, 0x59, 0x07, 0x10, 0x4a, 0xb7, 0x16, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xb1, 0x4a, 0x34, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x97, 0x2b, 0x45, 0xa9, 0xc8, 0x6a, 0x42, 0x40, 0xfc, 0x54, 0x43, 0x6f, 0x11, 0x18, 0x03, 0xc0, 0x00, 0x00, 0x20, 0x8f, 0xe8, 0x0e, 0x1c, 0x40, 0x66, 0x66, 0x48, 0x42, 0x3d, 0x00, 0x00, 0x00, 0x1d, 0x9b, 0x96, 0x3c, 0x2c, 0xd5, 0x9c, 0x3c, 0xd1, 0x39, 0xa8, 0x3c, 0x35, 0x35, 0x35, 0x00, 0x00, 0x00, 0x60, 0x41, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0e, 0x0e, 0x0d, 0x00, 0x00, 0x00, 0x33, 0x82, 0xba, 0x79, 0xe5, 0xaa, 0x44, 0x13, 0x58, 0xfc, 0x01, 0x59, 0x07, 0x10, 0x4a, 0xb7, 0x16, 0x59, 0x07, 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0xdb, 0x42, 0x17, 0x41, 0xa7, 0xf0, 0xaf, 0xa5, 0xc8, 0x6a, 0x42, 0x40, 0xa2, 0xad, 0xac, 0x28, 0x12, 0x18, 0x03, 0xc0, 0x00, 0x00, 0x8a, 0x8b, 0x52, 0x8d, 0x4c, 0x40, 0x10, 0xe2, 0xdb, 0x3c, 0x4b, 0xbd, 0x82, 0xbf, 0x52, 0x23, 0x1e, 0x50, 0x08, 0xf1, 0x9b, 0xbf, 0xd4, 0xa6, 0xd1, 0x7c, 0xcd, 0x16, 0xc8, 0x3f, 0x31, 0x27, 0xe1, 0x16, 0xa2, 0x6b, 0x10, 0x40, 0xc7, 0x1c, 0xc7, 0x39, 0x6a, 0x9c, 0x00, 0x40, 0xa0, 0x3c, 0x9f, 0x79, 0xca, 0xdd, 0x63, 0x40, 0x03, 0x00, 0x00, 0x00, 0x27, 0xbb, 0xff, 0xf8, 0xaa, 0x44, 0x12, 0x1c, 0x2a, 0x00, 0x00, 0xa0, 0x48, 0x00, 0x00, 0x00, 0x5a, 0xb4, 0x59, 0x07, 0x42, 0x4a, 0xb7, 0x16, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xb1, 0x4a, 0x34, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0xf0, 0x23, 0x3c, 0xa9, 0xc8, 0x6a, 0x42, 0x40, 0xdd, 0x10, 0x6c, 0x71, 0x11, 0x18, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x03, 0xa7, 0x18, 0x1c, 0x40, 0x66, 0x66, 0x48, 0x42, 0x3d, 0x00, 0x00, 0x00, 0x32, 0x9b, 0x96, 0x3c, 0x82, 0xd4, 0x9c, 0x3c, 0x5d, 0x3a, 0xa8, 0x3c, 0x35, 0x35, 0x35, 0x00, 0x00, 0x00, 0x60, 0x41, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0e, 0x0e, 0x0d, 0x00, 0x00, 0x00, 0x33, 0xcb, 0x95, 0xa0, 0x9b, 0xaa, 0x44, 0x13, 0x58, 0xfc, 0x01, 0x59, 0x07, 0x42, 0x4a, 0xb7, 0x16, 0x59, 0x07, 0x00, 0x00, 0x67, 0x66, 0x66, 0x66, 0xdb, 0x42, 0x17, 0x41, 0xe6, 0xae, 0xa1, 0xa5, 0xc8, 0x6a, 0x42, 0x40, 0x26, 0x1e, 0x82, 0x2b, 0x12, 0x18, 0x03, 0xc0, 0x00, 0x00, 0x62, 0xb6, 0x8b, 0x8e, 0x4c, 0x40, 0x10, 0x63, 0x42, 0x19, 0x38, 0x19, 0x7a, 0xbf, 0x1e, 0xa9, 0x79, 0x02, 0x24, 0x6c, 0x9d, 0xbf, 0x52, 0x13, 0x38, 0xa4, 0x35, 0x2c, 0xc8, 0x3f, 0xa9, 0x3b, 0x21, 0x59, 0xe0, 0xa0, 0x10, 0x40, 0x51, 0xd1, 0x8c, 0x50, 0x0b, 0xa0, 0x00, 0x40, 0x16, 0x40, 0x94, 0xbe, 0xc2, 0xdd, 0x63, 0x40, 0x03, 0x00, 0x00, 0x00, 0x20, 0x4d, 0xe7, 0xa2, 0xaa, 0x44, 0x12, 0x1c, 0x2a, 0x00, 0x00, 0xa0, 0x48, 0x00, 0x00, 0x00, 0x5a, 0xb4, 0x59, 0x07, 0x74, 0x4a, 0xb7, 0x16, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xb1, 0x4a, 0x34, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0xaa, 0x41, 0x32, 0xa9, 0xc8, 0x6a, 0x42, 0x40, 0xff, 0x59, 0xa8, 0x73, 0x11, 0x18, 0x03, 0xc0, 0x00, 0x00, 0xa0, 0xd6, 0x6b, 0x22, 0x1c, 0x40, 0x66, 0x66, 0x48, 0x42, 0x3d, 0x00, 0x00, 0x00, 0x92, 0x9b, 0x96, 0x3c, 0x70, 0xd3, 0x9c, 0x3c, 0x06, 0x3b, 0xa8, 0x3c, 0x35, 0x35, 0x35, 0x00}; const unsigned int sample_novatel6_gps_len = 500; buf.Write(sample_novatel6_gps, sample_novatel6_gps_len); buf.Seek(0); } CGPSInterface gps; gps.bindStream(&buf); gps.initialize(); gps.doProcess(); mrpt::hwdrivers::CGenericSensor::TListObservations obss; gps.getObservations(obss); EXPECT_EQ(obss.size(), 4U); auto itObs = obss.begin(); auto obsGPS1 = mrpt::ptr_cast<CObservationGPS>::from(itObs->second); ++itObs; auto obsGPS2 = mrpt::ptr_cast<CObservationGPS>::from(itObs->second); EXPECT_TRUE(obsGPS1); EXPECT_TRUE(obsGPS2); const auto* msg1 = obsGPS1->getMsgByClassPtr<gnss::Message_NV_OEM6_BESTPOS>(); EXPECT_TRUE(msg1 != nullptr); if (!msg1) return; EXPECT_TRUE(msg1->fields.num_sats_tracked == 15); const auto* msg2 = obsGPS2->getMsgByClassPtr<gnss::Message_NV_OEM6_INSPVAS>(); EXPECT_TRUE(msg2 != nullptr); if (!msg2) return; EXPECT_NEAR(msg2->fields.roll, 4.10511, 1e-4); }