car_pose_detector.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * @Description: 底盘z高度检测类,准确识别出平移,旋转,车宽,底盘高度,供3D车轮算法优化出车辆准确信息
  3. * @Author: yct
  4. * @Date: 2021-09-16 15:02:49
  5. * @LastEditTime: 2021-11-16 15:45:02
  6. * @LastEditors: yct
  7. */
  8. #ifndef Z_DETECTOR_HH
  9. #define Z_DETECTOR_HH
  10. #include <iostream>
  11. #include <chrono>
  12. #include <ceres/ceres.h>
  13. #include <pcl/common/common.h>
  14. #include <pcl/point_cloud.h>
  15. #include <pcl/point_types.h>
  16. #include <pcl/filters/passthrough.h>
  17. #include <pcl/filters/statistical_outlier_removal.h>
  18. #include <opencv2/opencv.hpp>
  19. #include "thread/singleton.h"
  20. class Car_pose_detector : public Singleton<Car_pose_detector> {
  21. friend class Singleton<Car_pose_detector>;
  22. public:
  23. struct CarDetectResult {
  24. float wheels_center_x = 0;
  25. float wheels_center_y = 0;
  26. float width = 0;
  27. float wheel_width = 0;
  28. float length = 0;
  29. float wheel_length = 0;
  30. float front_wheels_theta = 0;
  31. float theta = 0;
  32. float wheel_base = 0;
  33. float loss = 0;
  34. void reset() {
  35. wheels_center_x = 0;
  36. wheels_center_y = 0;
  37. theta = 0;
  38. width = 0;
  39. length = 0;
  40. wheel_width = 0;
  41. wheel_length = 0;
  42. front_wheels_theta = 0;
  43. wheel_base = 0;
  44. loss = 0;
  45. }
  46. std::string info() {
  47. char str[512];
  48. sprintf(str, "x:%0.3f y:%0.3f theta:%0.3f w:%0.3f l:%0.3f ww:%0.3f wl:%0.3f ft:%0.3f wb:%0.3f loss:%0.3f\n",
  49. wheels_center_x, wheels_center_y, theta, width, length, wheel_width, wheel_length, front_wheels_theta, wheel_base, loss);
  50. return str;
  51. }
  52. };
  53. Car_pose_detector(const Car_pose_detector &) = delete;
  54. Car_pose_detector &operator=(const Car_pose_detector &) = delete;
  55. ~Car_pose_detector() = default;
  56. // 检测底盘z方向值,去中心,使用mat加速
  57. bool
  58. detect_pose_mat(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_ptr, pcl::PointCloud<pcl::PointXYZ>::Ptr out_cloud_ptr,
  59. float &x, float &theta);
  60. private:
  61. // 父类的构造函数必须保护,子类的构造函数必须私有。
  62. Car_pose_detector();
  63. std::vector<double> line_;
  64. };
  65. #endif // !Z_DETECTOR_HH