preprocess.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /******************************************************************************
  2. * Copyright 2020 The Apollo Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *****************************************************************************/
  16. /*
  17. * Copyright 2018-2019 Autoware Foundation. All rights reserved.
  18. *
  19. * Licensed under the Apache License, Version 2.0 (the "License");
  20. * you may not use this file except in compliance with the License.
  21. * You may obtain a copy of the License at
  22. *
  23. * http://www.apache.org/licenses/LICENSE-2.0
  24. *
  25. * Unless required by applicable law or agreed to in writing, software
  26. * distributed under the License is distributed on an "AS IS" BASIS,
  27. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  28. * See the License for the specific language governing permissions and
  29. * limitations under the License.
  30. */
  31. /**
  32. * @file preprocess_points_cuda.h
  33. * @brief GPU version of preprocess points
  34. * @author Kosuke Murakami
  35. * @date 2019/02/26
  36. */
  37. /**
  38. * @author Yan haixu
  39. * Contact: just github.com/hova88
  40. * @date 2021/04/30
  41. */
  42. #pragma once
  43. class PreprocessPointsCuda {
  44. private:
  45. // initializer list
  46. const int num_threads_;
  47. const int max_num_pillars_;
  48. const int max_num_points_per_pillar_;
  49. const int num_point_feature_;
  50. const int num_inds_for_scan_;
  51. const int grid_x_size_;
  52. const int grid_y_size_;
  53. const int grid_z_size_;
  54. const float pillar_x_size_;
  55. const float pillar_y_size_;
  56. const float pillar_z_size_;
  57. const float min_x_range_;
  58. const float min_y_range_;
  59. const float min_z_range_;
  60. // end initializer list
  61. float* dev_pillar_point_feature_in_coors_;
  62. int* dev_pillar_count_histo_;
  63. int* dev_counter_;
  64. int* dev_pillar_count_;
  65. float* dev_points_mean_;
  66. public:
  67. /**
  68. * @brief Constructor
  69. * @param[in] num_threads Number of threads when launching cuda kernel
  70. * @param[in] num_point_feature Number of features in a point
  71. * @param[in] num_inds_for_scan Number of indexes for scan(cumsum)
  72. *
  73. * @param[in] max_num_pillars Maximum number of pillars
  74. * @param[in] max_points_per_pillar Maximum number of points per pillar
  75. * @param[in] grid_x_size Number of pillars in x-coordinate
  76. * @param[in] grid_y_size Number of pillars in y-coordinate
  77. * @param[in] grid_z_size Number of pillars in z-coordinate
  78. *
  79. * @param[in] pillar_x_size Size of x-dimension for a pillar
  80. * @param[in] pillar_y_size Size of y-dimension for a pillar
  81. * @param[in] pillar_z_size Size of z-dimension for a pillar
  82. *
  83. * @param[in] min_x_range Minimum x value for point cloud
  84. * @param[in] min_y_range Minimum y value for point cloud
  85. * @param[in] min_z_range Minimum z value for point cloud
  86. * @details Captital variables never change after the compile
  87. */
  88. PreprocessPointsCuda(const int num_threads, const int num_point_feature, const int num_inds_for_scan,
  89. const int max_num_pillars, const int max_points_per_pillar,
  90. const int grid_x_size, const int grid_y_size, const int grid_z_size, // grid size
  91. const float pillar_x_size, const float pillar_y_size, const float pillar_z_size, //voxel size
  92. const float min_x_range, const float min_y_range, const float min_z_range); // point cloud range
  93. ~PreprocessPointsCuda();
  94. /**
  95. * @brief CUDA preprocessing for input point cloud
  96. * @param[in] dev_points Point cloud array
  97. * @param[in] in_num_points The number of points
  98. * @param[mid] dev_x_coors X-coordinate indexes for corresponding pillars
  99. * @param[mid] dev_y_coors Y-coordinate indexes for corresponding pillars
  100. * @param[mid] dev_num_points_per_pillar
  101. * Number of points in corresponding pillars
  102. * @param[mid] pillar_point_feature
  103. * Values of point feature in each pillar
  104. * @param[mid] pillar_coors Array for coors of pillars
  105. * @param[mid] dev_points_mean Array for calculate the point center
  106. * @param[out] dev_sparse_pillar_map
  107. * Grid map representation for pillar-occupancy
  108. * @param[out] host_pillar_count
  109. * The number of valid pillars for an input point cloud
  110. * @param[out] dev_pfe_gather_feature
  111. * 11 dimensions feature for pfe input channel
  112. * @details Convert point cloud to pillar representation
  113. */
  114. void DoPreprocessPointsCuda(const float* dev_points,
  115. const int in_num_points,
  116. int* dev_x_coors,
  117. int* dev_y_coors,
  118. float* dev_num_points_per_pillar,
  119. float* dev_pillar_point_feature,
  120. float* dev_pillar_coors,
  121. int* dev_sparse_pillar_map,
  122. int* host_pillar_count,
  123. float* dev_pfe_gather_feature);
  124. };