wj_lidar_task.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef WJ_LIDAR_TASK_HH
  2. #define WJ_LIDAR_TASK_HH
  3. #include <string.h>
  4. #include <mutex>
  5. #include <atomic>
  6. #include <chrono>
  7. #include "pcl/point_cloud.h"
  8. #include "pcl/point_types.h"
  9. #include "../task/task_command_manager.h"
  10. #include "../error_code/error_code.h"
  11. // 万集测量结果结构体
  12. typedef struct WJ_LIDAR_MEASURE_RESULT
  13. {
  14. int terminal_id;
  15. float x;
  16. float y;
  17. float angle;
  18. float length;
  19. float width;
  20. float height;
  21. float wheel_base;
  22. bool correctness;
  23. } wj_measure_result;
  24. typedef struct WJ_LIDAR_COMMAND_INFO
  25. {
  26. int terminal_id;
  27. std::chrono::steady_clock::time_point command_time;
  28. int timeout_in_milliseconds;
  29. } wj_command;
  30. /**
  31. * 万集测量任务单
  32. * */
  33. class Wj_lidar_Task : public Task_Base
  34. {
  35. public:
  36. // 父类继承,初始化函数
  37. virtual Error_manager init();
  38. // 构造函数
  39. Wj_lidar_Task();
  40. // 析构
  41. ~Wj_lidar_Task();
  42. // 获取命令
  43. Error_manager get_command(wj_command &command);
  44. // 设置测量命令
  45. Error_manager set_command(wj_command command);
  46. // 将测量结果存入该任务单
  47. Error_manager set_result(wj_measure_result result);
  48. // 将测量结果传出
  49. Error_manager get_result(wj_measure_result &result);
  50. // 获取测量结果是否已存入该任务单的指标
  51. bool get_result_flag();
  52. // 填入点云
  53. void set_cloud(pcl::PointCloud<pcl::PointXYZ> cloud)
  54. {
  55. m_cloud = cloud;
  56. }
  57. // 获取万集点云
  58. pcl::PointCloud<pcl::PointXYZ> get_cloud()
  59. {
  60. return m_cloud;
  61. }
  62. private:
  63. // 测量指令信息
  64. wj_command m_command;
  65. // 测量结果
  66. wj_measure_result m_wj_measure_result;
  67. // 访问测量结果互斥锁
  68. std::mutex m_mutex;
  69. // 标记结果是否已被设置
  70. std::atomic<bool> mb_result_flag;
  71. // 任务中保存点云
  72. pcl::PointCloud<pcl::PointXYZ> m_cloud;
  73. };
  74. #endif // !WJ_LIDAR_TASK_HH