MRPT  1.9.9
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-2019, 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  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 (const 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 }
Classes related to the implementation of Hybrid Metric Topological (HMT) SLAM.
A high-performance stopwatch, with typical resolution of nanoseconds.
GLsizei GLsizei GLuint * obj
Definition: glext.h:4085
An implementation of Hybrid Metric Topological SLAM (HMT-SLAM).
Definition: CHMTSLAM.h:67
#define MRPT_TODO(x)
Definition: common.h:129



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 6e6d28d09 Wed Nov 13 18:58:42 2019 +0100 at miƩ nov 13 19:00:09 CET 2019