27 #include <SimoxUtility/math/convert/quat_to_rpy.h>
38 std::lock_guard g{_mutex};
40 settings->value(
"rsc",
"Armar6StateComponent").toString().toStdString());
42 settings->value(
"gco",
"GraspCandidateObserver").toString().toStdString());
49 std::lock_guard g{_mutex};
55 QString::fromStdString(
63 std::lock_guard g{_mutex};
68 "rsc",
"Robot State Component",
"*Component");
69 _dialog->addProxyFinder<grasping::GraspCandidateObserverInterfacePrx>(
70 "gco",
"Grasp Candidate Observer",
"*Observer");
72 return qobject_cast<SimpleConfigDialog*>(_dialog);
79 std::lock_guard g{_mutex};
82 _dialog->getProxyName(
"gco"));
92 std::lock_guard g{_mutex};
95 connect(_ui.pushButtonUpdateGC,
96 &QPushButton::clicked,
99 connect(_ui.treeWidgetGC,
100 &QTreeWidget::itemSelectionChanged,
104 connect(_ui.treeWidgetGC,
105 SIGNAL(itemChanged(QTreeWidgetItem*,
int)),
118 std::lock_guard g{_mutex};
125 _ui.treeWidgetGC->clear();
126 for (
auto& [prname, pr] : _providers)
128 pr.candidates.clear();
131 _tree_item_to_gc.clear();
138 const auto& pname = gc->providerName;
139 auto& pr = _providers[pname];
140 pr.provider_name = pname;
143 pr.item =
new QTreeWidgetItem;
144 pr.item->setCheckState(0, Qt::Unchecked);
145 _ui.treeWidgetGC->addTopLevelItem(pr.item);
146 pr.item->setText(0, QString::fromStdString(pname));
149 auto& gcdata = pr.candidates.emplace_back();
151 gcdata.idx = pr.candidates.size() - 1;
152 gcdata.provider = ≺
153 gcdata.item =
new QTreeWidgetItem;
154 gcdata.item->setCheckState(0, Qt::Unchecked);
155 pr.item->addChild(gcdata.item);
156 gcdata.item->setText(0, QString::fromStdString(gcdata.name()));
157 _tree_item_to_gc[gcdata.item] = &gcdata;
166 std::lock_guard g{_mutex};
170 std::vector<viz::Layer> layers;
171 for (
const auto& [pname, pr] : _providers)
174 auto& l = layers.back();
175 for (
const auto& gc : pr.candidates)
177 if (gc.item->checkState(0) == Qt::Unchecked)
179 gc_drawer.draw(gc.gc, l);
190 std::lock_guard g{_mutex};
191 const auto& selected = _ui.treeWidgetGC->selectedItems();
193 if (selected.empty())
198 else if (_tree_item_to_gc.count(selected.value(0)))
200 show_entry(_tree_item_to_gc.at(selected.value(0)));
206 GraspCandidateViewerWidgetController::show_entry(entry_gc* e)
210 _ui.labelGCIdx->setText(
"-");
211 _ui.labelNumGC->setText(
"-");
213 _ui.labelGPoseTX->setText(
"-");
214 _ui.labelGPoseTY->setText(
"-");
215 _ui.labelGPoseTZ->setText(
"-");
216 _ui.labelGPoseRX->setText(
"-");
217 _ui.labelGPoseRY->setText(
"-");
218 _ui.labelGPoseRZ->setText(
"-");
220 _ui.labelRPoseTX->setText(
"-");
221 _ui.labelRPoseTY->setText(
"-");
222 _ui.labelRPoseTZ->setText(
"-");
223 _ui.labelRPoseRX->setText(
"-");
224 _ui.labelRPoseRY->setText(
"-");
225 _ui.labelRPoseRZ->setText(
"-");
227 _ui.labelGApprTX->setText(
"-");
228 _ui.labelGApprTY->setText(
"-");
229 _ui.labelGApprTZ->setText(
"-");
231 _ui.labelSrcFrame->setText(
"-");
232 _ui.labelTrgFrame->setText(
"-");
233 _ui.labelSide->setText(
"-");
234 _ui.labelGraspProb->setText(
"-");
235 _ui.labelGraspgroupNr->setText(
"-");
236 _ui.labelGraspObjType->setText(
"-");
237 _ui.labelGraspProviderName->setText(
"-");
246 _ui.labelGCIdx->setText(QString::number(e->idx + 1));
247 _ui.labelNumGC->setText(QString::number(e->provider->candidates.size()));
249 _ui.labelGPoseTX->setText(QString::number(e->gc->graspPose->position->x));
250 _ui.labelGPoseTY->setText(QString::number(e->gc->graspPose->position->y));
251 _ui.labelGPoseTZ->setText(QString::number(e->gc->graspPose->position->z));
252 const Eigen::Vector3f vec_g = simox::math::quat_to_rpy({e->gc->graspPose->orientation->qw,
253 e->gc->graspPose->orientation->qx,
254 e->gc->graspPose->orientation->qy,
255 e->gc->graspPose->orientation->qz
258 _ui.labelGPoseRX->setText(QString::number(vec_g(0)));
259 _ui.labelGPoseRY->setText(QString::number(vec_g(1)));
260 _ui.labelGPoseRZ->setText(QString::number(vec_g(2)));
262 _ui.labelRPoseTX->setText(QString::number(e->gc->robotPose->position->x));
263 _ui.labelRPoseTY->setText(QString::number(e->gc->robotPose->position->y));
264 _ui.labelRPoseTZ->setText(QString::number(e->gc->robotPose->position->z));
265 const Eigen::Vector3f vec_r = simox::math::quat_to_rpy({e->gc->robotPose->orientation->qw,
266 e->gc->robotPose->orientation->qx,
267 e->gc->robotPose->orientation->qy,
268 e->gc->robotPose->orientation->qz
271 _ui.labelRPoseRX->setText(QString::number(vec_r(0)));
272 _ui.labelRPoseRY->setText(QString::number(vec_r(1)));
273 _ui.labelRPoseRZ->setText(QString::number(vec_r(2)));
275 _ui.labelGApprTX->setText(QString::number(e->gc->approachVector->x));
276 _ui.labelGApprTY->setText(QString::number(e->gc->approachVector->y));
277 _ui.labelGApprTZ->setText(QString::number(e->gc->approachVector->z));
279 _ui.labelSrcFrame->setText(QString::fromStdString(e->gc->sourceFrame));
280 _ui.labelTrgFrame->setText(QString::fromStdString(e->gc->targetFrame));
281 _ui.labelSide->setText(QString::fromStdString(e->gc->side));
282 _ui.labelGraspProb->setText(QString::number(e->gc->graspSuccessProbability));
283 _ui.labelGraspgroupNr->setText(QString::number(e->gc->groupNr));
284 switch (e->gc->objectType)
286 case objpose::ObjectType::AnyObject:
287 _ui.labelGraspObjType->setText(
"AnyObject");
289 case objpose::ObjectType::KnownObject:
290 _ui.labelGraspObjType->setText(
"KnownObject");
292 case objpose::ObjectType::UnknownObject:
293 _ui.labelGraspObjType->setText(
"UnknownObject");
296 _ui.labelGraspProviderName->setText(QString::fromStdString(e->gc->providerName));