icp_pipeline_from_yaml.cpp
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  * ------------------------------------------------------------------------- */
14 
15 using namespace mp2p_icp;
16 
17 std::tuple<mp2p_icp::ICP::Ptr, mp2p_icp::Parameters>
19  const mrpt::containers::yaml& icpParams,
20  const mrpt::system::VerbosityLevel& vLevel)
21 {
22  MRPT_START
23 
24  // ICP algorithm class:
25  const std::string icpClassName = icpParams["class_name"].as<std::string>();
26 
27  auto icp = std::dynamic_pointer_cast<mp2p_icp::ICP>(
28  mrpt::rtti::classFactory(icpClassName));
29  if (!icp)
30  THROW_EXCEPTION_FMT(
31  "Could not instantiate ICP algorithm named '%s'",
32  icpClassName.c_str());
33 
34  icp->setVerbosityLevel(vLevel);
35 
36  // Special derived-classes for library wrappers:
37  bool isDerived = false;
38  if (icpParams.has("derived"))
39  {
40  icp->initialize_derived(icpParams["derived"]);
41  isDerived = true;
42  }
43 
44  // ICP solver class:
45  if (icpParams.has("solvers")) icp->initialize_solvers(icpParams["solvers"]);
46 
47  // ICP matchers class:
48  if (icpParams.has("matchers"))
49  icp->initialize_matchers(icpParams["matchers"]);
50 
51  // ICP quality class:
52  ASSERT_(icpParams.has("quality"));
53  icp->initialize_quality_evaluators(icpParams["quality"]);
54 
55  // ICP parameters:
56  Parameters params;
57  if (!isDerived)
58  {
59  ASSERT_(icpParams.has("params"));
60  params.load_from(icpParams["params"]);
61  }
62 
63  return {icp, params};
64  MRPT_END
65 }
mp2p_icp
Definition: covariance.h:17
testing::internal::string
::std::string string
Definition: gtest.h:1979
mp2p_icp::icp_pipeline_from_yaml
std::tuple< mp2p_icp::ICP::Ptr, mp2p_icp::Parameters > icp_pipeline_from_yaml(const mrpt::containers::yaml &config, const mrpt::system::VerbosityLevel &vLevel=mrpt::system::LVL_INFO)
Definition: icp_pipeline_from_yaml.cpp:18
mp2p_icp::Parameters::load_from
void load_from(const mrpt::containers::yaml &p)
Definition: Parameters.cpp:58
icp_pipeline_from_yaml.h
Loads and setup an ICP pipeline from a YAML configuration file.
mp2p_icp::Parameters
Definition: Parameters.h:26


mp2p_icp
Author(s):
autogenerated on Thu Dec 26 2024 03:48:11