MRPT  2.0.4
TUserOptionsChecker.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
12 #include <mrpt/core/exceptions.h>
16 #include <mrpt/system/filesystem.h>
17 
25 
26 #include <iostream>
27 #include <string>
28 #include <vector>
29 
31 {
32 /**\brief Properties struct for both the Registration Decider and Optimizer
33  * classes
34  */
36 {
39  /**\brief Name of the decider or optimizer class
40  */
41  std::string name;
42  /**\brief General description of the decicder or optimizer class*/
43  std::string description;
44  /**\brief Class indicating if the current decider/optimizer class can be
45  * used
46  * in a multi-robot SLAM operation
47  */
48  bool is_mr_slam_class{false};
49  bool is_slam_2d{true};
50  bool is_slam_3d{false};
51 };
52 
53 /**\brief Properties struct for the Registration Decider classes.
54  *
55  * \ingroup mrpt_graphslam_grp
56  */
58 {
59  TRegistrationDeciderProps() = default;
60  ~TRegistrationDeciderProps() = default;
61  /**\brief Type of decider.
62  *
63  * Available options are:
64  * - node
65  * - edge
66  */
67  std::string type;
68  /**\brief Rawlog formats that the decider can be used in */
69  std::string rawlog_format;
70  /**\brief Measurements that the current decider class can utilize */
71  std::vector<std::string> observations_used;
72 };
73 
74 /**\brief Properties struct for the Optimizer classes.
75  *
76  * \ingroup mrpt_graphslam_grp
77  */
79 {
80  TOptimizerProps() = default;
81  ~TOptimizerProps() = default;
82 };
83 
84 /**\brief Class containing the declarations of supplementary methods that can
85  * be used in application-related code.
86  * Class instance can be handy for adding keeping the available
87  * deciders/optimizers in a compact manner and for verifying whether a given
88  * decider can be used.
89  *
90  * \ingroup mrpt_graphslam_grp
91  */
92 template <class GRAPH_t>
94 {
95  /**\name handy typedefs for the creation of deciders/optimzer instances from
96  * the corresponding strings
97  */
98  /**\{*/
99  using constraint_t = typename GRAPH_t::constraint_t;
100  using pose_t = typename GRAPH_t::constraint_t::type_value;
101  using node_regs_t = std::map<
102  std::string,
104  using edge_regs_t = std::map<
105  std::string,
107  using optimizers_t = std::map<
108  std::string,
110 
111  /**\}*/
112 
113  //
114  // methods
115  //
116  /**\brief Constructor */
118  /**\brief Destructor */
119  virtual ~TUserOptionsChecker();
120  /**\brief Create the necessary mappings from strings to the corresponding
121  * instance creation functors.
122  *
123  * Method is used for populating a map from string to instance creation
124  * function. The decider/optimzer can then be spawned according to the user
125  * selection.
126  *
127  */
128  virtual void createDeciderOptimizerMappings();
129  virtual void _createDeciderOptimizerMappings();
130  /**\brief Populate the available decider, optimizer classes available in
131  * user applications
132  */
133  virtual void populateDeciderOptimizerProperties();
134  /**\brief Check if the given registrator decider exists in the vector of
135  * deciders.
136  * \param[in] given_reg String specifying the type of decider - This should
137  * either be "node" or "edge"
138  * \return True if it exists, false otherwise
139  */
140  virtual bool checkRegistrationDeciderExists(
141  std::string given_reg, std::string reg_type) const;
142 
143  /**\brief Check if the given optimizer exists in the vector of optimizers.
144  * \return True if it exists, false otherwise
145  */
146  virtual bool checkOptimizerExists(std::string given_opt) const;
147 
148  /**\brief Print the registration deciders vector in a formatted manner to
149  * the
150  * standard output
151  * \param[in] reg_type Method prints both the node registration
152  * and edge registration deciders of the given vector unless specified
153  * otherwise. The available argument options are "node", "edge", "all"
154  */
155  virtual void dumpRegistrarsToConsole(std::string reg_type = "all") const;
156  /**\brief Print the optimizers vector in a formatted manner to the standard
157  * output.
158  */
159  virtual void dumpOptimizersToConsole() const;
160 
161  /**\name Methods for initializing decider/optimizer instances based on the
162  * user
163  * command line choices - http://stackoverflow.com/a/582456/2843583
164  *
165  * \warning Caller is responsible for deleting the initialized instances
166  */
167  /**\{*/
168  template <class T>
171  {
172  return new T;
173  }
174  template <class T>
177  {
178  return new T;
179  }
180  template <class T>
183  {
184  return new T;
185  }
186  /**}*/
187 
188  /**\name Mappings from registration decider/optimizer names to functors
189  * for creating instances of the corresponding classes
190  */
191  /**\{*/
195  /**\}*/
196 
197  /**\name Vectors containing descriptions about the available
198  * deciders/optimizers.
199  *
200  * Handy for displaying information to the user (e.g. in help text)
201  */
202  /**\{*/
203  std::vector<TRegistrationDeciderProps*> regs_descriptions;
204  std::vector<TOptimizerProps*> optimizers_descriptions;
205  /**\}*/
206 
207  const std::string sep_header;
208  const std::string sep_subheader;
209 };
210 } // namespace mrpt::graphslam::apps
Class containing the declarations of supplementary methods that can be used in application-related co...
virtual bool checkRegistrationDeciderExists(std::string given_reg, std::string reg_type) const
Check if the given registrator decider exists in the vector of deciders.
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...
std::map< std::string, mrpt::graphslam::deciders::CEdgeRegistrationDecider< GRAPH_T > *(*)()> edge_regs_t
virtual void populateDeciderOptimizerProperties()
Populate the available decider, optimizer classes available in user applications. ...
static mrpt::graphslam::deciders::CEdgeRegistrationDecider< GRAPH_t > * createEdgeRegistrationDecider()
static mrpt::graphslam::optimizers::CGraphSlamOptimizer< GRAPH_t > * createGraphSlamOptimizer()
typename GRAPH_T ::constraint_t::type_value pose_t
std::string description
General description of the decicder or optimizer class.
std::map< std::string, mrpt::graphslam::deciders::CNodeRegistrationDecider< GRAPH_T > *(*)()> node_regs_t
static mrpt::graphslam::deciders::CNodeRegistrationDecider< GRAPH_t > * createNodeRegistrationDecider()
virtual void createDeciderOptimizerMappings()
Create the necessary mappings from strings to the corresponding instance creation functors...
Interface for implementing graphSLAM optimizer classes.
virtual void dumpRegistrarsToConsole(std::string reg_type="all") const
Print the registration deciders vector in a formatted manner to the standard output.
Properties struct for both the Registration Decider and Optimizer classes.
std::map< std::string, mrpt::graphslam::optimizers::CGraphSlamOptimizer< GRAPH_T > *(*)()> optimizers_t
std::string name
Name of the decider or optimizer class.
Properties struct for the Optimizer classes.
virtual bool checkOptimizerExists(std::string given_opt) const
Check if the given optimizer exists in the vector of optimizers.
std::string rawlog_format
Rawlog formats that the decider can be used in.
std::vector< TOptimizerProps * > optimizers_descriptions
std::vector< TRegistrationDeciderProps * > regs_descriptions
virtual void dumpOptimizersToConsole() const
Print the optimizers vector in a formatted manner to the standard output.



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020