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
00035
00036
00037 #include <tf/transform_datatypes.h>
00038
00039
00040
00041
00042 #include <Eigen/Core>
00043
00044 #include <Eigen/LU>
00045
00046 #include "probabilistic_grasp_planner/probabilistic_planner_tools.h"
00047 #include "probabilistic_grasp_planner/distribution_evaluator.h"
00048
00049 using namespace Eigen;
00050
00051 namespace probabilistic_grasp_planner {
00052
00056 double NormalDistributionEvaluator::evaluate_position(const GraspWithMetadata &gstar,const GraspWithMetadata &grasp)
00057 {
00058
00059 Vector3d mean(gstar.tool_point_pose_.getOrigin().m_floats);
00060 Vector3d x(grasp.tool_point_pose_.getOrigin().m_floats);
00061 Vector3d delta(x-mean);
00062 Matrix3d covariance = Matrix3d::Zero();
00063 covariance(0,0) = covariance(1,1) = covariance(2,2) = pow(position_sigma_,2);
00064
00065 double ex = exp(-0.5*(delta.transpose() * covariance.inverse() * delta)(0,0));
00066
00067 return ex;
00068 }
00069
00073 double NormalDistributionEvaluator::evaluate_orientation(const GraspWithMetadata &gstar,const GraspWithMetadata &grasp)
00074 {
00075 double cos_angle = gstar.tool_point_pose_.getRotation().dot(grasp.tool_point_pose_.getRotation());
00076 double ex = exp(orientation_concentration_ * pow(cos_angle,2));
00077 double normalization = exp(orientation_concentration_);
00078 return ex / normalization;
00079 }
00080
00081 double NormalDistributionEvaluator::evaluate(const GraspWithMetadata &gstar,const GraspWithMetadata &grasp)
00082 {
00083 double value =evaluate_position(gstar, grasp)*evaluate_orientation(gstar, grasp);
00084 normalization_term_ += value;
00085 return value;
00086 }
00087
00088 double PolarNormalDistributionEvaluator::evaluate(const GraspWithMetadata &gstar,const GraspWithMetadata &grasp)
00089 {
00090 double m_r = 0.0;
00091 double position_stddev = 0.01;
00092 double m_theta = 0.0;
00093 double orientation_stddev = 0.174;
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 double cartesian_distance = 0;
00104 double rotation_distance = 0;
00105 gstar.getDistance(grasp,cartesian_distance, rotation_distance);
00106
00107 double p_position = exp(-pow((cartesian_distance-m_r),2)/(2*pow(position_stddev,2)));
00108
00109 double p_orientation = exp(-pow((rotation_distance-m_theta),2)/(2*pow(orientation_stddev,2)));
00110
00111 double pose_probability = p_position*p_orientation;
00112
00113 normalization_term_ += pose_probability;
00114 return pose_probability;
00115 }
00116
00117 }