Skip to content

Commit

Permalink
Added test case: empty localization tag
Browse files Browse the repository at this point in the history
Signed-off-by: Aditya <aditya050995@gmail.com>
  • Loading branch information
adityapande-1995 committed Mar 1, 2022
1 parent 654ceb8 commit 90f6917
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/ImuSensor_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
<< "<?xml version='1.0'?>"
<< "<sdf version='1.6'>"
<< " <model name='m1'>"
<< " <link name='link1'>"
<< " <sensor name='imu_sensor' type='imu'>"
<< " <topic>imu_test</topic>"
<< " <update_rate>1</update_rate>"
<< " <imu>"
<< " <orientation_reference_frame>"
<< " </orientation_reference_frame>"
<< " </imu>"
<< " <always_on>1</always_on>"
<< " <visualize>true</visualize>"
<< " </sensor>"
<< " </link>"
<< " </model>"
<< "</sdf>";

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<ignition::sensors::ImuSensor>(
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)
{
Expand Down

0 comments on commit 90f6917

Please sign in to comment.