Go to the documentation of this file.
17 template <
class GRAPH_T>
21 const bool enable_visuals)
23 m_options_checker(options_checker),
24 m_enable_visuals(enable_visuals)
36 template <
class GRAPH_T>
46 "Application will exit when the display window is closed.");
47 bool break_exec =
false;
51 std::this_thread::sleep_for(100ms);
76 "Releasing CDisplayWindow3D instance...");
84 "Releasing CWindowObserver instance...");
92 "Releasing CWindowManager instance...");
99 template <
class GRAPH_T>
101 const std::string& output_dir_fname)
106 using namespace mrpt;
110 output_dir_fname.c_str());
124 stringstream question;
127 question <<
"Directory exists. Choose between the "
128 <<
"following options" << std::endl;
129 question <<
"\t 1: Rename current folder and start new "
130 <<
"output directory (default)" << std::endl;
131 question <<
"\t 2: Remove existing contents and continue execution "
133 question <<
"\t 3: Handle potential conflict manually "
134 "(Halts program execution)"
136 question <<
"\t [ 1 | 2 | 3 ] --> ";
137 std::cout << question.str();
139 getline(cin, answer);
141 answer_int = atoi(&answer[0]);
169 string dst_fname = output_dir_fname + cur_date_validstr;
177 renameFile(output_dir_fname, dst_fname, &error_msg);
180 "\nError while trying to rename the output "
201 template <
class GRAPH_T>
203 const std::string& ini_fname,
const std::string& rawlog_fname,
204 const std::string& ground_truth_fname)
215 template <
class GRAPH_T>
220 mrpt::format(
"\nConfiguration file not found: \n%s\n", fname.c_str()));
227 "GeneralConfiguration",
"user_decides_about_output_dir",
false,
false);
229 "GeneralConfiguration",
"output_dir_fname",
"graphslam_results",
false);
231 cfg_file.
read_bool(
"GeneralConfiguration",
"save_graph",
true,
false);
233 cfg_file.
read_bool(
"GeneralConfiguration",
"save_3DScene",
true,
false);
235 cfg_file.
read_bool(
"GeneralConfiguration",
"save_map",
true,
false);
237 "GeneralConfiguration",
"save_graph_fname",
"output_graph.graph",
240 "GeneralConfiguration",
"save_3DScene_fname",
"scene.3DScene",
false);
242 "GeneralConfiguration",
"save_map_fname",
"output_map",
false);
245 template <
class GRAPH_T>
247 const std::string& node_reg_str,
const std::string& edge_reg_str,
248 const std::string& optimizer_str)
250 using namespace mrpt;
257 "\nNode Registration Decider %s is not available.\n",
258 node_reg_str.c_str()));
262 "\nEdge Registration Decider %s is not available.\n",
263 edge_reg_str.c_str()));
266 format(
"\nOptimizer %s is not available\n", optimizer_str.c_str()));
275 template <
class GRAPH_T>
282 template <
class GRAPH_T>
289 stringstream ss_out(
"");
291 ss_out <<
"\n------------[ graphslam-engine_app Parameters ]------------"
295 ss_out <<
"User decides about output dir? = "
299 ss_out <<
"Generate .graph file? = "
301 ss_out <<
"Generate .3DScene file? = "
318 template <
class GRAPH_T>
326 template <
class GRAPH_T>
335 template <
class GRAPH_T>
337 const std::string& output_dir_fname)
342 m_engine->generateReportFiles(output_dir_fname);
346 std::string save_graph_fname =
348 m_engine->saveGraph(&save_graph_fname);
352 std::string save_3DScene_fname =
354 m_engine->save3DScene(&save_3DScene_fname);
366 template <
class GRAPH_T>
373 map->saveMetricMapRepresentationToFile(fname);
376 template <
class GRAPH_T>
387 size_t curr_rawlog_entry;
391 bool cont_exec =
true;
392 while (CRawlog::getActionObservationPairOrObservation(
393 arch, action, observations, observation, curr_rawlog_entry) &&
398 cont_exec =
m_engine->_execGraphSlamStep(
399 action, observations, observation, curr_rawlog_entry);
404 template <
class GRAPH_T>
433 template <
class GRAPH_T>
436 std::map<std::string, bool> events_occurred;
440 bool request_to_exit = events_occurred.find(
"Ctrl+c")->second;
442 return !request_to_exit;
static uint64_t getCurrentTime() noexcept
std::shared_ptr< CObservation > Ptr
std::string m_save_3DScene_fname
bool renameFile(const std::string &oldFileName, const std::string &newFileName, std::string *error_msg=nullptr)
Renames a file - If the target path is different and the filesystem allows it, it will be moved to th...
void execute()
Method to be called for parsing the rawlog file provided and for running graphSLAM using that informa...
void initEngine(const std::string &node_reg_str, const std::string &edge_reg_str, const std::string &optimizer_str)
void readConfigFname(const std::string &fname)
Read configuration variables for the current graphSLAM execution from a .ini file.
void returnEventsStruct(std::map< std::string, bool > *codes_to_pressed, bool reset_keypresses=true)
Return a map of key code to a boolean indicating whether it was pressed since the previous time the c...
std::shared_ptr< mrpt::obs ::CSensoryFrame > Ptr
bool directoryExists(const std::string &fileName)
Test if a given directory exists (it fails if the given path refers to an existing file).
mrpt::graphslam::CGraphSlamEngine< GRAPH_T > * m_engine
std::string timeToString(const mrpt::system::TTimeStamp t)
Convert a timestamp into this textual form (UTC): HH:MM:SS.MMMMMM.
bool m_user_decides_about_output_dir
CGraphSlamHandler(mrpt::system::COutputLogger *logger, mrpt::graphslam::apps::TUserOptionsChecker< GRAPH_T > *options_checker, const bool enable_visuals=true)
bool read_bool(const std::string §ion, const std::string &name, bool defaultValue, bool failIfNotFound=false) const
std::shared_ptr< mrpt::obs ::CActionCollection > Ptr
void observeBegin(CObservable &obj)
Starts the subscription of this observer to the given object.
std::string m_save_map_fname
mrpt::opengl::COpenGLScene::Ptr & get3DSceneAndLock()
Gets a reference to the smart shared pointer that holds the internal scene (carefuly read introductio...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::graphslam::CWindowManager * m_win_manager
Monitor events in the visualization window.
bool fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
This namespace contains representation of robot actions and observations.
Class acts as a container for storing pointers to mrpt::gui::CDisplayWindow3D, mrpt::graphslam::CWind...
mrpt::graphslam::CWindowObserver * m_win_observer
std::string read_string(const std::string §ion, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
std::string fileNameStripInvalidChars(const std::string &filename, const char replacement_to_invalid_chars='_')
Replace invalid filename chars by underscores ('_') or any other user-given char.
std::string getParamsAsString() const
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.
Class containing the declarations of supplementary methods that can be used in application-related co...
SLAM methods related to graphs of pose constraints.
mrpt::graphslam::apps::TUserOptionsChecker< GRAPH_T > * m_options_checker
TUserOptionsChecker instance whose task is to evaluate the Registration Decider, Optimizer instances ...
void logFmt(const VerbosityLevel level, const char *fmt,...) const MRPT_printf_format_check(3
Alternative logging method, which mimics the printf behavior.
void setWindowObserverPtr(mrpt::graphslam::CWindowObserver *obsever_in)
Store the CWindowObserver pointer in the CWindowManager instance.
bool isOpen()
Returns false if the user has already closed the window.
std::string m_output_dir_fname
std::shared_ptr< mrpt::opengl ::COpenGLViewport > Ptr
void unlockAccess3DScene()
Unlocks the access to the internal 3D scene.
void setCDisplayWindow3DPtr(mrpt::gui::CDisplayWindow3D *win_in)
Store the CDisplayWindow3D pointer in the CWindowManager instance.
std::string m_rawlog_fname
mrpt::gui::CDisplayWindow3D * m_win
void setResultsDirName(const std::string &dirname)
Override the results directory filename that was initially set in the .ini file.
mrpt::Clock::time_point TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1,...
void forceRepaint()
Repaints the window.
void initOutputDir(const std::string &output_dir_fname="graphslam_results")
Initialize (clean up and create new files) the output directory.
void initVisualization()
Initialize visualization (e.g.
std::string m_save_graph_fname
Classes for creating GUI windows for 2D and 3D visualization.
mrpt::system::COutputLogger * m_logger
bool deleteFilesInDirectory(const std::string &s, bool deleteDirectoryAsWell=false)
Delete all the files in a given directory (nothing done if directory does not exists,...
Versatile class for consistent logging and management of output messages.
void saveResults(const std::string &output_dir_fname)
std::shared_ptr< mrpt::opengl ::COpenGLScene > Ptr
CArchiveStreamBase< STREAM > archiveFrom(STREAM &s)
Helper function to create a templatized wrapper CArchive object for a: MRPT's CStream,...
void printParams() const
Print in a formatted manner the general configuraiton variables for the current graphSLAM execution.
This class allows loading and storing values and vectors of different types from "....
#define ASSERTDEBMSG_(f, __ERROR_MSG)
static Ptr Create(Args &&... args)
#define ASSERTDEB_(f)
Defines an assertion mechanism - only when compiled in debug.
std::string trim(const std::string &str)
Removes leading and trailing spaces.
std::shared_ptr< mrpt::maps ::COccupancyGridMap2D > Ptr
void setPos(int x, int y) override
Changes the position of the window on the screen.
bool createDirectory(const std::string &dirName)
Creates a directory.
bool queryObserverForEvents()
Query the CWindowObserver instance for any pressed keys that might be of interest (e....
The namespace for 3D scene representation and rendering.
A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time.
Main file for the GraphSlamEngine.
std::string std::string format(std::string_view fmt, ARGS &&... args)
void saveMap(const std::string &fname)
Page generated by Doxygen 1.8.18 for MRPT 2.0.4 at Thu Sep 24 07:14:18 UTC 2020 | |