Main MRPT website > C++ reference for MRPT 1.5.7
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-2017, 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 { namespace graphslam { namespace apps {
12 
13 template<class GRAPH_t>
15  sep_header(40, '='),
16  sep_subheader(20, '-')
17 { }
18 
19 template<class GRAPH_t>
21  using namespace std;
22 
23  // release the instances holding the descriptions of the available
24  // deciders/optimizers
26  it = regs_descriptions.begin();
27  it != regs_descriptions.end();
28  ++it) {
29  delete *it;
30  }
32  it = optimizers_descriptions.begin();
33  it != optimizers_descriptions.end();
34  ++it) {
35  delete *it;
36  }
37 
38 }
39 
40 template<class GRAPH_t>
42  MRPT_START;
43 
44  using namespace mrpt::graphslam::deciders;
45  using namespace mrpt::graphslam::optimizers;
46  using namespace mrpt::graphs;
47  using namespace mrpt::poses;
48 
49  // node registration deciders
50  node_regs_map["CEmptyNRD"] =
51  &createNodeRegistrationDecider<CEmptyNRD<GRAPH_t> >;
52  node_regs_map["CFixedIntervalsNRD"] =
53  &createNodeRegistrationDecider<CFixedIntervalsNRD<GRAPH_t> >;
54  // edge registration deciders
55  edge_regs_map["CEmptyERD"] =
56  &createEdgeRegistrationDecider<CEmptyERD<GRAPH_t> >;
57  // optimizers
58  optimizers_map["CLevMarqGSO"] =
59  &createGraphSlamOptimizer<CLevMarqGSO<GRAPH_t> >;
60  optimizers_map["CEmptyGSO"] =
61  &createGraphSlamOptimizer<CLevMarqGSO<GRAPH_t> >;
62 
63  // create the decider optimizer, specific to the GRAPH_T template type
64  this->_createDeciderOptimizerMappings();
65 
66 
67  MRPT_END;
68 }
69 
70 template<class GRAPH_t>
72 }
73 
74 // deciders/optpimizers specific to the 2D SLAM cases
75 template<>
77  using namespace mrpt::graphs;
78 
79  node_regs_map["CICPCriteriaNRD"] =
80  &createNodeRegistrationDecider<CICPCriteriaNRD<CNetworkOfPoses2DInf> >;
81  edge_regs_map["CICPCriteriaERD"] =
82  &createEdgeRegistrationDecider<CICPCriteriaERD<CNetworkOfPoses2DInf> >;
83  edge_regs_map["CLoopCloserERD"] =
84  &createEdgeRegistrationDecider<CLoopCloserERD<CNetworkOfPoses2DInf> >;
85 
86 }
87 template<>
89  using namespace mrpt::graphs;
90 
91  node_regs_map["CICPCriteriaNRD"] =
92  &createNodeRegistrationDecider<CICPCriteriaNRD<CNetworkOfPoses2DInf_NA> >;
93  edge_regs_map["CICPCriteriaERD"] =
94  &createEdgeRegistrationDecider<CICPCriteriaERD<CNetworkOfPoses2DInf_NA> >;
95  edge_regs_map["CLoopCloserERD"] =
96  &createEdgeRegistrationDecider<CLoopCloserERD<CNetworkOfPoses2DInf_NA> >;
97 }
98 
99 // deciders/optpimizers specific to the 3D SLAM cases
100 template<>
102 
103 }
104 
105 template<class GRAPH_t>
107  std::string reg_type/*="all"*/) const {
108  MRPT_START;
109  using namespace std;
110  using namespace mrpt;
111 
112  ASSERTMSG_((system::strCmpI(reg_type, "node") ||
113  system::strCmpI(reg_type, "edge") ||
114  system::strCmpI(reg_type, "all")),
115  format("Registrar string '%s' does not match a known registrar name.\n"
116  "Specify 'node' 'edge' or 'all'", reg_type.c_str()));
117 
118 
119  if ( system::strCmpI(reg_type, "node") || system::strCmpI(reg_type, "edge") ) {
120 
121  cout << endl << "Available " << system::upperCase(reg_type) << " Registration Deciders: " << endl;
122  cout << sep_header << endl;
123 
125  dec_it = regs_descriptions.begin();
126  dec_it != regs_descriptions.end(); ++dec_it) {
127  TRegistrationDeciderProps* dec = *dec_it;
128  if ( system::strCmpI(dec->type, reg_type) ) {
129  cout << dec->name << endl;
130  cout << sep_subheader << endl;
131  cout << "\t- " << "Description: " << dec->description << endl;
132  cout << "\t- " << "Rawlog Format: " << dec->rawlog_format << endl;
133  cout << "\t- " << "Observations that can be used: " << endl;
134  cout << "\t- " << "Multi-robot SLAM capable decider: " <<
135  (dec->is_mr_slam_class? "TRUE": "FALSE") << endl;
136  cout << "\t- " << "SLAM Type: " << endl;
137  if (dec->is_slam_2d) {
138  cout << "\t\t+ " << "2D" << endl;
139  }
140  if (dec->is_slam_3d) {
141  cout << "\t\t+ " << "3D" << endl;
142  }
143  cout << endl;
144  for (vector<string>::const_iterator obs_it = dec->observations_used.begin();
145  obs_it != dec->observations_used.end(); ++obs_it) {
146  cout << "\t\t+ " << *obs_it << endl;
147  }
148  }
149  }
150  }
151  else { // print both
152  dumpRegistrarsToConsole("node");
153  dumpRegistrarsToConsole("edge");
154  }
155 
156  MRPT_END;
157 }
158 
159 template<class GRAPH_t>
161  MRPT_START;
162 
163  using namespace std;
164 
165  cout << endl << "Available GraphSlam Optimizer classes: " << endl;
166  cout << sep_header << endl;
167 
168  for (vector<TOptimizerProps*>::const_iterator opt_it = optimizers_descriptions.begin();
169  opt_it != optimizers_descriptions.end(); ++opt_it) {
170  TOptimizerProps* opt = *opt_it;
171  cout << opt->name << endl;
172  cout << sep_subheader << endl;
173  cout << "\t- " << "Description: " << opt->description << endl;
174 
175  cout << "\t- " << "Multi-robot SLAM capable optimizer: " <<
176  (opt->is_mr_slam_class? "TRUE": "FALSE");
177  cout << "\t- " << "SLAM Type: " << endl;
178  if (opt->is_slam_2d) {
179  cout << "\t\t+ " << "2D" << endl;
180  }
181  if (opt->is_slam_3d) {
182  cout << "\t\t+ " << "3D" << endl;
183  }
184  }
185  MRPT_END;
186 }
187 
188 template<class GRAPH_t>
190  std::string given_reg,
191  std::string reg_type) const {
192  MRPT_START;
193 
194  using namespace std;
195  using namespace mrpt;
196  using namespace mrpt::poses;
197 
198  ASSERTMSG_((system::strCmpI(reg_type, "node") ||
199  system::strCmpI(reg_type, "edge")),
200  format("Registrar string \"%s\" does not match a known registrar name.\n"
201  "Specify 'node' or 'edge' ", reg_type.c_str()));
202  bool found = false;
203 
205  dec_it = regs_descriptions.begin();
206  dec_it != regs_descriptions.end(); ++dec_it) {
207  TRegistrationDeciderProps* dec = *dec_it;
208 
209  // TODO - check this
210  // if decider is not suitable for the selected SLAM type, ignore.
211  pose_t p;
212  if ((!dec->is_slam_2d && IS_CLASS(&p, CPose2D)) ||
213  (!dec->is_slam_3d && IS_CLASS(&p, CPose3D))) {
214  continue;
215  }
216 
217  if (system::strCmpI(dec->type, reg_type)) {
218  if (system::strCmpI(dec->name, given_reg)) {
219  found = true;
220  return found;
221  }
222  }
223  }
224 
225  return found;
226  MRPT_END;
227 }
228 
229 template<class GRAPH_t>
231  MRPT_START;
232  using namespace std;
233  using namespace mrpt;
234  using namespace mrpt::poses;
235 
236  bool found = false;
237 
239  opt_it = optimizers_descriptions.begin();
240  opt_it != optimizers_descriptions.end(); ++opt_it) {
241  TOptimizerProps* opt = *opt_it;
242 
243  // if optimizer is not suitable for the selected SLAM type, ignore.
244  pose_t p;
245  if ((!opt->is_slam_2d && IS_CLASS(&p, CPose2D)) &&
246  (!opt->is_slam_3d && IS_CLASS(&p, CPose3D))) {
247  continue;
248  }
249 
250  if ( system::strCmpI(opt->name, given_opt) ) {
251  found = true;
252  return found;
253  }
254  }
255 
256  return found;
257  MRPT_END;
258 }
259 
260 template<class GRAPH_t>
262  MRPT_START;
263 
264  // reset the vectors - in case they contain any elements
265  regs_descriptions.clear();
266  optimizers_descriptions.clear();
267 
268  // registering the available deciders
269  { // CFixedIntervalsNRD
271  dec->name = "CFixedIntervalsNRD";
272  dec->description = "Register a new node if the distance from the previous node surpasses a predefined distance threshold. Uses odometry information for estimating the robot movement";
273  dec->type = "Node";
274  dec->rawlog_format = "Both";
275  dec->observations_used.push_back("CActionRobotMovement2D - Format #1");
276  dec->observations_used.push_back("CObservationOdometry - Format #2");
277  dec->is_slam_2d = true;
278  dec->is_slam_3d = true;
279 
280  regs_descriptions.push_back(dec);
281  }
282  { // CICPCriteriaNRD
284  dec->name = "CICPCriteriaNRD";
285  dec->description = "Register a new node if the distance from the previous node surpasses a predefined distance threshold. Uses 2D/3D RangeScans alignment for estimating the robot movement";
286  dec->type = "Node";
287  dec->rawlog_format = "#2 - Observation-only";
288  dec->observations_used.push_back("CObservation2DRangeScan - Format #2");
289  dec->observations_used.push_back("CObservation3DRangeScan - Format #2");
290  dec->is_slam_2d = true;
291 
292  regs_descriptions.push_back(dec);
293  }
294  { // CEmptyNRD
296  dec->name = "CEmptyNRD";
297  dec->description = "Empty Decider - does nothing when its class methods are called";
298  dec->type = "Node";
299  dec->rawlog_format = "Both";
300  dec->is_mr_slam_class = true;
301  dec->is_slam_2d = true;
302  dec->is_slam_3d = true;
303 
304  regs_descriptions.push_back(dec);
305  }
306  { // CICPCriteriaERD
308  dec->name = "CICPCriteriaERD";
309  dec->description = "Register a new edge by aligning the provided 2D/3D RangeScans of 2 nodes. Uses the goodness of the ICP Alignment as the criterium for adding a new edge";
310  dec->type = "Edge";
311  dec->rawlog_format = "Both";
312  dec->observations_used.push_back("CObservation2DRangeScan - Format #1, #2");
313  dec->observations_used.push_back("CObservation3DRangeScan - Format #2");
314  dec->is_slam_2d = true;
315 
316  regs_descriptions.push_back(dec);
317  }
318  { // CEmptyERD
320  dec->name = "CEmptyERD";
321  dec->description = "Empty Decider - does nothing when its class methods are called";
322  dec->type = "Edge";
323  dec->rawlog_format = "Both";
324  dec->is_mr_slam_class = true;
325  dec->is_slam_2d = true;
326  dec->is_slam_3d = true;
327 
328  regs_descriptions.push_back(dec);
329  }
330  { // CLoopCloserERD
332  dec->name = "CLoopCloserERD";
333  dec->description = "Partition the map and register *sets* of edges based on the Pairwise consistency matrix of each set.";
334  dec->type = "Edge";
335  dec->rawlog_format = "Both";
336  dec->observations_used.push_back("CObservation2DRangeScan - Format #1, #2");
337  dec->is_slam_2d = true;
338 
339  regs_descriptions.push_back(dec);
340  }
341 
342  // registering the available optimizers
343  { // CEmptyGSO
344  TOptimizerProps* opt = new TOptimizerProps;
345  opt->name = "CEmptyGSO";
346  opt->description = "Empty Optimizer - does nothing when its class methods are called";
347  opt->is_mr_slam_class = true;
348  opt->is_slam_2d = true;
349  opt->is_slam_3d = true;
350 
351  optimizers_descriptions.push_back(opt);
352  }
353 
354  { // CLevMarqGSO
355  TOptimizerProps* opt = new TOptimizerProps;
356  opt->name = "CLevMarqGSO";
357  opt->description = "Levenberg-Marqurdt non-linear graphSLAM solver";
358  opt->is_mr_slam_class = true;
359  opt->is_slam_2d = true;
360  opt->is_slam_3d = true;
361 
362  optimizers_descriptions.push_back(opt);
363  }
364 
365  MRPT_END
366 }
367 
368 
369 
370 } } } // END OF NAMESPACES
Class containing the declarations of supplementary methods that can be used in application-related co...
Abstract graph and tree data structures, plus generic graph algorithms.
Scalar * iterator
Definition: eigen_plugins.h:23
Properties struct for the Registration Decider classes.
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.
const Scalar * const_iterator
Definition: eigen_plugins.h:24
#define MRPT_END
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:21
std::string description
General description of the decicder or optimizer class.
GLsizei const GLchar ** string
Definition: glext.h:3919
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
#define MRPT_START
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:36
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:72
#define IS_CLASS(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::utils::CSerializable) is of t...
Definition: CObject.h:93
std::string name
Name of the decider or optimizer class.
std::string BASE_IMPEXP upperCase(const std::string &str)
Returns a upper-case version of a string.
Properties struct for the Optimizer classes.
std::string rawlog_format
Rawlog formats that the decider can be used in.
bool BASE_IMPEXP strCmpI(const std::string &s1, const std::string &s2)
Return true if the two strings are equal (case insensitive)
#define ASSERTMSG_(f, __ERROR_MSG)
GLfloat GLfloat p
Definition: glext.h:5587



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019