mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-03 16:27:46 +08:00
0.20.13: Refacoring MsgConversion by using laserScanFromPointCloud() from rtabmap library.
This commit is contained in:
+1
-1
@@ -31,7 +31,7 @@ find_package(find_object_2d)
|
|||||||
|
|
||||||
## System dependencies are found with CMake's conventions
|
## System dependencies are found with CMake's conventions
|
||||||
# find_package(Boost REQUIRED COMPONENTS system)
|
# find_package(Boost REQUIRED COMPONENTS system)
|
||||||
find_package(RTABMap 0.20.11 REQUIRED)
|
find_package(RTABMap 0.20.13 REQUIRED)
|
||||||
|
|
||||||
find_package(OpenCV REQUIRED)
|
find_package(OpenCV REQUIRED)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<package>
|
<package>
|
||||||
<name>rtabmap_ros</name>
|
<name>rtabmap_ros</name>
|
||||||
<version>0.20.11</version>
|
<version>0.20.13</version>
|
||||||
<description>RTAB-Map's ros-pkg. RTAB-Map is a RGB-D SLAM approach with real-time constraints.</description>
|
<description>RTAB-Map's ros-pkg. RTAB-Map is a RGB-D SLAM approach with real-time constraints.</description>
|
||||||
<maintainer email="[email protected]">Mathieu Labbe</maintainer>
|
<maintainer email="[email protected]">Mathieu Labbe</maintainer>
|
||||||
<author>Mathieu Labbe</author>
|
<author>Mathieu Labbe</author>
|
||||||
|
|||||||
+2
-100
@@ -2207,39 +2207,6 @@ bool convertScan3dMsg(
|
|||||||
UASSERT_MSG(scan3dMsg.data.size() == scan3dMsg.row_step*scan3dMsg.height,
|
UASSERT_MSG(scan3dMsg.data.size() == scan3dMsg.row_step*scan3dMsg.height,
|
||||||
uFormat("data=%d row_step=%d height=%d", scan3dMsg.data.size(), scan3dMsg.row_step, scan3dMsg.height).c_str());
|
uFormat("data=%d row_step=%d height=%d", scan3dMsg.data.size(), scan3dMsg.row_step, scan3dMsg.height).c_str());
|
||||||
|
|
||||||
bool hasNormals = false;
|
|
||||||
bool hasColors = false;
|
|
||||||
bool hasIntensity = false;
|
|
||||||
for(unsigned int i=0; i<scan3dMsg.fields.size(); ++i)
|
|
||||||
{
|
|
||||||
if(scan3dMsg.fields[i].name.compare("normal_x") == 0)
|
|
||||||
{
|
|
||||||
hasNormals = true;
|
|
||||||
}
|
|
||||||
if(scan3dMsg.fields[i].name.compare("rgb") == 0 || scan3dMsg.fields[i].name.compare("rgba") == 0)
|
|
||||||
{
|
|
||||||
hasColors = true;
|
|
||||||
}
|
|
||||||
if(scan3dMsg.fields[i].name.compare("intensity") == 0)
|
|
||||||
{
|
|
||||||
if(scan3dMsg.fields[i].datatype == sensor_msgs::PointField::FLOAT32)
|
|
||||||
{
|
|
||||||
hasIntensity = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
static bool warningShown = false;
|
|
||||||
if(!warningShown)
|
|
||||||
{
|
|
||||||
ROS_WARN("The input scan cloud has an \"intensity\" field "
|
|
||||||
"but the datatype (%d) is not supported. Intensity will be ignored. "
|
|
||||||
"This message is only shown once.", scan3dMsg.fields[i].datatype);
|
|
||||||
warningShown = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rtabmap::Transform scanLocalTransform = getTransform(frameId, scan3dMsg.header.frame_id, scan3dMsg.header.stamp, listener, waitForTransform);
|
rtabmap::Transform scanLocalTransform = getTransform(frameId, scan3dMsg.header.frame_id, scan3dMsg.header.stamp, listener, waitForTransform);
|
||||||
if(scanLocalTransform.isNull())
|
if(scanLocalTransform.isNull())
|
||||||
{
|
{
|
||||||
@@ -2267,73 +2234,8 @@ bool convertScan3dMsg(
|
|||||||
scanLocalTransform = sensorT * scanLocalTransform;
|
scanLocalTransform = sensorT * scanLocalTransform;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
scan = rtabmap::util3d::laserScanFromPointCloud(scan3dMsg);
|
||||||
if(hasNormals)
|
scan = rtabmap::LaserScan(scan, maxPoints, maxRange, scanLocalTransform);
|
||||||
{
|
|
||||||
if(hasColors)
|
|
||||||
{
|
|
||||||
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr pclScan(new pcl::PointCloud<pcl::PointXYZRGBNormal>);
|
|
||||||
pcl::fromROSMsg(scan3dMsg, *pclScan);
|
|
||||||
if(!pclScan->is_dense)
|
|
||||||
{
|
|
||||||
pclScan = rtabmap::util3d::removeNaNNormalsFromPointCloud(pclScan);
|
|
||||||
}
|
|
||||||
scan = rtabmap::LaserScan(rtabmap::util3d::laserScanFromPointCloud(*pclScan), maxPoints, maxRange, scanLocalTransform);
|
|
||||||
}
|
|
||||||
else if(hasIntensity)
|
|
||||||
{
|
|
||||||
pcl::PointCloud<pcl::PointXYZINormal>::Ptr pclScan(new pcl::PointCloud<pcl::PointXYZINormal>);
|
|
||||||
pcl::fromROSMsg(scan3dMsg, *pclScan);
|
|
||||||
if(!pclScan->is_dense)
|
|
||||||
{
|
|
||||||
pclScan = rtabmap::util3d::removeNaNNormalsFromPointCloud(pclScan);
|
|
||||||
}
|
|
||||||
scan = rtabmap::LaserScan(rtabmap::util3d::laserScanFromPointCloud(*pclScan), maxPoints, maxRange, scanLocalTransform);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pcl::PointCloud<pcl::PointNormal>::Ptr pclScan(new pcl::PointCloud<pcl::PointNormal>);
|
|
||||||
pcl::fromROSMsg(scan3dMsg, *pclScan);
|
|
||||||
if(!pclScan->is_dense)
|
|
||||||
{
|
|
||||||
pclScan = rtabmap::util3d::removeNaNNormalsFromPointCloud(pclScan);
|
|
||||||
}
|
|
||||||
scan = rtabmap::LaserScan(rtabmap::util3d::laserScanFromPointCloud(*pclScan), maxPoints, maxRange, scanLocalTransform);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(hasColors)
|
|
||||||
{
|
|
||||||
pcl::PointCloud<pcl::PointXYZRGB>::Ptr pclScan(new pcl::PointCloud<pcl::PointXYZRGB>);
|
|
||||||
pcl::fromROSMsg(scan3dMsg, *pclScan);
|
|
||||||
if(!pclScan->is_dense)
|
|
||||||
{
|
|
||||||
pclScan = rtabmap::util3d::removeNaNFromPointCloud(pclScan);
|
|
||||||
}
|
|
||||||
scan = rtabmap::LaserScan(rtabmap::util3d::laserScanFromPointCloud(*pclScan), maxPoints, maxRange, scanLocalTransform);
|
|
||||||
}
|
|
||||||
else if(hasIntensity)
|
|
||||||
{
|
|
||||||
pcl::PointCloud<pcl::PointXYZI>::Ptr pclScan(new pcl::PointCloud<pcl::PointXYZI>);
|
|
||||||
pcl::fromROSMsg(scan3dMsg, *pclScan);
|
|
||||||
if(!pclScan->is_dense)
|
|
||||||
{
|
|
||||||
pclScan = rtabmap::util3d::removeNaNFromPointCloud(pclScan);
|
|
||||||
}
|
|
||||||
scan = rtabmap::LaserScan(rtabmap::util3d::laserScanFromPointCloud(*pclScan), maxPoints, maxRange, scanLocalTransform);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pcl::PointCloud<pcl::PointXYZ>::Ptr pclScan(new pcl::PointCloud<pcl::PointXYZ>);
|
|
||||||
pcl::fromROSMsg(scan3dMsg, *pclScan);
|
|
||||||
if(!pclScan->is_dense)
|
|
||||||
{
|
|
||||||
pclScan = rtabmap::util3d::removeNaNFromPointCloud(pclScan);
|
|
||||||
}
|
|
||||||
scan = rtabmap::LaserScan(rtabmap::util3d::laserScanFromPointCloud(*pclScan), maxPoints, maxRange, scanLocalTransform);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user