58#include "pcl/filters/boost.h"
59#include "pcl/filters/voxel_grid.h"
60#include "pcl/kdtree/kdtree_flann.h"
61#include "pcl/point_types.h"
67namespace localization {
73 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
76 mean_(Eigen::Vector3d::Zero()),
77 icov_(Eigen::Matrix3d::Zero()) {}
102template <
typename Po
intT>
105 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
141 if (min_points_per_voxel > 2) {
144 AWARN <<
"Covariance calculation requires at least 3 "
145 <<
"points, setting Min Point per Voxel to 3 ";
154 inline void filter(
const std::vector<Leaf> &cell_leaf,
155 bool searchable =
true) {
167 typename std::map<size_t, Leaf>::iterator leaf_iter =
leaves_.find(index);
168 if (leaf_iter ==
leaves_.end()) {
195 typename std::map<size_t, Leaf>::iterator leaf_iter =
leaves_.find(idx);
196 if (leaf_iter ==
leaves_.end()) {
222 typename std::map<size_t, Leaf>::iterator leaf_iter =
leaves_.find(idx);
223 if (leaf_iter ==
leaves_.end()) {
240 std::vector<LeafConstPtr> *k_leaves,
241 std::vector<float> *k_sqr_distances,
242 unsigned int max_nn = 0);
288#include "modules/localization/ndt/ndt_locator/ndt_voxel_grid_covariance.hpp"
A searchable voxel structure containing the mean and covariance of the data.
void SetMinPointPerVoxel(int min_points_per_voxel)
Set the minimum number of points required for a cell to be used (must be 3 or greater for covariance ...
LeafConstPtr GetLeaf(int index)
Get the voxel containing point p.
pcl::KdTreeFLANN< PointT > kdtree_
KdTree generated using voxel_centroids_ (used for searching).
LeafConstPtr GetLeaf(PointT *p)
Get the voxel containing point p.
void SetMapLeftTopCorner(const Eigen::Vector3d &left_top_corner)
PointCloudPtr GetCentroids()
Get a pointcloud containing the voxel centroids.
int RadiusSearch(const PointT &point, double radius, std::vector< LeafConstPtr > *k_leaves, std::vector< float > *k_sqr_distances, unsigned int max_nn=0)
Search for all the nearest occupied voxels of the query point in a given radius.
void SetInputCloud(const PointCloudConstPtr &cloud)
Provide a pointer to the input dataset.
int min_points_per_voxel_
Minimum points contained with in a voxel to allow it to be usable.
Eigen::Vector4i divb_mul_
Eigen::Vector3d map_left_top_corner_
Left top corner.
PointCloudConstPtr input_
int GetMinPointPerVoxel()
Get the minimum number of points required for a cell to be used.
LeafConstPtr GetLeaf(Eigen::Vector3f *p)
Get the voxel containing point p.
void SetVoxelGridResolution(float lx, float ly, float lz)
void filter(const std::vector< Leaf > &cell_leaf, bool searchable=true)
Initializes voxel structure.
VoxelGridCovariance()
Constructor.
boost::shared_ptr< PointCloud > PointCloudPtr
pcl::PointCloud< PointT > PointCloud
const std::map< size_t, Leaf > & GetLeaves()
Get the leaf structure map.
std::vector< int > voxel_centroids_leaf_indices_
Indices of leaf structurs associated with each point.
boost::shared_ptr< const PointCloud > PointCloudConstPtr
PointCloudPtr voxel_centroids_
Point cloud containing centroids of voxels containing at least minimum number of points.
void SetMap(const std::vector< Leaf > &map_leaves, PointCloudPtr output)
Eigen::Array4f inverse_leaf_size_
std::map< size_t, Leaf > leaves_
Voxel structure containing all leaf nodes (includes voxels with less than a sufficient number of poin...
void GetDisplayCloud(pcl::PointCloud< pcl::PointXYZ > *cell_cloud)
Eigen::Vector4f leaf_size_
const Leaf * LeafConstPtr
Const pointer to VoxelGridCovariance leaf structure
Leaf * LeafPtr
Pointer to VoxelGridCovariance leaf structure
Simple structure to hold a centroid, covarince and the number of points in a leaf.
int nr_points_
Number of points contained by voxel.
Eigen::Vector3d GetMean() const
Get the voxel centroid.
Eigen::Matrix3d icov_
Inverse of voxel covariance matrix.
Eigen::Matrix3d GetInverseCov() const
Get the inverse of the voxel covariance.
int GetPointCount() const
Get the number of points contained by this voxel.
Eigen::Vector3d mean_
3D voxel centroid.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Leaf()