RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
RtabmapThread.h
1/*
2Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, 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
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON 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
25SOFTWARE, 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
34#include <rtabmap/utilite/UEventsHandler.h>
35#include <rtabmap/utilite/USemaphore.h>
36#include <rtabmap/utilite/UMutex.h>
37
38#include "rtabmap/core/RtabmapEvent.h"
39#include "rtabmap/core/SensorData.h"
40#include "rtabmap/core/Parameters.h"
41#include "rtabmap/core/OdometryEvent.h"
42
43#include <queue>
44
45class UTimer;
46
47namespace rtabmap {
48
49class Rtabmap;
50
104class RTABMAP_CORE_EXPORT RtabmapThread :
105 public UThreadNode,
106 public UEventsHandler
107{
108public:
110 enum State {
112 kStateProcessCommand
113 };
114
115public:
127 virtual ~RtabmapThread();
128
138 void setDetectorRate(float rate);
145 void setDataBufferSize(unsigned int bufferSize);
152 void createIntermediateNodes(bool enabled);
153
155 float getDetectorRate() const {return _rate;}
157 unsigned int getDataBufferSize() const {return _dataBufferMaxSize;}
159 bool getCreateIntermediateNodes() const {return _createIntermediateNodes;}
160
171 void close(bool databaseSaved, const std::string & databasePath = "");
172
173protected:
183 virtual bool handleEvent(UEvent * anEvent);
184
185private:
186 virtual void mainLoopBegin();
187 virtual void mainLoop();
188 virtual void mainLoopKill();
189 void process();
190 void addData(const OdometryEvent & odomEvent);
191 bool getData(OdometryEvent & data);
192 void pushNewState(State newState, const RtabmapEventCmd & cmdEvent = RtabmapEventCmd(RtabmapEventCmd::kCmdUndef));
193 void publishMap(bool optimized, bool full, bool graphOnly) const;
194
195private:
196 UMutex _stateMutex;
197 std::queue<State> _state;
198 std::queue<RtabmapEventCmd> _stateParam;
199
200 std::list<OdometryEvent> _dataBuffer;
201 std::list<double> _newMapEvents;
202 UMutex _dataMutex;
203 USemaphore _dataAdded;
204 unsigned int _dataBufferMaxSize;
205 float _rate;
206 bool _createIntermediateNodes;
207 double _previousStamp;
208
209 Rtabmap * _rtabmap;
210 bool _paused;
211 Transform lastPose_;
212 cv::Mat covariance_;
213
214 cv::Mat _userData;
215 UMutex _userDataMutex;
216};
217
218} /* namespace rtabmap */
219#endif /* RTABMAPTHREAD_H_ */
Backward-compatible alias header for UThread.
One processed frame with the pose the odometry integrated for it.
Command sent to RtabmapThread, with its parameters.
Runs a Rtabmap instance in its own thread, driven by events.
State
What the main loop does on its next wake-up.
bool getCreateIntermediateNodes() const
RtabmapThread(Rtabmap *rtabmap)
Constructor.
void createIntermediateNodes(bool enabled)
Keeps the frames skipped by setDetectorRate() as intermediate nodes.
void setDetectorRate(float rate)
Sets the maximum rate at which frames are processed (Hz, 0 = unlimited).
unsigned int getDataBufferSize() const
void close(bool databaseSaved, const std::string &databasePath="")
Joins the thread and closes rtabmap. This will delete rtabmap object if set.
virtual bool handleEvent(UEvent *anEvent)
Receives the events listed in the class description.
void setDataBufferSize(unsigned int bufferSize)
Sets how many frames may wait in the buffer (0 = unlimited).
float getDetectorRate() const
void clearBufferedData()
Drops the buffered frames, the pending user data and the odometry state.
Top-level RTAB-Map SLAM pipeline (mapping, localization and loop closure).
Definition Rtabmap.h:194
Represents a 3D rigid body transformation (rotation + translation).
Definition Transform.h:53