MRPT  1.9.9
TUserOptionsChecker_impl.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 // implementation of the TUserOptionsChecker class template methods
11 namespace mrpt::graphslam::apps
12 {
13 template <class GRAPH_t>
15  : sep_header(40, '='), sep_subheader(20, '-')
16 {
17 }
18 
19 template <class GRAPH_t>
21 {
22  using namespace std;
23 
24  // release the instances holding the descriptions of the available
25  // deciders/optimizers
27  regs_descriptions.begin();
28  it != regs_descriptions.end(); ++it)
29  {
30  delete *it;
31  }
33  optimizers_descriptions.begin();
34  it != optimizers_descriptions.end(); ++it)
35  {
36  delete *it;
37  }
38 }
39 
40 template <class GRAPH_t>
42 {
43  MRPT_START;
44 
45  using namespace mrpt::graphslam::deciders;
46  using namespace mrpt::graphslam::optimizers;
47  using namespace mrpt::graphs;
48  using namespace mrpt::poses;
49 
50  // node registration deciders
51  node_regs_map["CEmptyNRD"] =
52  &createNodeRegistrationDecider<CEmptyNRD<GRAPH_t>>;
53  node_regs_map["CFixedIntervalsNRD"] =
54  &createNodeRegistrationDecider<CFixedIntervalsNRD<GRAPH_t>>;
55  // edge registration deciders
56  edge_regs_map["CEmptyERD"] =
57  &createEdgeRegistrationDecider<CEmptyERD<GRAPH_t>>;
58  // optimizers
59  optimizers_map["CLevMarqGSO"] =
60  &createGraphSlamOptimizer<CLevMarqGSO<GRAPH_t>>;
61  optimizers_map["CEmptyGSO"] =
62  &createGraphSlamOptimizer<CLevMarqGSO<GRAPH_t>>;
63 
64  // create the decider optimizer, specific to the GRAPH_T template type
65  this->_createDeciderOptimizerMappings();
66 
67  MRPT_END;
68 }
69 
70 template <class GRAPH_t>
72 {
73 }
74 
75 // deciders/optpimizers specific to the 2D SLAM cases
76 template <>
77 inline void TUserOptionsChecker<
78  mrpt::graphs::CNetworkOfPoses2DInf>::_createDeciderOptimizerMappings()
79 {
80  using namespace mrpt::graphs;
81 
82  node_regs_map["CICPCriteriaNRD"] =
83  &createNodeRegistrationDecider<CICPCriteriaNRD<CNetworkOfPoses2DInf>>;
84  edge_regs_map["CICPCriteriaERD"] =
85  &createEdgeRegistrationDecider<CICPCriteriaERD<CNetworkOfPoses2DInf>>;
86  edge_regs_map["CLoopCloserERD"] =
87  &createEdgeRegistrationDecider<CLoopCloserERD<CNetworkOfPoses2DInf>>;
88 }
89 template <>
90 inline void TUserOptionsChecker<
91  mrpt::graphs::CNetworkOfPoses2DInf_NA>::_createDeciderOptimizerMappings()
92 {
93  using namespace mrpt::graphs;
94 
95  node_regs_map["CICPCriteriaNRD"] = &createNodeRegistrationDecider<
97  edge_regs_map["CICPCriteriaERD"] = &createEdgeRegistrationDecider<
99  edge_regs_map["CLoopCloserERD"] =
100  &createEdgeRegistrationDecider<CLoopCloserERD<CNetworkOfPoses2DInf_NA>>;
101 }
102 
103 // deciders/optpimizers specific to the 3D SLAM cases
104 template <>
105 inline void TUserOptionsChecker<
106  mrpt::graphs::CNetworkOfPoses3DInf>::_createDeciderOptimizerMappings()
107 {
108 }
109 
110 template <class GRAPH_t>
112  std::string reg_type /*="all"*/) const
113 {
114  MRPT_START;
115  using namespace std;
116  using namespace mrpt;
117 
119  (system::strCmpI(reg_type, "node") ||
120  system::strCmpI(reg_type, "edge") || system::strCmpI(reg_type, "all")),
121  format(
122  "Registrar string '%s' does not match a known registrar name.\n"
123  "Specify 'node' 'edge' or 'all'",
124  reg_type.c_str()));
125 
126  if (system::strCmpI(reg_type, "node") || system::strCmpI(reg_type, "edge"))
127  {
128  cout << endl
129  << "Available " << system::upperCase(reg_type)
130  << " Registration Deciders: " << endl;
131  cout << sep_header << endl;
132 
134  regs_descriptions.begin();
135  dec_it != regs_descriptions.end(); ++dec_it)
136  {
137  TRegistrationDeciderProps* dec = *dec_it;
138  if (system::strCmpI(dec->type, reg_type))
139  {
140  cout << dec->name << endl;
141  cout << sep_subheader << endl;
142  cout << "\t- "
143  << "Description: " << dec->description << endl;
144  cout << "\t- "
145  << "Rawlog Format: " << dec->rawlog_format << endl;
146  cout << "\t- "
147  << "Observations that can be used: " << endl;
148  cout << "\t- "
149  << "Multi-robot SLAM capable decider: "
150  << (dec->is_mr_slam_class ? "TRUE" : "FALSE") << endl;
151  cout << "\t- "
152  << "SLAM Type: " << endl;
153  if (dec->is_slam_2d)
154  {
155  cout << "\t\t+ "
156  << "2D" << endl;
157  }
158  if (dec->is_slam_3d)
159  {
160  cout << "\t\t+ "
161  << "3D" << endl;
162  }
163  cout << endl;
164  for (vector<string>::const_iterator obs_it =
165  dec->observations_used.begin();
166  obs_it != dec->observations_used.end(); ++obs_it)
167  {
168  cout << "\t\t+ " << *obs_it << endl;
169  }
170  }
171  }
172  }
173  else
174  { // print both
175  dumpRegistrarsToConsole("node");
176  dumpRegistrarsToConsole("edge");
177  }
178 
179  MRPT_END;
180 }
181 
182 template <class GRAPH_t>
184 {
185  MRPT_START;
186 
187  using namespace std;
188 
189  cout << endl << "Available GraphSlam Optimizer classes: " << endl;
190  cout << sep_header << endl;
191 
193  optimizers_descriptions.begin();
194  opt_it != optimizers_descriptions.end(); ++opt_it)
195  {
196  TOptimizerProps* opt = *opt_it;
197  cout << opt->name << endl;
198  cout << sep_subheader << endl;
199  cout << "\t- "
200  << "Description: " << opt->description << endl;
201 
202  cout << "\t- "
203  << "Multi-robot SLAM capable optimizer: "
204  << (opt->is_mr_slam_class ? "TRUE" : "FALSE");
205  cout << "\t- "
206  << "SLAM Type: " << endl;
207  if (opt->is_slam_2d)
208  {
209  cout << "\t\t+ "
210  << "2D" << endl;
211  }
212  if (opt->is_slam_3d)
213  {
214  cout << "\t\t+ "
215  << "3D" << endl;
216  }
217  }
218  MRPT_END;
219 }
220 
221 template <class GRAPH_t>
223  std::string given_reg, std::string reg_type) const
224 {
225  MRPT_START;
226 
227  using namespace std;
228  using namespace mrpt;
229  using namespace mrpt::poses;
230 
232  (system::strCmpI(reg_type, "node") ||
233  system::strCmpI(reg_type, "edge")),
234  format(
235  "Registrar string \"%s\" does not match a known registrar name.\n"
236  "Specify 'node' or 'edge' ",
237  reg_type.c_str()));
238  bool found = false;
239 
241  regs_descriptions.begin();
242  dec_it != regs_descriptions.end(); ++dec_it)
243  {
244  TRegistrationDeciderProps* dec = *dec_it;
245 
246  // TODO - check this
247  // if decider is not suitable for the selected SLAM type, ignore.
248  pose_t p;
249  if ((!dec->is_slam_2d && IS_CLASS(&p, CPose2D)) ||
250  (!dec->is_slam_3d && IS_CLASS(&p, CPose3D)))
251  {
252  continue;
253  }
254 
255  if (system::strCmpI(dec->type, reg_type))
256  {
257  if (system::strCmpI(dec->name, given_reg))
258  {
259  found = true;
260  return found;
261  }
262  }
263  }
264 
265  return found;
266  MRPT_END;
267 }
268 
269 template <class GRAPH_t>
271  std::string given_opt) const
272 {
273  MRPT_START;
274  using namespace std;
275  using namespace mrpt;
276  using namespace mrpt::poses;
277 
278  bool found = false;
279 
281  optimizers_descriptions.begin();
282  opt_it != optimizers_descriptions.end(); ++opt_it)
283  {
284  TOptimizerProps* opt = *opt_it;
285 
286  // if optimizer is not suitable for the selected SLAM type, ignore.
287  pose_t p;
288  if ((!opt->is_slam_2d && IS_CLASS(&p, CPose2D)) &&
289  (!opt->is_slam_3d && IS_CLASS(&p, CPose3D)))
290  {
291  continue;
292  }
293 
294  if (system::strCmpI(opt->name, given_opt))
295  {
296  found = true;
297  return found;
298  }
299  }
300 
301  return found;
302  MRPT_END;
303 }
304 
305 template <class GRAPH_t>
307 {
308  MRPT_START;
309 
310  // reset the vectors - in case they contain any elements
311  regs_descriptions.clear();
312  optimizers_descriptions.clear();
313 
314  // registering the available deciders
315  { // CFixedIntervalsNRD
317  dec->name = "CFixedIntervalsNRD";
318  dec->description =
319  "Register a new node if the distance from the previous node "
320  "surpasses a predefined distance threshold. Uses odometry "
321  "information for estimating the robot movement";
322  dec->type = "Node";
323  dec->rawlog_format = "Both";
324  dec->observations_used.push_back("CActionRobotMovement2D - Format #1");
325  dec->observations_used.push_back("CObservationOdometry - Format #2");
326  dec->is_slam_2d = true;
327  dec->is_slam_3d = true;
328 
329  regs_descriptions.push_back(dec);
330  }
331  { // CICPCriteriaNRD
333  dec->name = "CICPCriteriaNRD";
334  dec->description =
335  "Register a new node if the distance from the previous node "
336  "surpasses a predefined distance threshold. Uses 2D/3D RangeScans "
337  "alignment for estimating the robot movement";
338  dec->type = "Node";
339  dec->rawlog_format = "#2 - Observation-only";
340  dec->observations_used.push_back("CObservation2DRangeScan - Format #2");
341  dec->observations_used.push_back("CObservation3DRangeScan - Format #2");
342  dec->is_slam_2d = true;
343 
344  regs_descriptions.push_back(dec);
345  }
346  { // CEmptyNRD
348  dec->name = "CEmptyNRD";
349  dec->description =
350  "Empty Decider - does nothing when its class methods are called";
351  dec->type = "Node";
352  dec->rawlog_format = "Both";
353  dec->is_mr_slam_class = true;
354  dec->is_slam_2d = true;
355  dec->is_slam_3d = true;
356 
357  regs_descriptions.push_back(dec);
358  }
359  { // CICPCriteriaERD
361  dec->name = "CICPCriteriaERD";
362  dec->description =
363  "Register a new edge by aligning the provided 2D/3D RangeScans of "
364  "2 nodes. Uses the goodness of the ICP Alignment as the criterium "
365  "for adding a new edge";
366  dec->type = "Edge";
367  dec->rawlog_format = "Both";
368  dec->observations_used.push_back(
369  "CObservation2DRangeScan - Format #1, #2");
370  dec->observations_used.push_back("CObservation3DRangeScan - Format #2");
371  dec->is_slam_2d = true;
372 
373  regs_descriptions.push_back(dec);
374  }
375  { // CEmptyERD
377  dec->name = "CEmptyERD";
378  dec->description =
379  "Empty Decider - does nothing when its class methods are called";
380  dec->type = "Edge";
381  dec->rawlog_format = "Both";
382  dec->is_mr_slam_class = true;
383  dec->is_slam_2d = true;
384  dec->is_slam_3d = true;
385 
386  regs_descriptions.push_back(dec);
387  }
388  { // CLoopCloserERD
390  dec->name = "CLoopCloserERD";
391  dec->description =
392  "Partition the map and register *sets* of edges based on the "
393  "Pairwise consistency matrix of each set.";
394  dec->type = "Edge";
395  dec->rawlog_format = "Both";
396  dec->observations_used.push_back(
397  "CObservation2DRangeScan - Format #1, #2");
398  dec->is_slam_2d = true;
399 
400  regs_descriptions.push_back(dec);
401  }
402 
403  // registering the available optimizers
404  { // CEmptyGSO
405  TOptimizerProps* opt = new TOptimizerProps;
406  opt->name = "CEmptyGSO";
407  opt->description =
408  "Empty Optimizer - does nothing when its class methods are called";
409  opt->is_mr_slam_class = true;
410  opt->is_slam_2d = true;
411  opt->is_slam_3d = true;
412 
413  optimizers_descriptions.push_back(opt);
414  }
415 
416  { // CLevMarqGSO
417  TOptimizerProps* opt = new TOptimizerProps;
418  opt->name = "CLevMarqGSO";
419  opt->description = "Levenberg-Marqurdt non-linear graphSLAM solver";
420  opt->is_mr_slam_class = true;
421  opt->is_slam_2d = true;
422  opt->is_slam_3d = true;
423 
424  optimizers_descriptions.push_back(opt);
425  }
426 
427  MRPT_END
428 }
429 } // END OF NAMESPACES
430 
431 
Class containing the declarations of supplementary methods that can be used in application-related co...
Scalar * iterator
Definition: eigen_plugins.h:26
#define MRPT_START
Definition: exceptions.h:262
Abstract graph and tree data structures, plus generic graph algorithms.
Properties struct for the Registration Decider classes.
ICP-based Fixed Intervals Node Registration.
std::vector< std::string > observations_used
Measurements that the current decider class can utilize.
bool is_mr_slam_class
Class indicating if the current decider/optimizer class can be used in a multi-robot SLAM operation...
STL namespace.
A directed graph of pose constraints, with edges being the relative poses between pairs of nodes iden...
typename GRAPH_T ::constraint_t::type_value pose_t
std::string description
General description of the decicder or optimizer class.
GLsizei const GLchar ** string
Definition: glext.h:4101
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
#define ASSERTDEBMSG_(f, __ERROR_MSG)
Definition: exceptions.h:208
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:38
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:86
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
#define IS_CLASS(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::rtti::CObject) is of the give...
Definition: CObject.h:102
std::string name
Name of the decider or optimizer class.
std::string upperCase(const std::string &str)
Returns a upper-case version of a string.
#define MRPT_END
Definition: exceptions.h:266
Properties struct for the Optimizer classes.
std::string rawlog_format
Rawlog formats that the decider can be used in.
bool strCmpI(const std::string &s1, const std::string &s2)
Return true if the two strings are equal (case insensitive)
GLfloat GLfloat p
Definition: glext.h:6305
const Scalar * const_iterator
Definition: eigen_plugins.h:27



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020