RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
rtabmap::SensorCapture Class Referenceabstract

Abstract base class for sensor data capture (cameras, lidars, etc.) More...

#include <SensorCapture.h>

Inheritance diagram for rtabmap::SensorCapture:

Public Member Functions

virtual ~SensorCapture ()
 Virtual destructor.
 
SensorData takeData (SensorCaptureInfo *info=0)
 Captures sensor data with frame rate control.
 
virtual bool init (const std::string &calibrationFolder=".", const std::string &cameraName="")=0
 Initializes the sensor.
 
virtual std::string getSerial () const =0
 Returns the sensor's serial number or unique identifier.
 
virtual bool odomProvided () const
 Checks if the sensor provides odometry poses.
 
virtual bool getPose (double stamp, Transform &pose, cv::Mat &covariance, double maxWaitTime=0.06)
 Gets the sensor's pose estimate at a specific timestamp.
 
float getFrameRate () const
 Returns the target frame rate.
 
const TransformgetLocalTransform () const
 Returns the local transform from base frame to sensor frame.
 
void setFrameRate (float frameRate)
 Sets the target frame rate.
 
void setLocalTransform (const Transform &localTransform)
 Sets the local transform from base frame to sensor frame.
 
void resetTimer ()
 Resets the frame rate timer.
 

Protected Member Functions

 SensorCapture (float frameRate=0, const Transform &localTransform=Transform::getIdentity())
 Protected constructor.
 
virtual SensorData captureData (SensorCaptureInfo *info=0)=0
 Pure virtual method to capture sensor data.
 
int getNextSeqID ()
 Gets the next sequence ID.
 

Detailed Description

Abstract base class for sensor data capture (cameras, lidars, etc.)

SensorCapture provides a unified interface for capturing sensor data from various sensor types including cameras (RGB-D, stereo, mono) and lidars. It handles frame rate control, local transform management, and provides a common API for sensor initialization and data capture.

The class implements the Template Method pattern:

  • takeData() handles frame rate control and timing, then calls the pure virtual captureData() method implemented by derived classes
  • Derived classes must implement captureData() to perform the actual sensor capture

Key features:

  • Frame rate control: Automatic throttling to maintain target frame rate
  • Local transform: Transform from robot base frame to sensor frame
  • Capture timing: Tracks capture time and provides it via SensorCaptureInfo
  • Sequence IDs: Automatic sequence number generation for captured data

Derived classes include:

  • Camera: Base class for all camera types (RGB-D, stereo, mono, file readers, etc.)
  • Lidar: Base class for lidar sensors
Note
This is an abstract class. Use concrete implementations like CameraRGBD, CameraStereo, LidarVLP16, etc., or create custom derived classes.
See also
Camera
Lidar
SensorData
SensorCaptureInfo
SensorCaptureThread

Definition at line 78 of file SensorCapture.h.

Constructor & Destructor Documentation

◆ SensorCapture()

rtabmap::SensorCapture::SensorCapture ( float  frameRate = 0,
const Transform localTransform = Transform::getIdentity() 
)
protected

Protected constructor.

Creates a SensorCapture instance with the specified frame rate and local transform. This constructor is protected because SensorCapture is an abstract base class and should not be instantiated directly.

Parameters
frameRateTarget frame rate in Hz (0 = unlimited, capture as fast as possible)
localTransformTransform from base frame to sensor frame (default: identity)

Member Function Documentation

◆ takeData()

SensorData rtabmap::SensorCapture::takeData ( SensorCaptureInfo info = 0)

Captures sensor data with frame rate control.

This method handles frame rate throttling and timing, then calls the pure virtual captureData() method to perform the actual capture.

The method:

  • Enforces the target frame rate by sleeping if necessary
  • Measures capture time and stores it in SensorCaptureInfo
  • Assigns sequence IDs to captured data
  • Warns if the target frame rate cannot be reached
Parameters
infoOptional pointer to SensorCaptureInfo to fill with capture metadata (ID, timestamp, capture time). If null, no info is filled.
Returns
SensorData containing the captured sensor data
Note
If frame rate is 0, data is captured as fast as possible without throttling.
The returned SensorData should have rectified images if calibration was loaded.
See also
captureData()

◆ init()

virtual bool rtabmap::SensorCapture::init ( const std::string &  calibrationFolder = ".",
const std::string &  cameraName = "" 
)
pure virtual

Initializes the sensor.

Pure virtual method that must be implemented by derived classes to initialize the sensor hardware or data source. This typically involves:

  • Opening device connections or file streams
  • Loading camera calibration parameters
  • Configuring sensor settings
Parameters
calibrationFolderDirectory path where calibration files are located (default: current directory ".")
cameraNameBase name of the camera for loading calibration files (default: empty string)
Returns
True if initialization was successful, false otherwise
Note
Must be called before calling takeData() or captureData()

Implemented in rtabmap::CameraDepthAI, rtabmap::CameraFreenect, rtabmap::CameraFreenect2, rtabmap::CameraImages, rtabmap::CameraK4A, rtabmap::CameraK4W2, rtabmap::CameraMyntEye, rtabmap::CameraOpenni, rtabmap::CameraOpenNI2, rtabmap::CameraOpenNICV, rtabmap::CameraOrbbecSDK, rtabmap::CameraRealSense, rtabmap::CameraRealSense2, rtabmap::CameraRGBDImages, rtabmap::CameraSeerSense, rtabmap::CameraStereoDC1394, rtabmap::CameraStereoFlyCapture2, rtabmap::CameraStereoImages, rtabmap::CameraStereoTara, rtabmap::CameraStereoVideo, rtabmap::CameraStereoZed, rtabmap::CameraStereoZedOC, rtabmap::CameraVideo, rtabmap::DBReader, and rtabmap::LidarVLP16.

◆ getSerial()

virtual std::string rtabmap::SensorCapture::getSerial ( ) const
pure virtual

◆ odomProvided()

virtual bool rtabmap::SensorCapture::odomProvided ( ) const
inlinevirtual

Checks if the sensor provides odometry poses.

Some sensors (e.g., visual-inertial cameras) can provide pose estimates directly. This method indicates whether the sensor supports pose queries.

Returns
True if the sensor provides odometry poses, false otherwise
Note
Default implementation returns false. Derived classes should override if they support pose estimation.
See also
getPose()

Reimplemented in rtabmap::CameraImages, rtabmap::CameraMyntEye, rtabmap::CameraRealSense, rtabmap::CameraRealSense2, rtabmap::CameraSeerSense, rtabmap::CameraStereoZed, and rtabmap::DBReader.

Definition at line 152 of file SensorCapture.h.

◆ getPose()

virtual bool rtabmap::SensorCapture::getPose ( double  stamp,
Transform pose,
cv::Mat &  covariance,
double  maxWaitTime = 0.06 
)
inlinevirtual

Gets the sensor's pose estimate at a specific timestamp.

Queries the sensor for its pose estimate at the given timestamp. This is typically used for sensors that provide visual-inertial odometry or other pose estimation capabilities.

Parameters
stampTimestamp in seconds for which to query the pose
[out]poseOutput transform representing the sensor pose
[out]covarianceOutput covariance matrix (6x6) representing twist uncertainty
maxWaitTimeMaximum time in seconds to wait for pose data (default: 0.06)
Returns
True if pose was successfully retrieved, false otherwise
Note
Default implementation returns false. Derived classes should override if they support pose estimation.
See also
odomProvided()

Reimplemented in rtabmap::CameraSeerSense, rtabmap::CameraStereoZed, rtabmap::CameraRealSense2, and rtabmap::DBReader.

Definition at line 172 of file SensorCapture.h.

◆ getFrameRate()

float rtabmap::SensorCapture::getFrameRate ( ) const
inline

Returns the target frame rate.

Returns
Frame rate in Hz (0 = unlimited, capture as fast as possible)

Definition at line 180 of file SensorCapture.h.

◆ getLocalTransform()

const Transform & rtabmap::SensorCapture::getLocalTransform ( ) const
inline

Returns the local transform from base frame to sensor frame.

Returns
Const reference to the local transform

Definition at line 186 of file SensorCapture.h.

◆ setFrameRate()

void rtabmap::SensorCapture::setFrameRate ( float  frameRate)
inline

Sets the target frame rate.

Controls how often takeData() will capture data. The method will throttle captures to maintain the target rate.

Parameters
frameRateTarget frame rate in Hz (0 = unlimited, capture as fast as possible)
Note
Setting frame rate to 0 disables throttling and captures as fast as possible.

Definition at line 200 of file SensorCapture.h.

◆ setLocalTransform()

void rtabmap::SensorCapture::setLocalTransform ( const Transform localTransform)
inline

Sets the local transform from base frame to sensor frame.

The local transform represents the pose of the sensor relative to the robot's base frame. This is used to transform sensor data into the robot's coordinate system.

Parameters
localTransformTransform from base frame to sensor frame

Definition at line 210 of file SensorCapture.h.

◆ resetTimer()

void rtabmap::SensorCapture::resetTimer ( )

Resets the frame rate timer.

Resets the internal timer used for frame rate control. This is useful when starting a new capture session or after a pause.

◆ captureData()

virtual SensorData rtabmap::SensorCapture::captureData ( SensorCaptureInfo info = 0)
protectedpure virtual

Pure virtual method to capture sensor data.

This method must be implemented by derived classes to perform the actual sensor data capture. It is called by takeData() after frame rate throttling.

The returned SensorData should:

  • Have rectified images if calibration was loaded during init()
  • Include proper timestamps
  • Contain valid sensor data (images, depth, laser scans, etc.)
Parameters
infoOptional pointer to SensorCaptureInfo to fill with capture metadata. The base class will fill ID, timestamp, and capture time, but derived classes can add additional information.
Returns
SensorData containing the captured sensor data
Note
If capture fails, return an empty SensorData (id=0, stamp=0.0).
RGB and depth images should be already rectified if calibration was loaded.
See also
takeData()

Implemented in rtabmap::LidarVLP16.

◆ getNextSeqID()

int rtabmap::SensorCapture::getNextSeqID ( )
inlineprotected

Gets the next sequence ID.

Returns and increments the internal sequence counter. This is used to assign unique sequence numbers to captured data.

Returns
Next sequence ID (starts at 1, increments with each call)

Definition at line 264 of file SensorCapture.h.


The documentation for this class was generated from the following file: