registration_info.h
Go to the documentation of this file.
00001 
00064 #ifndef REGISTRATION_INFO_H_
00065 #define REGISTRATION_INFO_H_
00066 
00067 #include <pcl/common/common.h>
00068 #include <pcl/point_types.h>
00069 #include <pcl/point_cloud.h>
00070 
00071 #include <pcl/kdtree/kdtree.h>
00072 #include <pcl/filters/voxel_grid.h>
00073 #include "transf_est/tf_est_multi_cors.h"
00074 #include <pcl/registration/transformation_estimation_svd.h>
00075 #include "impl/modified_icp.hpp"
00076 
00077 namespace cob_3d_registration {
00078 
00086 template <typename Point>
00087 class Registration_Infobased : public GeneralRegistration<Point>
00088 {
00089 
00093   struct SORT_S {
00094     float dis;
00095     int ind;
00096 
00097     bool operator() (const SORT_S &i, const SORT_S &j) const { return (i.dis<j.dis);}
00098   };
00099 
00101   unsigned char *depth_map;
00102 
00104   boost::shared_ptr<const pcl::PointCloud<Point> > last_input_, last_input2_;
00105 
00107   std::vector<int> indices_pos2, indices_neg2;
00108   pcl::PointCloud<Point> source, target;
00109 
00111   pcl::PointCloud<Point> source2_, target2_;
00112 
00114   bool use_icp_;
00115 
00117   bool check_samples_;
00118 
00119   //settings
00120 
00122   float threshold_diff_, threshold_step_;
00123   int min_changes_, min_info_, max_info_;
00124 
00126   float tmax_;
00127 
00129   float rmax_;
00130 
00131   int bad_counter_;
00132 public:
00133   Registration_Infobased():
00134     depth_map(NULL), use_icp_(false),
00135     check_samples_(true),
00136     threshold_diff_(0.08), threshold_step_(0.08), min_changes_(800), min_info_(2), max_info_(16),
00137     tmax_(0.1), rmax_(0.1), bad_counter_(0),
00138     //threshold_diff_(0.06), min_changes_(4500), min_info_(1), max_info_(17), threshold_step_(0.06),
00139     //threshold_diff_(0.06), min_changes_(2600), min_info_(1), max_info_(17), threshold_step_(0.06),
00140     //threshold_diff_(0.06), min_changes_(4500), min_info_(1), max_info_(17), threshold_step_(0.06),
00141     odometry_last_(Eigen::Matrix4f::Identity()), odometry_(Eigen::Matrix4f::Identity()), failed_(0), standing_(0),
00142     use_odometry_(false), always_relevant_changes_(false), odo_is_good_(0), kinect_f_(0)
00143   {}
00144 
00145   //for freehand usage
00146   int getBadCounter() const {return bad_counter_;}
00147   void reset() {this->last_input_.reset();}
00148 
00149   void setThresholdDiff(const float f) {threshold_diff_=f;}
00150   void setThresholdStep(const float f) {threshold_step_=f;}
00151   void setMinChanges(const int f) {min_changes_=f;}
00152   void setMinInfo(const int f) {min_info_=f;}
00153   void setMaxInfo(const int f) {max_info_=f;}
00154   void setMaxAngularDistance(const float f) {rmax_=f;}
00155   void setMaxTranslationDistance(const float f) {tmax_=f;}
00157   void setCheckBySamples(const bool b) {check_samples_=b;} 
00158 
00159   void setUseICP(const bool b) {use_icp_=b;}
00160 
00162   void setKinectParameters(const float f, const float dx, const float dy) {
00163     kinect_f_=f;
00164     kinect_dx_=dx;
00165     kinect_dy_=dy;
00166   }
00167 
00169   void getClouds(pcl::PointCloud<Point> &tmp_pc_old, pcl::PointCloud<Point> &tmp_pc_new);
00170 
00171   virtual ~Registration_Infobased() {
00172     delete [] depth_map;
00173   }
00174 
00175   virtual boost::shared_ptr<pcl::PointCloud<Point> > getMap() {return register_.makeShared();}
00176 
00178   pcl::PointCloud<Point> getLastInput() {return *this->last_input_;}
00180   pcl::PointCloud<Point> getLastInput2() {return *this->last_input2_;}
00181   //debug HIRN-Points (activate DEBUG-Switch)
00182   pcl::PointCloud<Point> &getSource() {return source2_;}
00183   //debug HIRN-Points (activate DEBUG-Switch)
00184   pcl::PointCloud<Point> &getTarget() {return target2_;}
00185   virtual boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZRGB> > getMarkers2() {return this->markers_.makeShared();}
00186 
00188   virtual void setOdometry (const Eigen::Matrix4f &odometry) {
00189     odometry_ = odometry;
00190     if(!use_odometry_) {
00191       odometry_last_ = odometry_;
00192       use_odometry_=true;
00193     }
00194   }
00195 
00196   virtual bool compute() {
00197     if(!compute_features()) {
00198       bad_counter_=0;
00199       return false;
00200     }
00201     if(!compute_transformation())
00202       return false;
00203     bad_counter_=0;
00204     return true;
00205   }
00206 
00208   void SetAlwaysRelevantChanges(const bool b) {always_relevant_changes_=b;}
00209 
00210   virtual void setTransformation(const Eigen::Matrix4f &mat) {this->transformation_=mat;this->odometry_last_=Eigen::Matrix4f::Identity();this->odometry_=Eigen::Matrix4f::Identity();}
00211 
00212 private:
00213   pcl::PointCloud<Point> register_;
00214   pcl::PointCloud<pcl::PointXYZRGB> markers_;
00215   Eigen::Matrix4f odometry_last_, odometry_;
00216   int failed_, standing_;
00217   bool use_odometry_, always_relevant_changes_, odo_is_good_;
00218   float kinect_f_, kinect_dx_, kinect_dy_;
00219 
00220   virtual bool compute_features();
00221   virtual bool compute_corrospondences();
00222   virtual bool compute_transformation();
00223 
00224   void reproject();
00225   void getKinectParameters();
00226   bool checkSamples(const Eigen::Matrix4f &T, int *bad_out=NULL);
00227 
00228   inline float getMaxDiff2(const pcl::PointCloud<Point> &pc,const int ind,const pcl::PointCloud<Point> &pc2, int &mi);
00229   inline float getMaxDiff(const pcl::PointCloud<Point> &pc,const int ind);
00230   inline int getI(const int ind, const pcl::PointCloud<Point> &pc);
00231 };
00232 
00233 typedef Registration_Infobased<pcl::PointXYZ> Registration_HIRN_XYZ;
00234 
00235 }
00236 
00237 
00238 #endif /* REGISTRATION_INFO_H_ */


cob_3d_registration
Author(s): Joshua Hampp
autogenerated on Wed Aug 26 2015 11:02:36