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 
00035 #ifndef NDT_HISTOGRAM_HH
00036 #define NDT_HISTOGRAM_HH
00037 
00038 #include <ndt_map/ndt_map.h>
00039 #include <vector>
00040 
00041 namespace lslgeneric{
00042   class NDTHistogram{
00043   private:
00044     std::vector<int> histogramBinsFlat;
00045     std::vector<int> histogramBinsLine;
00046     std::vector<int> histogramBinsSphere;
00047     
00048     int N_LINE_BINS;
00049     int N_FLAT_BINS;
00050     int N_SPHERE_BINS;
00051     double D1, D2;
00052     bool inited;
00053 
00054     std::vector< Eigen::Transform<double,3,Eigen::Affine,Eigen::ColMajor>,Eigen::aligned_allocator<Eigen::Transform<double,3,Eigen::Affine,Eigen::ColMajor> > > topThree;
00055     double topThreeS[3];
00056 
00057     std::vector<int> dist_histogramBinsFlat[3];
00058     std::vector<int> dist_histogramBinsLine[3];
00059     std::vector<int> dist_histogramBinsSphere[3];
00060 
00061     std::vector<Eigen::Vector3d,Eigen::aligned_allocator<Eigen::Vector3d> > averageDirections;
00062     void constructHistogram(NDTMap &map);
00063     void incrementLineBin(double d);
00064     void incrementFlatBin(Eigen::Vector3d &normal, double d);
00065     void incrementSphereBin(double d);
00066 
00067     void computeDirections();
00068     void closedFormSolution(pcl::PointCloud<pcl::PointXYZ> &src, pcl::PointCloud<pcl::PointXYZ> &trgt,Eigen::Transform<double,3,Eigen::Affine,Eigen::ColMajor> &T);
00069   public:
00070     NDTHistogram();
00071     NDTHistogram (NDTMap &map);
00072     NDTHistogram (const NDTHistogram& other);
00073     
00074     
00075     void bestFitToHistogram(NDTHistogram &target, Eigen::Transform<double,3,Eigen::Affine,Eigen::ColMajor> &T, bool bound_transform = true);
00076     void printHistogram(bool bMatlab=false);
00077 
00078     
00079     double getTransform(size_t FIT_NUMBER, Eigen::Transform<double,3,Eigen::Affine,Eigen::ColMajor> &T){
00080       double ret = -1;
00081       T.setIdentity();
00082       if(FIT_NUMBER >=0 && FIT_NUMBER<3){
00083         T = topThree[FIT_NUMBER];
00084         ret = topThreeS[FIT_NUMBER];
00085       }
00086       return ret;
00087     }
00088 
00089     pcl::PointCloud<pcl::PointXYZ> getDominantDirections(int nDirections);
00090     double getSimilarity(NDTHistogram &other);
00091     double getSimilarity(NDTHistogram &other, Eigen::Transform<double,3,Eigen::Affine,Eigen::ColMajor> &T);
00092 
00093     std::vector<Eigen::Vector3d,Eigen::aligned_allocator<Eigen::Vector3d> > directions;
00094   public:
00095     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00096       };
00097 }
00098 #endif