00001 #include "../utest.h"
00002
00003 using namespace std;
00004 using namespace PointMatcherSupport;
00005
00006
00007
00008
00009
00010
00011
00012 class TransformationCheckerTest: public IcpHelper
00013 {
00014 public:
00015 std::shared_ptr<PM::TransformationChecker> transformCheck;
00016
00017
00018 virtual void SetUp()
00019 {
00020 icp.setDefault();
00021
00022
00023
00024 icp.transformationCheckers.clear();
00025 }
00026
00027
00028 virtual void TearDown(){}
00029
00030 void addFilter(string name, PM::Parameters params)
00031 {
00032 transformCheck =
00033 PM::get().TransformationCheckerRegistrar.create(name, params);
00034
00035 icp.transformationCheckers.push_back(transformCheck);
00036 }
00037 };
00038
00039
00040 TEST_F(TransformationCheckerTest, CounterTransformationChecker)
00041 {
00042 addFilter("CounterTransformationChecker", {{"maxIterationCount", toParam(20)}});
00043 validate2dTransformation();
00044 }
00045
00046 TEST_F(TransformationCheckerTest, DifferentialTransformationChecker)
00047 {
00048 addFilter("DifferentialTransformationChecker", {
00049 {"minDiffRotErr", toParam(0.001)},
00050 {"minDiffTransErr", toParam(0.001)},
00051 {"smoothLength", toParam(4)}
00052 }
00053 );
00054 validate2dTransformation();
00055 }
00056
00057 TEST_F(TransformationCheckerTest, BoundTransformationChecker)
00058 {
00059
00060
00061
00062 std::shared_ptr<PM::TransformationChecker> extraTransformCheck;
00063
00064 extraTransformCheck = PM::get().TransformationCheckerRegistrar.create(
00065 "CounterTransformationChecker"
00066 );
00067 icp.transformationCheckers.push_back(extraTransformCheck);
00068
00069 addFilter("BoundTransformationChecker", {
00070 {"maxRotationNorm", toParam(1.0)},
00071 {"maxTranslationNorm", toParam(1.0)}
00072 }
00073 );
00074 validate2dTransformation();
00075 }
00076
00077
00078
00079
00080 TEST(Transformation, RigidTransformation)
00081 {
00082 std::shared_ptr<PM::Transformation> rigidTrans;
00083 rigidTrans = PM::get().REG(Transformation).create("RigidTransformation");
00084
00085
00086
00087 PM::Matrix T_3D = PM::Matrix::Identity(4,4);
00088
00089
00090 T_3D << 0.99935116, 0.13669771, 0.03436585, 1.71138524,
00091 -0.02633967, 0.99326295, -0.04907545, -0.10860933,
00092 -0.03615132, 0.04400287, 0.99820427, -0.04454497,
00093 0. , 0. , 0. , 1.;
00094
00095 EXPECT_FALSE(rigidTrans->checkParameters(T_3D));
00096
00097 EXPECT_THROW(rigidTrans->compute(data3D, T_3D), TransformationError);
00098
00099
00100 for(int i = 0; i < 10; i++)
00101 {
00102 T_3D = rigidTrans->correctParameters(T_3D);
00103 ASSERT_TRUE(rigidTrans->checkParameters(T_3D));
00104 }
00105
00106
00107
00108 PM::Matrix T_2D_non_ortho = PM::Matrix::Identity(3,3);
00109 T_2D_non_ortho(0,0) = 0.8;
00110 T_2D_non_ortho(0,1) = -0.5;
00111 T_2D_non_ortho(1,0) = 0.5;
00112 T_2D_non_ortho(1,1) = 0.8;
00113
00114 EXPECT_FALSE(rigidTrans->checkParameters(T_2D_non_ortho));
00115
00116 EXPECT_THROW(rigidTrans->compute(data2D, T_2D_non_ortho), TransformationError);
00117
00118
00119 for(int i = 0; i < 10; i++)
00120 {
00121 T_2D_non_ortho = rigidTrans->correctParameters(T_2D_non_ortho);
00122 EXPECT_TRUE(rigidTrans->checkParameters(T_2D_non_ortho));
00123 }
00124
00125
00126
00127 PM::Matrix T_2D_reflection = PM::Matrix::Identity(3,3);
00128 T_2D_reflection(1,1) = -1;
00129
00130 EXPECT_THROW(rigidTrans->correctParameters(T_2D_reflection), TransformationError);
00131 }