measuretask.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef MEASURETASK_H
  2. #define MEASURETASK_H
  3. #include "common.h"
  4. #include "TaskQueue/BaseTask.h"
  5. #include "laser/Laser.h"
  6. #include "modbus/PLCMonitor.h"
  7. #ifndef PI
  8. #define PI 3.14159265
  9. #endif
  10. enum ERROR_CODE
  11. {
  12. eSucc=0
  13. ,eArea //车位区域错误
  14. ,eLidar //雷达点云不重合
  15. ,eCloud //点云为空
  16. ,eNoCar //未检测到车
  17. ,eMulCar //多辆车
  18. ,eDistance //车间距过小
  19. ,eLimitL=101
  20. ,eLimitT
  21. ,eLimitR
  22. ,eLimitB
  23. };
  24. typedef struct stCarPosition
  25. {
  26. float x;
  27. float y;
  28. float a;
  29. float l;
  30. float w;
  31. float h;
  32. ERROR_CODE error_code;
  33. cv::RotatedRect rrect;
  34. int pos_id; //车位ID
  35. stCarPosition()
  36. {
  37. error_code = eSucc;
  38. pos_id = -1;
  39. }
  40. }CarPosition;
  41. std::string Error_string(ERROR_CODE code);
  42. bool RegionInRegion(std::vector<cv::Point2f>& mini_poly, std::vector<cv::Point2f>& large_poly);
  43. double distance_polys(std::vector<cv::Point2f> poly1, std::vector<cv::Point2f> poly2);
  44. typedef void(*ResultCallback)(QtMessageData msg, void*);
  45. class MeasureTask : public tq::BaseTask
  46. {
  47. public:
  48. MeasureTask(std::vector<CLaser*> lasers,int position_id,
  49. modbus::CPLCMonitor* pcl, Automatic::stCalibParam param);
  50. virtual void Main();
  51. virtual void Cancel();
  52. void SetResultCallback(void* ptr,ResultCallback func = NULL);
  53. protected:
  54. static void PushPoint(CPoint3D point, void* pointer);
  55. bool IsLaserReady();
  56. ERROR_CODE SelectResult(int plate_index, std::vector<CarPosition> results, CarPosition& result);
  57. //žùŸÝ³µÁŸÎ»Ö÷ÖÅ䳵λID, ²»ÔÚ³µÎ»µÄ³µÁŸÐÅϢɟ³ý
  58. ERROR_CODE Dispatch_posID(std::vector<CarPosition>& results);
  59. protected:
  60. std::vector<CLaser*> m_lasers;
  61. modbus::CPLCMonitor* m_plc;
  62. int m_position_id; //³µÎ»id
  63. Automatic::stCalibParam m_calib_param; //ÓÐÐ§ÇøÓò
  64. PointCloudT m_cloud;
  65. mutable std::mutex m_mutex;
  66. static std::mutex* g_mutex;
  67. bool m_exit;
  68. ResultCallback m_post_result_func;
  69. void* m_ptr;
  70. };
  71. #endif // MEASURETASK_H