Main MRPT website > C++ reference for MRPT 1.5.6
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 using namespace mrpt::slam;
18 using namespace mrpt::hmtslam;
19 using namespace mrpt::utils;
20 
21 /*---------------------------------------------------------------
22 
23  CHMTSLAM_3D_viewer
24 
25  Optional 3D real-time viewer within HMT-SLAM
26 
27  ---------------------------------------------------------------*/
28 void CHMTSLAM::thread_3D_viewer( )
29 {
30  CHMTSLAM *obj = this;
31  CTicTac tictac;
32 
33  try
34  {
35  // Start thread:
36  // -------------------------
37  obj->logFmt(mrpt::utils::LVL_DEBUG,"[thread_3D_viewer] Thread started (ID=0x%08lX)\n", mrpt::system::getCurrentThreadId() );
38 
39  // --------------------------------------------
40  // The main loop
41  // Executes until termination is signaled
42  // --------------------------------------------
43  while ( !obj->m_terminateThreads )
44  {
46  }; // end while execute thread
47 
48  // Finish thread:
49  // -------------------------
50  time_t timCreat,timExit; double timCPU=0;
51  try { mrpt::system::getCurrentThreadTimes( timCreat,timExit,timCPU); } catch(...) {};
52  obj->logFmt(mrpt::utils::LVL_DEBUG,"[thread_3D_viewer] Thread finished. CPU time used:%.06f secs \n",timCPU);
53  obj->m_terminationFlag_3D_viewer = true;
54 
55  }
56  catch(std::exception &e)
57  {
58  obj->m_terminationFlag_3D_viewer = true;
59 
60  // Release semaphores:
61 
62  obj->logFmt(mrpt::utils::LVL_ERROR,"%s", e.what() );
63 
64  // DEBUG: Terminate application:
65  obj->m_terminateThreads = true;
66 
67  }
68  catch(...)
69  {
70  obj->m_terminationFlag_3D_viewer = true;
71 
72  obj->logFmt(mrpt::utils::LVL_ERROR,
73  "\n---------------------- EXCEPTION CAUGHT! ---------------------\n"
74  " In CHierarchicalMappingFramework::thread_3D_viewer. Unexpected runtime error!!\n");
75 
76  // DEBUG: Terminate application:
77  obj->m_terminateThreads = true;
78  }
79 
80 }
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
unsigned long BASE_IMPEXP getCurrentThreadId() MRPT_NO_THROWS
Returns the ID of the current thread.
Definition: threads.cpp:211
Classes related to the implementation of Hybrid Metric Topological (HMT) SLAM.
GLsizei GLsizei GLuint * obj
Definition: glext.h:3902
An implementation of Hybrid Metric Topological SLAM (HMT-SLAM).
Definition: CHMTSLAM.h:59
void BASE_IMPEXP getCurrentThreadTimes(time_t &creationTime, time_t &exitTime, double &cpuTime)
Returns the creation and exit times of the current thread and its CPU time consumed.
Definition: threads.cpp:339
void BASE_IMPEXP sleep(int time_ms) MRPT_NO_THROWS
An OS-independent method for sending the current thread to "sleep" for a given period of time...
Definition: threads.cpp:57
This class implements a high-performance stopwatch.
Definition: CTicTac.h:24



Page generated by Doxygen 1.8.14 for MRPT 1.5.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019