1+ #ifndef RMCL_ROS_CORRECTION_RCC_VULKAN_HPP
2+ #define RMCL_ROS_CORRECTION_RCC_VULKAN_HPP
3+
4+ #include < rmagine/types/MemoryCuda.hpp>
5+ #include < rmagine/types/PointCloud.hpp>
6+ #include < rmagine/map/VulkanMap.hpp>
7+
8+ #include < rmagine/simulation/SphereSimulatorVulkan.hpp>
9+ #include < rmagine/simulation/PinholeSimulatorVulkan.hpp>
10+ #include < rmagine/simulation/O1DnSimulatorVulkan.hpp>
11+ #include < rmagine/simulation/OnDnSimulatorVulkan.hpp>
12+
13+ #include < rmagine/types/MemoryVulkanCudaInterop.hpp>
14+
15+ #include < rmcl/registration/CorrespondencesCUDA.hpp>
16+
17+ namespace rm = rmagine;
18+
19+ namespace rmcl
20+ {
21+
22+ /* *
23+ * this is not a very mice way to handle the views, but i could not find a better way right now...
24+ *
25+ * views need to be recreated every time the results buffers get resized...
26+ *
27+ * however using these views to copy from vulkan memory to cuda memory is faster than copying directly,
28+ * because you dont need to fetch a file descriptor every time.
29+ */
30+ struct ViewContainer
31+ {
32+ ViewContainer (rm::MemoryView<uint8_t , rm::DEVICE_LOCAL_VULKAN>& hits,
33+ rm::MemoryView<rm::Point, rm::DEVICE_LOCAL_VULKAN>& points,
34+ rm::MemoryView<rm::Vector, rm::DEVICE_LOCAL_VULKAN>& normals) :
35+ hits_view (hits), points_view(points), normals_view(normals) {}
36+
37+ rmagine::MemoryView<uint8_t , rm::VULKAN_AS_CUDA> hits_view;
38+ rmagine::MemoryView<rm::Point, rm::VULKAN_AS_CUDA> points_view;
39+ rmagine::MemoryView<rm::Vector, rm::VULKAN_AS_CUDA> normals_view;
40+ };
41+ using ViewContainerPtr = std::unique_ptr<ViewContainer>;
42+
43+
44+
45+ class RCCVulkanSpherical
46+ : public CorrespondencesCUDA
47+ , public rmagine::ModelSetter<rmagine::SphericalModel>
48+ , protected rmagine::SphereSimulatorVulkan
49+ {
50+ public:
51+
52+ RCCVulkanSpherical (
53+ rmagine::VulkanMapPtr map);
54+
55+ void setModel (const rmagine::SphericalModel& sensor_model);
56+
57+ virtual void setTsb (const rmagine::Transform& Tsb) override ;
58+
59+ virtual void find (const rmagine::Transform& Tbm_est);
60+
61+ private:
62+
63+ rmagine::SphericalModel model_cache_;
64+
65+ // TODO: mapping in gegenrichtung nutzen, sobald es in rmagine existiert
66+ rmagine::Bundle<
67+ rmagine::Points<rm::DEVICE_LOCAL_VULKAN>, // model points
68+ rmagine::Normals<rm::DEVICE_LOCAL_VULKAN>, // model normals
69+ rmagine::Hits<rm::DEVICE_LOCAL_VULKAN> // correspondence mask
70+ > model_buffers_vulkan_;
71+
72+ ViewContainerPtr viewContainer = nullptr ;
73+ };
74+
75+
76+ class RCCVulkanPinhole
77+ : public CorrespondencesCUDA
78+ , public rmagine::ModelSetter<rmagine::PinholeModel>
79+ , protected rmagine::PinholeSimulatorVulkan
80+ {
81+ public:
82+
83+ RCCVulkanPinhole (
84+ rmagine::VulkanMapPtr map);
85+
86+ void setModel (const rmagine::PinholeModel& sensor_model);
87+
88+ virtual void setTsb (const rmagine::Transform& Tsb) override ;
89+
90+ virtual void find (const rmagine::Transform& Tbm_est);
91+
92+ private:
93+ rmagine::PinholeModel model_cache_;
94+
95+ // TODO: mapping in gegenrichtung nutzen, sobald es in rmagine existiert
96+ rmagine::Bundle<
97+ rmagine::Points<rm::DEVICE_LOCAL_VULKAN>, // model points
98+ rmagine::Normals<rm::DEVICE_LOCAL_VULKAN>, // model normals
99+ rmagine::Hits<rm::DEVICE_LOCAL_VULKAN> // correspondence mask
100+ > model_buffers_vulkan_;
101+
102+ ViewContainerPtr viewContainer = nullptr ;
103+ };
104+
105+
106+ class RCCVulkanO1Dn
107+ : public CorrespondencesCUDA
108+ , public rmagine::ModelSetter<rmagine::O1DnModel>
109+ , protected rmagine::O1DnSimulatorVulkan
110+ {
111+ public:
112+
113+ RCCVulkanO1Dn (
114+ rmagine::VulkanMapPtr map);
115+
116+ void setModel (const rmagine::O1DnModel& sensor_model);
117+
118+ virtual void setTsb (const rmagine::Transform& Tsb) override ;
119+
120+ virtual void find (const rmagine::Transform& Tbm_est);
121+
122+ private:
123+ rmagine::O1DnModel model_cache_;
124+
125+ // TODO: mapping in gegenrichtung nutzen, sobald es in rmagine existiert
126+ rmagine::Bundle<
127+ rmagine::Points<rm::DEVICE_LOCAL_VULKAN>, // model points
128+ rmagine::Normals<rm::DEVICE_LOCAL_VULKAN>, // model normals
129+ rmagine::Hits<rm::DEVICE_LOCAL_VULKAN> // correspondence mask
130+ > model_buffers_vulkan_;
131+
132+ ViewContainerPtr viewContainer = nullptr ;
133+ };
134+
135+ class RCCVulkanOnDn
136+ : public CorrespondencesCUDA
137+ , public rmagine::ModelSetter<rmagine::OnDnModel>
138+ , protected rmagine::OnDnSimulatorVulkan
139+ {
140+ public:
141+
142+ RCCVulkanOnDn (
143+ rmagine::VulkanMapPtr map);
144+
145+ void setModel (const rmagine::OnDnModel& sensor_model);
146+
147+ virtual void setTsb (const rmagine::Transform& Tsb) override ;
148+
149+ virtual void find (const rmagine::Transform& Tbm_est);
150+
151+ private:
152+ rmagine::OnDnModel model_cache_;
153+
154+ // TODO: mapping in gegenrichtung nutzen, sobald es in rmagine existiert
155+ rmagine::Bundle<
156+ rmagine::Points<rm::DEVICE_LOCAL_VULKAN>, // model points
157+ rmagine::Normals<rm::DEVICE_LOCAL_VULKAN>, // model normals
158+ rmagine::Hits<rm::DEVICE_LOCAL_VULKAN> // correspondence mask
159+ > model_buffers_vulkan_;
160+
161+ ViewContainerPtr viewContainer = nullptr ;
162+ };
163+
164+
165+ } // namespace rmcl
166+
167+ #endif // RMCL_ROS_CORRECTION_RCC_EMBREE_HPP
0 commit comments