43 #include <pcl/features/ppf.h>
44 #include <pcl/registration/registration.h>
46 #include <unordered_map>
56 struct HashKeyStruct :
public std::pair<int, std::pair<int, std::pair<int, int>>> {
62 this->second.first = b;
63 this->second.second.first = c;
64 this->second.second.second = d;
70 const std::size_t h1 = std::hash<int>{}(s.first);
71 const std::size_t h2 = std::hash<int>{}(s.second.first);
72 const std::size_t h3 = std::hash<int>{}(s.second.second.first);
73 const std::size_t h4 = std::hash<int>{}(s.second.second.second);
74 return h1 ^ (h2 << 1) ^ (h3 << 2) ^ (h4 << 3);
79 std::pair<std::size_t, std::size_t>,
82 using Ptr = shared_ptr<PPFHashMapSearch>;
83 using ConstPtr = shared_ptr<const PPFHashMapSearch>;
92 static_cast<float>(
M_PI),
93 float distance_discretization_step = 0.01f)
95 , internals_initialized_(false)
96 , angle_discretization_step_(angle_discretization_step)
97 , distance_discretization_step_(distance_discretization_step)
120 std::vector<std::pair<std::size_t, std::size_t>>& indices);
135 return angle_discretization_step_;
143 return distance_discretization_step_;
158 bool internals_initialized_;
160 float angle_discretization_step_, distance_discretization_step_;
175 template <
typename Po
intSource,
typename Po
intTarget>
192 std::vector<PoseWithVotes, Eigen::aligned_allocator<PoseWithVotes>>;
214 , scene_reference_point_sampling_rate_(5)
215 , clustering_position_diff_threshold_(0.01f)
216 , clustering_rotation_diff_threshold_(20.0f / 180.0f * static_cast<float>(
M_PI))
227 clustering_position_diff_threshold_ = clustering_position_diff_threshold;
237 return clustering_position_diff_threshold_;
248 clustering_rotation_diff_threshold_ = clustering_rotation_diff_threshold;
256 return clustering_rotation_diff_threshold_;
266 scene_reference_point_sampling_rate_ = scene_reference_point_sampling_rate;
274 return scene_reference_point_sampling_rate_;
285 search_method_ = search_method;
292 return search_method_;
306 const Eigen::Matrix4f& guess)
override;
313 uindex_t scene_reference_point_sampling_rate_;
318 float clustering_position_diff_threshold_, clustering_rotation_diff_threshold_;
327 poseWithVotesCompareFunction(
const PoseWithVotes& a,
const PoseWithVotes& b);
332 clusterVotesCompareFunction(
const std::pair<std::size_t, unsigned int>& a,
333 const std::pair<std::size_t, unsigned int>& b);
344 posesWithinErrorBounds(Eigen::Affine3f& pose1, Eigen::Affine3f& pose2);
348 #include <pcl/registration/impl/ppf_registration.hpp>
shared_ptr< KdTreeFLANN< PointT, Dist > > Ptr
float getAngleDiscretizationStep() const
Returns the angle discretization step parameter (the step value between each bin of the hash map for ...
std::vector< std::vector< float > > alpha_m_
shared_ptr< FeatureHashMapType > FeatureHashMapTypePtr
std::unordered_multimap< HashKeyStruct, std::pair< std::size_t, std::size_t >, HashKeyStruct > FeatureHashMapType
shared_ptr< PPFHashMapSearch > Ptr
shared_ptr< const PPFHashMapSearch > ConstPtr
void nearestNeighborSearch(float &f1, float &f2, float &f3, float &f4, std::vector< std::pair< std::size_t, std::size_t >> &indices)
Function for finding the nearest neighbors for the given feature inside the discretized hash map.
Ptr makeShared()
Convenience method for returning a copy of the class instance as a shared_ptr.
PPFHashMapSearch(float angle_discretization_step=12.0f/180.0f *static_cast< float >(M_PI), float distance_discretization_step=0.01f)
Constructor for the PPFHashMapSearch class which sets the two step parameters for the enclosed data s...
float getDistanceDiscretizationStep() const
Returns the distance discretization step parameter (the step value between each bin of the hash map f...
void setInputFeatureCloud(PointCloud< PPFSignature >::ConstPtr feature_cloud)
Method that sets the feature cloud to be inserted in the hash map.
float getModelDiameter() const
Returns the maximum distance found between any feature pair in the given input feature cloud.
Class that registers two point clouds based on their sets of PPFSignatures.
typename PointCloudSource::Ptr PointCloudSourcePtr
unsigned int getSceneReferencePointSamplingRate()
Returns the parameter for the scene reference point sampling rate of the algorithm.
float getRotationClusteringThreshold()
Returns the parameter defining the rotation clustering threshold.
typename PointCloudTarget::Ptr PointCloudTargetPtr
void setRotationClusteringThreshold(float clustering_rotation_diff_threshold)
Method for setting the rotation clustering parameter.
PPFHashMapSearch::Ptr getSearchMethod()
Getter function for the search method of the class.
typename PointCloudSource::ConstPtr PointCloudSourceConstPtr
PPFRegistration()
Empty constructor that initializes all the parameters of the algorithm with default values.
pcl::PointCloud< PointSource > PointCloudSource
void setSceneReferencePointSamplingRate(unsigned int scene_reference_point_sampling_rate)
Method for setting the scene reference point sampling rate.
std::vector< PoseWithVotes, Eigen::aligned_allocator< PoseWithVotes > > PoseWithVotesList
float getPositionClusteringThreshold()
Returns the parameter defining the position difference clustering parameter.
typename PointCloudTarget::ConstPtr PointCloudTargetConstPtr
void setPositionClusteringThreshold(float clustering_position_diff_threshold)
Method for setting the position difference clustering parameter.
void setInputTarget(const PointCloudTargetConstPtr &cloud) override
Provide a pointer to the input target (e.g., the point cloud that we want to align the input source t...
void setSearchMethod(PPFHashMapSearch::Ptr search_method)
Function that sets the search method for the algorithm.
shared_ptr< PointCloud< PointSource > > Ptr
shared_ptr< const PointCloud< PointT > > ConstPtr
Registration represents the base registration class for general purpose, ICP-like methods.
detail::int_type_t< detail::index_type_size, false > uindex_t
Type used for an unsigned index in PCL.
Data structure to hold the information for the key in the feature hash map of the PPFHashMapSearch cl...
HashKeyStruct(int a, int b, int c, int d)
std::size_t operator()(const HashKeyStruct &s) const noexcept
Structure for storing a pose (represented as an Eigen::Affine3f) and an integer for counting votes.
PoseWithVotes(Eigen::Affine3f &a_pose, unsigned int &a_votes)