ndt_cuda.cuh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef FAST_GICP_NDT_CUDA_CUH
  2. #define FAST_GICP_NDT_CUDA_CUH
  3. #include <memory>
  4. #include <vector>
  5. #include <Eigen/Core>
  6. #include <Eigen/Geometry>
  7. #include <fast_gicp/ndt/ndt_settings.hpp>
  8. #include <fast_gicp/gicp/gicp_settings.hpp>
  9. namespace thrust {
  10. template <typename T1, typename T2>
  11. class pair;
  12. template <typename T>
  13. class device_allocator;
  14. template <typename T, typename Alloc>
  15. class device_vector;
  16. } // namespace thrust
  17. namespace fast_gicp {
  18. namespace cuda {
  19. class GaussianVoxelMap;
  20. class NDTCudaCore {
  21. public:
  22. using Points = thrust::device_vector<Eigen::Vector3f, thrust::device_allocator<Eigen::Vector3f>>;
  23. using Indices = thrust::device_vector<int, thrust::device_allocator<int>>;
  24. using Matrices = thrust::device_vector<Eigen::Matrix3f, thrust::device_allocator<Eigen::Matrix3f>>;
  25. using Correspondences = thrust::device_vector<thrust::pair<int, int>, thrust::device_allocator<thrust::pair<int, int>>>;
  26. using VoxelCoordinates = thrust::device_vector<Eigen::Vector3i, thrust::device_allocator<Eigen::Vector3i>>;
  27. EIGEN_MAKE_ALIGNED_OPERATOR_NEW
  28. NDTCudaCore();
  29. ~NDTCudaCore();
  30. void set_distance_mode(fast_gicp::NDTDistanceMode mode);
  31. void set_resolution(double resolution);
  32. void set_neighbor_search_method(fast_gicp::NeighborSearchMethod method, double radius);
  33. void swap_source_and_target();
  34. void set_source_cloud(const std::vector<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f>>& cloud);
  35. void set_target_cloud(const std::vector<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f>>& cloud);
  36. void create_voxelmaps();
  37. void create_target_voxelmap();
  38. void create_source_voxelmap();
  39. void update_correspondences(const Eigen::Isometry3d& trans);
  40. double compute_error(const Eigen::Isometry3d& trans, Eigen::Matrix<double, 6, 6>* H, Eigen::Matrix<double, 6, 1>* b) const;
  41. public:
  42. fast_gicp::NDTDistanceMode distance_mode;
  43. double resolution;
  44. std::unique_ptr<VoxelCoordinates> offsets;
  45. std::unique_ptr<Points> source_points;
  46. std::unique_ptr<Points> target_points;
  47. std::unique_ptr<GaussianVoxelMap> source_voxelmap;
  48. std::unique_ptr<GaussianVoxelMap> target_voxelmap;
  49. Eigen::Isometry3f linearized_x;
  50. std::unique_ptr<Correspondences> correspondences;
  51. };
  52. } // namespace cuda
  53. } // namespace fast_gicp
  54. #endif