mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 09:30:25 +08:00
util3d: Fixed color not copied on laser scan conversion
This commit is contained in:
@@ -2698,7 +2698,16 @@ void DatabaseViewer::update(int value,
|
||||
//add scan
|
||||
if(ui_->checkBox_showScan->isChecked() && data.laserScanRaw().cols)
|
||||
{
|
||||
if(data.laserScanRaw().channels() == 6)
|
||||
if(data.laserScanRaw().channels() == 7)
|
||||
{
|
||||
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr scan = util3d::laserScanToPointCloudRGBNormal(data.laserScanRaw(), data.laserScanInfo().localTransform());
|
||||
if(ui_->doubleSpinBox_voxelSize->value() > 0.0)
|
||||
{
|
||||
scan = util3d::voxelize(scan, ui_->doubleSpinBox_voxelSize->value());
|
||||
}
|
||||
cloudViewer_->addCloud("scan", scan, pose, Qt::yellow);
|
||||
}
|
||||
else if(data.laserScanRaw().channels() == 6)
|
||||
{
|
||||
pcl::PointCloud<pcl::PointNormal>::Ptr scan = util3d::laserScanToPointCloudNormal(data.laserScanRaw(), data.laserScanInfo().localTransform());
|
||||
if(ui_->doubleSpinBox_voxelSize->value() > 0.0)
|
||||
@@ -2707,6 +2716,15 @@ void DatabaseViewer::update(int value,
|
||||
}
|
||||
cloudViewer_->addCloud("scan", scan, pose, Qt::yellow);
|
||||
}
|
||||
else if(data.laserScanRaw().channels() == 4)
|
||||
{
|
||||
pcl::PointCloud<pcl::PointXYZRGB>::Ptr scan = util3d::laserScanToPointCloudRGB(data.laserScanRaw(), data.laserScanInfo().localTransform());
|
||||
if(ui_->doubleSpinBox_voxelSize->value() > 0.0)
|
||||
{
|
||||
scan = util3d::voxelize(scan, ui_->doubleSpinBox_voxelSize->value());
|
||||
}
|
||||
cloudViewer_->addCloud("scan", scan, pose, Qt::yellow);
|
||||
}
|
||||
else
|
||||
{
|
||||
pcl::PointCloud<pcl::PointXYZ>::Ptr scan = util3d::laserScanToPointCloud(data.laserScanRaw(), data.laserScanInfo().localTransform());
|
||||
|
||||
@@ -2920,7 +2920,7 @@ void MainWindow::createAndAddScanToMap(int nodeId, const Transform & pose, int m
|
||||
}
|
||||
|
||||
// Do ceiling/floor filtering
|
||||
if(scan.channels() > 2 && // don't filter 2D scans
|
||||
if((scan.channels() > 2 && scan.channels() != 5) && // don't filter 2D scans
|
||||
(_preferencesDialog->getScanFloorFilteringHeight() != 0.0 ||
|
||||
_preferencesDialog->getScanCeilingFilteringHeight() != 0.0))
|
||||
{
|
||||
@@ -2987,7 +2987,7 @@ void MainWindow::createAndAddScanToMap(int nodeId, const Transform & pose, int m
|
||||
iter->sensorData().laserScanInfo().localTransform().z());
|
||||
|
||||
pcl::PointCloud<pcl::Normal>::Ptr normals;
|
||||
if(cloud->size())
|
||||
if(cloud.get() && cloud->size())
|
||||
{
|
||||
if(scan.channels() == 2 || scan.channels() == 5)
|
||||
{
|
||||
@@ -3003,7 +3003,7 @@ void MainWindow::createAndAddScanToMap(int nodeId, const Transform & pose, int m
|
||||
}
|
||||
else
|
||||
{
|
||||
UASSERT(cloudRGB->size()); // Assuming 4 channels cannot be 2D
|
||||
UASSERT(cloudRGB.get() && cloudRGB->size()); // Assuming 4 channels cannot be 2D
|
||||
normals = util3d::computeNormals(cloudRGB, _preferencesDialog->getScanNormalKSearch(), _preferencesDialog->getScanNormalRadiusSearch(), scanViewpoint);
|
||||
cloudRGBWithNormals.reset(new pcl::PointCloud<pcl::PointXYZRGBNormal>);
|
||||
pcl::concatenateFields(*cloudRGB, *normals, *cloudRGBWithNormals);
|
||||
|
||||
Reference in New Issue
Block a user