Added doc/test for SensorEvent, added doc for SensorCaptureInfo

This commit is contained in:
matlabbe
2025-12-23 17:50:31 -08:00
parent 0b6a8a0828
commit a4d32c31b6
4 changed files with 521 additions and 25 deletions
@@ -33,10 +33,50 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace rtabmap
{
/**
* @class SensorCaptureInfo
* @brief Metadata structure for sensor data capture and processing
*
* SensorCaptureInfo contains metadata about sensor data capture, including timing
* information for various processing steps, camera identification, and odometry
* information. This information is typically attached to SensorEvent objects to
* provide context about how the sensor data was captured and processed.
*
* The class tracks timing for various processing stages:
* - **Capture**: Time to capture data from the sensor
* - **Processing**: Time for various image processing steps (deskewing, disparity,
* mirroring, exposure compensation, decimation, histogram equalization, etc.)
* - **Depth processing**: Time for depth-related operations (scan from depth,
* undistort depth, bilateral filtering)
* - **Total**: Total processing time
*
* Odometry information includes:
* - **Pose**: The odometry pose at the time of capture
* - **Covariance**: Uncertainty of the odometry twist (6x6 matrix)
* - **Velocity**: 6DOF velocity vector [vx, vy, vz, vroll, vpitch, vyaw]
*
* @note All timing values are in seconds (float).
* @note The odometry covariance matrix is initialized to identity by default.
*
* @see SensorEvent
* @see SensorData
*/
class SensorCaptureInfo
{
public:
/**
* @brief Default constructor
*
* Initializes all fields to default values:
* - cameraName: empty string
* - id: 0
* - stamp: 0.0
* - All timing fields: 0.0f
* - odomPose: null transform
* - odomCovariance: 6x6 identity matrix
* - odomVelocity: empty vector
*/
SensorCaptureInfo() :
cameraName(""),
id(0),
@@ -55,28 +95,41 @@ public:
odomCovariance(cv::Mat::eye(6,6,CV_64FC1))
{
}
/**
* @brief Virtual destructor
*/
virtual ~SensorCaptureInfo() {}
std::string cameraName;
int id;
double stamp;
float timeCapture;
float timeDeskewing;
float timeDisparity;
float timeMirroring;
float timeStereoExposureCompensation;
float timeImageDecimation;
float timeHistogramEqualization;
float timeScanFromDepth;
float timeUndistortDepth;
float timeBilateralFiltering;
float timeTotal;
Transform odomPose;
cv::Mat odomCovariance;
std::vector<float> odomVelocity;
std::string cameraName; ///< Camera/sensor name identifier
int id; ///< Capture ID (typically matches SensorData ID)
double stamp; ///< Timestamp in seconds (typically matches SensorData stamp)
// Timing information (all in seconds)
float timeCapture; ///< Time to capture data from the sensor (seconds)
float timeDeskewing; ///< Time for laser scan deskewing (seconds)
float timeDisparity; ///< Time to compute stereo disparity (seconds)
float timeMirroring; ///< Time for image mirroring/flipping (seconds)
float timeStereoExposureCompensation; ///< Time for stereo exposure compensation (seconds)
float timeImageDecimation; ///< Time for image decimation/downsampling (seconds)
float timeHistogramEqualization; ///< Time for histogram equalization (seconds)
float timeScanFromDepth; ///< Time to convert depth image to laser scan (seconds)
float timeUndistortDepth; ///< Time to undistort depth image (seconds)
float timeBilateralFiltering; ///< Time for bilateral filtering of depth (seconds)
float timeTotal; ///< Total processing time (seconds)
// Odometry information
Transform odomPose; ///< Odometry pose at the time of capture (in odometry coordinate frame)
cv::Mat odomCovariance; ///< Odometry twist covariance matrix (6x6, CV_64FC1). Default: identity matrix
std::vector<float> odomVelocity; ///< 6DOF odometry velocity [vx, vy, vz, vroll, vpitch, vyaw] (m/s, rad/s)
};
//backward compatibility
/**
* @deprecated Use SensorCaptureInfo instead
* @brief Backward compatibility typedef
*
* CameraInfo is deprecated. Use SensorCaptureInfo instead.
*/
RTABMAP_DEPRECATED typedef SensorCaptureInfo CameraInfo;
} // namespace rtabmap
+121 -6
View File
@@ -34,16 +34,57 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace rtabmap
{
/**
* @class SensorEvent
* @brief Event class for sensor data communication in RTAB-Map's event system
*
* SensorEvent is an event class that extends UEvent and is used to communicate
* sensor data (images, depth, laser scans, etc.) through RTAB-Map's event-driven
* architecture. It is typically posted by sensor capture threads and handled by
* event handlers (e.g., RtabmapThread, DataRecorder, CalibrationDialog).
*
* The class supports two event codes:
* - **kCodeData**: Indicates that new sensor data is available
* - **kCodeNoMoreImages**: Indicates that the sensor stream has ended (end of file, camera disconnected, etc.)
*
* SensorEvent carries:
* - **SensorData**: The actual sensor data (images, depth, scans, camera models, etc.)
* - **SensorCaptureInfo**: Metadata about the capture (camera name, timing information, odometry pose, etc.)
*
* @note This class is part of RTAB-Map's event system. Handlers should check the event code
* and class name before processing the event.
*
* @see UEvent
* @see SensorData
* @see SensorCaptureInfo
* @see UEventsHandler
* @see UEventsManager
*/
class SensorEvent :
public UEvent
{
public:
/**
* @enum Code
* @brief Event codes for SensorEvent
*/
enum Code {
kCodeData,
kCodeNoMoreImages
kCodeData, ///< Event code indicating new sensor data is available
kCodeNoMoreImages ///< Event code indicating the sensor stream has ended
};
public:
/**
* @brief Constructor from a single image
*
* Creates a SensorEvent with kCodeData containing a single image.
* This is a convenience constructor for simple image-only sensor data.
*
* @param image The image to include in the sensor data
* @param seq Sequence number (default: 0)
* @param stamp Timestamp in seconds (default: 0.0)
* @param cameraName Optional camera name identifier (default: empty)
*/
SensorEvent(const cv::Mat & image, int seq=0, double stamp = 0.0, const std::string & cameraName = std::string()) :
UEvent(kCodeData),
data_(image, seq, stamp)
@@ -51,23 +92,57 @@ public:
sensorCaptureInfo_.cameraName = cameraName;
}
/**
* @brief Constructor for end-of-stream event
*
* Creates a SensorEvent with kCodeNoMoreImages to signal that the sensor
* stream has ended (e.g., end of file, camera disconnected).
*
* @note This constructor does not include any sensor data.
*/
SensorEvent() :
UEvent(kCodeNoMoreImages)
{
}
/**
* @brief Constructor from SensorData
*
* Creates a SensorEvent with kCodeData containing the provided SensorData.
*
* @param data The sensor data to include in the event
*/
SensorEvent(const SensorData & data) :
UEvent(kCodeData),
data_(data)
{
}
/**
* @brief Constructor from SensorData with camera name
*
* Creates a SensorEvent with kCodeData containing the provided SensorData
* and camera name.
*
* @param data The sensor data to include in the event
* @param cameraName Camera name identifier
*/
SensorEvent(const SensorData & data, const std::string & cameraName) :
UEvent(kCodeData),
data_(data)
{
sensorCaptureInfo_.cameraName = cameraName;
}
/**
* @brief Constructor from SensorData with full capture info
*
* Creates a SensorEvent with kCodeData containing the provided SensorData
* and complete sensor capture information (camera name, timing, odometry, etc.).
*
* @param data The sensor data to include in the event
* @param sensorCaptureInfo Complete sensor capture information
*/
SensorEvent(const SensorData & data, const SensorCaptureInfo & sensorCaptureInfo) :
UEvent(kCodeData),
data_(data),
@@ -75,20 +150,60 @@ public:
{
}
// Image or descriptors
/**
* @brief Returns the sensor data contained in this event
*
* Returns the SensorData object containing images, depth, laser scans,
* camera models, and other sensor information.
*
* @return Const reference to the sensor data
*/
const SensorData & data() const {return data_;}
/**
* @brief Returns the camera name
*
* Returns the camera name identifier from the sensor capture info.
*
* @return Const reference to the camera name string
*/
const std::string & cameraName() const {return sensorCaptureInfo_.cameraName;}
/**
* @brief Returns the sensor capture information
*
* Returns the complete sensor capture information including camera name,
* timing information, odometry pose, covariance, and other metadata.
*
* @return Const reference to the sensor capture info
*/
const SensorCaptureInfo & info() const {return sensorCaptureInfo_;}
/**
* @brief Virtual destructor
*/
virtual ~SensorEvent() {}
/**
* @brief Returns the class name for event identification
*
* Returns "SensorEvent" to allow event handlers to identify this event type.
*
* @return Class name string "SensorEvent"
*/
virtual std::string getClassName() const {return std::string("SensorEvent");}
private:
SensorData data_;
SensorCaptureInfo sensorCaptureInfo_;
SensorData data_; ///< Sensor data (images, depth, scans, camera models, etc.)
SensorCaptureInfo sensorCaptureInfo_; ///< Sensor capture metadata (camera name, timing, odometry, etc.)
};
//backward compatibility
/**
* @deprecated Use SensorEvent instead
* @brief Backward compatibility typedef
*
* CameraEvent is deprecated. Use SensorEvent instead.
*/
RTABMAP_DEPRECATED typedef SensorEvent CameraEvent;
} // namespace rtabmap