Go to the documentation of this file.00001 #include <ndt_map/ndt_histogram.h>
00002
00003 #include <ndt_map/pointcloud_utils.h>
00004 #include <ndt_map/lazy_grid.h>
00005
00006 #include "pcl/point_cloud.h"
00007 #include "sensor_msgs/PointCloud2.h"
00008 #include "pcl/io/pcd_io.h"
00009 #include "pcl/features/feature.h"
00010 #include <cstdio>
00011
00012 #include <fstream>
00013
00014
00015
00016 using namespace std;
00017
00018 int main (int argc, char** argv) {
00019
00020 if(argc!=3){
00021 cout<<"usage: histTest point_cloud1 point_cloud2\n";
00022 return(-1);
00023 }
00024 pcl::PointCloud<pcl::PointXYZ> cloud, cloud2, cloud3;
00025 pcl::PointCloud<pcl::PointXYZI> outCloud;
00026
00027
00028
00029
00030 lslgeneric::LazyGrid tr(0.5);
00031
00032 #ifdef FULLTESTER
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 #else
00073
00074 pcl::io::loadPCDFile<pcl::PointXYZ> (argv[1], cloud);
00075 pcl::io::loadPCDFile<pcl::PointXYZ> (argv[2], cloud2);
00076
00077 lslgeneric::NDTMap nd(&tr);
00078 nd.loadPointCloud(cloud);
00079
00080 lslgeneric::NDTMap nd2(&tr);
00081 nd2.loadPointCloud(cloud2);
00082
00083 nd.computeNDTCells();
00084 nd2.computeNDTCells();
00085
00086 lslgeneric::NDTHistogram nh(nd);
00087 lslgeneric::NDTHistogram nh2(nd2);
00088 cout<<"1 =========== \n";
00089 nh.printHistogram(true);
00090 cout<<"2 =========== \n";
00091 nh2.printHistogram(true);
00092
00093 Eigen::Transform<double,3,Eigen::Affine,Eigen::ColMajor> T;
00094
00095 nh2.bestFitToHistogram(nh,T,true);
00096 cout<<" ==================== \n Transform R "<<T.rotation()<<"\nt "<<T.translation().transpose()<<endl;
00097
00098 cout<<"scan similarity is "<<nh2.getSimilarity(nh)<<endl;
00099 cloud3 = lslgeneric::transformPointCloud(T,cloud2);
00100
00101 lslgeneric::NDTMap nd3(&tr);
00102 nd3.loadPointCloud(cloud3);
00103 nd3.computeNDTCells();
00104
00105 lslgeneric::NDTHistogram nh3(nd3);
00106 cout<<"3 =========== \n";
00107 nh3.printHistogram(true);
00108
00109
00110 char fname[50];
00111
00112 std::vector<Eigen::Vector3d,Eigen::aligned_allocator<Eigen::Vector3d> > directions = nh.directions;
00113 cout<<"direction = [";
00114 for(int i=0; i<directions.size(); i++)
00115 {
00116 cout<<directions[i].transpose()<<";";
00117 }
00118 cout<<"];\n";
00119 #endif
00120
00121
00122
00123 return (0);
00124 }
00125
00126
00127