From 90f691735879fb91b60362a6eb6450219f0b933c Mon Sep 17 00:00:00 2001 From: Aditya Date: Tue, 1 Mar 2022 12:20:36 -0800 Subject: [PATCH] Added test case: empty localization tag Signed-off-by: Aditya --- src/ImuSensor_TEST.cc | 57 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/ImuSensor_TEST.cc b/src/ImuSensor_TEST.cc index 30d552a6..35fe2208 100644 --- a/src/ImuSensor_TEST.cc +++ b/src/ImuSensor_TEST.cc @@ -757,6 +757,63 @@ TEST(ImuSensor_TEST, NamedFrameOrientationReference) } } +////////////////////////////////////////////////// +TEST(ImuSensor_TEST, LocalizationTagEmpty) +{ + // Create a sensor manager + ignition::sensors::Manager mgr; + + sdf::ElementPtr imuSDF; + + std::ostringstream stream; + stream + << "" + << "" + << " " + << " " + << " " + << " imu_test" + << " 1" + << " " + << " " + << " " + << " " + << " 1" + << " true" + << " " + << " " + << " " + << ""; + + sdf::SDFPtr sdfParsed(new sdf::SDF()); + sdf::init(sdfParsed); + if (!sdf::readString(stream.str(), sdfParsed)) + { + imuSDF = sdf::ElementPtr(); + } + else + { + imuSDF = sdfParsed->Root()->GetElement("model")->GetElement("link") + ->GetElement("sensor"); + } + + // Create an ImuSensor + auto sensor = mgr.CreateSensor( + imuSDF); + sensor->SetWorldFrameOrientation(math::Quaterniond(0, 0, 0), + sensors::WorldFrameEnumType::ENU); + + // Make sure the above dynamic cast worked. + ASSERT_NE(nullptr, sensor); + + sensor->Update(std::chrono::steady_clock::duration( + std::chrono::nanoseconds(10000000))); + + math::Quaterniond orientValue(math::Vector3d(0, 0, 0)); + EXPECT_EQ(orientValue, sensor->Orientation()); + +} + ////////////////////////////////////////////////// int main(int argc, char **argv) {