small_gicp
pcl_proxy.hpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright 2024 Kenji Koide
2 // SPDX-License-Identifier: MIT
3 #pragma once
4 
5 #include <pcl/point_cloud.h>
7 
8 namespace small_gicp {
9 
11 template <typename PointT>
13  PointCloudProxy(const pcl::PointCloud<PointT>& cloud, std::vector<Eigen::Matrix4d>& covs) : cloud(cloud), covs(covs) {}
14 
15  const pcl::PointCloud<PointT>& cloud;
16  std::vector<Eigen::Matrix4d>& covs;
17 };
18 
19 namespace traits {
20 template <typename PointT>
21 struct Traits<PointCloudProxy<PointT>> {
23 
24  static size_t size(const Points& points) { return points.cloud.size(); }
25 
26  static bool has_points(const Points& points) { return !points.cloud.points.empty(); }
27  static bool has_covs(const Points& points) { return !points.covs.empty(); }
28 
29  static const Eigen::Vector4d point(const Points& points, size_t i) { return points.cloud.at(i).getVector4fMap().template cast<double>(); }
30  static const Eigen::Matrix4d& cov(const Points& points, size_t i) { return points.covs[i]; }
31 
32  static void resize(Points& points, size_t n) { points.covs.resize(n); }
33  static void set_cov(Points& points, size_t i, const Eigen::Matrix4d& cov) { points.covs[i] = cov; }
34 };
35 
36 } // namespace traits
37 
38 } // namespace small_gicp
auto cov(const T &points, size_t i)
Get i-th covariance. Only the top-left 3x3 matrix is filled, and the bottom row and the right col mus...
Definition: traits.hpp:52
Definition: flat_container.hpp:12
Proxy class to access PCL point cloud with external covariance matrices.
Definition: pcl_proxy.hpp:12
const pcl::PointCloud< PointT > & cloud
Point cloud.
Definition: pcl_proxy.hpp:15
PointCloudProxy(const pcl::PointCloud< PointT > &cloud, std::vector< Eigen::Matrix4d > &covs)
Definition: pcl_proxy.hpp:13
std::vector< Eigen::Matrix4d > & covs
Covariance matrices.
Definition: pcl_proxy.hpp:16
static void set_cov(Points &points, size_t i, const Eigen::Matrix4d &cov)
Definition: pcl_proxy.hpp:33
static size_t size(const Points &points)
Definition: pcl_proxy.hpp:24
static const Eigen::Matrix4d & cov(const Points &points, size_t i)
Definition: pcl_proxy.hpp:30
static bool has_points(const Points &points)
Definition: pcl_proxy.hpp:26
static void resize(Points &points, size_t n)
Definition: pcl_proxy.hpp:32
static const Eigen::Vector4d point(const Points &points, size_t i)
Definition: pcl_proxy.hpp:29
static bool has_covs(const Points &points)
Definition: pcl_proxy.hpp:27
Definition: traits.hpp:13