ndt_histogram.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2010, AASS Research Center, Orebro University.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of AASS Research Center nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
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     //get the transform that brings me close to target
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     //call this to get the 1/2/3 best option, AFTER a call to bestFitToHistogram
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


ndt_map
Author(s): Todor Stoyanov, Jari Saarinen, Henrik Andreasson
autogenerated on Wed Aug 26 2015 15:24:40