MRPT  1.9.9
CGraphSlamHandler.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 #pragma once
10 
12 #include <mrpt/core/exceptions.h>
15 #include <mrpt/system/filesystem.h>
16 
21 
22 #include <iostream>
23 #include <sstream>
24 #include <string>
25 
26 /**\brief Manage variables and methods related to applications executing
27  * graphSLAM using the mrpt-graphslam API.
28  *
29  * CGraphSlamHandler class instances deal with the following:
30  * - Manage user interaction with the visuals (e.g. CDisplayWindow instance)
31  * - Manage general user options (e.g. user output directory preferences)
32  */
33 template <class GRAPH_T = mrpt::graphs::CNetworkOfPoses2DInf>
35 {
36  public:
40  const bool enable_visuals = true);
42  /**\brief Set the relevant filenames for instantiating CGraphSlamEngine
43  * instance
44  */
45  void setFNames(
46  const std::string& ini_fname, const std::string& rawlog_fname,
47  const std::string& ground_truth_fname = std::string());
48  /**\brief Print in a formatted manner the general configuraiton variables
49  * for
50  * the current graphSLAM execution
51  *
52  * \sa readConfigFname, getParamsAsString
53  */
54  void printParams() const;
55  /** Fetch the general configuraiton variables for the current graphSLAM
56  * execution
57  */
58  /**\{*/
59  void getParamsAsString(std::string* str) const;
60  std::string getParamsAsString() const;
61  /**\}*/
62  /**\brief Initialize visualization (e.g. the CDisplayWindow instance that
63  * shows the overall graphSLAM execution)
64  */
65  void initVisualization();
66  /**\brief Method to be called for parsing the rawlog file provided and for
67  * running graphSLAM using that information
68  */
69  void execute();
70  void initEngine(
71  const std::string& node_reg_str, const std::string& edge_reg_str,
72  const std::string& optimizer_str);
73  /**\brief Override the results directory filename that was initially set in
74  * the .ini file.
75  */
76  void setResultsDirName(const std::string& dirname);
77 
78  protected:
79  /**\brief Initialize (clean up and create new files) the output directory.
80  *
81  * If directory already exists (most probably from previous runs), the user
82  * is given 3 options:
83  * - Remove the current directory contents
84  * - Rename (and keep) the current directory contents
85  * - Manually handle the conflict
86  *
87  * User can also set the .ini parameter user_decides_about_output_dir flag
88  * to false, if he doesn't care about the previous results directory. In
89  * this case the 1st choice is picked.
90  *
91  * \param[in] Name of the output directory to be used
92  *
93  * \sa CGraphSlamEngine::initResultsFile
94  */
95  void initOutputDir(
96  const std::string& output_dir_fname = "graphslam_results");
97  /**\brief Query the CWindowObserver instance for any pressed keys that might
98  * be of interest (e.g. <C-c>)
99  *
100  * \return True if graphslam execution is to be continued normally
101  */
102  bool queryObserverForEvents();
103  /**\brief Read configuration variables for the current graphSLAM execution
104  * from a .ini file
105  *
106  * \sa printParams
107  */
108  void readConfigFname(const std::string& fname);
109  void saveResults(const std::string& output_dir_fname);
110  void saveMap(const std::string& fname);
111 
112  std::string m_output_dir_fname;
114 
118 
119  std::string m_ini_fname;
120  std::string m_rawlog_fname;
121  std::string m_gt_fname;
122 
123  std::string m_save_graph_fname;
124  std::string m_save_3DScene_fname;
125  std::string m_save_map_fname;
126 
131 
133 
134  /**\brief TUserOptionsChecker instance whose task is to evaluate the
135  * Registration Decider, Optimizer instances that are given by the user.
136  */
138 
139  bool m_do_save_results = true;
140  bool m_has_set_fnames = false;
141  ;
142  bool m_enable_visuals;
143 };
144 
145 #include "CGraphSlamHandler_impl.h"
void setResultsDirName(const std::string &dirname)
Override the results directory filename that was initially set in the .ini file.
void readConfigFname(const std::string &fname)
Read configuration variables for the current graphSLAM execution from a .ini file.
void printParams() const
Print in a formatted manner the general configuraiton variables for the current graphSLAM execution...
std::string m_rawlog_fname
std::string m_save_graph_fname
void saveResults(const std::string &output_dir_fname)
bool queryObserverForEvents()
Query the CWindowObserver instance for any pressed keys that might be of interest (e...
std::string m_output_dir_fname
CGraphSlamHandler(mrpt::system::COutputLogger *logger, mrpt::graphslam::apps::TUserOptionsChecker< GRAPH_T > *options_checker, const bool enable_visuals=true)
std::string m_save_map_fname
std::string getParamsAsString() const
void initVisualization()
Initialize visualization (e.g.
Versatile class for consistent logging and management of output messages.
Manage variables and methods related to applications executing graphSLAM using the mrpt-graphslam API...
Main file for the GraphSlamEngine.
void saveMap(const std::string &fname)
mrpt::graphslam::CWindowManager * m_win_manager
void execute()
Method to be called for parsing the rawlog file provided and for running graphSLAM using that informa...
mrpt::gui::CDisplayWindow3D * m_win
Monitor events in the visualization window.
void setFNames(const std::string &ini_fname, const std::string &rawlog_fname, const std::string &ground_truth_fname=std::string())
Set the relevant filenames for instantiating CGraphSlamEngine instance.
mrpt::system::COutputLogger * m_logger
void initEngine(const std::string &node_reg_str, const std::string &edge_reg_str, const std::string &optimizer_str)
std::string m_save_3DScene_fname
mrpt::graphslam::CGraphSlamEngine< GRAPH_T > * m_engine
void initOutputDir(const std::string &output_dir_fname="graphslam_results")
Initialize (clean up and create new files) the output directory.
mrpt::graphslam::CWindowObserver * m_win_observer
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.
mrpt::graphslam::apps::TUserOptionsChecker< GRAPH_T > * m_options_checker
TUserOptionsChecker instance whose task is to evaluate the Registration Decider, Optimizer instances ...



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020