RTAB-Map 0.24.5
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
SensorCapture.h
1/*
2Copyright (c) 2010-2022, Mathieu Labbe
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 names of its contributors may be used to endorse or promote products
13 derived from this software without specific prior written permission.
14
15THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
19DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*/
26
27#pragma once
28
29#include "rtabmap/core/rtabmap_core_export.h" // DLL export/import defines
30
31#include <opencv2/imgcodecs.hpp>
32#include <opencv2/videoio.hpp>
33#include <rtabmap/core/SensorCaptureInfo.h>
34#include "rtabmap/core/SensorData.h"
35#include <set>
36#include <stack>
37#include <list>
38#include <vector>
39
40class UDirectory;
41class UTimer;
42
43namespace rtabmap
44{
45
79class RTABMAP_CORE_EXPORT SensorCapture
80{
81public:
85 virtual ~SensorCapture();
86
109
127 virtual bool init(const std::string & calibrationFolder = ".", const std::string & cameraName = "") = 0;
128
138 virtual std::string getSerial() const = 0;
139
153 virtual bool odomProvided() const { return false; }
154
173 virtual bool getPose(double stamp, Transform & pose, cv::Mat & covariance, double maxWaitTime = 0.06) { return false; }
174
175 // Getters
176
181 float getFrameRate() const {return _frameRate;}
182
187 const Transform & getLocalTransform() const {return _localTransform;}
188
189 // Setters
190
201 void setFrameRate(float frameRate) {_frameRate = frameRate;}
202
211 void setLocalTransform(const Transform & localTransform) {_localTransform= localTransform;}
212
220
221protected:
232 SensorCapture(float frameRate = 0, const Transform & localTransform = Transform::getIdentity());
233
255 virtual SensorData captureData(SensorCaptureInfo * info = 0) = 0;
256
265 int getNextSeqID() {return ++_seq;}
266
267private:
268 float _frameRate;
269 Transform _localTransform;
270 UTimer * _frameRateTimer;
271 int _seq;
272};
273
274
275} // namespace rtabmap
Metadata structure for sensor data capture and processing.
Abstract base class for sensor data capture (cameras, lidars, etc.)
virtual ~SensorCapture()
Virtual destructor.
void setLocalTransform(const Transform &localTransform)
Sets the local transform from base frame to sensor frame.
virtual bool init(const std::string &calibrationFolder=".", const std::string &cameraName="")=0
Initializes the sensor.
void setFrameRate(float frameRate)
Sets the target frame rate.
virtual bool getPose(double stamp, Transform &pose, cv::Mat &covariance, double maxWaitTime=0.06)
Gets the sensor's pose estimate at a specific timestamp.
virtual std::string getSerial() const =0
Returns the sensor's serial number or unique identifier.
virtual SensorData captureData(SensorCaptureInfo *info=0)=0
Pure virtual method to capture sensor data.
const Transform & getLocalTransform() const
Returns the local transform from base frame to sensor frame.
SensorData takeData(SensorCaptureInfo *info=0)
Captures sensor data with frame rate control.
int getNextSeqID()
Gets the next sequence ID.
SensorCapture(float frameRate=0, const Transform &localTransform=Transform::getIdentity())
Protected constructor.
virtual bool odomProvided() const
Checks if the sensor provides odometry poses.
float getFrameRate() const
Returns the target frame rate.
void resetTimer()
Resets the frame rate timer.
Container class for all sensor data captured at a specific time.
Definition SensorData.h:97
Represents a 3D rigid body transformation (rotation + translation).
Definition Transform.h:53