From e705b2df46748a0b429e60971ede49c92192ff46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81rgio=20Agostinho?= Date: Sat, 29 Sep 2018 09:43:44 +0200 Subject: [PATCH] Revise direction test in SampleConsensusModelParallelLine/RANSAC to be consistent with set tolerance. --- .../test_sample_consensus_line_models.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/sample_consensus/test_sample_consensus_line_models.cpp b/test/sample_consensus/test_sample_consensus_line_models.cpp index e3266244f98..6ef73dd4ee2 100644 --- a/test/sample_consensus/test_sample_consensus_line_models.cpp +++ b/test/sample_consensus/test_sample_consensus_line_models.cpp @@ -40,6 +40,7 @@ #include +#include #include #include #include @@ -132,9 +133,11 @@ TEST (SampleConsensusModelParallelLine, RANSAC) cloud.points[15].getVector3fMap () << -1.05f, 5.01f, 5.0f; // Create a shared line model pointer directly + const double eps = 0.1; //angle eps in radians + const Eigen::Vector3f axis (0, 0, 1); SampleConsensusModelParallelLinePtr model (new SampleConsensusModelParallelLine (cloud.makeShared ())); - model->setAxis (Eigen::Vector3f (0, 0, 1)); - model->setEpsAngle (0.1); + model->setAxis (axis); + model->setEpsAngle (eps); // Create the RANSAC object RandomSampleConsensus sac (model, 0.1); @@ -154,9 +157,11 @@ TEST (SampleConsensusModelParallelLine, RANSAC) Eigen::VectorXf coeff; sac.getModelCoefficients (coeff); EXPECT_EQ (6, coeff.size ()); - EXPECT_NEAR (0, coeff[3], 1e-4); - EXPECT_NEAR (0, coeff[4], 1e-4); - EXPECT_NEAR (1, coeff[5], 1e-4); + + // Make sure the returned direction respects the angular constraint + double angle_diff = getAngle3D (axis, coeff.tail<3> ()); + angle_diff = std::min (angle_diff, M_PI - angle_diff); + EXPECT_GT (eps, angle_diff); // Projection tests PointCloud proj_points;