Go to the documentation of this file.00001 #ifndef NDT_FUSER_HH
00002 #define NDT_FUSER_HH
00003 #ifndef NO_NDT_VIZ
00004 #include <ndt_visualisation/ndt_viz.h>
00005 #endif
00006 #include <ndt_map/ndt_map.h>
00007 #include <ndt_registration/ndt_matcher_d2d_2d.h>
00008 #include <ndt_registration/ndt_matcher_d2d.h>
00009 #include <ndt_map/pointcloud_utils.h>
00010
00011 #include <Eigen/Eigen>
00012 #include <pcl/point_cloud.h>
00013 #include <sys/time.h>
00014
00015 namespace lslgeneric {
00021 class NDTFuser{
00022 public:
00023 Eigen::Affine3d Tnow, Tlast_fuse;
00024 lslgeneric::NDTMap *map;
00025 bool checkConsistency;
00026 double max_translation_norm, max_rotation_norm;
00027 double sensor_range;
00028 bool be2D;
00029 #ifndef NO_NDT_VIZ
00030 NDTViz *viewer;
00031 #endif
00032 NDTFuser(double map_resolution, double map_size_x_, double map_size_y_, double map_size_z_, double sensor_range_ = 3, bool visualize_=false, bool be2D_=false){
00033 isInit = false;
00034 resolution = map_resolution;
00035 sensor_pose.setIdentity();
00036 checkConsistency = false;
00037 visualize = true;
00038 translation_fuse_delta = 0.05;
00039 rotation_fuse_delta = 0.01;
00040 max_translation_norm = 1.;
00041 max_rotation_norm = M_PI/4;
00042 map_size_x = map_size_x_;
00043 map_size_y = map_size_y_;
00044 map_size_z = map_size_z_;
00045 visualize = visualize_;
00046 be2D = be2D_;
00047 sensor_range = sensor_range_;
00048 #ifndef NO_NDT_VIZ
00049 viewer = new NDTViz(visualize);
00050 #endif
00051 std::cout<<"MAP: resolution: "<<resolution<<" size "<<map_size_x<<" "<<map_size_y<<" "<<map_size_z<<std::endl;
00052 map = new lslgeneric::NDTMap(new lslgeneric::LazyGrid(resolution));
00053 }
00054 ~NDTFuser()
00055 {
00056 delete map;
00057 #ifndef NO_NDT_VIZ
00058 delete viewer;
00059 #endif
00060 }
00061
00062 double getDoubleTime()
00063 {
00064 struct timeval time;
00065 gettimeofday(&time,NULL);
00066 return time.tv_sec + time.tv_usec * 1e-6;
00067 }
00068 void setSensorPose(Eigen::Affine3d spose){
00069 sensor_pose = spose;
00070 }
00071
00072 bool wasInit()
00073 {
00074 return isInit;
00075 }
00076
00080 void initialize(Eigen::Affine3d initPos, pcl::PointCloud<pcl::PointXYZ> &cloud);
00085 Eigen::Affine3d update(Eigen::Affine3d Tmotion, pcl::PointCloud<pcl::PointXYZ> &cloud);
00086
00087 private:
00088 bool isInit;
00089
00090 double resolution;
00091 double map_size;
00092
00093 double translation_fuse_delta, rotation_fuse_delta;
00094 double map_size_x;
00095 double map_size_y;
00096 double map_size_z;
00097 bool visualize;
00098
00099 Eigen::Affine3d sensor_pose;
00100 lslgeneric::NDTMatcherD2D matcher;
00101 lslgeneric::NDTMatcherD2D_2D matcher2D;
00102
00103 public:
00104 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00105
00106 };
00107 }
00108 #endif