robust_kernels.h
Go to the documentation of this file.
1 /* -------------------------------------------------------------------------
2  * A repertory of multi primitive-to-primitive (MP2P) ICP algorithms in C++
3  * Copyright (C) 2018-2024 Jose Luis Blanco, University of Almeria
4  * See LICENSE for license information.
5  * ------------------------------------------------------------------------- */
12 #pragma once
13 
14 #include <mrpt/core/bits_math.h>
15 #include <mrpt/typemeta/TEnumType.h>
16 
17 #include <cstdint>
18 #include <functional>
19 
20 namespace mp2p_icp
21 {
25 enum class RobustKernel : uint8_t
26 {
28  None = 0,
29 
32 
34  Cauchy,
35 };
36 
37 using robust_sqrt_weight_func_t = std::function<double(double /*errSqr*/)>;
38 
50  const RobustKernel kernel, const double kernelParam)
51 {
52  const double kernelParamSqr = mrpt::square(kernelParam);
53 
54  switch (kernel)
55  {
56  case RobustKernel::None:
57  return {}; // empty
58  break;
59 
68  return [kernelParamSqr, kernelParam](double errorSqr) -> double
69  { return (kernelParamSqr) / mrpt::square(errorSqr + kernelParam); };
70 
80  return [kernelParamSqr](double errorSqr) -> double
81  { return (kernelParamSqr) / (errorSqr + kernelParamSqr); };
82 
83  default:
84  throw std::invalid_argument("Unknown kernel type");
85  };
86 };
87 
88 } // namespace mp2p_icp
89 
90 // This allows reading/writing the enum type to strings, e.g. in YAML files.
91 MRPT_ENUM_TYPE_BEGIN_NAMESPACE(mp2p_icp, mp2p_icp::RobustKernel)
92 MRPT_FILL_ENUM(RobustKernel::None);
93 MRPT_FILL_ENUM(RobustKernel::GemanMcClure);
94 MRPT_FILL_ENUM(RobustKernel::Cauchy);
95 MRPT_ENUM_TYPE_END()
mp2p_icp::RobustKernel
RobustKernel
Definition: robust_kernels.h:25
mp2p_icp
Definition: covariance.h:17
MRPT_FILL_ENUM
MRPT_FILL_ENUM(RobustKernel::None)
mp2p_icp::robust_sqrt_weight_func_t
std::function< double(double)> robust_sqrt_weight_func_t
Definition: robust_kernels.h:37
mp2p_icp::RobustKernel::Cauchy
@ Cauchy
Cauchy kernel (Lee2013IROS).
mp2p_icp::RobustKernel::None
@ None
None: plain least-squares.
mp2p_icp::RobustKernel::GemanMcClure
@ GemanMcClure
Generalized GemanMcClure kernel (Zhang97ivc, Agarwal15phd).
mp2p_icp::create_robust_kernel
robust_sqrt_weight_func_t create_robust_kernel(const RobustKernel kernel, const double kernelParam)
Definition: robust_kernels.h:49


mp2p_icp
Author(s):
autogenerated on Wed Feb 26 2025 03:45:48