icp_svd_registration.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * @Description: ICP SVD lidar odometry
  3. * @Author: Ge Yao
  4. * @Date: 2020-10-24 21:46:57
  5. */
  6. #ifndef LIDAR_LOCALIZATION_MODELS_REGISTRATION_ICP_SVD_REGISTRATION_HPP_
  7. #define LIDAR_LOCALIZATION_MODELS_REGISTRATION_ICP_SVD_REGISTRATION_HPP_
  8. #include <yaml-cpp/yaml.h>
  9. #include <Eigen/Dense>
  10. #include <pcl/kdtree/kdtree_flann.h>
  11. class ICPSVDRegistration {
  12. public:
  13. ICPSVDRegistration(const YAML::Node& node);
  14. ICPSVDRegistration(
  15. float max_corr_dist,
  16. float trans_eps,
  17. float euc_fitness_eps,
  18. int max_iter
  19. );
  20. bool SetInputTarget(const pcl::PointCloud<pcl::PointXYZ>::Ptr& input_target);
  21. bool ScanMatch(
  22. const pcl::PointCloud<pcl::PointXYZ>::Ptr& input_source,
  23. const Eigen::Matrix4f& predict_pose,
  24. pcl::PointCloud<pcl::PointXYZ>::Ptr& result_cloud_ptr,
  25. Eigen::Matrix4f& result_pose
  26. );
  27. private:
  28. bool SetRegistrationParam(
  29. float max_corr_dist,
  30. float trans_eps,
  31. float euc_fitness_eps,
  32. int max_iter
  33. );
  34. private:
  35. size_t GetCorrespondence(
  36. const pcl::PointCloud<pcl::PointXYZ>::Ptr &input_source,
  37. std::vector<Eigen::Vector3f> &xs,
  38. std::vector<Eigen::Vector3f> &ys
  39. );
  40. void GetTransform(
  41. const std::vector<Eigen::Vector3f> &xs,
  42. const std::vector<Eigen::Vector3f> &ys,
  43. Eigen::Matrix4f &transformation
  44. );
  45. bool IsSignificant(
  46. const Eigen::Matrix4f &transformation,
  47. const float trans_eps
  48. );
  49. float max_corr_dist_;
  50. float trans_eps_;
  51. float euc_fitness_eps_;
  52. int max_iter_;
  53. pcl::PointCloud<pcl::PointXYZ>::Ptr input_target_;
  54. pcl::KdTreeFLANN<pcl::PointXYZ>::Ptr input_target_kdtree_;
  55. pcl::PointCloud<pcl::PointXYZ>::Ptr input_source_;
  56. // Eigen::Matrix4f transformation_;
  57. };
  58. #endif