Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tracking] Use SFINAE instead of relying on macro PCL_TRACKING_NORMAL_SUPPORTED #4643

Merged
merged 3 commits into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions tracking/include/pcl/tracking/impl/particle_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,11 @@ ParticleFilterTracker<PointInT, StateT>::computeTransformedPointCloudWithoutNorm

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template <typename PointInT, typename StateT>
template <typename PointT, pcl::traits::HasNormal<PointT>>
void
ParticleFilterTracker<PointInT, StateT>::computeTransformedPointCloudWithNormal(
#ifdef PCL_TRACKING_NORMAL_SUPPORTED
const StateT& hypothesis, pcl::Indices& indices, PointCloudIn& cloud)
#else
const StateT&, pcl::Indices&, PointCloudIn&)
#endif
{
#ifdef PCL_TRACKING_NORMAL_SUPPORTED
const Eigen::Affine3f trans = toEigenMatrix(hypothesis);
// destructively assigns to cloud
pcl::transformPointCloudWithNormals<PointInT>(*ref_, cloud, trans);
Expand All @@ -318,11 +314,6 @@ ParticleFilterTracker<PointInT, StateT>::computeTransformedPointCloudWithNormal(
if (theta > occlusion_angle_thr_)
indices.push_back(i);
}
#else
PCL_WARN("[pcl::%s::computeTransformedPointCloudWithoutNormal] "
"use_normal_ == true is not supported in this Point Type.\n",
getClassName().c_str());
#endif
}

template <typename PointInT, typename StateT>
Expand Down
17 changes: 17 additions & 0 deletions tracking/include/pcl/tracking/particle_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <pcl/tracking/tracker.h>
#include <pcl/tracking/tracking.h>
#include <pcl/memory.h>
#include <pcl/point_types.h>

namespace pcl {
namespace tracking {
Expand Down Expand Up @@ -438,6 +439,7 @@ class ParticleFilterTracker : public Tracker<PointInT, StateT> {
pcl::Indices& indices,
PointCloudIn& cloud);

#ifdef DOXYGEN_ONLY
/** \brief Compute a reference pointcloud transformed to the pose that hypothesis
* represents and calculate indices taking occlusion into account.
* \param[in] hypothesis a particle which represents a hypothesis.
Expand All @@ -449,6 +451,21 @@ class ParticleFilterTracker : public Tracker<PointInT, StateT> {
computeTransformedPointCloudWithNormal(const StateT& hypothesis,
pcl::Indices& indices,
PointCloudIn& cloud);
#else
template <typename PointT = PointInT, traits::HasNormal<PointT> = true>
void
computeTransformedPointCloudWithNormal(const StateT& hypothesis,
pcl::Indices& indices,
PointCloudIn& cloud);
template <typename PointT = PointInT, traits::HasNoNormal<PointT> = true>
void
computeTransformedPointCloudWithNormal(const StateT&, pcl::Indices&, PointCloudIn&)
{
PCL_WARN("[pcl::%s::computeTransformedPointCloudWithoutNormal] "
"use_normal_ == true is not supported in this Point Type.\n",
getClassName().c_str());
}
#endif

/** \brief Compute a reference pointcloud transformed to the pose that hypothesis
* represents and calculate indices without taking occlusion into account.
Expand Down
23 changes: 8 additions & 15 deletions tracking/src/kld_adaptive_particle_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,13 @@
#ifndef PCL_NO_PRECOMPILE
#include <pcl/impl/instantiate.hpp>
#include <pcl/point_types.h>
#define PCL_TRACKING_NORMAL_SUPPORTED

// clang-format off
PCL_INSTANTIATE_PRODUCT(KLDAdaptiveParticleFilterTracker,
((pcl::PointNormal)
(pcl::PointXYZINormal)
(pcl::PointXYZRGBNormal))
(PCL_STATE_POINT_TYPES))
PCL_INSTANTIATE_PRODUCT(KLDAdaptiveParticleFilterOMPTracker,
((pcl::PointNormal)
(pcl::PointXYZINormal)
(pcl::PointXYZRGBNormal))
(PCL_STATE_POINT_TYPES))
// clang-format on
#undef PCL_TRACKING_NORMAL_SUPPORTED
// clang-format off
PCL_INSTANTIATE_PRODUCT(KLDAdaptiveParticleFilterOMPTracker,
((pcl::PointXYZ)
(pcl::PointXYZRGBNormal)
(pcl::PointXYZ)
(pcl::PointXYZI)
(pcl::PointXYZRGBA)
(pcl::PointXYZRGB)
Expand All @@ -66,8 +55,12 @@ PCL_INSTANTIATE_PRODUCT(KLDAdaptiveParticleFilterOMPTracker,
(pcl::PointWithViewpoint)
(pcl::PointWithScale))
(PCL_STATE_POINT_TYPES))
PCL_INSTANTIATE_PRODUCT(KLDAdaptiveParticleFilterTracker,
((pcl::PointXYZ)

PCL_INSTANTIATE_PRODUCT(KLDAdaptiveParticleFilterOMPTracker,
((pcl::PointNormal)
(pcl::PointXYZINormal)
(pcl::PointXYZRGBNormal)
(pcl::PointXYZ)
(pcl::PointXYZI)
(pcl::PointXYZRGBA)
(pcl::PointXYZRGB)
Expand Down
21 changes: 7 additions & 14 deletions tracking/src/particle_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,13 @@
#ifndef PCL_NO_PRECOMPILE
#include <pcl/impl/instantiate.hpp>
#include <pcl/point_types.h>
#define PCL_TRACKING_NORMAL_SUPPORTED

// clang-format off
PCL_INSTANTIATE_PRODUCT(ParticleFilterTracker,
((pcl::PointNormal)
(pcl::PointXYZINormal)
(pcl::PointXYZRGBNormal))
(PCL_STATE_POINT_TYPES))
PCL_INSTANTIATE_PRODUCT(ParticleFilterOMPTracker,
((pcl::PointNormal)
(pcl::PointXYZINormal)
(pcl::PointXYZRGBNormal))
(PCL_STATE_POINT_TYPES))
// clang-format on
#undef PCL_TRACKING_NORMAL_SUPPORTED
// clang-format off
PCL_INSTANTIATE_PRODUCT(ParticleFilterTracker,
((pcl::PointXYZ)
(pcl::PointXYZRGBNormal)
(pcl::PointXYZ)
(pcl::PointXYZI)
(pcl::PointXYZRGBA)
(pcl::PointXYZRGB)
Expand All @@ -66,8 +55,12 @@ PCL_INSTANTIATE_PRODUCT(ParticleFilterTracker,
(pcl::PointWithViewpoint)
(pcl::PointWithScale))
(PCL_STATE_POINT_TYPES))

PCL_INSTANTIATE_PRODUCT(ParticleFilterOMPTracker,
((pcl::PointXYZ)
((pcl::PointNormal)
(pcl::PointXYZINormal)
(pcl::PointXYZRGBNormal)
(pcl::PointXYZ)
(pcl::PointXYZI)
(pcl::PointXYZRGBA)
(pcl::PointXYZRGB)
Expand Down