MRPT  2.0.5
CHMTSLAM_3D_viewer.cpp
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 #include "hmtslam-precomp.h" // Precomp header
11 
12 #include <mrpt/io/CFileStream.h>
13 #include <mrpt/random.h>
14 #include <mrpt/system/CTicTac.h>
15 #include <mrpt/system/os.h>
16 
17 #include <thread>
18 
19 using namespace mrpt::slam;
20 using namespace mrpt::hmtslam;
21 using namespace mrpt::system;
22 using namespace std::literals;
23 
24 /*---------------------------------------------------------------
25 
26  CHMTSLAM_3D_viewer
27 
28  Optional 3D real-time viewer within HMT-SLAM
29 
30  ---------------------------------------------------------------*/
31 void CHMTSLAM::thread_3D_viewer()
32 {
33  CHMTSLAM* obj = this;
34  CTicTac tictac;
35 
36  try
37  {
38  // Start thread:
39  // -------------------------
40  obj->logFmt(
42  "[thread_3D_viewer] Thread started (ID=0x%08lX)\n",
43  std::this_thread::get_id());
44 
45  // --------------------------------------------
46  // The main loop
47  // Executes until termination is signaled
48  // --------------------------------------------
49  while (!obj->m_terminateThreads)
50  {
51  std::this_thread::sleep_for(100ms);
52  }; // end while execute thread
53 
54  // Finish thread:
55  // -------------------------
56  obj->m_terminationFlag_3D_viewer = true;
57  }
58  catch (const std::exception& e)
59  {
60  obj->m_terminationFlag_3D_viewer = true;
61 
62  // Release semaphores:
63 
64  obj->logFmt(mrpt::system::LVL_ERROR, "%s", e.what());
65 
66  // DEBUG: Terminate application:
67  obj->m_terminateThreads = true;
68  }
69  catch (...)
70  {
71  obj->m_terminationFlag_3D_viewer = true;
72 
73  obj->logFmt(
75  "\n---------------------- EXCEPTION CAUGHT! ---------------------\n"
76  " In CHierarchicalMappingFramework::thread_3D_viewer. Unexpected "
77  "runtime error!!\n");
78 
79  // DEBUG: Terminate application:
80  obj->m_terminateThreads = true;
81  }
82 }
void logFmt(const VerbosityLevel level, const char *fmt,...) const MRPT_printf_format_check(3
Alternative logging method, which mimics the printf behavior.
Classes related to the implementation of Hybrid Metric Topological (HMT) SLAM.
std::atomic_bool m_terminationFlag_3D_viewer
Definition: CHMTSLAM.h:341
A high-performance stopwatch, with typical resolution of nanoseconds.
An implementation of Hybrid Metric Topological SLAM (HMT-SLAM).
Definition: CHMTSLAM.h:67
std::atomic_bool m_terminateThreads
Termination flag for signaling all threads to terminate.
Definition: CHMTSLAM.h:337



Page generated by Doxygen 1.8.14 for MRPT 2.0.5 Git: eda5ade6c Tue Aug 4 12:48:50 2020 +0200 at mar ago 4 13:00:11 CEST 2020