car_pose_detector.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 "tool/singleton.hpp"
  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. float uniform_x = 0;
  35. float uniform_y = 0;
  36. float forward_dis = 0;
  37. bool correct = false;
  38. void reset() {
  39. wheels_center_x = 0;
  40. wheels_center_y = 0;
  41. theta = 0;
  42. width = 0;
  43. length = 0;
  44. wheel_width = 0;
  45. wheel_length = 0;
  46. front_wheels_theta = 0;
  47. wheel_base = 0;
  48. loss = 0;
  49. uniform_x = 0;
  50. uniform_y = 0;
  51. forward_dis = 0;
  52. correct = false;
  53. }
  54. std::string info() {
  55. char str[512];
  56. 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",
  57. wheels_center_x, wheels_center_y, theta * 180.0 / M_PI, width, length, wheel_width, wheel_length, front_wheels_theta * 180.0 / M_PI, wheel_base, loss);
  58. return str;
  59. }
  60. };
  61. Car_pose_detector(const Car_pose_detector &) = delete;
  62. Car_pose_detector &operator=(const Car_pose_detector &) = delete;
  63. ~Car_pose_detector() = default;
  64. // 检测底盘z方向值,去中心,使用mat加速
  65. bool
  66. detect_pose_mat(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_ptr, pcl::PointCloud<pcl::PointXYZ>::Ptr out_cloud_ptr,
  67. float &x, float &theta);
  68. private:
  69. // 父类的构造函数必须保护,子类的构造函数必须私有。
  70. Car_pose_detector();
  71. std::vector<double> line_;
  72. };
  73. #endif // !Z_DETECTOR_HH