48 defs->topic(debugObserver);
50 defs->optional(enableRemoteGui,
"remoteGui.enable",
"Enable/Disable Remote GUI");
51 defs->optional(
gui.trackNewEntities,
52 "EnableTrackingOfNewEntities",
53 "Enable/Disable the automatic visual tracking of newly commited Entities");
55 defs->optional(enableVisualizeKnownGraspCandidates,
56 "p.enableVisualizeKnownGraspCandidates");
57 defs->optional(enableVisualizeKnownGraspCandidatesPreposes,
58 "p.enableVisualizeKnownGraspCandidatesPreposes");
59 defs->optional(enableVisualizeKnownGraspCandidatesApproach,
60 "p.enableVisualizeKnownGraspCandidatesApproach");
62 defs->optional(frequencyHzVisualizeKnownGraspCandidates,
63 "p.frequencyHzVisualizeKnownGraspCandidates");
67 defs->optional(properties_.coreSeg.graspCandidate.maxHistorySize,
68 "GraspCandidate.CoreMaxHistorySize",
69 "Max history size of the " +
QUOTED(
"GraspCandidate") +
72 defs->optional(properties_.coreSeg.bimanualGraspCandidate.maxHistorySize,
73 "BimanualGraspCandidate.CoreMaxHistorySize",
74 "Max history size of the " +
QUOTED(
"BimanualGraspCandidate") +
77 defs->optional(properties_.coreSeg.knownGraspCandidate.maxHistorySize,
78 "KnownGraspCandidate.CoreMaxHistorySize",
79 "Max history size of the " +
QUOTED(
"KnownGraspCandidate") +
102 armarx::grasping::arondto::GraspCandidate::ToAronType())
106 armarx::grasping::arondto::BimanualGraspCandidate::ToAronType())
110 armarx::armem::grasping::arondto::KnownGraspInfo::ToAronType())
113 knownGraspProviderSegment.init();
131 taskVisuKnownGrasps =
133 taskVisuKnownGrasps->start();
139 if (taskVisuKnownGrasps)
141 taskVisuKnownGrasps->stop();
142 taskVisuKnownGrasps =
nullptr;
147 for (
auto& [_, layer] : graspVisuPerObject)
150 layer.markForDeletion();
153 arviz.commit(simox::alg::get_values(graspVisuPerObject));
154 graspVisuPerObject.clear();
165 armem::data::CommitResult
168 std::vector<armem::MemoryID> trackedEntityIds;
170 std::unique_lock lock(
gui.visualizationMutex);
171 trackedEntityIds =
gui.trackedEntityIds;
174 if (!trackedEntityIds.empty())
176 for (
auto& update :
commit.updates)
180 if (std::find(trackedEntityIds.begin(), trackedEntityIds.end(), entityID) !=
181 trackedEntityIds.end())
184 [
this](
const auto& instance) { removeInstanceFromVisu(instance.id()); });
189 if (
gui.trackNewEntities)
191 for (
auto& update :
commit.updates)
197 std::unique_lock lock(
gui.visualizationMutex);
198 gui.trackedEntityIds.emplace_back(entityID);
199 trackedEntityIds.emplace_back(entityID);
206 gui.tab.rebuild =
true;
209 if (!trackedEntityIds.empty())
211 for (
auto& update :
commit.updates)
215 if (std::find(trackedEntityIds.begin(), trackedEntityIds.end(), entityID) !=
216 trackedEntityIds.end())
219 [
this](
const auto& instance) { addInstanceToVisu(instance.id()); });
230 armem::actions::data::GetActionsOutputSeq
235 GetActionsOutputSeq outputs;
236 for (
const auto& input : inputs)
247 std::vector<MenuEntry>
actions;
253 if (std::find(
gui.trackedEntityIds.begin(),
254 gui.trackedEntityIds.end(),
255 memoryID) ==
gui.trackedEntityIds.end())
257 actions.push_back(Action{
"track",
"Track this entity in arviz"});
262 Action{
"untrack",
"Stop tracking this entity in arviz"});
268 Action{
"track",
"Track all underlying entities in arviz"});
270 Action{
"untrack",
"Stop tracking all underlying entities in arviz"});
274 actions.push_back(Action{
"vis",
"Visualize all contained grasp candidates"});
276 Action{
"rem",
"Remove all contained grasp candidates from visualization"});
277 actions.push_back(SubMenu{
"high",
278 "Highlight all contain grasp candidates",
279 {Action{
"pink",
"in pink"},
280 Action{
"red",
"in red"},
281 Action{
"blue",
"in blue"},
282 Action{
"yellow",
"in yellow"},
283 Action{
"purple",
"in purple"}}});
284 actions.push_back(Action{
"reset",
"Reset highlight layer"});
287 outputs.push_back({menu.toIce()});
294 armem::actions::data::ExecuteActionOutputSeq
298 ExecuteActionOutputSeq outputs;
300 for (
const auto& input : inputs)
303 if (input.actionPath == ActionPath{
"vis"} || input.actionPath == ActionPath{
"rem"})
313 std::stringstream sstream;
314 sstream <<
"Currently visualization for CoreSegment "
316 outputs.emplace_back(
false, sstream.str());
322 if (input.actionPath == ActionPath{
"vis"})
324 addInstanceToVisu(memoryID);
326 else if (input.actionPath == ActionPath{
"rem"})
328 removeInstanceFromVisu(memoryID);
334 [
this, &input](
const auto& instance)
336 if (input.actionPath == ActionPath{
"vis"})
338 addInstanceToVisu(instance.id());
340 else if (input.actionPath == ActionPath{
"rem"})
342 removeInstanceFromVisu(instance.id());
349 [
this, &input](
const auto& instance)
351 if (input.actionPath == ActionPath{
"vis"})
353 addInstanceToVisu(instance.id());
355 else if (input.actionPath == ActionPath{
"rem"})
357 removeInstanceFromVisu(instance.id());
364 [
this, &input](
const auto& instance)
366 if (input.actionPath == ActionPath{
"vis"})
368 addInstanceToVisu(instance.id());
370 else if (input.actionPath == ActionPath{
"rem"})
372 removeInstanceFromVisu(instance.id());
378 if (input.actionPath == ActionPath{
"rem"})
380 std::unique_lock lock(
gui.visualizationMutex);
381 gui.visibleInstanceIds.clear();
383 for (std::string& layer :
gui.activeLayers)
385 arviz.commitDeleteLayer(layer +
"_reachable");
386 arviz.commitDeleteLayer(layer +
"_unreachable");
388 gui.activeLayers.clear();
390 else if (input.actionPath == ActionPath{
"vis"})
395 .forEachInstance([
this](
const auto& instance)
396 { addInstanceToVisu(instance.id()); });
400 visualizeGraspCandidates();
401 outputs.emplace_back(
true,
"");
407 std::stringstream sstream;
408 sstream <<
"MemoryID " << memoryID
409 <<
" does not refer to a valid Grasp Memory Part.";
410 outputs.emplace_back(
false, sstream.str());
413 else if (input.actionPath == ActionPath{
"track"} ||
414 input.actionPath == ActionPath{
"untrack"})
416 std::vector<armem::MemoryID> entityIDs;
419 entityIDs.emplace_back(memoryID);
424 [&entityIDs](
const auto& entity) { entityIDs.emplace_back(entity.id()); });
431 .forEachEntity([&entityIDs](
const auto& entity)
432 { entityIDs.emplace_back(entity.id()); });
434 for (
auto& entityID : entityIDs)
436 if (input.actionPath == ActionPath{
"track"})
440 [
this](
const auto& instance) { addInstanceToVisu(instance.id()); });
441 gui.trackedEntityIds.push_back(entityID);
443 outputs.emplace_back(
true,
"");
445 else if (input.actionPath == ActionPath{
"untrack"})
447 auto pos = std::find(
448 gui.trackedEntityIds.begin(),
gui.trackedEntityIds.end(), entityID);
449 if (pos !=
gui.trackedEntityIds.end())
451 gui.trackedEntityIds.erase(pos);
454 outputs.emplace_back(
true,
"");
458 else if (input.actionPath.front() ==
"high")
460 addToHighlightLayer(memoryID, input.actionPath.back());
462 else if (input.actionPath == ActionPath{
"reset"})
464 arviz.commit(
arviz.layer(
"HighlightedGrasps"));
468 std::stringstream sstream;
469 sstream <<
"Action path " << input.actionPath <<
" is not defined.";
470 outputs.emplace_back(
false, sstream.str());
484 gui.tab.selectAll.setLabel(
"Select All");
485 gui.tab.deselectAll.setLabel(
"Deselect All");
486 gui.tab.showUnlimitedInstances.setValue(
gui.unlimitedInstances);
487 gui.tab.maxInstances.setRange(0, 1000);
488 gui.tab.maxInstances.setValue(
gui.maxInstances);
514 std::vector<std::string> options =
518 options.push_back(
"<None>");
522 options.insert(options.begin(),
"<All>");
525 gui.tab.selectProvider.setOptions(options);
527 if (
gui.providerIndex >= 0 &&
528 gui.providerIndex <
static_cast<int>(options.size()))
530 gui.tab.selectProvider.setIndex(
gui.providerIndex);
531 gui.provider = options[
gui.providerIndex];
533 root.
add(
gui.tab.selectProvider,
Pos{row, 0});
538 .getCoreSegment(
gui.coreSegment)
539 .hasProviderSegment(
gui.provider))
541 std::vector<MemoryID> providers;
545 std::vector<std::string> options;
547 if (
gui.provider ==
"<All>")
551 .forEachProviderSegment([&providers](
const auto& provider)
552 { providers.push_back(provider.id()); });
559 for (
MemoryID& provider : providers)
561 for (std::string& entity :
562 workingMemory().getProviderSegment(provider).getEntityNames())
564 options.push_back(entity);
569 options.push_back(
"<None>");
573 options.insert(options.begin(),
"<All>");
575 gui.tab.selectEntity.setOptions(options);
576 if (
gui.entityIndex >= 0 &&
577 gui.entityIndex <
static_cast<int>(options.size()))
579 gui.tab.selectEntity.setIndex(
gui.entityIndex);
580 gui.entity = options[
gui.entityIndex];
582 root.
add(
gui.tab.selectEntity,
Pos{row, 0});
586 if (
gui.entity ==
"<All>" ||
587 (
gui.provider ==
"<All>" &&
590 .getCoreSegment(
gui.coreSegment)
591 .getProviderSegment(
gui.provider)
592 .hasEntity(
gui.entity))
594 std::vector<MemoryID> entities;
598 std::vector<std::string> options;
599 for (
MemoryID& provider : providers)
601 if (
gui.entity ==
"<All>")
604 [&entities](
auto& entity)
605 { entities.push_back(entity.id()); });
614 provider.providerSegmentName,
623 [
this, &options](
const auto& snapshot)
627 gui.timeMap[time] = snapshot.time();
628 options.push_back(time);
634 options.push_back(
"<None>");
638 options.insert(options.begin(),
"<All>");
640 gui.tab.selectSnapshot.setOptions(options);
641 if (
gui.snapshotIndex >= 0 &&
642 gui.snapshotIndex <
static_cast<int>(options.size()))
644 gui.tab.selectSnapshot.setIndex(
gui.snapshotIndex);
645 if (options[
gui.snapshotIndex] !=
"<None>")
647 gui.snapshot = options[
gui.snapshotIndex];
650 root.
add(
gui.tab.selectSnapshot,
Pos{row, 0});
654 if (
gui.snapshot ==
"<All>")
663 gui.timeMap.at(
gui.snapshot)))
673 root.
add(
Label(
"Show all Instances"),
Pos{row, 0});
674 root.
add(
gui.tab.showUnlimitedInstances,
Pos{row, 1});
676 root.
add(
Label(
"Limit for shown Instances"),
Pos{row, 0});
677 root.
add(
gui.tab.maxInstances,
Pos{row, 1});
679 root.
add(
gui.tab.selectAll,
Pos{row, 0});
681 root.
add(
gui.tab.deselectAll,
Pos{row, 0});
683 gui.tab.checkInstances.clear();
684 std::vector<MemoryID> snapshots;
687 if (
gui.snapshot ==
"<All>")
690 [&snapshots](
auto& snapshot)
691 { snapshots.push_back(snapshot.id()); });
696 gui.timeMap.at(
gui.snapshot)))
701 .getSnapshot(
gui.timeMap.at(
gui.snapshot))
707 for (
MemoryID& snapshot : snapshots)
710 [
this, &row, &root, &instances](
const auto& instance)
712 if (
gui.unlimitedInstances || instances <
gui.maxInstances)
714 std::unique_lock lock(
gui.visualizationMutex);
716 gui.tab.checkInstances[instance.id().str()] =
718 if (std::find(
gui.visibleInstanceIds.begin(),
719 gui.visibleInstanceIds.end(),
721 gui.visibleInstanceIds.end())
723 gui.tab.checkInstances.at(instance.id().str())
726 root.
add(
gui.tab.checkInstances[instance.id().str()],
738 root.
add(
Label(
"Show all Instances"),
Pos{row, 0});
739 root.
add(
gui.tab.showUnlimitedInstances,
Pos{row, 1});
741 root.
add(
Label(
"Limit for shown Instances"),
Pos{row, 0});
742 root.
add(
gui.tab.maxInstances,
Pos{row, 1});
744 root.
add(
gui.tab.selectAll,
Pos{row, 0});
746 root.
add(
gui.tab.deselectAll,
Pos{row, 0});
748 gui.tab.checkInstances.clear();
753 gui.tab.checkInstances.clear();
755 std::vector<std::string> options = {
"<None>"};
757 gui.tab.selectSnapshot.setOptions(options);
761 root.
add(
gui.tab.selectSnapshot,
Pos{row, 0});
763 root.
add(
Label(
"Show all Instances"),
Pos{row, 0});
764 root.
add(
gui.tab.showUnlimitedInstances,
Pos{row, 1});
766 root.
add(
Label(
"Limit for shown Instances"),
Pos{row, 0});
767 root.
add(
gui.tab.maxInstances,
Pos{row, 1});
769 root.
add(
gui.tab.selectAll,
Pos{row, 0});
771 root.
add(
gui.tab.deselectAll,
Pos{row, 0});
777 gui.tab.checkInstances.clear();
779 std::vector<std::string> options = {
"<None>"};
781 gui.tab.selectEntity.setOptions(options);
785 root.
add(
gui.tab.selectEntity,
Pos{row, 0});
788 gui.tab.selectSnapshot.setOptions(options);
792 root.
add(
gui.tab.selectSnapshot,
Pos{row, 0});
794 root.
add(
Label(
"Show all Instances"),
Pos{row, 0});
795 root.
add(
gui.tab.showUnlimitedInstances,
Pos{row, 1});
797 root.
add(
Label(
"Limit for shown Instances"),
Pos{row, 0});
798 root.
add(
gui.tab.maxInstances,
Pos{row, 1});
800 root.
add(
gui.tab.selectAll,
Pos{row, 0});
802 root.
add(
gui.tab.deselectAll,
Pos{row, 0});
808 gui.tab.checkInstances.clear();
810 std::vector<std::string> options = {
"<None>"};
811 gui.tab.selectProvider.setOptions(options);
815 root.
add(
gui.tab.selectProvider,
Pos{row, 0});
818 gui.tab.selectEntity.setOptions(options);
822 root.
add(
gui.tab.selectEntity,
Pos{row, 0});
825 gui.tab.selectSnapshot.setOptions(options);
829 root.
add(
gui.tab.selectSnapshot,
Pos{row, 0});
831 root.
add(
Label(
"Show all Instances"),
Pos{row, 0});
832 root.
add(
gui.tab.showUnlimitedInstances,
Pos{row, 1});
834 root.
add(
Label(
"Limit for shown Instances"),
Pos{row, 0});
835 root.
add(
gui.tab.maxInstances,
Pos{row, 1});
837 root.
add(
gui.tab.selectAll,
Pos{row, 0});
839 root.
add(
gui.tab.deselectAll,
Pos{row, 0});
846 gui.tab.rebuild =
false;
850 [](
const armarx::armem::grasping::arondto::KnownGraspSet& graspSet) -> std::string
852 ARMARX_VERBOSE <<
"Grasping with " << graspSet.robot <<
" and with the endeffector named"
853 << graspSet.endeffector;
855 if (graspSet.robot ==
"Armar6" or graspSet.robot ==
"ArmarDE" or graspSet.robot ==
"Armar7")
857 if (graspSet.endeffector ==
"TCP_R")
861 if (graspSet.endeffector ==
"TCP_L")
865 if (graspSet.endeffector ==
"Hand_R_EEF")
869 if (graspSet.endeffector ==
"Hand_L_EEF")
873 ARMARX_ERROR <<
"Unknown TCP `" << graspSet.endeffector <<
"` for robot `"
874 << graspSet.robot <<
"`!";
877 if (graspSet.robot ==
"Armar3")
879 if (graspSet.endeffector ==
"Hand R")
883 if (graspSet.endeffector ==
"Hand L")
887 ARMARX_ERROR <<
"Unknown TCP `" << graspSet.endeffector <<
"` for robot `"
888 << graspSet.robot <<
"`!";
891 ARMARX_ERROR <<
"Unknown TCP `" << graspSet.endeffector <<
"` for robot `" << graspSet.robot
893 throw std::exception();
897 armarx::armem::server::grasp::GraspMemory::visualizeKnownGraspCandidates()
899 if (not enableVisualizeKnownGraspCandidates)
906 while (not taskVisuKnownGrasps->isStopped())
910 const std::vector<robot_state::description::RobotDescription> robotDescriptions =
914 std::map<std::string, robot_state::description::RobotDescription>
916 for (
const auto& robotDescription : robotDescriptions)
918 robotDescriptionMap.emplace(robotDescription.name, robotDescription);
922 for (
const auto& robotDescription : robotDescriptions)
924 if (robots.count(robotDescription.name) > 0)
931 if (
auto robot = VirtualRobot::RobotIO::loadRobot(
932 robotDescription.xml.toSystemPath(), VirtualRobot::BaseIO::eStructure))
934 ARMARX_INFO <<
"Loaded robot `" << robotDescription.name <<
"`";
935 robots.emplace(robotDescription.name, robot);
939 ARMARX_INFO <<
"Failed to load robot `" << robotDescription.name
940 <<
"` from file `" << robotDescription.xml.toSystemPath()
946 std::map<std::string, std::vector<armarx::armem::grasping::arondto::KnownGraspInfo>>
951 .getCoreSegment(
"KnownGraspCandidate")
953 [&graspsForObject](
const auto& entityInstance)
955 const armarx::armem::grasping::arondto::KnownGraspInfo dto =
956 armarx::armem::grasping::arondto::KnownGraspInfo::FromAron(
957 entityInstance.data());
959 const MemoryID memoryId = entityInstance.id();
962 graspsForObject[memoryId.entityName].push_back(dto);
967 for (
auto& [_, layer] : graspVisuPerObject)
974 const auto objects = getObjectPoses();
976 for (
const auto&
object : objects)
978 const std::string layerName =
object.objectID.str();
979 auto layer = arviz.layer(layerName);
982 const std::string objectClassName =
object.objectID.getClassID().str();
984 if (graspsForObject.count(objectClassName) == 0)
989 const auto& graspInfos = graspsForObject.at(objectClassName);
991 for (
const auto& graspInfo : graspInfos)
993 for (
const auto& [_, graspSet] : graspInfo.graspSets)
996 if (robotDescriptionMap.count(graspSet.robot) == 0)
1001 const std::string side =
GetSide(graspSet);
1002 const std::string bodyPartName = side +
"Hand";
1004 const auto& robotDescription = robotDescriptionMap.at(graspSet.robot);
1005 const auto& visuPart =
1006 robotDescription.visualization.body_parts.at(bodyPartName);
1008 const armarx::PackagePath visuRobotPartXML{visuPart.xml.package,
1011 for (
const auto& grasp : graspSet.grasps)
1013 const std::string visuName = graspSet.robot +
"::" + graspSet.name +
1014 "::" +
object.providerName +
1015 "::" +
object.objectID.str() +
1019 if (robots.count(graspSet.robot) == 0)
1024 const auto robot = robots.at(graspSet.robot);
1026 const auto handRootNode =
1027 robot->getRobotNode(visuPart.root_node_name);
1028 if (handRootNode ==
nullptr)
1030 ARMARX_INFO <<
"Node `" << visuPart.root_node_name
1031 <<
"` not available for robot `" << graspSet.robot
1036 const auto eefNode = robot->getEndEffector(graspSet.endeffector);
1037 if (eefNode ==
nullptr)
1039 ARMARX_INFO <<
"End-effector `" << graspSet.endeffector
1040 <<
"` not available for robot `" << graspSet.robot
1045 const auto tcp = eefNode->getTcp();
1048 ARMARX_INFO <<
"End-effector `" << graspSet.endeffector
1049 <<
"` does not provide a TCP";
1053 const Eigen::Isometry3f eef_T_hand_root{
1054 handRootNode->getPoseInFrame(tcp)};
1056 const Eigen::Isometry3f global_T_grasp_pose =
1057 Eigen::Isometry3f{
object.objectPoseGlobal} *
1058 Eigen::Isometry3f{grasp.pose}.inverse();
1062 viz::Robot graspHandVisu(visuName +
"_grasp");
1063 graspHandVisu.useCollisionModel()
1064 .file(visuRobotPartXML)
1066 Eigen::Isometry3f{global_T_grasp_pose * eef_T_hand_root}
1069 layer.add(graspHandVisu);
1073 if (grasp.prepose.has_value())
1075 const Eigen::Isometry3f global_T_prepose =
1076 Eigen::Isometry3f{
object.objectPoseGlobal} *
1077 Eigen::Isometry3f{grasp.prepose.value()}.inverse();
1080 if (enableVisualizeKnownGraspCandidatesPreposes)
1082 viz::Robot graspHandVisuPrepose(visuName +
"_prepose");
1083 graspHandVisuPrepose.useCollisionModel()
1084 .file(visuRobotPartXML)
1085 .pose(Eigen::Isometry3f{global_T_prepose *
1088 .overrideColor(viz::Color::blue());
1090 layer.add(graspHandVisuPrepose);
1094 if (enableVisualizeKnownGraspCandidatesApproach)
1096 viz::Arrow arrow(visuName +
"_approach");
1098 .fromTo(global_T_prepose.translation(),
1099 global_T_grasp_pose.translation())
1100 .color(viz::Color::green());
1109 graspVisuPerObject[layerName] = layer;
1112 arviz.commit(simox::alg::get_values(graspVisuPerObject));
1115 metronome.waitForNextTick();
1120 armarx::armem::server::grasp::GraspMemory::visualizeGraspCandidates()
1122 std::unique_lock lock(gui.visualizationMutex);
1123 armarx::grasping::GraspCandidateVisu visu;
1124 std::map<std::string, viz::Layer> reachableLayers;
1125 std::map<std::string, viz::Layer> unreachableLayers;
1129 for (
auto& element : gui.visibleInstanceIds)
1131 std::string entityName = element.entityName;
1133 if (reachableLayers.find(entityName) == reachableLayers.end())
1135 reachableLayers[entityName] = arviz.layer(entityName +
"_reachable");
1136 unreachableLayers[entityName] = arviz.layer(entityName +
"_unreachable");
1137 gui.activeLayers.push_back(entityName);
1140 armarx::grasping::GraspCandidate candidate;
1142 armarx::grasping::arondto::GraspCandidate aronTransform;
1144 aronTransform.fromAron(workingMemory().getInstance(element).
data());
1146 fromAron(aronTransform, candidate);
1150 reachableLayers.at(entityName),
1151 unreachableLayers.at(entityName));
1155 std::vector<viz::Layer> layers;
1156 for (
auto& [entityName, layer] : reachableLayers)
1158 layers.push_back(layer);
1159 layers.push_back(unreachableLayers.at(entityName));
1161 arviz.commit(layers);
1165 armarx::armem::server::grasp::GraspMemory::addInstanceToVisu(
1166 const armarx::armem::MemoryID& instance)
1168 std::unique_lock lock(gui.visualizationMutex);
1170 std::find(gui.visibleInstanceIds.begin(), gui.visibleInstanceIds.end(), instance);
1172 if (position == gui.visibleInstanceIds.end())
1174 gui.visibleInstanceIds.push_back(instance);
1179 armarx::armem::server::grasp::GraspMemory::removeInstanceFromVisu(
1180 const armarx::armem::MemoryID& instance)
1182 std::unique_lock lock(gui.visualizationMutex);
1184 std::find(gui.visibleInstanceIds.begin(), gui.visibleInstanceIds.end(), instance);
1186 if (position != gui.visibleInstanceIds.end())
1188 gui.visibleInstanceIds.erase(position);
1192 std::string entityName = instance.
entityName;
1194 if (std::none_of(gui.visibleInstanceIds.begin(),
1195 gui.visibleInstanceIds.end(),
1196 [&entityName](
const armem::MemoryID&
id)
1197 { return id.entityName == entityName; }))
1199 arviz.commitDeleteLayer(entityName +
"_reachable");
1200 arviz.commitDeleteLayer(entityName +
"_unreachable");
1203 auto layerPos = std::find(gui.activeLayers.begin(), gui.activeLayers.end(), entityName);
1205 if (layerPos != gui.activeLayers.end())
1207 gui.activeLayers.erase(layerPos);
1212 GraspMemory::addToHighlightLayer(
const MemoryID& memoryID,
const std::string color)
1214 viz::Color handColor;
1216 if (color ==
"pink")
1218 handColor = viz::Color::pink();
1220 else if (color ==
"red")
1222 handColor = viz::Color::red();
1224 else if (color ==
"blue")
1226 handColor = viz::Color::blue();
1228 else if (color ==
"yellow")
1230 handColor = viz::Color::yellow();
1232 else if (color ==
"purple")
1234 handColor = viz::Color::purple();
1237 viz::Layer highlightLayer =
arviz.layer((
"HighlightedGrasps"));
1238 armarx::grasping::GraspCandidateVisu visu;
1240 std::vector<armem::MemoryID> instances;
1244 instances.push_back(memoryID);
1249 [&instances](
const auto& instance) { instances.push_back(instance.id()); });
1254 [&instances](
const auto& instance) { instances.push_back(instance.id()); });
1259 [&instances](
const auto& instance) { instances.push_back(instance.id()); });
1266 .forEachInstance([&instances](
const auto& instance)
1267 { instances.push_back(instance.id()); });
1270 armarx::grasping::GraspCandidate candidate;
1272 armarx::grasping::arondto::GraspCandidate aronTransform;
1274 for (armem::MemoryID& instance : instances)
1278 fromAron(aronTransform, candidate);
1282 hand.color(handColor);
1283 highlightLayer.
add(hand);
1286 arviz.commit(highlightLayer);
1302 if (
gui.tab.selectProvider.hasValueChanged())
1304 gui.provider =
gui.tab.selectProvider.getValue();
1305 gui.providerIndex =
gui.tab.selectProvider.getIndex();
1306 gui.entityIndex = 0;
1307 gui.snapshotIndex = 0;
1308 gui.tab.rebuild =
true;
1311 if (
gui.tab.selectEntity.hasValueChanged())
1313 gui.entity =
gui.tab.selectEntity.getValue();
1314 gui.entityIndex =
gui.tab.selectEntity.getIndex();
1315 gui.snapshotIndex = 0;
1316 gui.tab.rebuild =
true;
1319 if (
gui.tab.selectSnapshot.hasValueChanged())
1321 gui.snapshot =
gui.tab.selectSnapshot.getValue();
1322 gui.snapshotIndex =
gui.tab.selectSnapshot.getIndex();
1323 gui.tab.rebuild =
true;
1326 if (
gui.tab.showUnlimitedInstances.hasValueChanged())
1328 gui.unlimitedInstances =
gui.tab.showUnlimitedInstances.getValue();
1329 gui.tab.rebuild =
true;
1332 if (
gui.tab.maxInstances.hasValueChanged())
1334 gui.maxInstances =
gui.tab.maxInstances.getValue();
1335 gui.tab.rebuild =
true;
1338 if (
gui.tab.selectAll.wasClicked())
1340 for (
auto& element :
gui.tab.checkInstances)
1342 element.second.setValue(
true);
1346 if (
gui.tab.deselectAll.wasClicked())
1348 for (
auto& element :
gui.tab.checkInstances)
1350 element.second.setValue(
false);
1354 for (
auto& element :
gui.tab.checkInstances)
1356 if (element.second.hasValueChanged())
1358 if (element.second.getValue())
1369 visualizeGraspCandidates();
1371 if (
gui.tab.rebuild)