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
mrpt::graphslam::apps::TOptimizerProps::TOptimizerProps
TOptimizerProps()=default
filesystem.h
mrpt::graphslam::deciders::CNodeRegistrationDecider< GRAPH_t >
CPose3DPDFGaussianInf.h
CNetworkOfPoses.h
mrpt::graphslam::apps::TUserOptionsChecker::_createDeciderOptimizerMappings
virtual void _createDeciderOptimizerMappings()
Definition: TUserOptionsChecker_impl.h:69
mrpt::graphslam::apps::TUserOptionsChecker::optimizers_descriptions
std::vector< TOptimizerProps * > optimizers_descriptions
Definition: TUserOptionsChecker.h:204
exceptions.h
mrpt::graphslam::apps::TRegistrationDeciderOrOptimizerProps
Properties struct for both the Registration Decider and Optimizer classes.
Definition: TUserOptionsChecker.h:35
mrpt::graphslam::apps::TUserOptionsChecker::checkRegistrationDeciderExists
virtual bool checkRegistrationDeciderExists(std::string given_reg, std::string reg_type) const
Check if the given registrator decider exists in the vector of deciders.
Definition: TUserOptionsChecker_impl.h:217
CFixedIntervalsNRD.h
mrpt::graphslam::apps::TUserOptionsChecker::optimizers_map
optimizers_t optimizers_map
Definition: TUserOptionsChecker.h:194
mrpt::graphslam::apps::TUserOptionsChecker< mrpt::graphs::CNetworkOfPoses2DInf >::edge_regs_t
std::map< std::string, mrpt::graphslam::deciders::CEdgeRegistrationDecider< mrpt::graphs::CNetworkOfPoses2DInf > *(*)()> edge_regs_t
Definition: TUserOptionsChecker.h:106
mrpt::graphslam::apps::TUserOptionsChecker::dumpOptimizersToConsole
virtual void dumpOptimizersToConsole() const
Print the optimizers vector in a formatted manner to the standard output.
Definition: TUserOptionsChecker_impl.h:179
mrpt::graphslam::apps::TUserOptionsChecker::populateDeciderOptimizerProperties
virtual void populateDeciderOptimizerProperties()
Populate the available decider, optimizer classes available in user applications.
Definition: TUserOptionsChecker_impl.h:299
mrpt::graphslam::deciders::CEdgeRegistrationDecider< GRAPH_t >
mrpt::graphslam::optimizers::CGraphSlamOptimizer
Interface for implementing graphSLAM optimizer classes.
Definition: CGraphSlamOptimizer.h:34
mrpt::graphslam::apps::TUserOptionsChecker::node_regs_map
node_regs_t node_regs_map
Definition: TUserOptionsChecker.h:192
mrpt::graphslam::apps::TUserOptionsChecker::TUserOptionsChecker
TUserOptionsChecker()
Constructor.
Definition: TUserOptionsChecker_impl.h:14
mrpt::graphslam::apps::TRegistrationDeciderProps::type
std::string type
Type of decider.
Definition: TUserOptionsChecker.h:67
mrpt::graphslam::apps::TRegistrationDeciderOrOptimizerProps::is_mr_slam_class
bool is_mr_slam_class
Class indicating if the current decider/optimizer class can be used in a multi-robot SLAM operation.
Definition: TUserOptionsChecker.h:48
CICPCriteriaERD.h
mrpt::graphslam::apps::TRegistrationDeciderOrOptimizerProps::TRegistrationDeciderOrOptimizerProps
TRegistrationDeciderOrOptimizerProps()=default
mrpt::graphslam::apps::TUserOptionsChecker::createEdgeRegistrationDecider
static mrpt::graphslam::deciders::CEdgeRegistrationDecider< GRAPH_t > * createEdgeRegistrationDecider()
Definition: TUserOptionsChecker.h:176
mrpt::graphslam::apps::TUserOptionsChecker< mrpt::graphs::CNetworkOfPoses2DInf >::constraint_t
typename mrpt::graphs::CNetworkOfPoses2DInf ::constraint_t constraint_t
Definition: TUserOptionsChecker.h:99
mrpt::graphslam::apps::TRegistrationDeciderProps::~TRegistrationDeciderProps
~TRegistrationDeciderProps()=default
mrpt::graphslam::apps::TUserOptionsChecker::edge_regs_map
edge_regs_t edge_regs_map
Definition: TUserOptionsChecker.h:193
mrpt::graphslam::apps::TOptimizerProps::~TOptimizerProps
~TOptimizerProps()=default
mrpt::graphslam::apps::TRegistrationDeciderProps::observations_used
std::vector< std::string > observations_used
Measurements that the current decider class can utilize.
Definition: TUserOptionsChecker.h:71
mrpt::graphslam::apps
Definition: TUserOptionsChecker.h:30
mrpt::graphslam::apps::TUserOptionsChecker
Class containing the declarations of supplementary methods that can be used in application-related co...
Definition: TUserOptionsChecker.h:93
mrpt::graphslam::apps::TRegistrationDeciderOrOptimizerProps::description
std::string description
General description of the decicder or optimizer class.
Definition: TUserOptionsChecker.h:43
mrpt::graphslam::apps::TRegistrationDeciderOrOptimizerProps::name
std::string name
Name of the decider or optimizer class.
Definition: TUserOptionsChecker.h:41
mrpt::graphslam::apps::TUserOptionsChecker::createGraphSlamOptimizer
static mrpt::graphslam::optimizers::CGraphSlamOptimizer< GRAPH_t > * createGraphSlamOptimizer()
Definition: TUserOptionsChecker.h:182
mrpt::graphslam::apps::TUserOptionsChecker< mrpt::graphs::CNetworkOfPoses2DInf >::pose_t
typename mrpt::graphs::CNetworkOfPoses2DInf ::constraint_t::type_value pose_t
Definition: TUserOptionsChecker.h:100
mrpt::graphslam::apps::TUserOptionsChecker< mrpt::graphs::CNetworkOfPoses2DInf >::node_regs_t
std::map< std::string, mrpt::graphslam::deciders::CNodeRegistrationDecider< mrpt::graphs::CNetworkOfPoses2DInf > *(*)()> node_regs_t
Definition: TUserOptionsChecker.h:103
CEmptyNRD.h
CICPCriteriaNRD.h
mrpt::graphslam::apps::TUserOptionsChecker::sep_header
const std::string sep_header
Definition: TUserOptionsChecker.h:207
mrpt::graphslam::apps::TRegistrationDeciderOrOptimizerProps::is_slam_2d
bool is_slam_2d
Definition: TUserOptionsChecker.h:49
mrpt::graphslam::apps::TRegistrationDeciderProps::TRegistrationDeciderProps
TRegistrationDeciderProps()=default
mrpt::graphslam::apps::TRegistrationDeciderOrOptimizerProps::~TRegistrationDeciderOrOptimizerProps
~TRegistrationDeciderOrOptimizerProps()=default
mrpt::graphslam::apps::TRegistrationDeciderOrOptimizerProps::is_slam_3d
bool is_slam_3d
Definition: TUserOptionsChecker.h:50
mrpt::graphslam::apps::TUserOptionsChecker::createDeciderOptimizerMappings
virtual void createDeciderOptimizerMappings()
Create the necessary mappings from strings to the corresponding instance creation functors.
Definition: TUserOptionsChecker_impl.h:39
CPosePDFGaussianInf.h
CLevMarqGSO.h
mrpt::graphslam::apps::TUserOptionsChecker::dumpRegistrarsToConsole
virtual void dumpRegistrarsToConsole(std::string reg_type="all") const
Print the registration deciders vector in a formatted manner to the standard output.
Definition: TUserOptionsChecker_impl.h:109
CLoopCloserERD.h
CEmptyERD.h
mrpt::graphslam::apps::TUserOptionsChecker::createNodeRegistrationDecider
static mrpt::graphslam::deciders::CNodeRegistrationDecider< GRAPH_t > * createNodeRegistrationDecider()
Definition: TUserOptionsChecker.h:170
TUserOptionsChecker_impl.h
mrpt::graphslam::apps::TUserOptionsChecker::checkOptimizerExists
virtual bool checkOptimizerExists(std::string given_opt) const
Check if the given optimizer exists in the vector of optimizers.
Definition: TUserOptionsChecker_impl.h:264
mrpt::graphslam::apps::TUserOptionsChecker::regs_descriptions
std::vector< TRegistrationDeciderProps * > regs_descriptions
Definition: TUserOptionsChecker.h:203
mrpt::graphslam::apps::TUserOptionsChecker< mrpt::graphs::CNetworkOfPoses2DInf >::optimizers_t
std::map< std::string, mrpt::graphslam::optimizers::CGraphSlamOptimizer< mrpt::graphs::CNetworkOfPoses2DInf > *(*)()> optimizers_t
Definition: TUserOptionsChecker.h:109
mrpt::graphslam::apps::TRegistrationDeciderProps::rawlog_format
std::string rawlog_format
Rawlog formats that the decider can be used in.
Definition: TUserOptionsChecker.h:69
mrpt::graphslam::apps::TOptimizerProps
Properties struct for the Optimizer classes.
Definition: TUserOptionsChecker.h:78
mrpt::graphslam::apps::TUserOptionsChecker::sep_subheader
const std::string sep_subheader
Definition: TUserOptionsChecker.h:208
mrpt::graphslam::apps::TUserOptionsChecker::~TUserOptionsChecker
virtual ~TUserOptionsChecker()
Destructor.
Definition: TUserOptionsChecker_impl.h:20
mrpt::graphslam::apps::TRegistrationDeciderProps
Properties struct for the Registration Decider classes.
Definition: TUserOptionsChecker.h:57



Page generated by Doxygen 1.8.17 for MRPT 2.0.4 at Sat Jun 27 14:00:59 UTC 2020