test.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // Created by zx on 2023/10/23.
  3. //
  4. #include "test.h"
  5. int main(int argc, char** argv) {
  6. ZX::InitGlog("MeasureNodeAlgTest", ETC_PATH"MeasureNodeAlgTest/MeasureNodeAlgTestLog/");
  7. const char *VELODYNE_MANAGER_PARAMETER_PATH = ETC_PATH"MeasureNode/velodyne_manager.prototxt";
  8. const char *LEFT_WHEEL_MODEL = ETC_PATH"MeasureNode/left_model.txt";
  9. const char *RIGHT_WHEEL_MODEL = ETC_PATH"MeasureNode/right_model.txt";
  10. // 初始化点云获取通信
  11. CloudDataMqttAsync::instance();
  12. // 加载区域配置
  13. velodyne::velodyneManagerParams t_velo_params;
  14. if (!proto_tool::read_proto_param(VELODYNE_MANAGER_PARAMETER_PATH, t_velo_params)) {
  15. LOG(ERROR) << "velodyne_manager read_proto_param failed form " << VELODYNE_MANAGER_PARAMETER_PATH;
  16. return EXIT_FAILURE;
  17. }
  18. LOG(ERROR) << "velodyne_manager read_proto_param failed form " << VELODYNE_MANAGER_PARAMETER_PATH;
  19. // 加载模型
  20. pcl::PointCloud<pcl::PointXYZ>::Ptr left = pcl::PointCloud<pcl::PointXYZ>::Ptr(new pcl::PointCloud<pcl::PointXYZ>);
  21. pcl::PointCloud<pcl::PointXYZ>::Ptr right = pcl::PointCloud<pcl::PointXYZ>::Ptr(new pcl::PointCloud<pcl::PointXYZ>);
  22. if (!read_pointcloud(LEFT_WHEEL_MODEL, left)) {
  23. LOG(ERROR) << "cannot read left model form " << LEFT_WHEEL_MODEL;
  24. return EXIT_FAILURE;
  25. }
  26. if (!read_pointcloud(RIGHT_WHEEL_MODEL, right)) {
  27. LOG(ERROR) << "cannot read right model form " << RIGHT_WHEEL_MODEL;
  28. return EXIT_FAILURE;
  29. }
  30. std::map<int, GroundRegion *> mp_region;
  31. for (auto &region: t_velo_params.region()) {
  32. mp_region.insert(std::pair<int, GroundRegion *>(region.region_id(), new GroundRegion()));
  33. mp_region.find(region.region_id())->second->init(region, left, right);
  34. }
  35. while (true) {
  36. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  37. }
  38. return EXIT_SUCCESS;
  39. }