32 #include <QPushButton>
34 #include <QListWidget>
44 updateTimer =
new QTimer(
this);
54 pointCloudProviderNames.clear();
55 QList<QVariant>
names = settings->value(
"pointCloudProviderNames", QList<QVariant>()).toList();
56 for (
int i = 0; i <
names.count(); i++)
58 pointCloudProviderNames.push_back(
names[i].
toString().toStdString());
61 filteredPointCloudProviderNames.clear();
62 names = settings->value(
"filteredPointCloudProviderNames", QList<QVariant>()).toList();
63 for (
int i = 0; i <
names.count(); i++)
65 filteredPointCloudProviderNames.push_back(
names[i].
toString().toStdString());
68 pointCloudProviderDisplayNames.clear();
69 names = settings->value(
"pointCloudProviderDisplayNames", QList<QVariant>()).toList();
70 for (
int i = 0; i <
names.count(); i++)
72 pointCloudProviderDisplayNames.push_back(
names[i].
toString().toStdString());
75 pipelineConfigFiles.clear();
76 names = settings->value(
"pipelineConfigFiles", QList<QVariant>()).toList();
77 for (
int i = 0; i <
names.count(); i++)
79 pipelineConfigFiles.push_back(
names[i].
toString().toStdString());
82 pointCloudSegmenterName = settings->value(
"pointCloudSegmenterName",
"").toString().toStdString();
83 primitiveExtractorName = settings->value(
"primitiveExtractorName",
"").toString().toStdString();
84 affordanceExtractionName = settings->value(
"affordanceExtractionName",
"").toString().toStdString();
85 pipelineVisualizationName = settings->value(
"pipelineVisualizationName",
"").toString().toStdString();
86 robotStateComponentName = settings->value(
"robotStateComponentName",
"").toString().toStdString();
87 platform = settings->value(
"platform",
"").toString().toStdString();
92 QList<QVariant>
names;
93 for (
auto& name : pointCloudProviderNames)
95 names.append(QString::fromStdString(name));
97 settings->setValue(
"pointCloudProviderNames",
names);
100 for (
auto& name : filteredPointCloudProviderNames)
102 names.append(QString::fromStdString(name));
104 settings->setValue(
"filteredPointCloudProviderNames",
names);
107 for (
auto& name : pointCloudProviderDisplayNames)
109 names.append(QString::fromStdString(name));
111 settings->setValue(
"pointCloudProviderDisplayNames",
names);
114 for (
auto&
filename : pipelineConfigFiles)
118 settings->setValue(
"pipelineConfigFiles",
names);
120 settings->setValue(
"pointCloudSegmenterName", QString::fromStdString(pointCloudSegmenterName));
121 settings->setValue(
"primitiveExtractorName", QString::fromStdString(primitiveExtractorName));
122 settings->setValue(
"affordanceExtractionName", QString::fromStdString(affordanceExtractionName));
123 settings->setValue(
"pipelineVisualizationName", QString::fromStdString(pipelineVisualizationName));
124 settings->setValue(
"robotStateComponentName", QString::fromStdString(robotStateComponentName));
125 settings->setValue(
"platform", QString::fromStdString(platform));
130 for (
auto& provider : pointCloudProviderNames)
135 for (
auto& provider : filteredPointCloudProviderNames)
149 pointCloudProviders.clear();
150 for (
auto& provider : pointCloudProviderNames)
152 pointCloudProviders.push_back(getProxy<visionx::CapturingPointCloudProviderInterfacePrx>(provider));
155 filteredPointCloudProviders.clear();
156 for (
auto& provider : filteredPointCloudProviderNames)
158 filteredPointCloudProviders.push_back(getProxy<armarx::PointCloudFilterInterfacePrx>(provider));
161 pointCloudSegmenter = getProxy<visionx::PointCloudSegmenterInterfacePrx>(pointCloudSegmenterName);
162 primitiveExtractor = getProxy<visionx::PrimitiveMapperInterfacePrx>(primitiveExtractorName);
163 affordanceExtraction = getProxy<AffordanceExtractionInterfacePrx>(affordanceExtractionName);
164 pipelineVisualization = getProxy<AffordancePipelineVisualizationInterfacePrx>(pipelineVisualizationName);
165 robotStateComponent = getProxy<RobotStateComponentInterfacePrx>(robotStateComponentName);
168 widget.comboBoxSegmentation->clear();
169 for (
unsigned int i = 0; i < pipelineConfigFiles.size(); i++)
171 widget.comboBoxSegmentation->addItem(QString::fromStdString(
"C" +
std::to_string(i)));
175 widget.comboBoxPointCloudSource->clear();
176 for (
auto& provider : pointCloudProviderDisplayNames)
178 widget.comboBoxPointCloudSource->addItem(QString::fromStdString(provider));
180 widget.comboBoxPointCloudSource->setCurrentIndex(0);
184 pipelineVisualization->clearVisualization();
188 connect(widget.pushButtonStart, SIGNAL(clicked()),
this, SLOT(
startPipeline()));
189 connect(widget.pushButtonPause, SIGNAL(clicked()),
this, SLOT(
pausePipeline()));
190 connect(widget.pushButtonStep, SIGNAL(clicked()),
this, SLOT(
stepPipeline()));
192 connect(widget.comboBoxCropping, SIGNAL(currentIndexChanged(
int)),
this, SLOT(
croppingSelected(
int)));
193 connect(widget.comboBoxPointCloudSource, SIGNAL(currentIndexChanged(
int)),
this, SLOT(
pointCloudSourceSelected(
int)));
199 updateTimer->start(500);
202 widget.comboBoxCropping->setCurrentIndex(3);
205 widget.comboBoxSegmentation->setCurrentIndex(0);
210 QMetaObject::invokeMethod(
this,
"visualizationOptionsChanged", Qt::QueuedConnection, Q_ARG(
bool,
true));
226 widget.labelProviderStatus->setText(
"Stopped");
227 widget.labelSegmenterStatus->setText(
"Stopped");
228 widget.labelPrimitivesStatus->setText(
"Stopped");
229 widget.labelAffordancesStatus->setText(
"Stopped");
236 bool providerStatus = pointCloudProviders[currentPointCloudProvider]->isCaptureEnabled();
237 bool segmenterStatus = pointCloudSegmenter->isPipelineStepEnabled();
238 bool primitivesStatus = primitiveExtractor->isPipelineStepEnabled();
239 bool affordancesStatus = affordanceExtraction->isPipelineStepEnabled();
241 widget.labelProviderStatus->setText(providerStatus ?
"Running" :
"Paused");
242 widget.labelSegmenterStatus->setText(segmenterStatus ?
"Running" :
"Paused");
243 widget.labelPrimitivesStatus->setText(primitivesStatus ?
"Running" :
"Paused");
244 widget.labelAffordancesStatus->setText(affordancesStatus ?
"Running" :
"Paused");
246 widget.labelProviderTimestamp->setText(formatTimestamp(pointCloudProviders[currentPointCloudProvider]->getPointCloudFormat()->timeProvided));
247 widget.labelSegmenterTimestamp->setText(formatTimestamp(pointCloudSegmenter->getLastProcessedTimestamp()->timestamp));
248 widget.labelPrimitivesTimestamp->setText(formatTimestamp(primitiveExtractor->getLastProcessedTimestamp()->timestamp));
249 widget.labelAffordancesTimestamp->setText(formatTimestamp(affordanceExtraction->getLastProcessedTimestamp()->timestamp));
251 bool status = providerStatus && segmenterStatus && primitivesStatus && affordancesStatus;
252 widget.pushButtonStart->setEnabled(!
status);
253 widget.pushButtonPause->setEnabled(
status);
254 widget.pushButtonStep->setEnabled(!
status);
256 catch (
const Ice::ConnectionRefusedException& e)
266 pointCloudSegmenter->enablePipelineStep();
267 primitiveExtractor->enablePipelineStep();
268 affordanceExtraction->enablePipelineStep();
269 pointCloudProviders[currentPointCloudProvider]->begin_startCapture();
276 pointCloudProviders[currentPointCloudProvider]->begin_stopCapture();
277 pointCloudSegmenter->disablePipelineStep();
278 primitiveExtractor->disablePipelineStep();
279 affordanceExtraction->disablePipelineStep();
286 pointCloudSegmenter->enablePipelineStep();
287 primitiveExtractor->enablePipelineStep();
288 affordanceExtraction->enablePipelineStep();
289 pointCloudProviders[currentPointCloudProvider]->begin_startCaptureForNumFrames(1);
294 pipelineVisualization->begin_enableVisualization(widget.checkBoxShowPrimitives->isChecked(), widget.checkBoxShowAffordances->isChecked(),
false);
299 std::string
filename = QFileDialog::getOpenFileName(
getWidget(), tr(
"Open Affordance Scene"),
"~", tr(
"Scene Files (*.scene)")).toStdString();
305 affordanceExtraction->importScene(
filename);
310 std::string
filename = QFileDialog::getSaveFileName(NULL, tr(
"Save Affordance Scene"),
"", tr(
"Scene Files (*.scene)")).toStdString();
316 affordanceExtraction->exportScene(
filename);
324 float root_z = PosePtr::dynamicCast(robotStateComponent->getSynchronizedRobot()->getGlobalPose())->toEigen()(2, 3);
330 min << -10000, -10000, -10000;
331 max << 10000, 10000, 10000;
335 min << -3000, 300, 0 - root_z;
336 max << 3000, 3000, 3000 - root_z;
340 min << -2000, 300, 300 - root_z;
341 max << 2000, 3000, 2500 - root_z;
345 min << -1000, 300, 600 - root_z;
346 max << 1000, 2000, 1500 - root_z;
350 min << -500, 300, 1000 - root_z;
351 max << 500, 2000, 1500 - root_z;
359 for (
auto& provider : filteredPointCloudProviders)
367 currentPointCloudProvider =
index;
368 pointCloudSegmenter->begin_changePointCloudProvider(filteredPointCloudProviderNames[currentPointCloudProvider] +
"Result");
375 if (
index < 0 ||
static_cast<std::size_t
>(
index) >= pipelineConfigFiles.size())
380 primitiveExtractor->loadParametersFromFile(pipelineConfigFiles[
index]);
381 pointCloudSegmenter->loadLccpParametersFromFile(pipelineConfigFiles[
index]);
384 QString AffordancePipelineGuiWidgetController::formatTimestamp(
long timestamp)
387 return QString(time.toDateTime().substr(time.toDateTime().find(
' ') + 1).c_str());
397 return qobject_cast<AffordancePipelineGuiConfigDialog*>(configDialog);
402 pointCloudProviderNames = configDialog->getProviderNames();
403 pointCloudProviderDisplayNames = configDialog->getProviderDisplayNames();
404 filteredPointCloudProviderNames = configDialog->getFilteredProviderNames();
405 pipelineConfigFiles = configDialog->getPipelineConfigurationFiles();
407 pointCloudSegmenterName = configDialog->pointCloudSegmenterProxyFinder->getSelectedProxyName().toStdString();
408 primitiveExtractorName = configDialog->primitiveExtractorProxyFinder->getSelectedProxyName().toStdString();
409 affordanceExtractionName = configDialog->affordanceExtractionProxyFinder->getSelectedProxyName().toStdString();
410 pipelineVisualizationName = configDialog->pipelineVisualizationProxyFinder->getSelectedProxyName().toStdString();
411 robotStateComponentName = configDialog->robotStateComponentProxyFinder->getSelectedProxyName().toStdString();
412 platform = configDialog->getPlatform();
419 if (parent != customToolbar->parent())
421 customToolbar->setParent(parent);
424 return customToolbar;
427 customToolbar =
new QToolBar(parent);
428 customToolbar->setIconSize(QSize(16, 16));
429 customToolbar->addAction(QIcon(
":/icons/document-open-folder.png"),
"Load Scene File",
this, SLOT(
loadScene()));
430 customToolbar->addAction(QIcon(
":/icons/document-save-5.ico"),
"Save Scene File",
this, SLOT(
saveScene()));
432 return customToolbar;