MRPT  2.0.4
CRegistrationDeciderOrOptimizer.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 
15 #include <mrpt/obs/CObservation.h>
16 #include <mrpt/obs/CSensoryFrame.h>
19 
20 #include <map>
21 #include <string>
22 
23 namespace mrpt::graphslam
24 {
25 /**\brief Interface for implementing node/edge registration deciders or
26  * optimizer classes.
27  *
28  * Specific interfaces - for implementing node/edge deciders / optimizers -
29  * can inherit from CRegistrationDeciderOrOptimizer so that they can make use
30  * of the generic methods defined in the latter.
31  *
32  * \note \b Convention: For the already implemented deciders/optimizers the
33  * following naming convention has been used:
34  * - NRD: Node Registration Decider class
35  * - ERD: Edge Registration Decider class
36  * - GSO: GraphSlam Optimizer class
37  *
38  * \ingroup mrpt_graphslam_grp
39  */
40 template <class GRAPH_T = typename mrpt::graphs::CNetworkOfPoses2DInf>
42 {
43  public:
45  ~CRegistrationDeciderOrOptimizer() override = default;
46  /**\brief Generic method for fetching the incremental action-observations
47  * (or
48  * observation-only) measurements
49  *
50  * \return True if operation was successful. Criteria for Success depend on
51  * the decider/optimizer implementing this method
52  */
53  virtual bool updateState(
55  mrpt::obs::CSensoryFrame::Ptr observations,
56  mrpt::obs::CObservation::Ptr observation) = 0;
57  /**\brief Fetch a CWindowManager pointer.
58  *
59  * CWindowManager instance should contain a CDisplayWindow3D* and,
60  * optionally, a CWindowObserver pointer so that interaction with the
61  * window is possible
62  */
63  virtual void setWindowManagerPtr(
64  mrpt::graphslam::CWindowManager* win_manager);
65 
66  /**\brief Fetch a std::mutex for locking the GRAPH_T
67  * resource.
68  *
69  * Handy for realising multithreading in the derived classes.
70  *
71  * \warning Beware that prior to the decider/optimizer public method call,
72  * the CCriticalSection will already be locked from CGraphSlamEngine_t
73  * instance, but this isn't effective in multithreaded implementations where
74  * the decider/optimizer itself has to lock the function at which the extra
75  * thread runs.
76  */
77  virtual void setCriticalSectionPtr(std::mutex* graph_section);
78  /**\brief Initialize visual objects in CDisplayWindow (e.g. \em add an
79  * object to scene).
80  *
81  * \exception std::exception If the method is called without having first
82  * provided a CDisplayWindow3D* to the class instance
83  *
84  * \sa setWindowManagerPtr, updateVisuals
85  */
86  virtual void initializeVisuals();
87  /**\brief Update the relevant visual features in CDisplayWindow.
88  *
89  *\exception std::exception If the method is called without having first
90  * provided a CDisplayWindow3D* to the class instance
91  *
92  * \sa setWindowManagerPtr, initializeVisuals
93  */
94  virtual void updateVisuals();
95  /**\brief Get a list of the window events that happened since the last call.
96  *
97  * Method in derived classes is automatically called from the
98  * CGraphSlamEngine_t instance. After that, decider/optimizer should just
99  * fetch the parameters that it is interested in.
100  */
101  virtual void notifyOfWindowEvents(
102  const std::map<std::string, bool>& events_occurred);
103  /**\brief Load the necessary for the decider/optimizer configuration
104  * parameters.
105  */
106  virtual void loadParams(const std::string& source_fname);
107  /**\brief Print the problem parameters - relevant to the decider/optimizer
108  * to the
109  * screen in a unified/compact way.
110  */
111  virtual void printParams() const;
112  /**\brief Fill the provided string with a detailed report of the
113  * decider/optimizer state.
114  *
115  * Report should include (part of) the following:
116  * - Timing of important methods
117  * - Properties fo class at the current time
118  * - Logging of commands until current time
119  */
120  virtual void getDescriptiveReport(std::string* report_str) const;
121 
122  /**\brief Fetch the graph on which the decider/optimizer will work on.
123  *
124  */
125  virtual void setGraphPtr(GRAPH_T* graph);
126 
127  /**\brief Initialize the COutputLogger, CTimeLogger instances given the
128  * name of the decider/optimizer at hand
129  */
130  virtual void initializeLoggers(const std::string& name);
131  virtual void setClassName(const std::string& name);
132  bool isMultiRobotSlamClass();
133 
134  std::string getClassName() const { return m_class_name; };
135 
136  protected:
137  /**\brief Handy function for making all the visuals assertions in a
138  * compact manner
139  */
140  virtual void assertVisualsVars();
141  /**\brief Pointer to the graph that is under construction */
142  GRAPH_T* m_graph = nullptr;
143  std::mutex* m_graph_section = nullptr;
144 
145  /** \name Visuals-related variables methods
146  */
147  /**\{*/
148  /**\brief Pointer to the CWindowManager object used to store
149  * visuals-related instances
150  */
152  /**\brief Window to use */
154  /**\brief CWindowObserver object for monitoring various visual-oriented
155  * events.*/
157  bool m_initialized_visuals = false;
158  /**\}*/
159 
160  /**\brief Time logger instance */
162  /**\brief Name of the class instance */
163  std::string m_class_name = "CRegistrationDeciderOrOptimizer";
164  /**\brief Boolean indicating if the current class can be used in
165  * multi-robot SLAM operations
166  */
167  bool is_mr_slam_class = false;
168 
169  /**\brief Separator string to be used in debugging messages
170  */
171  static const std::string header_sep;
172  static const std::string report_sep;
173 };
174 } // namespace mrpt::graphslam
virtual void notifyOfWindowEvents(const std::map< std::string, bool > &events_occurred)
Get a list of the window events that happened since the last call.
mrpt::gui::CDisplayWindow3D * m_win
Window to use.
virtual void loadParams(const std::string &source_fname)
Load the necessary for the decider/optimizer configuration parameters.
virtual bool updateState(mrpt::obs::CActionCollection::Ptr action, mrpt::obs::CSensoryFrame::Ptr observations, mrpt::obs::CObservation::Ptr observation)=0
Generic method for fetching the incremental action-observations (or observation-only) measurements...
virtual void printParams() const
Print the problem parameters - relevant to the decider/optimizer to the screen in a unified/compact w...
static const std::string header_sep
Separator string to be used in debugging messages.
virtual void setCriticalSectionPtr(std::mutex *graph_section)
Fetch a std::mutex for locking the GRAPH_T resource.
mrpt::graphslam::CWindowObserver * m_win_observer
CWindowObserver object for monitoring various visual-oriented events.
bool is_mr_slam_class
Boolean indicating if the current class can be used in multi-robot SLAM operations.
virtual void setGraphPtr(GRAPH_T *graph)
Fetch the graph on which the decider/optimizer will work on.
mrpt::graphslam::CWindowManager * m_win_manager
Pointer to the CWindowManager object used to store visuals-related instances.
SLAM methods related to graphs of pose constraints.
virtual void initializeVisuals()
Initialize visual objects in CDisplayWindow (e.g.
Versatile class for consistent logging and management of output messages.
Interface for implementing node/edge registration deciders or optimizer classes.
virtual void getDescriptiveReport(std::string *report_str) const
Fill the provided string with a detailed report of the decider/optimizer state.
virtual void initializeLoggers(const std::string &name)
Initialize the COutputLogger, CTimeLogger instances given the name of the decider/optimizer at hand...
virtual void setWindowManagerPtr(mrpt::graphslam::CWindowManager *win_manager)
Fetch a CWindowManager pointer.
GRAPH_T * m_graph
Pointer to the graph that is under construction.
virtual void assertVisualsVars()
Handy function for making all the visuals assertions in a compact manner.
A versatile "profiler" that logs the time spent within each pair of calls to enter(X)-leave(X), among other stats.
Monitor events in the visualization window.
virtual void updateVisuals()
Update the relevant visual features in CDisplayWindow.
mrpt::system::CTimeLogger m_time_logger
Time logger instance.
Class acts as a container for storing pointers to mrpt::gui::CDisplayWindow3D, mrpt::graphslam::CWind...
A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time.



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