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

Relax requirements in eigen22d test. Always provide a normalized result in pcl::transformPlane. #2503

Merged
merged 3 commits into from
Oct 11, 2018
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ build_script:
-DBUILD_global_tests=ON
-DBUILD_simulation=OFF
-DBUILD_tools=OFF
-DBUILD_tests_common=OFF
-DBUILD_tests_features=OFF
-DBUILD_tests_filters=OFF
..
Expand Down
8 changes: 7 additions & 1 deletion common/include/pcl/common/impl/eigen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,11 @@ pcl::transformPlane (const Eigen::Matrix<Scalar, 4, 1> &plane_in,
plane.coeffs () << plane_in;
plane.transform (transformation);
plane_out << plane.coeffs ();

// Versions prior to 3.3.2 don't normalize the result
#if !EIGEN_VERSION_AT_LEAST (3, 3, 2)
plane_out /= plane_out.template head<3> ().norm ();
#endif
}

//////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -850,7 +855,8 @@ pcl::transformPlane (const pcl::ModelCoefficients::Ptr plane_in,
pcl::ModelCoefficients::Ptr plane_out,
const Eigen::Transform<Scalar, 3, Eigen::Affine> &transformation)
{
Eigen::Matrix < Scalar, 4, 1 > v_plane_in (std::vector < Scalar > (plane_in->values.begin (), plane_in->values.end ()).data ());
std::vector<Scalar> values (plane_in->values.begin (), plane_in->values.end ());
Eigen::Matrix < Scalar, 4, 1 > v_plane_in (values.data ());
pcl::transformPlane (v_plane_in, v_plane_in, transformation);
plane_out->values.resize (4);
for (int i = 0; i < 4; i++)
Expand Down
10 changes: 6 additions & 4 deletions test/common/test_eigen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,25 +497,25 @@ TEST (PCL, eigen22d)
// test if U * V * U^T = M
r_result = r_vectors * r_eigenvalues.asDiagonal () * r_vectors.transpose ();
r_error = r_result - r_matrix;
diff = r_error.cwiseAbs (). sum ();
diff = r_error.cwiseAbs ().maxCoeff ();
EXPECT_LE (diff, epsilon);

// test if the eigenvalues are orthonormal
g_result = r_vectors * r_vectors.transpose ();
g_error = g_result - RMatrix::Identity ();
diff = g_error.cwiseAbs (). sum ();
diff = g_error.cwiseAbs ().maxCoeff ();
EXPECT_LE (diff, epsilon);

// test if column major matrices are also calculated correctly
eigen22 (c_matrix, c_vectors, c_eigenvalues);
c_result = c_vectors * c_eigenvalues.asDiagonal () * c_vectors.transpose ();
c_error = c_result - c_matrix;
diff = c_error.cwiseAbs (). sum ();
diff = c_error.cwiseAbs ().maxCoeff ();
EXPECT_LE (diff, epsilon);

g_result = c_vectors * c_vectors.transpose ();
g_error = g_result - CMatrix::Identity ();
diff = g_error.cwiseAbs (). sum ();
diff = g_error.cwiseAbs ().maxCoeff ();
EXPECT_LE (diff, epsilon);
}
}
Expand Down Expand Up @@ -932,6 +932,8 @@ TEST (PCL, transformPlane)
transformationd.linear() = (Eigen::Matrix3d) Eigen::AngleAxisd(M_PI/7, Eigen::Vector3d::UnitY())
* Eigen::AngleAxisd(M_PI/4, Eigen::Vector3d::UnitZ());
test << 5.35315, 2.89914, 0.196848, -49.2788;
test /= test.head<3> ().norm ();

tolerance = 1e-4;

plane->values[0] = 5.4;
Expand Down