ground_region.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // Created by zx on 2021/5/20.
  3. //
  4. #ifndef LIDARMEASURE__GROUD_REGION_HPP_
  5. #define LIDARMEASURE__GROUD_REGION_HPP_
  6. #include "error_code.h"
  7. #include "detect_wheel_ceres.h"
  8. #include "configure.pb.h"
  9. #include "vlp16.hpp"
  10. #include <glog/logging.h>
  11. #include <google/protobuf/io/zero_copy_stream_impl.h>
  12. #include <google/protobuf/text_format.h>
  13. #include "thread_condition.h"
  14. using google::protobuf::io::FileInputStream;
  15. using google::protobuf::io::FileOutputStream;
  16. using google::protobuf::io::ZeroCopyInputStream;
  17. using google::protobuf::io::CodedInputStream;
  18. using google::protobuf::io::ZeroCopyOutputStream;
  19. using google::protobuf::io::CodedOutputStream;
  20. using google::protobuf::Message;
  21. #include <pcl/point_types.h>
  22. #include <pcl/point_cloud.h>
  23. #include "ground_measure_msg.pb.h"
  24. class Ground_region
  25. {
  26. public:
  27. Ground_region();
  28. ~Ground_region();
  29. Error_manager init(std::string configure_file);
  30. Error_manager init(ground_region::Configure configure);
  31. Error_manager detect(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud,const ground_region::Box& box,
  32. detect_wheel_ceres::Detect_result& result);
  33. private:
  34. bool read_proto_param(std::string file, ::google::protobuf::Message& parameter);
  35. Error_manager sync_capture(std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr>& cloud,double timeout_second=1.0);
  36. pcl::PointCloud<pcl::PointXYZ>::Ptr scans2cloud(const velodyne::Frame& frame,const ground_region::Calib_parameter& calib);
  37. //预处理点云, 并并判断雷达状态
  38. Error_manager prehandle_cloud(std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr>& clouds,
  39. message::Ground_measure_statu_msg& msg);
  40. bool classify_ceres_detect(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud,double thresh_z,
  41. detect_wheel_ceres::Detect_result& result);
  42. static void thread_measure_func(Ground_region* p);
  43. std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> segmentation(pcl::PointCloud<pcl::PointXYZ>::Ptr sor_cloud);
  44. double distance(cv::Point2f p1, cv::Point2f p2);
  45. bool isRect(std::vector<cv::Point2f>& points);
  46. private:
  47. std::vector<velodyne::VLP16Capture*> m_lidars;
  48. ground_region::Configure m_configure;
  49. std::thread* m_running_thread;
  50. Thread_condition m_exit_condition;
  51. detect_wheel_ceres m_detector;
  52. };
  53. #endif //LIDARMEASURE__GROUD_REGION_HPP_