ndt_omp.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. /*
  2. * Software License Agreement (BSD License)
  3. *
  4. * Point Cloud Library (PCL) - www.pointclouds.org
  5. * Copyright (c) 2010-2012, Willow Garage, Inc.
  6. * Copyright (c) 2012-, Open Perception, Inc.
  7. *
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. *
  14. * * Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions and the following disclaimer.
  16. * * Redistributions in binary form must reproduce the above
  17. * copyright notice, this list of conditions and the following
  18. * disclaimer in the documentation and/or other materials provided
  19. * with the distribution.
  20. * * Neither the name of the copyright holder(s) nor the names of its
  21. * contributors may be used to endorse or promote products derived
  22. * from this software without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  25. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  26. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  27. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  28. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  29. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  30. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  31. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  32. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  33. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  34. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  35. * POSSIBILITY OF SUCH DAMAGE.
  36. *
  37. * $Id$
  38. *
  39. */
  40. #ifndef PCL_REGISTRATION_NDT_OMP_H_
  41. #define PCL_REGISTRATION_NDT_OMP_H_
  42. #include <pcl/registration/registration.h>
  43. #include <pcl/search/impl/search.hpp>
  44. #include "voxel_grid_covariance_omp.h"
  45. #include <unsupported/Eigen/NonLinearOptimization>
  46. namespace pclomp
  47. {
  48. enum NeighborSearchMethod {
  49. KDTREE,
  50. DIRECT26,
  51. DIRECT7,
  52. DIRECT1
  53. };
  54. /** \brief A 3D Normal Distribution Transform registration implementation for point cloud data.
  55. * \note For more information please see
  56. * <b>Magnusson, M. (2009). The Three-Dimensional Normal-Distributions Transform —
  57. * an Efficient Representation for Registration, Surface Analysis, and Loop Detection.
  58. * PhD thesis, Orebro University. Orebro Studies in Technology 36.</b>,
  59. * <b>More, J., and Thuente, D. (1994). Line Search Algorithm with Guaranteed Sufficient Decrease
  60. * In ACM Transactions on Mathematical Software.</b> and
  61. * Sun, W. and Yuan, Y, (2006) Optimization Theory and Methods: Nonlinear Programming. 89-100
  62. * \note Math refactored by Todor Stoyanov.
  63. * \author Brian Okorn (Space and Naval Warfare Systems Center Pacific)
  64. */
  65. template<typename PointSource, typename PointTarget>
  66. class NormalDistributionsTransform : public pcl::Registration<PointSource, PointTarget>
  67. {
  68. protected:
  69. typedef typename pcl::Registration<PointSource, PointTarget>::PointCloudSource PointCloudSource;
  70. typedef typename PointCloudSource::Ptr PointCloudSourcePtr;
  71. typedef typename PointCloudSource::ConstPtr PointCloudSourceConstPtr;
  72. typedef typename pcl::Registration<PointSource, PointTarget>::PointCloudTarget PointCloudTarget;
  73. typedef typename PointCloudTarget::Ptr PointCloudTargetPtr;
  74. typedef typename PointCloudTarget::ConstPtr PointCloudTargetConstPtr;
  75. typedef pcl::PointIndices::Ptr PointIndicesPtr;
  76. typedef pcl::PointIndices::ConstPtr PointIndicesConstPtr;
  77. /** \brief Typename of searchable voxel grid containing mean and covariance. */
  78. typedef pclomp::VoxelGridCovariance<PointTarget> TargetGrid;
  79. /** \brief Typename of pointer to searchable voxel grid. */
  80. typedef TargetGrid* TargetGridPtr;
  81. /** \brief Typename of const pointer to searchable voxel grid. */
  82. typedef const TargetGrid* TargetGridConstPtr;
  83. /** \brief Typename of const pointer to searchable voxel grid leaf. */
  84. typedef typename TargetGrid::LeafConstPtr TargetGridLeafConstPtr;
  85. public:
  86. #if PCL_VERSION >= PCL_VERSION_CALC(1, 10, 0)
  87. typedef pcl::shared_ptr< NormalDistributionsTransform<PointSource, PointTarget> > Ptr;
  88. typedef pcl::shared_ptr< const NormalDistributionsTransform<PointSource, PointTarget> > ConstPtr;
  89. #else
  90. typedef boost::shared_ptr< NormalDistributionsTransform<PointSource, PointTarget> > Ptr;
  91. typedef boost::shared_ptr< const NormalDistributionsTransform<PointSource, PointTarget> > ConstPtr;
  92. #endif
  93. /** \brief Constructor.
  94. * Sets \ref outlier_ratio_ to 0.35, \ref step_size_ to 0.05 and \ref resolution_ to 1.0
  95. */
  96. NormalDistributionsTransform();
  97. /** \brief Empty destructor */
  98. virtual ~NormalDistributionsTransform() {}
  99. void setNumThreads(int n) {
  100. num_threads_ = n;
  101. }
  102. /** \brief Provide a pointer to the input target (e.g., the point cloud that we want to align the input source to).
  103. * \param[in] cloud the input point cloud target
  104. */
  105. inline void
  106. setInputTarget(const PointCloudTargetConstPtr &cloud)
  107. {
  108. pcl::Registration<PointSource, PointTarget>::setInputTarget(cloud);
  109. init();
  110. }
  111. /** \brief Set/change the voxel grid resolution.
  112. * \param[in] resolution side length of voxels
  113. */
  114. inline void
  115. setResolution(float resolution)
  116. {
  117. // Prevents unnecessary voxel initiations
  118. if (resolution_ != resolution)
  119. {
  120. resolution_ = resolution;
  121. if (input_)
  122. init();
  123. }
  124. }
  125. /** \brief Get voxel grid resolution.
  126. * \return side length of voxels
  127. */
  128. inline float
  129. getResolution() const
  130. {
  131. return (resolution_);
  132. }
  133. /** \brief Get the newton line search maximum step length.
  134. * \return maximum step length
  135. */
  136. inline double
  137. getStepSize() const
  138. {
  139. return (step_size_);
  140. }
  141. /** \brief Set/change the newton line search maximum step length.
  142. * \param[in] step_size maximum step length
  143. */
  144. inline void
  145. setStepSize(double step_size)
  146. {
  147. step_size_ = step_size;
  148. }
  149. /** \brief Get the point cloud outlier ratio.
  150. * \return outlier ratio
  151. */
  152. inline double
  153. getOutlierRatio() const
  154. {
  155. return (outlier_ratio_);
  156. }
  157. /** \brief Set/change the point cloud outlier ratio.
  158. * \param[in] outlier_ratio outlier ratio
  159. */
  160. inline void
  161. setOutlierRatio(double outlier_ratio)
  162. {
  163. outlier_ratio_ = outlier_ratio;
  164. }
  165. inline void setNeighborhoodSearchMethod(NeighborSearchMethod method) {
  166. search_method = method;
  167. }
  168. /** \brief Get the registration alignment probability.
  169. * \return transformation probability
  170. */
  171. inline double
  172. getTransformationProbability() const
  173. {
  174. return (trans_probability_);
  175. }
  176. /** \brief Get the number of iterations required to calculate alignment.
  177. * \return final number of iterations
  178. */
  179. inline int
  180. getFinalNumIteration() const
  181. {
  182. return (nr_iterations_);
  183. }
  184. /** \brief Convert 6 element transformation vector to affine transformation.
  185. * \param[in] x transformation vector of the form [x, y, z, roll, pitch, yaw]
  186. * \param[out] trans affine transform corresponding to given transformation vector
  187. */
  188. static void
  189. convertTransform(const Eigen::Matrix<double, 6, 1> &x, Eigen::Affine3f &trans)
  190. {
  191. trans = Eigen::Translation<float, 3>(float(x(0)), float(x(1)), float(x(2))) *
  192. Eigen::AngleAxis<float>(float(x(3)), Eigen::Vector3f::UnitX()) *
  193. Eigen::AngleAxis<float>(float(x(4)), Eigen::Vector3f::UnitY()) *
  194. Eigen::AngleAxis<float>(float(x(5)), Eigen::Vector3f::UnitZ());
  195. }
  196. /** \brief Convert 6 element transformation vector to transformation matrix.
  197. * \param[in] x transformation vector of the form [x, y, z, roll, pitch, yaw]
  198. * \param[out] trans 4x4 transformation matrix corresponding to given transformation vector
  199. */
  200. static void
  201. convertTransform(const Eigen::Matrix<double, 6, 1> &x, Eigen::Matrix4f &trans)
  202. {
  203. Eigen::Affine3f _affine;
  204. convertTransform(x, _affine);
  205. trans = _affine.matrix();
  206. }
  207. // negative log likelihood function
  208. // lower is better
  209. double calculateScore(const PointCloudSource& cloud) const;
  210. protected:
  211. using pcl::Registration<PointSource, PointTarget>::reg_name_;
  212. using pcl::Registration<PointSource, PointTarget>::getClassName;
  213. using pcl::Registration<PointSource, PointTarget>::input_;
  214. using pcl::Registration<PointSource, PointTarget>::indices_;
  215. using pcl::Registration<PointSource, PointTarget>::target_;
  216. using pcl::Registration<PointSource, PointTarget>::nr_iterations_;
  217. using pcl::Registration<PointSource, PointTarget>::max_iterations_;
  218. using pcl::Registration<PointSource, PointTarget>::previous_transformation_;
  219. using pcl::Registration<PointSource, PointTarget>::final_transformation_;
  220. using pcl::Registration<PointSource, PointTarget>::transformation_;
  221. using pcl::Registration<PointSource, PointTarget>::transformation_epsilon_;
  222. using pcl::Registration<PointSource, PointTarget>::converged_;
  223. using pcl::Registration<PointSource, PointTarget>::corr_dist_threshold_;
  224. using pcl::Registration<PointSource, PointTarget>::inlier_threshold_;
  225. using pcl::Registration<PointSource, PointTarget>::update_visualizer_;
  226. /** \brief Estimate the transformation and returns the transformed source (input) as output.
  227. * \param[out] output the resultant input transformed point cloud dataset
  228. */
  229. virtual void
  230. computeTransformation(PointCloudSource &output)
  231. {
  232. computeTransformation(output, Eigen::Matrix4f::Identity());
  233. }
  234. /** \brief Estimate the transformation and returns the transformed source (input) as output.
  235. * \param[out] output the resultant input transformed point cloud dataset
  236. * \param[in] guess the initial gross estimation of the transformation
  237. */
  238. virtual void
  239. computeTransformation(PointCloudSource &output, const Eigen::Matrix4f &guess);
  240. /** \brief Initiate covariance voxel structure. */
  241. void inline
  242. init()
  243. {
  244. target_cells_.setLeafSize(resolution_, resolution_, resolution_);
  245. target_cells_.setInputCloud(target_);
  246. // Initiate voxel structure.
  247. target_cells_.filter(true);
  248. }
  249. /** \brief Compute derivatives of probability function w.r.t. the transformation vector.
  250. * \note Equation 6.10, 6.12 and 6.13 [Magnusson 2009].
  251. * \param[out] score_gradient the gradient vector of the probability function w.r.t. the transformation vector
  252. * \param[out] hessian the hessian matrix of the probability function w.r.t. the transformation vector
  253. * \param[in] trans_cloud transformed point cloud
  254. * \param[in] p the current transform vector
  255. * \param[in] compute_hessian flag to calculate hessian, unnecessary for step calculation.
  256. */
  257. double
  258. computeDerivatives(Eigen::Matrix<double, 6, 1> &score_gradient,
  259. Eigen::Matrix<double, 6, 6> &hessian,
  260. PointCloudSource &trans_cloud,
  261. Eigen::Matrix<double, 6, 1> &p,
  262. bool compute_hessian = true);
  263. /** \brief Compute individual point contributions to derivatives of probability function w.r.t. the transformation vector.
  264. * \note Equation 6.10, 6.12 and 6.13 [Magnusson 2009].
  265. * \param[in,out] score_gradient the gradient vector of the probability function w.r.t. the transformation vector
  266. * \param[in,out] hessian the hessian matrix of the probability function w.r.t. the transformation vector
  267. * \param[in] x_trans transformed point minus mean of occupied covariance voxel
  268. * \param[in] c_inv covariance of occupied covariance voxel
  269. * \param[in] compute_hessian flag to calculate hessian, unnecessary for step calculation.
  270. */
  271. double
  272. updateDerivatives(Eigen::Matrix<double, 6, 1> &score_gradient,
  273. Eigen::Matrix<double, 6, 6> &hessian,
  274. const Eigen::Matrix<float, 4, 6> &point_gradient_,
  275. const Eigen::Matrix<float, 24, 6> &point_hessian_,
  276. const Eigen::Vector3d &x_trans, const Eigen::Matrix3d &c_inv,
  277. bool compute_hessian = true) const;
  278. /** \brief Precompute angular components of derivatives.
  279. * \note Equation 6.19 and 6.21 [Magnusson 2009].
  280. * \param[in] p the current transform vector
  281. * \param[in] compute_hessian flag to calculate hessian, unnecessary for step calculation.
  282. */
  283. void
  284. computeAngleDerivatives(Eigen::Matrix<double, 6, 1> &p, bool compute_hessian = true);
  285. /** \brief Compute point derivatives.
  286. * \note Equation 6.18-21 [Magnusson 2009].
  287. * \param[in] x point from the input cloud
  288. * \param[in] compute_hessian flag to calculate hessian, unnecessary for step calculation.
  289. */
  290. void
  291. computePointDerivatives(Eigen::Vector3d &x, Eigen::Matrix<double, 3, 6>& point_gradient_, Eigen::Matrix<double, 18, 6>& point_hessian_, bool compute_hessian = true) const;
  292. void
  293. computePointDerivatives(Eigen::Vector3d &x, Eigen::Matrix<float, 4, 6>& point_gradient_, Eigen::Matrix<float, 24, 6>& point_hessian_, bool compute_hessian = true) const;
  294. /** \brief Compute hessian of probability function w.r.t. the transformation vector.
  295. * \note Equation 6.13 [Magnusson 2009].
  296. * \param[out] hessian the hessian matrix of the probability function w.r.t. the transformation vector
  297. * \param[in] trans_cloud transformed point cloud
  298. * \param[in] p the current transform vector
  299. */
  300. void
  301. computeHessian(Eigen::Matrix<double, 6, 6> &hessian,
  302. PointCloudSource &trans_cloud,
  303. Eigen::Matrix<double, 6, 1> &p);
  304. /** \brief Compute individual point contributions to hessian of probability function w.r.t. the transformation vector.
  305. * \note Equation 6.13 [Magnusson 2009].
  306. * \param[in,out] hessian the hessian matrix of the probability function w.r.t. the transformation vector
  307. * \param[in] x_trans transformed point minus mean of occupied covariance voxel
  308. * \param[in] c_inv covariance of occupied covariance voxel
  309. */
  310. void
  311. updateHessian(Eigen::Matrix<double, 6, 6> &hessian,
  312. const Eigen::Matrix<double, 3, 6> &point_gradient_,
  313. const Eigen::Matrix<double, 18, 6> &point_hessian_,
  314. const Eigen::Vector3d &x_trans, const Eigen::Matrix3d &c_inv) const;
  315. /** \brief Compute line search step length and update transform and probability derivatives using More-Thuente method.
  316. * \note Search Algorithm [More, Thuente 1994]
  317. * \param[in] x initial transformation vector, \f$ x \f$ in Equation 1.3 (Moore, Thuente 1994) and \f$ \vec{p} \f$ in Algorithm 2 [Magnusson 2009]
  318. * \param[in] step_dir descent direction, \f$ p \f$ in Equation 1.3 (Moore, Thuente 1994) and \f$ \delta \vec{p} \f$ normalized in Algorithm 2 [Magnusson 2009]
  319. * \param[in] step_init initial step length estimate, \f$ \alpha_0 \f$ in Moore-Thuente (1994) and the normal of \f$ \delta \vec{p} \f$ in Algorithm 2 [Magnusson 2009]
  320. * \param[in] step_max maximum step length, \f$ \alpha_max \f$ in Moore-Thuente (1994)
  321. * \param[in] step_min minimum step length, \f$ \alpha_min \f$ in Moore-Thuente (1994)
  322. * \param[out] score final score function value, \f$ f(x + \alpha p) \f$ in Equation 1.3 (Moore, Thuente 1994) and \f$ score \f$ in Algorithm 2 [Magnusson 2009]
  323. * \param[in,out] score_gradient gradient of score function w.r.t. transformation vector, \f$ f'(x + \alpha p) \f$ in Moore-Thuente (1994) and \f$ \vec{g} \f$ in Algorithm 2 [Magnusson 2009]
  324. * \param[out] hessian hessian of score function w.r.t. transformation vector, \f$ f''(x + \alpha p) \f$ in Moore-Thuente (1994) and \f$ H \f$ in Algorithm 2 [Magnusson 2009]
  325. * \param[in,out] trans_cloud transformed point cloud, \f$ X \f$ transformed by \f$ T(\vec{p},\vec{x}) \f$ in Algorithm 2 [Magnusson 2009]
  326. * \return final step length
  327. */
  328. double
  329. computeStepLengthMT(const Eigen::Matrix<double, 6, 1> &x,
  330. Eigen::Matrix<double, 6, 1> &step_dir,
  331. double step_init,
  332. double step_max, double step_min,
  333. double &score,
  334. Eigen::Matrix<double, 6, 1> &score_gradient,
  335. Eigen::Matrix<double, 6, 6> &hessian,
  336. PointCloudSource &trans_cloud);
  337. /** \brief Update interval of possible step lengths for More-Thuente method, \f$ I \f$ in More-Thuente (1994)
  338. * \note Updating Algorithm until some value satisfies \f$ \psi(\alpha_k) \leq 0 \f$ and \f$ \phi'(\alpha_k) \geq 0 \f$
  339. * and Modified Updating Algorithm from then on [More, Thuente 1994].
  340. * \param[in,out] a_l first endpoint of interval \f$ I \f$, \f$ \alpha_l \f$ in Moore-Thuente (1994)
  341. * \param[in,out] f_l value at first endpoint, \f$ f_l \f$ in Moore-Thuente (1994), \f$ \psi(\alpha_l) \f$ for Update Algorithm and \f$ \phi(\alpha_l) \f$ for Modified Update Algorithm
  342. * \param[in,out] g_l derivative at first endpoint, \f$ g_l \f$ in Moore-Thuente (1994), \f$ \psi'(\alpha_l) \f$ for Update Algorithm and \f$ \phi'(\alpha_l) \f$ for Modified Update Algorithm
  343. * \param[in,out] a_u second endpoint of interval \f$ I \f$, \f$ \alpha_u \f$ in Moore-Thuente (1994)
  344. * \param[in,out] f_u value at second endpoint, \f$ f_u \f$ in Moore-Thuente (1994), \f$ \psi(\alpha_u) \f$ for Update Algorithm and \f$ \phi(\alpha_u) \f$ for Modified Update Algorithm
  345. * \param[in,out] g_u derivative at second endpoint, \f$ g_u \f$ in Moore-Thuente (1994), \f$ \psi'(\alpha_u) \f$ for Update Algorithm and \f$ \phi'(\alpha_u) \f$ for Modified Update Algorithm
  346. * \param[in] a_t trial value, \f$ \alpha_t \f$ in Moore-Thuente (1994)
  347. * \param[in] f_t value at trial value, \f$ f_t \f$ in Moore-Thuente (1994), \f$ \psi(\alpha_t) \f$ for Update Algorithm and \f$ \phi(\alpha_t) \f$ for Modified Update Algorithm
  348. * \param[in] g_t derivative at trial value, \f$ g_t \f$ in Moore-Thuente (1994), \f$ \psi'(\alpha_t) \f$ for Update Algorithm and \f$ \phi'(\alpha_t) \f$ for Modified Update Algorithm
  349. * \return if interval converges
  350. */
  351. bool
  352. updateIntervalMT(double &a_l, double &f_l, double &g_l,
  353. double &a_u, double &f_u, double &g_u,
  354. double a_t, double f_t, double g_t);
  355. /** \brief Select new trial value for More-Thuente method.
  356. * \note Trial Value Selection [More, Thuente 1994], \f$ \psi(\alpha_k) \f$ is used for \f$ f_k \f$ and \f$ g_k \f$
  357. * until some value satisfies the test \f$ \psi(\alpha_k) \leq 0 \f$ and \f$ \phi'(\alpha_k) \geq 0 \f$
  358. * then \f$ \phi(\alpha_k) \f$ is used from then on.
  359. * \note Interpolation Minimizer equations from Optimization Theory and Methods: Nonlinear Programming By Wenyu Sun, Ya-xiang Yuan (89-100).
  360. * \param[in] a_l first endpoint of interval \f$ I \f$, \f$ \alpha_l \f$ in Moore-Thuente (1994)
  361. * \param[in] f_l value at first endpoint, \f$ f_l \f$ in Moore-Thuente (1994)
  362. * \param[in] g_l derivative at first endpoint, \f$ g_l \f$ in Moore-Thuente (1994)
  363. * \param[in] a_u second endpoint of interval \f$ I \f$, \f$ \alpha_u \f$ in Moore-Thuente (1994)
  364. * \param[in] f_u value at second endpoint, \f$ f_u \f$ in Moore-Thuente (1994)
  365. * \param[in] g_u derivative at second endpoint, \f$ g_u \f$ in Moore-Thuente (1994)
  366. * \param[in] a_t previous trial value, \f$ \alpha_t \f$ in Moore-Thuente (1994)
  367. * \param[in] f_t value at previous trial value, \f$ f_t \f$ in Moore-Thuente (1994)
  368. * \param[in] g_t derivative at previous trial value, \f$ g_t \f$ in Moore-Thuente (1994)
  369. * \return new trial value
  370. */
  371. double
  372. trialValueSelectionMT(double a_l, double f_l, double g_l,
  373. double a_u, double f_u, double g_u,
  374. double a_t, double f_t, double g_t);
  375. /** \brief Auxiliary function used to determine endpoints of More-Thuente interval.
  376. * \note \f$ \psi(\alpha) \f$ in Equation 1.6 (Moore, Thuente 1994)
  377. * \param[in] a the step length, \f$ \alpha \f$ in More-Thuente (1994)
  378. * \param[in] f_a function value at step length a, \f$ \phi(\alpha) \f$ in More-Thuente (1994)
  379. * \param[in] f_0 initial function value, \f$ \phi(0) \f$ in Moore-Thuente (1994)
  380. * \param[in] g_0 initial function gradiant, \f$ \phi'(0) \f$ in More-Thuente (1994)
  381. * \param[in] mu the step length, constant \f$ \mu \f$ in Equation 1.1 [More, Thuente 1994]
  382. * \return sufficient decrease value
  383. */
  384. inline double
  385. auxiliaryFunction_PsiMT(double a, double f_a, double f_0, double g_0, double mu = 1.e-4)
  386. {
  387. return (f_a - f_0 - mu * g_0 * a);
  388. }
  389. /** \brief Auxiliary function derivative used to determine endpoints of More-Thuente interval.
  390. * \note \f$ \psi'(\alpha) \f$, derivative of Equation 1.6 (Moore, Thuente 1994)
  391. * \param[in] g_a function gradient at step length a, \f$ \phi'(\alpha) \f$ in More-Thuente (1994)
  392. * \param[in] g_0 initial function gradiant, \f$ \phi'(0) \f$ in More-Thuente (1994)
  393. * \param[in] mu the step length, constant \f$ \mu \f$ in Equation 1.1 [More, Thuente 1994]
  394. * \return sufficient decrease derivative
  395. */
  396. inline double
  397. auxiliaryFunction_dPsiMT(double g_a, double g_0, double mu = 1.e-4)
  398. {
  399. return (g_a - mu * g_0);
  400. }
  401. /** \brief The voxel grid generated from target cloud containing point means and covariances. */
  402. TargetGrid target_cells_;
  403. //double fitness_epsilon_;
  404. /** \brief The side length of voxels. */
  405. float resolution_;
  406. /** \brief The maximum step length. */
  407. double step_size_;
  408. /** \brief The ratio of outliers of points w.r.t. a normal distribution, Equation 6.7 [Magnusson 2009]. */
  409. double outlier_ratio_;
  410. /** \brief The normalization constants used fit the point distribution to a normal distribution, Equation 6.8 [Magnusson 2009]. */
  411. double gauss_d1_, gauss_d2_, gauss_d3_;
  412. /** \brief The probability score of the transform applied to the input cloud, Equation 6.9 and 6.10 [Magnusson 2009]. */
  413. double trans_probability_;
  414. /** \brief Precomputed Angular Gradient
  415. *
  416. * The precomputed angular derivatives for the jacobian of a transformation vector, Equation 6.19 [Magnusson 2009].
  417. */
  418. Eigen::Vector3d j_ang_a_, j_ang_b_, j_ang_c_, j_ang_d_, j_ang_e_, j_ang_f_, j_ang_g_, j_ang_h_;
  419. Eigen::Matrix<float, 8, 4> j_ang;
  420. /** \brief Precomputed Angular Hessian
  421. *
  422. * The precomputed angular derivatives for the hessian of a transformation vector, Equation 6.19 [Magnusson 2009].
  423. */
  424. Eigen::Vector3d h_ang_a2_, h_ang_a3_,
  425. h_ang_b2_, h_ang_b3_,
  426. h_ang_c2_, h_ang_c3_,
  427. h_ang_d1_, h_ang_d2_, h_ang_d3_,
  428. h_ang_e1_, h_ang_e2_, h_ang_e3_,
  429. h_ang_f1_, h_ang_f2_, h_ang_f3_;
  430. Eigen::Matrix<float, 16, 4> h_ang;
  431. /** \brief The first order derivative of the transformation of a point w.r.t. the transform vector, \f$ J_E \f$ in Equation 6.18 [Magnusson 2009]. */
  432. // Eigen::Matrix<double, 3, 6> point_gradient_;
  433. /** \brief The second order derivative of the transformation of a point w.r.t. the transform vector, \f$ H_E \f$ in Equation 6.20 [Magnusson 2009]. */
  434. // Eigen::Matrix<double, 18, 6> point_hessian_;
  435. int num_threads_;
  436. public:
  437. NeighborSearchMethod search_method;
  438. EIGEN_MAKE_ALIGNED_OPERATOR_NEW
  439. };
  440. }
  441. #endif // PCL_REGISTRATION_NDT_H_