Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise direction test in SampleConsensusModelParallelLine/RANSAC to be consistent with set tolerance. #2491

Merged
merged 1 commit into from
Sep 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions test/sample_consensus/test_sample_consensus_line_models.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

#include <pcl/pcl_tests.h>

#include <pcl/common/common.h>
#include <pcl/sample_consensus/ransac.h>
#include <pcl/sample_consensus/sac_model_line.h>
#include <pcl/sample_consensus/sac_model_parallel_line.h>
Expand Down Expand Up @@ -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<PointXYZ> (cloud.makeShared ()));
model->setAxis (Eigen::Vector3f (0, 0, 1));
model->setEpsAngle (0.1);
model->setAxis (axis);
model->setEpsAngle (eps);

// Create the RANSAC object
RandomSampleConsensus<PointXYZ> sac (model, 0.1);
Expand All @@ -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<PointXYZ> proj_points;
Expand Down