defines.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #pragma once
  2. #include <glog/logging.h>
  3. #include <iostream>
  4. #include <memory>
  5. #include <pcl/point_types.h>
  6. #include <pcl/point_cloud.h>
  7. #include "error_code/error_code.hpp"
  8. #include "tool/pathcreator.h"
  9. namespace ZX {
  10. /************************************ 定义 **********************************/
  11. const size_t PACKET_HEAD_SIZE = 12;
  12. const size_t PACKET_END_SIZE = 4;
  13. /************************************ 枚举 **********************************/
  14. enum LidarMessageType {
  15. UNKNOW_TYPE = 0, // 未知类型
  16. PointXYZ_TYPE, // 三维点:x、y、z点
  17. PointXYZI_TYPE, // 三维点(含置信度i):x、y、z、i
  18. PointXYZPYR_TYPE, // 三维点(含三个角度):x、y、z、pitch、yaw、roll
  19. PointRYR_TYPE, // 三维极坐标:roll、yaw、r
  20. LIDAR_RS_HELIOS_16P, // 速腾聚创雷达,基于PointRYR,但r的精度是0.25cm
  21. PointTYPE_MAX // 最后一个,检测用
  22. };
  23. static void shut_down_logging(const char *data, size_t size) {
  24. time_t tt;
  25. time(&tt);
  26. tt = tt + 8 * 3600; // transform the time zone
  27. tm *t = gmtime(&tt);
  28. char buf[255] = {0};
  29. sprintf(buf, "./%d%02d%02d-%02d%02d%02d-dump.txt",
  30. t->tm_year + 1900,
  31. t->tm_mon + 1,
  32. t->tm_mday,
  33. t->tm_hour,
  34. t->tm_min,
  35. t->tm_sec);
  36. FILE *tp_file = fopen(buf, "w");
  37. fprintf(tp_file, data, strlen(data));
  38. fclose(tp_file);
  39. }
  40. // 例子: ZX::InitGlog("MeasureNode", ETC_PATH"MeasureNode/MeasureNodeLog/");
  41. static void InitGlog(const char * project_name, const char *logPath) {
  42. PathCreator pc;
  43. pc.Mkdir(logPath);
  44. google::InitGoogleLogging(project_name);
  45. google::SetStderrLogging(google::INFO);
  46. google::SetLogDestination(google::INFO, logPath);
  47. google::SetLogFilenameExtension(".txt");
  48. google::InstallFailureSignalHandler();
  49. google::InstallFailureWriter(&ZX::shut_down_logging);
  50. FLAGS_colorlogtostderr = true; // Set log color
  51. FLAGS_logbufsecs = 0; // Set log output speed(s)
  52. FLAGS_max_log_size = 24; // Set max log file size(GB)
  53. FLAGS_stop_logging_if_full_disk = true;
  54. }
  55. }
  56. // pcl 拓展点云类型
  57. namespace pcl {
  58. /************************************ 结构体 **********************************/
  59. struct EIGEN_ALIGN16 PointALL // 强制SSE填充以获得正确的内存对齐
  60. {
  61. PCL_ADD_POINT4D; // 添加XYZ+填充类型的首选方式
  62. float intensity;
  63. float pitch;
  64. float roll;
  65. float yaw;
  66. float r;
  67. PCL_MAKE_ALIGNED_OPERATOR_NEW // 确保新的分配器内存是对齐的
  68. };
  69. struct EIGEN_ALIGN16 PointRPRY // 强制SSE填充以获得正确的内存对齐
  70. {
  71. float r;
  72. float pitch;
  73. float roll;
  74. float yaw;
  75. PCL_MAKE_ALIGNED_OPERATOR_NEW // 确保新的分配器内存是对齐的
  76. };
  77. struct EIGEN_ALIGN16 PointRYR // 强制SSE填充以获得正确的内存对齐
  78. {
  79. float r;
  80. float yaw;
  81. float roll;
  82. PCL_MAKE_ALIGNED_OPERATOR_NEW // 确保新的分配器内存是对齐的
  83. };
  84. }