wheel_detector.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #pragma once
  2. #include "thread/singleton.h"
  3. #include <pcl/point_cloud.h>
  4. #include <pcl/point_types.h>
  5. #include <pcl/filters/passthrough.h>
  6. #include <pcl/filters/statistical_outlier_removal.h>
  7. class singleWheelDetector : public Singleton<singleWheelDetector> {
  8. friend class Singleton<singleWheelDetector>;
  9. public:
  10. struct WheelDetectResult {
  11. bool haveCloud = false;
  12. bool segmentOk = false;
  13. bool detectOk = false;
  14. pcl::PointXYZ center;
  15. float confidence = 0;
  16. float theta = 0;
  17. void reset() {
  18. haveCloud = false;
  19. segmentOk = false;
  20. detectOk = false;
  21. center.x = 0;
  22. center.y = 0;
  23. center.z = 0;
  24. confidence = 0;
  25. theta = 0;
  26. }
  27. std::string info() {
  28. char str[512];
  29. sprintf(str, "x: %.3f, y: %.3f, z: %.3f, theta: %.3f", center.x, center.y, center.z, theta);
  30. return str;
  31. }
  32. };
  33. singleWheelDetector &operator=(const singleWheelDetector &) = delete;
  34. ~singleWheelDetector() override = default;
  35. // 检测底盘z方向值,去中心,使用mat加速
  36. bool detect(pcl::PointCloud<pcl::PointXYZ>::Ptr in_cloud_ptr, pcl::PointCloud<pcl::PointXYZ>::Ptr out_cloud_ptr,
  37. WheelDetectResult &result);
  38. protected:
  39. // 父类的构造函数必须保护,子类的构造函数必须私有。
  40. singleWheelDetector();
  41. private:
  42. std::vector<double> line_;
  43. };