Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00036
00037
00038 #include "probabilistic_grasp_planner/distribution_evaluator.h"
00039 #include "probabilistic_grasp_planner/probabilistic_planner_tools.h"
00040
00041 #include <gtest/gtest.h>
00042
00043
00044 TEST(DistributionEvaluator, testUniformDistribution)
00045 {
00046 probabilistic_grasp_planner::UniformDistributionEvaluator evaluator;
00047
00048 probabilistic_grasp_planner::GraspWithMetadata grasp;
00049 EXPECT_DOUBLE_EQ(evaluator.get_normalization_term(),0);
00050 double res = evaluator.evaluate(grasp,grasp);
00051 EXPECT_DOUBLE_EQ(res, 1.0);
00052
00053 }
00054
00055
00056
00057 TEST(DistributionEvaluator, testNormalDistribution)
00058 {
00059 double position_sigma = 0.01;
00060 double orientation_concentration = 10.0;
00061
00062 probabilistic_grasp_planner::NormalDistributionEvaluator evaluator2(position_sigma, orientation_concentration);
00063 EXPECT_DOUBLE_EQ(evaluator2.get_normalization_term(),0);
00064
00065 probabilistic_grasp_planner::GraspWithMetadata gstar;
00066 gstar.tool_point_pose_.setIdentity();
00067
00068 probabilistic_grasp_planner::GraspWithMetadata grasp1;
00069 grasp1.tool_point_pose_.setIdentity();
00070 grasp1.tool_point_pose_.setOrigin(tf::Vector3(0.01,0,0));
00071
00072 double res = evaluator2.evaluate(gstar,grasp1);
00073 EXPECT_DOUBLE_EQ(res, 0.60653065971263342);
00074
00075 probabilistic_grasp_planner::GraspWithMetadata grasp2;
00076 grasp2.tool_point_pose_.setIdentity();
00077 grasp2.tool_point_pose_.setOrigin(tf::Vector3(0.01,0.01,0));
00078 res = evaluator2.evaluate(gstar,grasp2);
00079 EXPECT_DOUBLE_EQ(res, 0.36787944117144233);
00080
00081 probabilistic_grasp_planner::GraspWithMetadata grasp3;
00082 grasp3.tool_point_pose_.setIdentity();
00083 tf::Matrix3x3 basis;
00084 basis.setEulerYPR(0.0,0.0,0.0);
00085 grasp3.tool_point_pose_.setBasis(basis);
00086 res = evaluator2.evaluate(gstar,grasp3);
00087 EXPECT_DOUBLE_EQ(res, 1.0);
00088
00089 basis.setEulerYPR(0.0,0.0,M_PI_4);
00090 grasp3.tool_point_pose_.setBasis(basis);
00091 res = evaluator2.evaluate(gstar,grasp3);
00092 EXPECT_DOUBLE_EQ(res, 0.23120139832879863);
00093
00094 }
00095
00096
00097
00098
00099 int main(int argc, char **argv)
00100 {
00101 testing::InitGoogleTest(&argc, argv);
00102 return RUN_ALL_TESTS();
00103 }