mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-03 01:50:24 +08:00
GUI: added option to show octomap as a point cloud (less GPU power required)
This commit is contained in:
@@ -439,7 +439,7 @@ pcl::PointCloud<pcl::PointXYZRGB>::Ptr OctoMap::createCloud(
|
|||||||
int gi=0;
|
int gi=0;
|
||||||
for (octomap::ColorOcTree::iterator it = octree_->begin(treeDepth); it != octree_->end(); ++it)
|
for (octomap::ColorOcTree::iterator it = octree_->begin(treeDepth); it != octree_->end(); ++it)
|
||||||
{
|
{
|
||||||
if(octree_->isNodeOccupied(*it))
|
if(octree_->isNodeOccupied(*it) && (obstacleIndices || emptyIndices == 0))
|
||||||
{
|
{
|
||||||
octomap::point3d pt = octree_->keyToCoord(it.getKey());
|
octomap::point3d pt = octree_->keyToCoord(it.getKey());
|
||||||
if(octree_->getTreeDepth() == it.getDepth() && hasColor_)
|
if(octree_->getTreeDepth() == it.getDepth() && hasColor_)
|
||||||
@@ -465,7 +465,7 @@ pcl::PointCloud<pcl::PointXYZRGB>::Ptr OctoMap::createCloud(
|
|||||||
}
|
}
|
||||||
++oi;
|
++oi;
|
||||||
}
|
}
|
||||||
else
|
else if(emptyIndices || obstacleIndices == 0)
|
||||||
{
|
{
|
||||||
octomap::point3d pt = octree_->keyToCoord(it.getKey());
|
octomap::point3d pt = octree_->keyToCoord(it.getKey());
|
||||||
(*cloud)[oi] = pcl::PointXYZRGB(it->getColor().r, it->getColor().g, it->getColor().b);
|
(*cloud)[oi] = pcl::PointXYZRGB(it->getColor().r, it->getColor().g, it->getColor().b);
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ public:
|
|||||||
bool isCloudsShown(int index) const; // 0=map, 1=odom
|
bool isCloudsShown(int index) const; // 0=map, 1=odom
|
||||||
bool isOctomapUpdated() const;
|
bool isOctomapUpdated() const;
|
||||||
bool isOctomapShown() const;
|
bool isOctomapShown() const;
|
||||||
|
bool isOctomapCubeRendering() const;
|
||||||
bool isOctomap2dGrid() const;
|
bool isOctomap2dGrid() const;
|
||||||
int getOctomapTreeDepth() const;
|
int getOctomapTreeDepth() const;
|
||||||
bool isOctomapGroundAnObstacle() const;
|
bool isOctomapGroundAnObstacle() const;
|
||||||
|
|||||||
@@ -2387,6 +2387,7 @@ void MainWindow::updateMapCloud(
|
|||||||
|
|
||||||
#ifdef RTABMAP_OCTOMAP
|
#ifdef RTABMAP_OCTOMAP
|
||||||
_cloudViewer->removeOctomap();
|
_cloudViewer->removeOctomap();
|
||||||
|
_cloudViewer->removeCloud("octomap_cloud");
|
||||||
if(_preferencesDialog->isOctomapUpdated())
|
if(_preferencesDialog->isOctomapUpdated())
|
||||||
{
|
{
|
||||||
UDEBUG("");
|
UDEBUG("");
|
||||||
@@ -2398,7 +2399,19 @@ void MainWindow::updateMapCloud(
|
|||||||
{
|
{
|
||||||
UDEBUG("");
|
UDEBUG("");
|
||||||
UTimer time;
|
UTimer time;
|
||||||
_cloudViewer->addOctomap(_octomap, _preferencesDialog->getOctomapTreeDepth());
|
if(_preferencesDialog->isOctomapCubeRendering())
|
||||||
|
{
|
||||||
|
_cloudViewer->addOctomap(_octomap, _preferencesDialog->getOctomapTreeDepth());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pcl::IndicesPtr obstacles(new std::vector<int>);
|
||||||
|
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud = _octomap->createCloud(_preferencesDialog->getOctomapTreeDepth(), obstacles.get());
|
||||||
|
if(obstacles->size())
|
||||||
|
{
|
||||||
|
_cloudViewer->addCloud("octomap_cloud", cloud);
|
||||||
|
}
|
||||||
|
}
|
||||||
UINFO("Octomap show 3d map time = %fs", time.ticks());
|
UINFO("Octomap show 3d map time = %fs", time.ticks());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -382,6 +382,7 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
|
|||||||
connect(_ui->spinBox_octomap_treeDepth, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel()));
|
connect(_ui->spinBox_octomap_treeDepth, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel()));
|
||||||
connect(_ui->checkBox_octomap_2dgrid, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel()));
|
connect(_ui->checkBox_octomap_2dgrid, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel()));
|
||||||
connect(_ui->checkBox_octomap_show3dMap, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel()));
|
connect(_ui->checkBox_octomap_show3dMap, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel()));
|
||||||
|
connect(_ui->checkBox_octomap_cubeRendering, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel()));
|
||||||
|
|
||||||
connect(_ui->groupBox_organized, SIGNAL(toggled(bool)), this, SLOT(makeObsoleteCloudRenderingPanel()));
|
connect(_ui->groupBox_organized, SIGNAL(toggled(bool)), this, SLOT(makeObsoleteCloudRenderingPanel()));
|
||||||
connect(_ui->doubleSpinBox_mesh_angleTolerance, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteCloudRenderingPanel()));
|
connect(_ui->doubleSpinBox_mesh_angleTolerance, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteCloudRenderingPanel()));
|
||||||
@@ -1260,6 +1261,7 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox)
|
|||||||
_ui->spinBox_octomap_treeDepth->setValue(16);
|
_ui->spinBox_octomap_treeDepth->setValue(16);
|
||||||
_ui->checkBox_octomap_2dgrid->setChecked(true);
|
_ui->checkBox_octomap_2dgrid->setChecked(true);
|
||||||
_ui->checkBox_octomap_show3dMap->setChecked(true);
|
_ui->checkBox_octomap_show3dMap->setChecked(true);
|
||||||
|
_ui->checkBox_octomap_cubeRendering->setChecked(true);
|
||||||
_ui->doubleSpinBox_octomap_occupancyThr->setValue(0.5);
|
_ui->doubleSpinBox_octomap_occupancyThr->setValue(0.5);
|
||||||
}
|
}
|
||||||
else if(groupBox->objectName() == _ui->groupBox_logging1->objectName())
|
else if(groupBox->objectName() == _ui->groupBox_logging1->objectName())
|
||||||
@@ -1616,6 +1618,7 @@ void PreferencesDialog::readGuiSettings(const QString & filePath)
|
|||||||
_ui->spinBox_octomap_treeDepth->setValue(settings.value("octomap_depth", _ui->spinBox_octomap_treeDepth->value()).toInt());
|
_ui->spinBox_octomap_treeDepth->setValue(settings.value("octomap_depth", _ui->spinBox_octomap_treeDepth->value()).toInt());
|
||||||
_ui->checkBox_octomap_2dgrid->setChecked(settings.value("octomap_2dgrid", _ui->checkBox_octomap_2dgrid->isChecked()).toBool());
|
_ui->checkBox_octomap_2dgrid->setChecked(settings.value("octomap_2dgrid", _ui->checkBox_octomap_2dgrid->isChecked()).toBool());
|
||||||
_ui->checkBox_octomap_show3dMap->setChecked(settings.value("octomap_3dmap", _ui->checkBox_octomap_show3dMap->isChecked()).toBool());
|
_ui->checkBox_octomap_show3dMap->setChecked(settings.value("octomap_3dmap", _ui->checkBox_octomap_show3dMap->isChecked()).toBool());
|
||||||
|
_ui->checkBox_octomap_cubeRendering->setChecked(settings.value("octomap_cube", _ui->checkBox_octomap_cubeRendering->isChecked()).toBool());
|
||||||
_ui->doubleSpinBox_octomap_occupancyThr->setValue(settings.value("octomap_occupancy_thr", _ui->doubleSpinBox_octomap_occupancyThr->value()).toDouble());
|
_ui->doubleSpinBox_octomap_occupancyThr->setValue(settings.value("octomap_occupancy_thr", _ui->doubleSpinBox_octomap_occupancyThr->value()).toDouble());
|
||||||
|
|
||||||
_ui->groupBox_organized->setChecked(settings.value("meshing", _ui->groupBox_organized->isChecked()).toBool());
|
_ui->groupBox_organized->setChecked(settings.value("meshing", _ui->groupBox_organized->isChecked()).toBool());
|
||||||
@@ -2046,6 +2049,7 @@ void PreferencesDialog::writeGuiSettings(const QString & filePath) const
|
|||||||
settings.setValue("octomap_depth", _ui->spinBox_octomap_treeDepth->value());
|
settings.setValue("octomap_depth", _ui->spinBox_octomap_treeDepth->value());
|
||||||
settings.setValue("octomap_2dgrid", _ui->checkBox_octomap_2dgrid->isChecked());
|
settings.setValue("octomap_2dgrid", _ui->checkBox_octomap_2dgrid->isChecked());
|
||||||
settings.setValue("octomap_3dmap", _ui->checkBox_octomap_show3dMap->isChecked());
|
settings.setValue("octomap_3dmap", _ui->checkBox_octomap_show3dMap->isChecked());
|
||||||
|
settings.setValue("octomap_cube", _ui->checkBox_octomap_cubeRendering->isChecked());
|
||||||
settings.setValue("octomap_occupancy_thr", _ui->doubleSpinBox_octomap_occupancyThr->value());
|
settings.setValue("octomap_occupancy_thr", _ui->doubleSpinBox_octomap_occupancyThr->value());
|
||||||
|
|
||||||
|
|
||||||
@@ -3812,6 +3816,10 @@ bool PreferencesDialog::isOctomapShown() const
|
|||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
bool PreferencesDialog::isOctomapCubeRendering() const
|
||||||
|
{
|
||||||
|
return _ui->checkBox_octomap_cubeRendering->isChecked();
|
||||||
|
}
|
||||||
bool PreferencesDialog::isOctomap2dGrid() const
|
bool PreferencesDialog::isOctomap2dGrid() const
|
||||||
{
|
{
|
||||||
#ifdef RTABMAP_OCTOMAP
|
#ifdef RTABMAP_OCTOMAP
|
||||||
|
|||||||
@@ -63,9 +63,9 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>-450</y>
|
<y>0</y>
|
||||||
<width>673</width>
|
<width>678</width>
|
||||||
<height>2496</height>
|
<height>2417</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_16">
|
<layout class="QVBoxLayout" name="verticalLayout_16">
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
<enum>QFrame::Raised</enum>
|
<enum>QFrame::Raised</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>5</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="page_22">
|
<widget class="QWidget" name="page_22">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_29" stretch="0,1">
|
<layout class="QVBoxLayout" name="verticalLayout_29" stretch="0,1">
|
||||||
@@ -1747,20 +1747,7 @@ Show a yellow background when the number of odometry inliers goes under this thr
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_72" columnstretch="0,1">
|
<layout class="QGridLayout" name="gridLayout_72" columnstretch="0,1">
|
||||||
<item row="1" column="0">
|
<item row="2" column="1">
|
||||||
<widget class="QSpinBox" name="spinBox_octomap_treeDepth">
|
|
||||||
<property name="minimum">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>16</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>16</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QLabel" name="label_octomap_treeDepth">
|
<widget class="QLabel" name="label_octomap_treeDepth">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Octomap maximum tree depth (max 16). The highest depth means the smallest resolution of the map (cell size). At smallest resolution the octomap shows RGB colors. Other resolutions produce z-axis gradient colored octomap.</string>
|
<string>Octomap maximum tree depth (max 16). The highest depth means the smallest resolution of the map (cell size). At smallest resolution the octomap shows RGB colors. Other resolutions produce z-axis gradient colored octomap.</string>
|
||||||
@@ -1774,6 +1761,19 @@ Show a yellow background when the number of odometry inliers goes under this thr
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
|
<widget class="QSpinBox" name="spinBox_octomap_treeDepth">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>16</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>16</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
<widget class="QCheckBox" name="checkBox_octomap_2dgrid">
|
<widget class="QCheckBox" name="checkBox_octomap_2dgrid">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
@@ -1783,7 +1783,7 @@ Show a yellow background when the number of odometry inliers goes under this thr
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QLabel" name="label_octomap_treeDepth_2">
|
<widget class="QLabel" name="label_octomap_treeDepth_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Show 2D occupancy grid map from OctoMap projection.</string>
|
<string>Show 2D occupancy grid map from OctoMap projection.</string>
|
||||||
@@ -1819,7 +1819,7 @@ Show a yellow background when the number of odometry inliers goes under this thr
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QLabel" name="label_octomap_treeDepth_4">
|
<widget class="QLabel" name="label_octomap_treeDepth_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Occupancy threshold.</string>
|
<string>Occupancy threshold.</string>
|
||||||
@@ -1832,7 +1832,7 @@ Show a yellow background when the number of odometry inliers goes under this thr
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_octomap_occupancyThr">
|
<widget class="QDoubleSpinBox" name="doubleSpinBox_octomap_occupancyThr">
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<double>1.000000000000000</double>
|
<double>1.000000000000000</double>
|
||||||
@@ -1842,6 +1842,29 @@ Show a yellow background when the number of odometry inliers goes under this thr
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLabel" name="label_octomap_treeDepth_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cube rendering. Disable to show as a point cloud (a lot less GPU power required).</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="textInteractionFlags">
|
||||||
|
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QCheckBox" name="checkBox_octomap_cubeRendering">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user