Skip to content

Commit

Permalink
Fix float tests in test_scans.cpp (OctoMap#363)
Browse files Browse the repository at this point in the history
Tests failed in unrelated PR OctoMap#362
  • Loading branch information
ahornung authored Mar 7, 2022
1 parent c8b4da4 commit 59883e4
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions octomap/src/testing/test_scans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ void printUsage(char* self){
exit(1);
}

void comparePose(const pose6d& first, const pose6d& sec){
EXPECT_FLOAT_EQ(first.x(), sec.x());
EXPECT_FLOAT_EQ(first.y(), sec.y());
EXPECT_FLOAT_EQ(first.z(), sec.z());

EXPECT_FLOAT_EQ(first.roll(), sec.roll());
EXPECT_FLOAT_EQ(first.pitch(), sec.pitch());
EXPECT_FLOAT_EQ(first.yaw(), sec.yaw());
}

void comparePoint(const point3d& first, const point3d& sec){
EXPECT_FLOAT_EQ(first.x(), sec.x());
EXPECT_FLOAT_EQ(first.y(), sec.y());
EXPECT_FLOAT_EQ(first.z(), sec.z());
}

int main(int argc, char** argv) {
if (argc != 2){
printUsage(argv[0]);
Expand Down Expand Up @@ -53,15 +69,15 @@ int main(int argc, char** argv) {
ScanNode* refScanNode = *referenceGraph.begin();

EXPECT_EQ(scanNode->id, refScanNode->id);
EXPECT_EQ(scanNode->pose, refScanNode->pose);
comparePose(scanNode->pose, refScanNode->pose);
EXPECT_EQ(scanNode->scan->size(), refScanNode->scan->size());

for (size_t i = 0; i < scanNode->scan->size(); ++i){
EXPECT_EQ((*scanNode->scan)[i], (*refScanNode->scan)[i]);
comparePoint((*scanNode->scan)[i], (*refScanNode->scan)[i]);
}

}
// test reading and writing to file
// test reading and writing to file - to verify, are the values really exactly equal or just close?
{
std::cout << "Testing ScanGraph I/O" << std::endl;

Expand Down

0 comments on commit 59883e4

Please sign in to comment.