mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-03 16:27:46 +08:00
add validation check for scan-message (#1151)
* add validation check for scan-message Signed-off-by: goes <[email protected]> * remove abundant logger Signed-off-by: goes <[email protected]> * fit into main Signed-off-by: GoesM <[email protected]> --------- Signed-off-by: goes <[email protected]> Signed-off-by: GoesM <[email protected]> Co-authored-by: goes <[email protected]> Co-authored-by: matlabbe <[email protected]>
This commit is contained in:
@@ -2591,6 +2591,24 @@ bool convertScanMsg(
|
||||
double waitForTransform,
|
||||
bool outputInFrameId)
|
||||
{
|
||||
// scan message validation check
|
||||
if(scan2dMsg.angle_increment == 0.0f) {
|
||||
ROS_ERROR("convertScanMsg: angle_increment should not be 0!");
|
||||
return false;
|
||||
}
|
||||
if(scan2dMsg.range_min > scan2dMsg.range_max) {
|
||||
ROS_ERROR("convertScanMsg: range_min (%f) should be smaller than range_max (%f)!", scan2dMsg.range_min, scan2dMsg.range_max);
|
||||
return false;
|
||||
}
|
||||
if(scan2dMsg.angle_increment > 0 && scan2dMsg.angle_max < scan2dMsg.angle_min) {
|
||||
ROS_ERROR("convertScanMsg: Angle increment (%f) should be negative if angle_min(%f) > angle_max(%f)!", scan2dMsg.angle_increment, scan2dMsg.angle_min, scan2dMsg.angle_max);
|
||||
return false;
|
||||
}
|
||||
else if (scan2dMsg.angle_increment < 0 && scan2dMsg.angle_max > scan2dMsg.angle_min) {
|
||||
ROS_ERROR("convertScanMsg: Angle increment (%f) should positive if angle_min(%f) < angle_max(%f)!", scan2dMsg.angle_increment, scan2dMsg.angle_min, scan2dMsg.angle_max);
|
||||
return false;
|
||||
}
|
||||
|
||||
// make sure the frame of the laser is updated during the whole scan time
|
||||
rtabmap::Transform tmpT = getMovingTransform(
|
||||
scan2dMsg.header.frame_id,
|
||||
|
||||
Reference in New Issue
Block a user