4343
4444namespace pcl {
4545
46- template <typename PointSource, typename PointTarget>
47- NormalDistributionsTransform<PointSource, PointTarget>::NormalDistributionsTransform()
46+ template <typename PointSource, typename PointTarget, typename Scalar>
47+ NormalDistributionsTransform<PointSource, PointTarget, Scalar>::
48+ NormalDistributionsTransform ()
4849: target_cells_()
4950, resolution_(1 .0f )
5051, step_size_(0.1 )
@@ -68,10 +69,10 @@ NormalDistributionsTransform<PointSource, PointTarget>::NormalDistributionsTrans
6869 max_iterations_ = 35 ;
6970}
7071
71- template <typename PointSource, typename PointTarget>
72+ template <typename PointSource, typename PointTarget, typename Scalar >
7273void
73- NormalDistributionsTransform<PointSource, PointTarget>::computeTransformation(
74- PointCloudSource& output, const Eigen::Matrix4f & guess)
74+ NormalDistributionsTransform<PointSource, PointTarget, Scalar >::computeTransformation(
75+ PointCloudSource& output, const Matrix4 & guess)
7576{
7677 nr_iterations_ = 0 ;
7778 converged_ = false ;
@@ -85,7 +86,7 @@ NormalDistributionsTransform<PointSource, PointTarget>::computeTransformation(
8586 -2 * std::log ((-std::log (gauss_c1 * std::exp (-0.5 ) + gauss_c2) - gauss_d3) /
8687 gauss_d1_);
8788
88- if (guess != Eigen::Matrix4f ::Identity ()) {
89+ if (guess != Matrix4 ::Identity ()) {
8990 // Initialise final transformation to the guessed one
9091 final_transformation_ = guess;
9192 // Apply guessed transformation prior to search for neighbours
@@ -97,14 +98,15 @@ NormalDistributionsTransform<PointSource, PointTarget>::computeTransformation(
9798 point_jacobian_.block <3 , 3 >(0 , 0 ).setIdentity ();
9899 point_hessian_.setZero ();
99100
100- Eigen::Transform<float , 3 , Eigen::Affine, Eigen::ColMajor> eig_transformation;
101+ Eigen::Transform<Scalar , 3 , Eigen::Affine, Eigen::ColMajor> eig_transformation;
101102 eig_transformation.matrix () = final_transformation_;
102103
103104 // Convert initial guess matrix to 6 element transformation vector
104105 Eigen::Matrix<double , 6 , 1 > transform, score_gradient;
105- Eigen::Vector3f init_translation = eig_transformation.translation ();
106- Eigen::Vector3f init_rotation = eig_transformation.rotation ().eulerAngles (0 , 1 , 2 );
107- transform << init_translation.cast <double >(), init_rotation.cast <double >();
106+ Vector3 init_translation = eig_transformation.translation ();
107+ Vector3 init_rotation = eig_transformation.rotation ().eulerAngles (0 , 1 , 2 );
108+ transform << init_translation.template cast <double >(),
109+ init_rotation.template cast <double >();
108110
109111 Eigen::Matrix<double , 6 , 6 > hessian;
110112
@@ -179,9 +181,9 @@ NormalDistributionsTransform<PointSource, PointTarget>::computeTransformation(
179181 trans_likelihood_ = score / static_cast <double >(input_->size ());
180182}
181183
182- template <typename PointSource, typename PointTarget>
184+ template <typename PointSource, typename PointTarget, typename Scalar >
183185double
184- NormalDistributionsTransform<PointSource, PointTarget>::computeDerivatives(
186+ NormalDistributionsTransform<PointSource, PointTarget, Scalar >::computeDerivatives(
185187 Eigen::Matrix<double , 6 , 1 >& score_gradient,
186188 Eigen::Matrix<double , 6 , 6 >& hessian,
187189 const PointCloudSource& trans_cloud,
@@ -230,9 +232,9 @@ NormalDistributionsTransform<PointSource, PointTarget>::computeDerivatives(
230232 return score;
231233}
232234
233- template <typename PointSource, typename PointTarget>
235+ template <typename PointSource, typename PointTarget, typename Scalar >
234236void
235- NormalDistributionsTransform<PointSource, PointTarget>::computeAngleDerivatives(
237+ NormalDistributionsTransform<PointSource, PointTarget, Scalar >::computeAngleDerivatives(
236238 const Eigen::Matrix<double , 6 , 1 >& transform, bool compute_hessian)
237239{
238240 // Simplified math for near 0 angles
@@ -315,9 +317,9 @@ NormalDistributionsTransform<PointSource, PointTarget>::computeAngleDerivatives(
315317 }
316318}
317319
318- template <typename PointSource, typename PointTarget>
320+ template <typename PointSource, typename PointTarget, typename Scalar >
319321void
320- NormalDistributionsTransform<PointSource, PointTarget>::computePointDerivatives(
322+ NormalDistributionsTransform<PointSource, PointTarget, Scalar >::computePointDerivatives(
321323 const Eigen::Vector3d& x, bool compute_hessian)
322324{
323325 // Calculate first derivative of Transformation Equation 6.17 w.r.t. transform vector.
@@ -361,9 +363,9 @@ NormalDistributionsTransform<PointSource, PointTarget>::computePointDerivatives(
361363 }
362364}
363365
364- template <typename PointSource, typename PointTarget>
366+ template <typename PointSource, typename PointTarget, typename Scalar >
365367double
366- NormalDistributionsTransform<PointSource, PointTarget>::updateDerivatives(
368+ NormalDistributionsTransform<PointSource, PointTarget, Scalar >::updateDerivatives(
367369 Eigen::Matrix<double , 6 , 1 >& score_gradient,
368370 Eigen::Matrix<double , 6 , 6 >& hessian,
369371 const Eigen::Vector3d& x_trans,
@@ -409,9 +411,9 @@ NormalDistributionsTransform<PointSource, PointTarget>::updateDerivatives(
409411 return score_inc;
410412}
411413
412- template <typename PointSource, typename PointTarget>
414+ template <typename PointSource, typename PointTarget, typename Scalar >
413415void
414- NormalDistributionsTransform<PointSource, PointTarget>::computeHessian(
416+ NormalDistributionsTransform<PointSource, PointTarget, Scalar >::computeHessian(
415417 Eigen::Matrix<double , 6 , 6 >& hessian, const PointCloudSource& trans_cloud)
416418{
417419 hessian.setZero ();
@@ -451,9 +453,9 @@ NormalDistributionsTransform<PointSource, PointTarget>::computeHessian(
451453 }
452454}
453455
454- template <typename PointSource, typename PointTarget>
456+ template <typename PointSource, typename PointTarget, typename Scalar >
455457void
456- NormalDistributionsTransform<PointSource, PointTarget>::updateHessian(
458+ NormalDistributionsTransform<PointSource, PointTarget, Scalar >::updateHessian(
457459 Eigen::Matrix<double , 6 , 6 >& hessian,
458460 const Eigen::Vector3d& x_trans,
459461 const Eigen::Matrix3d& c_inv) const
@@ -486,9 +488,9 @@ NormalDistributionsTransform<PointSource, PointTarget>::updateHessian(
486488 }
487489}
488490
489- template <typename PointSource, typename PointTarget>
491+ template <typename PointSource, typename PointTarget, typename Scalar >
490492bool
491- NormalDistributionsTransform<PointSource, PointTarget>::updateIntervalMT(
493+ NormalDistributionsTransform<PointSource, PointTarget, Scalar >::updateIntervalMT(
492494 double & a_l,
493495 double & f_l,
494496 double & g_l,
@@ -531,9 +533,9 @@ NormalDistributionsTransform<PointSource, PointTarget>::updateIntervalMT(
531533 return true ;
532534}
533535
534- template <typename PointSource, typename PointTarget>
536+ template <typename PointSource, typename PointTarget, typename Scalar >
535537double
536- NormalDistributionsTransform<PointSource, PointTarget>::trialValueSelectionMT(
538+ NormalDistributionsTransform<PointSource, PointTarget, Scalar >::trialValueSelectionMT(
537539 double a_l,
538540 double f_l,
539541 double g_l,
@@ -644,9 +646,9 @@ NormalDistributionsTransform<PointSource, PointTarget>::trialValueSelectionMT(
644646 }
645647}
646648
647- template <typename PointSource, typename PointTarget>
649+ template <typename PointSource, typename PointTarget, typename Scalar >
648650double
649- NormalDistributionsTransform<PointSource, PointTarget>::computeStepLengthMT(
651+ NormalDistributionsTransform<PointSource, PointTarget, Scalar >::computeStepLengthMT(
650652 const Eigen::Matrix<double , 6 , 1 >& x,
651653 Eigen::Matrix<double , 6 , 1 >& step_dir,
652654 double step_init,
0 commit comments