mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-05 17:47:49 +08:00
SensorData's isValid() method checks whether camera models are valid (#1769)
* SensorData's isValid() method checks whether camera models are valid * Added tests and doc --------- Co-authored-by: matlabbe <[email protected]>
This commit is contained in:
@@ -470,21 +470,33 @@ public:
|
||||
* @brief Checks if the sensor data is valid
|
||||
*
|
||||
* Returns true if the sensor data contains at least one of:
|
||||
* - Valid ID (> 0) or non-zero stamp
|
||||
* - Valid ID (> 0)
|
||||
* - Images (raw or compressed)
|
||||
* - Depth/right images (raw or compressed)
|
||||
* - Depth confidence (raw or compressed)
|
||||
* - Laser scan (raw or compressed)
|
||||
* - Camera models (mono or stereo)
|
||||
* - Camera models (mono or stereo), at least one valid for projection
|
||||
* (see CameraModel::isValidForProjection() and StereoCameraModel::isValidForProjection())
|
||||
* - User data (raw or compressed)
|
||||
* - Keypoints and descriptors
|
||||
* - Occupancy grid cells (ground, obstacles or empty)
|
||||
* - IMU data
|
||||
*
|
||||
*
|
||||
* @note The stamp is not considered: a SensorData with only a stamp set is not valid
|
||||
* (e.g., an empty message converted from ROS still has its header stamp
|
||||
* and a camera model created from an empty camera info).
|
||||
*
|
||||
* @return True if the sensor data contains any valid information, false otherwise
|
||||
*/
|
||||
bool isValid() const {
|
||||
bool hasCameraModel = false;
|
||||
for (size_t i=0; i < _cameraModels.size() && !hasCameraModel; ++i)
|
||||
hasCameraModel = _cameraModels[i].isValidForProjection();
|
||||
if (!hasCameraModel)
|
||||
for (size_t i=0; i < _stereoCameraModels.size() && !hasCameraModel; ++i)
|
||||
hasCameraModel = _stereoCameraModels[i].isValidForProjection();
|
||||
|
||||
return !(_id == 0 &&
|
||||
_stamp == 0.0 &&
|
||||
_imageRaw.empty() &&
|
||||
_imageCompressed.empty() &&
|
||||
_depthOrRightRaw.empty() &&
|
||||
@@ -493,8 +505,7 @@ public:
|
||||
_depthConfidenceCompressed.empty() &&
|
||||
_laserScanRaw.isEmpty() &&
|
||||
_laserScanCompressed.isEmpty() &&
|
||||
_cameraModels.empty() &&
|
||||
_stereoCameraModels.empty() &&
|
||||
!hasCameraModel &&
|
||||
_userDataRaw.empty() &&
|
||||
_userDataCompressed.empty() &&
|
||||
_keypoints.size() == 0 &&
|
||||
|
||||
Reference in New Issue
Block a user