Main MRPT website > C++ reference for MRPT 1.9.9
CHMTSLAM_3D_viewer.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "hmtslam-precomp.h" // Precomp header
11 
12 #include <mrpt/system/CTicTac.h>
13 #include <mrpt/random.h>
14 #include <mrpt/io/CFileStream.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  MRPT_TODO("Fix thread times")
57  // try { mrpt::system::getCurrentThreadTimes( timCreat,timExit,timCPU);
58  // } catch(...) {};
59  // obj->logFmt(mrpt::system::LVL_DEBUG,"[thread_3D_viewer] Thread
60  // finished. CPU time used:%.06f secs \n",timCPU);
61  obj->m_terminationFlag_3D_viewer = true;
62  }
63  catch (std::exception& e)
64  {
65  obj->m_terminationFlag_3D_viewer = true;
66 
67  // Release semaphores:
68 
69  obj->logFmt(mrpt::system::LVL_ERROR, "%s", e.what());
70 
71  // DEBUG: Terminate application:
72  obj->m_terminateThreads = true;
73  }
74  catch (...)
75  {
76  obj->m_terminationFlag_3D_viewer = true;
77 
78  obj->logFmt(
80  "\n---------------------- EXCEPTION CAUGHT! ---------------------\n"
81  " In CHierarchicalMappingFramework::thread_3D_viewer. Unexpected "
82  "runtime error!!\n");
83 
84  // DEBUG: Terminate application:
85  obj->m_terminateThreads = true;
86  }
87 }
os.h
mrpt::system::CTicTac
A high-performance stopwatch, with typical resolution of nanoseconds.
Definition: system/CTicTac.h:19
mrpt::hmtslam::CHMTSLAM
An implementation of Hybrid Metric Topological SLAM (HMT-SLAM).
Definition: CHMTSLAM.h:68
obj
GLsizei GLsizei GLuint * obj
Definition: glext.h:4070
hmtslam-precomp.h
random.h
mrpt::hmtslam
Classes related to the implementation of Hybrid Metric Topological (HMT) SLAM.
Definition: CHierarchicalMapMHPartition.h:30
mrpt::system::LVL_DEBUG
@ LVL_DEBUG
Definition: system/COutputLogger.h:30
CTicTac.h
MRPT_TODO
#define MRPT_TODO(x)
Definition: common.h:129
mrpt::system::LVL_ERROR
@ LVL_ERROR
Definition: system/COutputLogger.h:33
CFileStream.h
mrpt::slam
Definition: CMultiMetricMapPDF.h:27
mrpt::system
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
Definition: math_frwds.h:25



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST