RtabmapThread.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifndef RTABMAPTHREAD_H_
29 #define RTABMAPTHREAD_H_
30 
31 #include "rtabmap/core/rtabmap_core_export.h" // DLL export/import defines
32 
36 #include <rtabmap/utilite/UMutex.h>
37 
42 
43 #include <queue>
44 
45 class UTimer;
46 
47 namespace rtabmap {
48 
49 class Rtabmap;
50 
51 class RTABMAP_CORE_EXPORT RtabmapThread :
52  public UThreadNode,
53  public UEventsHandler
54 {
55 public:
56  enum State {
58  kStateProcessCommand
59  };
60 
61 public:
62  // take ownership
64  virtual ~RtabmapThread();
65 
66  void clearBufferedData();
67  void setDetectorRate(float rate);
68  void setDataBufferSize(unsigned int bufferSize);
69  void createIntermediateNodes(bool enabled);
70 
71  float getDetectorRate() const {return _rate;}
72  unsigned int getDataBufferSize() const {return _dataBufferMaxSize;}
73  bool getCreateIntermediateNodes() const {return _createIntermediateNodes;}
74 
82  void close(bool databaseSaved, const std::string & databasePath = "");
83 
84 protected:
85  virtual bool handleEvent(UEvent * anEvent);
86 
87 private:
88  virtual void mainLoopBegin();
89  virtual void mainLoop();
90  virtual void mainLoopKill();
91  void process();
92  void addData(const OdometryEvent & odomEvent);
93  bool getData(OdometryEvent & data);
94  void pushNewState(State newState, const RtabmapEventCmd & cmdEvent = RtabmapEventCmd(RtabmapEventCmd::kCmdUndef));
95  void publishMap(bool optimized, bool full, bool graphOnly) const;
96 
97 private:
99  std::queue<State> _state;
100  std::queue<RtabmapEventCmd> _stateParam;
101 
102  std::list<OdometryEvent> _dataBuffer;
103  std::list<double> _newMapEvents;
106  unsigned int _dataBufferMaxSize;
107  float _rate;
111 
113  bool _paused;
115  cv::Mat covariance_;
116 
117  cv::Mat _userData;
119 };
120 
121 } /* namespace rtabmap */
122 #endif /* RTABMAPTHREAD_H_ */
UEventsHandler
Definition: UEventsHandler.h:128
rtabmap::OdometryEvent
Definition: OdometryEvent.h:39
rtabmap::RtabmapThread::getDataBufferSize
unsigned int getDataBufferSize() const
Definition: RtabmapThread.h:72
rtabmap::RtabmapThread::getCreateIntermediateNodes
bool getCreateIntermediateNodes() const
Definition: RtabmapThread.h:73
rtabmap::RtabmapEventCmd
Definition: RtabmapEvent.h:57
UThreadNode.h
rtabmap::RtabmapThread::_paused
bool _paused
Definition: RtabmapThread.h:113
SensorData.h
rtabmap::RtabmapThread::_rtabmap
Rtabmap * _rtabmap
Definition: RtabmapThread.h:112
rtabmap::RtabmapThread::_dataAdded
USemaphore _dataAdded
Definition: RtabmapThread.h:105
rtabmap::RtabmapEventCmd::kCmdUndef
@ kCmdUndef
Definition: RtabmapEvent.h:62
Parameters.h
UEvent
Definition: UEvent.h:57
rtabmap::RtabmapThread::_createIntermediateNodes
bool _createIntermediateNodes
Definition: RtabmapThread.h:108
rtabmap::RtabmapThread::_userData
cv::Mat _userData
Definition: RtabmapThread.h:117
RtabmapEvent.h
rtabmap::RtabmapThread::getDetectorRate
float getDetectorRate() const
Definition: RtabmapThread.h:71
UMutex
Definition: UMutex.h:54
rtabmap::RtabmapThread::_previousStamp
double _previousStamp
Definition: RtabmapThread.h:110
UMutex.h
rtabmap::RtabmapThread::_frameRateTimer
UTimer * _frameRateTimer
Definition: RtabmapThread.h:109
rtabmap::RtabmapThread::_dataBuffer
std::list< OdometryEvent > _dataBuffer
Definition: RtabmapThread.h:102
OdometryEvent.h
rtabmap::RtabmapThread::lastPose_
Transform lastPose_
Definition: RtabmapThread.h:114
rtabmap::RtabmapThread::_dataBufferMaxSize
unsigned int _dataBufferMaxSize
Definition: RtabmapThread.h:106
rtabmap::RtabmapThread::_stateMutex
UMutex _stateMutex
Definition: RtabmapThread.h:98
State
rtabmap::Transform
Definition: Transform.h:41
full
@ full
Definition: lz4.c:365
UThread
Definition: UThread.h:86
UEventsHandler.h
rtabmap::RtabmapThread::_dataMutex
UMutex _dataMutex
Definition: RtabmapThread.h:104
rtabmap::RtabmapThread::covariance_
cv::Mat covariance_
Definition: RtabmapThread.h:115
rtabmap::RtabmapThread::_state
std::queue< State > _state
Definition: RtabmapThread.h:99
USemaphore
Definition: USemaphore.h:54
USemaphore.h
UTimer
Definition: UTimer.h:46
rtabmap::RtabmapThread::_userDataMutex
UMutex _userDataMutex
Definition: RtabmapThread.h:118
rtabmap::Rtabmap
Definition: Rtabmap.h:54
rtabmap::RtabmapThread::_newMapEvents
std::list< double > _newMapEvents
Definition: RtabmapThread.h:103
rtabmap::RtabmapThread::_rate
float _rate
Definition: RtabmapThread.h:107
rtabmap
Definition: CameraARCore.cpp:35
rtabmap::RtabmapThread::_stateParam
std::queue< RtabmapEventCmd > _stateParam
Definition: RtabmapThread.h:100
rtabmap::RtabmapThread
Definition: RtabmapThread.h:51
rtabmap::RtabmapThread::kStateDetecting
@ kStateDetecting
Definition: RtabmapThread.h:57


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:15