MRPT  2.0.4
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"
CGraphSlamHandler::m_has_set_fnames
bool m_has_set_fnames
Definition: CGraphSlamHandler.h:140
filesystem.h
CGraphSlamHandler::m_save_graph
bool m_save_graph
Definition: CGraphSlamHandler.h:115
CGraphSlamHandler::m_save_3DScene_fname
std::string m_save_3DScene_fname
Definition: CGraphSlamHandler.h:124
exceptions.h
CGraphSlamHandler::execute
void execute()
Method to be called for parsing the rawlog file provided and for running graphSLAM using that informa...
Definition: CGraphSlamHandler_impl.h:377
CWindowManager.h
CGraphSlamHandler::m_ini_fname
std::string m_ini_fname
Definition: CGraphSlamHandler.h:119
CGraphSlamHandler::initEngine
void initEngine(const std::string &node_reg_str, const std::string &edge_reg_str, const std::string &optimizer_str)
Definition: CGraphSlamHandler_impl.h:246
CGraphSlamHandler::readConfigFname
void readConfigFname(const std::string &fname)
Read configuration variables for the current graphSLAM execution from a .ini file.
Definition: CGraphSlamHandler_impl.h:216
CGraphSlamEngine.h
CGraphSlamHandler::m_engine
mrpt::graphslam::CGraphSlamEngine< GRAPH_T > * m_engine
Definition: CGraphSlamHandler.h:127
CGraphSlamHandler::m_do_save_results
bool m_do_save_results
Definition: CGraphSlamHandler.h:139
CConfigFile.h
CGraphSlamHandler::m_user_decides_about_output_dir
bool m_user_decides_about_output_dir
Definition: CGraphSlamHandler.h:113
CGraphSlamHandler::CGraphSlamHandler
CGraphSlamHandler(mrpt::system::COutputLogger *logger, mrpt::graphslam::apps::TUserOptionsChecker< GRAPH_T > *options_checker, const bool enable_visuals=true)
Definition: CGraphSlamHandler_impl.h:18
CGraphSlamHandler::m_save_map_fname
std::string m_save_map_fname
Definition: CGraphSlamHandler.h:125
CGraphSlamHandler::m_win_manager
mrpt::graphslam::CWindowManager * m_win_manager
Definition: CGraphSlamHandler.h:128
mrpt::graphslam::CWindowObserver
Monitor events in the visualization window.
Definition: CWindowObserver.h:24
CDisplayWindow3D.h
mrpt::graphslam::CWindowManager
Class acts as a container for storing pointers to mrpt::gui::CDisplayWindow3D, mrpt::graphslam::CWind...
Definition: CWindowManager.h:27
CGraphSlamHandler::m_win_observer
mrpt::graphslam::CWindowObserver * m_win_observer
Definition: CGraphSlamHandler.h:129
CGraphSlamHandler::getParamsAsString
std::string getParamsAsString() const
Definition: CGraphSlamHandler_impl.h:319
CGraphSlamHandler::setFNames
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.
Definition: CGraphSlamHandler_impl.h:202
mrpt::graphslam::apps::TUserOptionsChecker
Class containing the declarations of supplementary methods that can be used in application-related co...
Definition: TUserOptionsChecker.h:93
CGraphSlamHandler::m_options_checker
mrpt::graphslam::apps::TUserOptionsChecker< GRAPH_T > * m_options_checker
TUserOptionsChecker instance whose task is to evaluate the Registration Decider, Optimizer instances ...
Definition: CGraphSlamHandler.h:137
CGraphSlamHandler::m_output_dir_fname
std::string m_output_dir_fname
Definition: CGraphSlamHandler.h:112
COutputLogger.h
CGraphSlamHandler
Manage variables and methods related to applications executing graphSLAM using the mrpt-graphslam API...
Definition: CGraphSlamHandler.h:34
TUserOptionsChecker.h
CGraphSlamHandler::m_rawlog_fname
std::string m_rawlog_fname
Definition: CGraphSlamHandler.h:120
CGraphSlamHandler::m_win
mrpt::gui::CDisplayWindow3D * m_win
Definition: CGraphSlamHandler.h:130
CGraphSlamHandler::setResultsDirName
void setResultsDirName(const std::string &dirname)
Override the results directory filename that was initially set in the .ini file.
Definition: CGraphSlamHandler_impl.h:327
CGraphSlamHandler::m_enable_visuals
bool m_enable_visuals
Definition: CGraphSlamHandler.h:141
CGraphSlamHandler_impl.h
CGraphSlamHandler::initOutputDir
void initOutputDir(const std::string &output_dir_fname="graphslam_results")
Initialize (clean up and create new files) the output directory.
Definition: CGraphSlamHandler_impl.h:100
CGraphSlamHandler::m_gt_fname
std::string m_gt_fname
Definition: CGraphSlamHandler.h:121
CGraphSlamHandler::initVisualization
void initVisualization()
Initialize visualization (e.g.
Definition: CGraphSlamHandler_impl.h:405
CGraphSlamHandler::m_save_graph_fname
std::string m_save_graph_fname
Definition: CGraphSlamHandler.h:123
CWindowObserver.h
CGraphSlamHandler::m_logger
mrpt::system::COutputLogger * m_logger
Definition: CGraphSlamHandler.h:132
mrpt::system::COutputLogger
Versatile class for consistent logging and management of output messages.
Definition: system/COutputLogger.h:117
CGraphSlamHandler::saveResults
void saveResults(const std::string &output_dir_fname)
Definition: CGraphSlamHandler_impl.h:336
CGraphSlamHandler::m_save_3DScene
bool m_save_3DScene
Definition: CGraphSlamHandler.h:116
CGraphSlamHandler::~CGraphSlamHandler
~CGraphSlamHandler()
Definition: CGraphSlamHandler_impl.h:37
CGraphSlamHandler::printParams
void printParams() const
Print in a formatted manner the general configuraiton variables for the current graphSLAM execution.
Definition: CGraphSlamHandler_impl.h:276
CGraphSlamHandler::queryObserverForEvents
bool queryObserverForEvents()
Query the CWindowObserver instance for any pressed keys that might be of interest (e....
Definition: CGraphSlamHandler_impl.h:434
mrpt::gui::CDisplayWindow3D
A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time.
Definition: CDisplayWindow3D.h:117
mrpt::graphslam::CGraphSlamEngine
Main file for the GraphSlamEngine.
Definition: CGraphSlamEngine.h:140
CGraphSlamHandler::m_save_map
bool m_save_map
Definition: CGraphSlamHandler.h:117
CGraphSlamHandler::saveMap
void saveMap(const std::string &fname)
Definition: CGraphSlamHandler_impl.h:367



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