25 #include <SimoxUtility/math/convert/quat_to_rpy.h>
36 std::lock_guard g{_mutex};
44 std::lock_guard g{_mutex};
52 std::lock_guard g{_mutex};
57 _dialog->addProxyFinder<grasping::GraspCandidateObserverInterfacePrx>(
"gco",
"Grasp Candidate Observer",
"*Observer");
59 return qobject_cast<SimpleConfigDialog*>(_dialog);
64 std::lock_guard g{_mutex};
75 std::lock_guard g{_mutex};
78 connect(_ui.pushButtonUpdateGC, &QPushButton::clicked,
80 connect(_ui.treeWidgetGC, &QTreeWidget::itemSelectionChanged,
83 connect(_ui.treeWidgetGC, SIGNAL(itemChanged(QTreeWidgetItem*,
int)),
93 std::lock_guard g{_mutex};
100 _ui.treeWidgetGC->clear();
101 for (
auto& [prname, pr] : _providers)
103 pr.candidates.clear();
106 _tree_item_to_gc.clear();
113 const auto& pname = gc->providerName;
114 auto& pr = _providers[pname];
115 pr.provider_name = pname;
118 pr.item =
new QTreeWidgetItem;
119 pr.item->setCheckState(0, Qt::Unchecked);
120 _ui.treeWidgetGC-> addTopLevelItem(pr.item);
121 pr.item->setText(0, QString::fromStdString(pname));
124 auto& gcdata = pr.candidates.emplace_back();
126 gcdata.idx = pr.candidates.size() - 1;
127 gcdata.provider = ≺
128 gcdata.item =
new QTreeWidgetItem;
129 gcdata.item->setCheckState(0, Qt::Unchecked);
130 pr.item->addChild(gcdata.item);
131 gcdata.item->setText(0, QString::fromStdString(gcdata.name()));
132 _tree_item_to_gc[gcdata.item] = &gcdata;
140 std::lock_guard g{_mutex};
144 std::vector<viz::Layer> layers;
145 for (
const auto& [pname, pr] : _providers)
148 auto& l = layers.back();
149 for (
const auto& gc : pr.candidates)
151 if (gc.item->checkState(0) == Qt::Unchecked)
153 gc_drawer.draw(gc.gc, l);
162 std::lock_guard g{_mutex};
163 const auto& selected = _ui.treeWidgetGC->selectedItems();
165 if (selected.empty())
170 else if (_tree_item_to_gc.count(selected.value(0)))
172 show_entry(_tree_item_to_gc.at(selected.value(0)));
177 void GraspCandidateViewerWidgetController::show_entry(entry_gc* e)
181 _ui.labelGCIdx ->setText(
"-");
182 _ui.labelNumGC ->setText(
"-");
184 _ui.labelGPoseTX ->setText(
"-");
185 _ui.labelGPoseTY ->setText(
"-");
186 _ui.labelGPoseTZ ->setText(
"-");
187 _ui.labelGPoseRX ->setText(
"-");
188 _ui.labelGPoseRY ->setText(
"-");
189 _ui.labelGPoseRZ ->setText(
"-");
191 _ui.labelRPoseTX ->setText(
"-");
192 _ui.labelRPoseTY ->setText(
"-");
193 _ui.labelRPoseTZ ->setText(
"-");
194 _ui.labelRPoseRX ->setText(
"-");
195 _ui.labelRPoseRY ->setText(
"-");
196 _ui.labelRPoseRZ ->setText(
"-");
198 _ui.labelGApprTX ->setText(
"-");
199 _ui.labelGApprTY ->setText(
"-");
200 _ui.labelGApprTZ ->setText(
"-");
202 _ui.labelSrcFrame ->setText(
"-");
203 _ui.labelTrgFrame ->setText(
"-");
204 _ui.labelSide ->setText(
"-");
205 _ui.labelGraspProb ->setText(
"-");
206 _ui.labelGraspgroupNr ->setText(
"-");
207 _ui.labelGraspObjType ->setText(
"-");
208 _ui.labelGraspProviderName->setText(
"-");
217 _ui.labelGCIdx ->setText(QString::number(e->idx + 1));
218 _ui.labelNumGC ->setText(QString::number(e->provider->candidates.size()));
220 _ui.labelGPoseTX ->setText(QString::number(e->gc->graspPose->position->x));
221 _ui.labelGPoseTY ->setText(QString::number(e->gc->graspPose->position->y));
222 _ui.labelGPoseTZ ->setText(QString::number(e->gc->graspPose->position->z));
223 const Eigen::Vector3f vec_g = simox::math::quat_to_rpy(
225 e->gc->graspPose->orientation->qw,
226 e->gc->graspPose->orientation->qx,
227 e->gc->graspPose->orientation->qy,
228 e->gc->graspPose->orientation->qz
232 _ui.labelGPoseRX ->setText(QString::number(vec_g(0)));
233 _ui.labelGPoseRY ->setText(QString::number(vec_g(1)));
234 _ui.labelGPoseRZ ->setText(QString::number(vec_g(2)));
236 _ui.labelRPoseTX ->setText(QString::number(e->gc->robotPose->position->x));
237 _ui.labelRPoseTY ->setText(QString::number(e->gc->robotPose->position->y));
238 _ui.labelRPoseTZ ->setText(QString::number(e->gc->robotPose->position->z));
239 const Eigen::Vector3f vec_r = simox::math::quat_to_rpy(
241 e->gc->robotPose->orientation->qw,
242 e->gc->robotPose->orientation->qx,
243 e->gc->robotPose->orientation->qy,
244 e->gc->robotPose->orientation->qz
248 _ui.labelRPoseRX ->setText(QString::number(vec_r(0)));
249 _ui.labelRPoseRY ->setText(QString::number(vec_r(1)));
250 _ui.labelRPoseRZ ->setText(QString::number(vec_r(2)));
252 _ui.labelGApprTX ->setText(QString::number(e->gc->approachVector->x));
253 _ui.labelGApprTY ->setText(QString::number(e->gc->approachVector->y));
254 _ui.labelGApprTZ ->setText(QString::number(e->gc->approachVector->z));
256 _ui.labelSrcFrame ->setText(QString::fromStdString(e->gc->sourceFrame));
257 _ui.labelTrgFrame ->setText(QString::fromStdString(e->gc->targetFrame));
258 _ui.labelSide ->setText(QString::fromStdString(e->gc->side));
259 _ui.labelGraspProb ->setText(QString::number(e->gc->graspSuccessProbability));
260 _ui.labelGraspgroupNr ->setText(QString::number(e->gc->groupNr));
261 switch (e->gc->objectType)
263 case objpose::ObjectType::AnyObject :
264 _ui.labelGraspObjType->setText(
"AnyObject");
266 case objpose::ObjectType::KnownObject :
267 _ui.labelGraspObjType->setText(
"KnownObject");
269 case objpose::ObjectType::UnknownObject :
270 _ui.labelGraspObjType->setText(
"UnknownObject");
273 _ui.labelGraspProviderName->setText(QString::fromStdString(e->gc->providerName));