defines.hpp 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. static void InitGlog(const char * project_name, const char *logPath) {
  41. PathCreator pc;
  42. pc.Mkdir(logPath);
  43. google::InitGoogleLogging(project_name);
  44. google::SetStderrLogging(google::INFO);
  45. google::SetLogDestination(google::INFO, logPath);
  46. google::SetLogFilenameExtension(".txt");
  47. google::InstallFailureSignalHandler();
  48. google::InstallFailureWriter(&ZX::shut_down_logging);
  49. FLAGS_colorlogtostderr = true; // Set log color
  50. FLAGS_logbufsecs = 0; // Set log output speed(s)
  51. FLAGS_max_log_size = 24; // Set max log file size(GB)
  52. FLAGS_stop_logging_if_full_disk = true;
  53. }
  54. }
  55. // pcl 拓展点云类型
  56. namespace pcl {
  57. /************************************ 结构体 **********************************/
  58. struct EIGEN_ALIGN16 PointALL // 强制SSE填充以获得正确的内存对齐
  59. {
  60. PCL_ADD_POINT4D; // 添加XYZ+填充类型的首选方式
  61. float intensity;
  62. float pitch;
  63. float roll;
  64. float yaw;
  65. float r;
  66. PCL_MAKE_ALIGNED_OPERATOR_NEW // 确保新的分配器内存是对齐的
  67. };
  68. struct EIGEN_ALIGN16 PointRPRY // 强制SSE填充以获得正确的内存对齐
  69. {
  70. float r;
  71. float pitch;
  72. float roll;
  73. float yaw;
  74. PCL_MAKE_ALIGNED_OPERATOR_NEW // 确保新的分配器内存是对齐的
  75. };
  76. struct EIGEN_ALIGN16 PointRYR // 强制SSE填充以获得正确的内存对齐
  77. {
  78. float r;
  79. float yaw;
  80. float roll;
  81. PCL_MAKE_ALIGNED_OPERATOR_NEW // 确保新的分配器内存是对齐的
  82. };
  83. }