mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 01:20:25 +08:00
DbViewer: fixed voxelize assert when voxel size is set and there are no laser scans in database
This commit is contained in:
@@ -142,7 +142,8 @@ pcl::PointCloud<pcl::PointXYZ>::Ptr voxelize(
|
|||||||
float voxelSize)
|
float voxelSize)
|
||||||
{
|
{
|
||||||
UASSERT(voxelSize > 0.0f);
|
UASSERT(voxelSize > 0.0f);
|
||||||
UASSERT((cloud->is_dense && cloud->size()) || (!cloud->is_dense && indices->size()));
|
UASSERT_MSG((cloud->is_dense && cloud->size()) || (!cloud->is_dense && indices->size()),
|
||||||
|
uFormat("Cloud size=%d indices=%d is_dense=%s", (int)cloud->size(), (int)indices->size(), cloud->is_dense?"true":"false").c_str());
|
||||||
pcl::PointCloud<pcl::PointXYZ>::Ptr output(new pcl::PointCloud<pcl::PointXYZ>);
|
pcl::PointCloud<pcl::PointXYZ>::Ptr output(new pcl::PointCloud<pcl::PointXYZ>);
|
||||||
pcl::VoxelGrid<pcl::PointXYZ> filter;
|
pcl::VoxelGrid<pcl::PointXYZ> filter;
|
||||||
filter.setLeafSize(voxelSize, voxelSize, voxelSize);
|
filter.setLeafSize(voxelSize, voxelSize, voxelSize);
|
||||||
@@ -160,7 +161,8 @@ pcl::PointCloud<pcl::PointNormal>::Ptr voxelize(
|
|||||||
float voxelSize)
|
float voxelSize)
|
||||||
{
|
{
|
||||||
UASSERT(voxelSize > 0.0f);
|
UASSERT(voxelSize > 0.0f);
|
||||||
UASSERT((cloud->is_dense && cloud->size()) || (!cloud->is_dense && indices->size()));
|
UASSERT_MSG((cloud->is_dense && cloud->size()) || (!cloud->is_dense && indices->size()),
|
||||||
|
uFormat("Cloud size=%d indices=%d is_dense=%s", (int)cloud->size(), (int)indices->size(), cloud->is_dense?"true":"false").c_str());
|
||||||
pcl::PointCloud<pcl::PointNormal>::Ptr output(new pcl::PointCloud<pcl::PointNormal>);
|
pcl::PointCloud<pcl::PointNormal>::Ptr output(new pcl::PointCloud<pcl::PointNormal>);
|
||||||
pcl::VoxelGrid<pcl::PointNormal> filter;
|
pcl::VoxelGrid<pcl::PointNormal> filter;
|
||||||
filter.setLeafSize(voxelSize, voxelSize, voxelSize);
|
filter.setLeafSize(voxelSize, voxelSize, voxelSize);
|
||||||
@@ -178,7 +180,8 @@ pcl::PointCloud<pcl::PointXYZRGB>::Ptr voxelize(
|
|||||||
float voxelSize)
|
float voxelSize)
|
||||||
{
|
{
|
||||||
UASSERT(voxelSize > 0.0f);
|
UASSERT(voxelSize > 0.0f);
|
||||||
UASSERT((cloud->is_dense && cloud->size()) || (!cloud->is_dense && indices->size()));
|
UASSERT_MSG((cloud->is_dense && cloud->size()) || (!cloud->is_dense && indices->size()),
|
||||||
|
uFormat("Cloud size=%d indices=%d is_dense=%s", (int)cloud->size(), (int)indices->size(), cloud->is_dense?"true":"false").c_str());
|
||||||
pcl::PointCloud<pcl::PointXYZRGB>::Ptr output(new pcl::PointCloud<pcl::PointXYZRGB>);
|
pcl::PointCloud<pcl::PointXYZRGB>::Ptr output(new pcl::PointCloud<pcl::PointXYZRGB>);
|
||||||
pcl::VoxelGrid<pcl::PointXYZRGB> filter;
|
pcl::VoxelGrid<pcl::PointXYZRGB> filter;
|
||||||
filter.setLeafSize(voxelSize, voxelSize, voxelSize);
|
filter.setLeafSize(voxelSize, voxelSize, voxelSize);
|
||||||
@@ -196,7 +199,8 @@ pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr voxelize(
|
|||||||
float voxelSize)
|
float voxelSize)
|
||||||
{
|
{
|
||||||
UASSERT(voxelSize > 0.0f);
|
UASSERT(voxelSize > 0.0f);
|
||||||
UASSERT((cloud->is_dense && cloud->size()) || (!cloud->is_dense && indices->size()));
|
UASSERT_MSG((cloud->is_dense && cloud->size()) || (!cloud->is_dense && indices->size()),
|
||||||
|
uFormat("Cloud size=%d indices=%d is_dense=%s", (int)cloud->size(), (int)indices->size(), cloud->is_dense?"true":"false").c_str());
|
||||||
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr output(new pcl::PointCloud<pcl::PointXYZRGBNormal>);
|
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr output(new pcl::PointCloud<pcl::PointXYZRGBNormal>);
|
||||||
pcl::VoxelGrid<pcl::PointXYZRGBNormal> filter;
|
pcl::VoxelGrid<pcl::PointXYZRGBNormal> filter;
|
||||||
filter.setLeafSize(voxelSize, voxelSize, voxelSize);
|
filter.setLeafSize(voxelSize, voxelSize, voxelSize);
|
||||||
|
|||||||
@@ -3502,15 +3502,15 @@ void DatabaseViewer::updateConstraintView(
|
|||||||
cloudTo=util3d::cloudRGBFromSensorData(dataTo, 1, 0, 0, indicesTo.get(), ui_->parameters_toolbox->getParameters());
|
cloudTo=util3d::cloudRGBFromSensorData(dataTo, 1, 0, 0, indicesTo.get(), ui_->parameters_toolbox->getParameters());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cloudTo.get() && cloudTo->size())
|
if(cloudTo.get() && indicesTo->size())
|
||||||
{
|
{
|
||||||
cloudTo = rtabmap::util3d::transformPointCloud(cloudTo, t);
|
cloudTo = rtabmap::util3d::transformPointCloud(cloudTo, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gain compensation
|
// Gain compensation
|
||||||
if(ui_->doubleSpinBox_gainCompensationRadius->value()>0.0 &&
|
if(ui_->doubleSpinBox_gainCompensationRadius->value()>0.0 &&
|
||||||
cloudFrom.get() && cloudFrom->size() &&
|
cloudFrom.get() && indicesFrom->size() &&
|
||||||
cloudTo.get() && cloudTo->size())
|
cloudTo.get() && indicesTo->size())
|
||||||
{
|
{
|
||||||
UTimer t;
|
UTimer t;
|
||||||
GainCompensator compensator(ui_->doubleSpinBox_gainCompensationRadius->value());
|
GainCompensator compensator(ui_->doubleSpinBox_gainCompensationRadius->value());
|
||||||
@@ -3520,7 +3520,7 @@ void DatabaseViewer::updateConstraintView(
|
|||||||
UINFO("Gain compensation time = %fs", t.ticks());
|
UINFO("Gain compensation time = %fs", t.ticks());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cloudFrom.get() && cloudFrom->size())
|
if(cloudFrom.get() && indicesFrom->size())
|
||||||
{
|
{
|
||||||
if(ui_->doubleSpinBox_voxelSize->value() > 0.0)
|
if(ui_->doubleSpinBox_voxelSize->value() > 0.0)
|
||||||
{
|
{
|
||||||
@@ -3528,7 +3528,7 @@ void DatabaseViewer::updateConstraintView(
|
|||||||
}
|
}
|
||||||
constraintsViewer_->addCloud("cloud0", cloudFrom, pose, Qt::red);
|
constraintsViewer_->addCloud("cloud0", cloudFrom, pose, Qt::red);
|
||||||
}
|
}
|
||||||
if(cloudTo.get() && cloudTo->size())
|
if(cloudTo.get() && indicesTo->size())
|
||||||
{
|
{
|
||||||
if(ui_->doubleSpinBox_voxelSize->value() > 0.0)
|
if(ui_->doubleSpinBox_voxelSize->value() > 0.0)
|
||||||
{
|
{
|
||||||
@@ -3755,6 +3755,8 @@ void DatabaseViewer::updateConstraintView(
|
|||||||
// Added loop closure scans
|
// Added loop closure scans
|
||||||
constraintsViewer_->removeCloud("scan0");
|
constraintsViewer_->removeCloud("scan0");
|
||||||
constraintsViewer_->removeCloud("scan1");
|
constraintsViewer_->removeCloud("scan1");
|
||||||
|
if(!dataFrom.laserScanRaw().empty())
|
||||||
|
{
|
||||||
if(dataFrom.laserScanRaw().channels() == 6)
|
if(dataFrom.laserScanRaw().channels() == 6)
|
||||||
{
|
{
|
||||||
pcl::PointCloud<pcl::PointNormal>::Ptr scan;
|
pcl::PointCloud<pcl::PointNormal>::Ptr scan;
|
||||||
@@ -3775,6 +3777,9 @@ void DatabaseViewer::updateConstraintView(
|
|||||||
}
|
}
|
||||||
constraintsViewer_->addCloud("scan0", scan, pose, Qt::yellow);
|
constraintsViewer_->addCloud("scan0", scan, pose, Qt::yellow);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if(!dataTo.laserScanRaw().empty())
|
||||||
|
{
|
||||||
if(dataTo.laserScanRaw().channels() == 6)
|
if(dataTo.laserScanRaw().channels() == 6)
|
||||||
{
|
{
|
||||||
pcl::PointCloud<pcl::PointNormal>::Ptr scan;
|
pcl::PointCloud<pcl::PointNormal>::Ptr scan;
|
||||||
@@ -3796,6 +3801,7 @@ void DatabaseViewer::updateConstraintView(
|
|||||||
constraintsViewer_->addCloud("scan1", scan, pose, Qt::magenta);
|
constraintsViewer_->addCloud("scan1", scan, pose, Qt::magenta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//update coordinate
|
//update coordinate
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user