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-2017, 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/utils/CTicTac.h>
13 #include <mrpt/random.h>
14 #include <mrpt/utils/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::utils;
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(
41  mrpt::utils::LVL_DEBUG,
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  time_t timCreat, timExit;
57  double timCPU = 0;
58  MRPT_TODO("Fix thread times")
59  // try { mrpt::system::getCurrentThreadTimes( timCreat,timExit,timCPU);
60  // } catch(...) {};
61  // obj->logFmt(mrpt::utils::LVL_DEBUG,"[thread_3D_viewer] Thread
62  // finished. CPU time used:%.06f secs \n",timCPU);
63  obj->m_terminationFlag_3D_viewer = true;
64  }
65  catch (std::exception& e)
66  {
67  obj->m_terminationFlag_3D_viewer = true;
68 
69  // Release semaphores:
70 
71  obj->logFmt(mrpt::utils::LVL_ERROR, "%s", e.what());
72 
73  // DEBUG: Terminate application:
74  obj->m_terminateThreads = true;
75  }
76  catch (...)
77  {
78  obj->m_terminationFlag_3D_viewer = true;
79 
80  obj->logFmt(
81  mrpt::utils::LVL_ERROR,
82  "\n---------------------- EXCEPTION CAUGHT! ---------------------\n"
83  " In CHierarchicalMappingFramework::thread_3D_viewer. Unexpected "
84  "runtime error!!\n");
85 
86  // DEBUG: Terminate application:
87  obj->m_terminateThreads = true;
88  }
89 }
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Classes related to the implementation of Hybrid Metric Topological (HMT) SLAM.
GLsizei GLsizei GLuint * obj
Definition: glext.h:4070
An implementation of Hybrid Metric Topological SLAM (HMT-SLAM).
Definition: CHMTSLAM.h:65
#define MRPT_TODO(x)
This class implements a high-performance stopwatch.
Definition: CTicTac.h:23



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019