Transformations.cpp
Go to the documentation of this file.
00001 #include "../utest.h"
00002 
00003 using namespace std;
00004 using namespace PointMatcherSupport;
00005 
00006 
00007 //---------------------------
00008 // Transformation Checker modules
00009 //---------------------------
00010 
00011 // Utility classes
00012 class TransformationCheckerTest: public IcpHelper
00013 {
00014 public:
00015         PM::TransformationChecker* transformCheck;
00016 
00017         // Will be called for every tests
00018         virtual void SetUp()
00019         {
00020                 icp.setDefault();
00021                 // Uncomment for consol outputs
00022                 //setLogger(PM::get().LoggerRegistrar.create("FileLogger"));
00023                 
00024                 icp.transformationCheckers.clear();
00025         }
00026 
00027         // Will be called for every tests
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", map_list_of ("maxIterationCount", toParam(20)) );
00043         validate2dTransformation();
00044 }
00045 
00046 TEST_F(TransformationCheckerTest, DifferentialTransformationChecker)
00047 {
00048         addFilter("DifferentialTransformationChecker", map_list_of
00049                 ("minDiffRotErr", toParam(0.001))
00050                 ("minDiffTransErr", toParam(0.001))
00051                 ("smoothLength", toParam(4))
00052         );
00053         validate2dTransformation();
00054 }
00055 
00056 TEST_F(TransformationCheckerTest, BoundTransformationChecker)
00057 {
00058         // Since that transChecker is trigger when the distance is growing
00059         // and that we do not expect that to happen in the test dataset, we
00060         // keep the Counter to get out of the looop     
00061         PM::TransformationChecker* extraTransformCheck;
00062         
00063         extraTransformCheck = PM::get().TransformationCheckerRegistrar.create(
00064                 "CounterTransformationChecker"
00065         );
00066         icp.transformationCheckers.push_back(extraTransformCheck);
00067         
00068         addFilter("BoundTransformationChecker", map_list_of
00069                 ("maxRotationNorm", toParam(1.0))
00070                 ("maxTranslationNorm", toParam(1.0))
00071         );
00072         validate2dTransformation();
00073 }
00074 
00075 //---------------------------
00076 // Transformation
00077 //---------------------------
00078 TEST(Transformation, RigidTransformation)
00079 {
00080         PM::Transformation* rigidTrans;
00081         rigidTrans = PM::get().REG(Transformation).create("RigidTransformation");
00082 
00083         //-------------------------------------
00084         // Construct a 3D non-orthogonal matrix
00085         PM::Matrix T_3D = PM::Matrix::Identity(4,4);
00086         T_3D(0,0) = 2.3;
00087         T_3D(0,1) = 0.03;
00088 
00089         EXPECT_FALSE(rigidTrans->checkParameters(T_3D));
00090 
00091         EXPECT_THROW(rigidTrans->compute(data3D, T_3D), TransformationError);
00092 
00093         // Check stability over iterations
00094         for(int i = 0; i < 10; i++)
00095         {
00096                 T_3D = rigidTrans->correctParameters(T_3D);
00097                 EXPECT_TRUE(rigidTrans->checkParameters(T_3D));
00098         }
00099 
00100         //-------------------------------------
00101         // Construct a 2D non-orthogonal matrix
00102         PM::Matrix T_2D = PM::Matrix::Identity(3,3);
00103         T_2D(1,0) = 8.99;
00104         T_2D(0,1) = 4.03;
00105 
00106         EXPECT_FALSE(rigidTrans->checkParameters(T_2D));
00107 
00108         EXPECT_THROW(rigidTrans->compute(data2D, T_2D), TransformationError);
00109 
00110         // Check stability over iterations
00111         for(int i = 0; i < 10; i++)
00112         {
00113                 T_2D = rigidTrans->correctParameters(T_2D);
00114                 EXPECT_TRUE(rigidTrans->checkParameters(T_2D));
00115         }
00116 
00117 }


upstream_src
Author(s):
autogenerated on Mon Oct 6 2014 10:27:42