From 46a544d008c798b318934220e2ee3c13ae091f5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81rgio=20Agostinho?= Date: Mon, 1 Oct 2018 10:57:46 +0200 Subject: [PATCH 1/3] Relax eigen22d test criteria by defining the threshold on the matrix individual components. --- test/common/test_eigen.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/common/test_eigen.cpp b/test/common/test_eigen.cpp index 1106ea76f6e..1cde1b9304e 100644 --- a/test/common/test_eigen.cpp +++ b/test/common/test_eigen.cpp @@ -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); } } From 448e042c06e14f3b6f96152577777f6041e8b033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81rgio=20Agostinho?= Date: Mon, 1 Oct 2018 11:17:42 +0200 Subject: [PATCH 2/3] Always provide a normalized result in pcl::transformPlane. --- common/include/pcl/common/impl/eigen.hpp | 8 +++++++- test/common/test_eigen.cpp | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/common/include/pcl/common/impl/eigen.hpp b/common/include/pcl/common/impl/eigen.hpp index cd12e16b277..d9005cb7f60 100644 --- a/common/include/pcl/common/impl/eigen.hpp +++ b/common/include/pcl/common/impl/eigen.hpp @@ -842,6 +842,11 @@ pcl::transformPlane (const Eigen::Matrix &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 } ////////////////////////////////////////////////////////////////////////////////////////// @@ -850,7 +855,8 @@ pcl::transformPlane (const pcl::ModelCoefficients::Ptr plane_in, pcl::ModelCoefficients::Ptr plane_out, const Eigen::Transform &transformation) { - Eigen::Matrix < Scalar, 4, 1 > v_plane_in (std::vector < Scalar > (plane_in->values.begin (), plane_in->values.end ()).data ()); + std::vector 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++) diff --git a/test/common/test_eigen.cpp b/test/common/test_eigen.cpp index 1cde1b9304e..4c23361753f 100644 --- a/test/common/test_eigen.cpp +++ b/test/common/test_eigen.cpp @@ -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; From d56ce857324bc2d47962ee3708617e0af59f5415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81rgio=20Agostinho?= Date: Mon, 1 Oct 2018 11:43:01 +0200 Subject: [PATCH 3/3] Enable tests_common in AppVeyor. --- .appveyor.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 96346a83610..e65caafb92f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -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 ..