rotate_center_caliber.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //
  2. // Created by zx on 2021/8/27.
  3. //
  4. #ifndef ROTATE_CANTER_CALIBER_HH
  5. #define ROTATE_CANTER_CALIBER_HH
  6. #include <pcl/point_types.h>
  7. #include <pcl/point_cloud.h>
  8. #include <pcl/io/pcd_io.h>
  9. #include "../velodyne_lidar/match3d/detect_ceres3d.h"
  10. #include <vector>
  11. #include "../tool/singleton.h"
  12. class rotate_center_caliber:public Singleton<rotate_center_caliber>
  13. {
  14. typedef struct
  15. {
  16. float theta;
  17. float dx;
  18. float dy;
  19. }match_transform;
  20. // 子类必须把父类设定为友元函数,这样父类才能使用子类的私有构造函数。
  21. friend class Singleton<rotate_center_caliber>;
  22. public:
  23. // 必须关闭拷贝构造和赋值构造,只能通过 get_instance 函数来进行操作唯一的实例。
  24. rotate_center_caliber(const rotate_center_caliber&)=delete;
  25. rotate_center_caliber& operator =(const rotate_center_caliber&)= delete;
  26. ~rotate_center_caliber()=default;
  27. void rotate_center_caliber_init();
  28. void rotate_center_caliber_uninit();
  29. void set_first_frame(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_model);
  30. bool push_cloud(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud);
  31. static Eigen::Matrix4f match(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_center, pcl::PointCloud<pcl::PointXYZ>::Ptr cloud, Eigen::Matrix<float, 6, 1> init_transform);
  32. protected:
  33. bool solve();
  34. void updata_points();
  35. private:
  36. // 父类的构造函数必须保护,子类的构造函数必须私有。
  37. rotate_center_caliber()=default;
  38. protected:
  39. pcl::PointCloud<pcl::PointXYZ>::Ptr m_model_cloud;
  40. std::vector<match_transform> m_match_datas;
  41. detect_ceres3d* mp_matcher;
  42. //待解算的参数, 原点中心坐标和旋转中心坐标
  43. pcl::PointXYZ m_center;
  44. float m_rotation_center_x;
  45. float m_rotation_center_y;
  46. };
  47. #endif //ROTATE_CANTER_CALIBER_HH