44 defs->topic(debugObserver);
46 defs->optional(enableRemoteGui,
"remoteGui.enable",
"Enable/Disable Remote GUI");
47 defs->optional(
gui.trackNewEntities,
48 "EnableTrackingOfNewEntities",
49 "Enable/Disable the automatic visual tracking of newly commited Entities");
51 defs->optional(enableVisualizeKnownGraspCandidates,
52 "p.enableVisualizeKnownGraspCandidates");
53 defs->optional(enableVisualizeKnownGraspCandidatesPreposes,
54 "p.enableVisualizeKnownGraspCandidatesPreposes");
55 defs->optional(enableVisualizeKnownGraspCandidatesApproach,
56 "p.enableVisualizeKnownGraspCandidatesApproach");
58 defs->optional(frequencyHzVisualizeKnownGraspCandidates,
59 "p.frequencyHzVisualizeKnownGraspCandidates");
63 defs->optional(properties_.coreSeg.graspCandidate.maxHistorySize,
64 "GraspCandidate.CoreMaxHistorySize",
65 "Max history size of the " +
QUOTED(
"GraspCandidate") +
68 defs->optional(properties_.coreSeg.bimanualGraspCandidate.maxHistorySize,
69 "BimanualGraspCandidate.CoreMaxHistorySize",
70 "Max history size of the " +
QUOTED(
"BimanualGraspCandidate") +
73 defs->optional(properties_.coreSeg.knownGraspCandidate.maxHistorySize,
74 "KnownGraspCandidate.CoreMaxHistorySize",
75 "Max history size of the " +
QUOTED(
"KnownGraspCandidate") +
98 armarx::grasping::arondto::GraspCandidate::ToAronType())
102 armarx::grasping::arondto::BimanualGraspCandidate::ToAronType())
106 armarx::armem::grasping::arondto::KnownGraspInfo::ToAronType())
109 knownGraspProviderSegment.init();
127 taskVisuKnownGrasps =
129 taskVisuKnownGrasps->start();
135 if (taskVisuKnownGrasps)
137 taskVisuKnownGrasps->stop();
138 taskVisuKnownGrasps =
nullptr;
143 for (
auto& [_, layer] : graspVisuPerObject)
146 layer.markForDeletion();
149 arviz.commit(simox::alg::get_values(graspVisuPerObject));
150 graspVisuPerObject.clear();
161 armem::data::CommitResult
164 std::vector<armem::MemoryID> trackedEntityIds;
166 std::unique_lock lock(
gui.visualizationMutex);
167 trackedEntityIds =
gui.trackedEntityIds;
170 if (!trackedEntityIds.empty())
172 for (
auto& update :
commit.updates)
176 if (std::find(trackedEntityIds.begin(), trackedEntityIds.end(), entityID) !=
177 trackedEntityIds.end())
180 [
this](
const auto& instance) { removeInstanceFromVisu(instance.id()); });
185 if (
gui.trackNewEntities)
187 for (
auto& update :
commit.updates)
193 std::unique_lock lock(
gui.visualizationMutex);
194 gui.trackedEntityIds.emplace_back(entityID);
195 trackedEntityIds.emplace_back(entityID);
202 gui.tab.rebuild =
true;
205 if (!trackedEntityIds.empty())
207 for (
auto& update :
commit.updates)
211 if (std::find(trackedEntityIds.begin(), trackedEntityIds.end(), entityID) !=
212 trackedEntityIds.end())
215 [
this](
const auto& instance) { addInstanceToVisu(instance.id()); });
226 armem::actions::data::GetActionsOutputSeq
231 GetActionsOutputSeq outputs;
232 for (
const auto& input : inputs)
243 std::vector<MenuEntry>
actions;
249 if (std::find(
gui.trackedEntityIds.begin(),
250 gui.trackedEntityIds.end(),
251 memoryID) ==
gui.trackedEntityIds.end())
253 actions.push_back(Action{
"track",
"Track this entity in arviz"});
258 Action{
"untrack",
"Stop tracking this entity in arviz"});
264 Action{
"track",
"Track all underlying entities in arviz"});
266 Action{
"untrack",
"Stop tracking all underlying entities in arviz"});
270 actions.push_back(Action{
"vis",
"Visualize all contained grasp candidates"});
272 Action{
"rem",
"Remove all contained grasp candidates from visualization"});
273 actions.push_back(SubMenu{
"high",
274 "Highlight all contain grasp candidates",
275 {Action{
"pink",
"in pink"},
276 Action{
"red",
"in red"},
277 Action{
"blue",
"in blue"},
278 Action{
"yellow",
"in yellow"},
279 Action{
"purple",
"in purple"}}});
280 actions.push_back(Action{
"reset",
"Reset highlight layer"});
283 outputs.push_back({menu.toIce()});
290 armem::actions::data::ExecuteActionOutputSeq
294 ExecuteActionOutputSeq outputs;
296 for (
const auto& input : inputs)
299 if (input.actionPath == ActionPath{
"vis"} || input.actionPath == ActionPath{
"rem"})
309 std::stringstream sstream;
310 sstream <<
"Currently visualization for CoreSegment "
312 outputs.emplace_back(
false, sstream.str());
318 if (input.actionPath == ActionPath{
"vis"})
320 addInstanceToVisu(memoryID);
322 else if (input.actionPath == ActionPath{
"rem"})
324 removeInstanceFromVisu(memoryID);
330 [
this, &input](
const auto& instance)
332 if (input.actionPath == ActionPath{
"vis"})
334 addInstanceToVisu(instance.id());
336 else if (input.actionPath == ActionPath{
"rem"})
338 removeInstanceFromVisu(instance.id());
345 [
this, &input](
const auto& instance)
347 if (input.actionPath == ActionPath{
"vis"})
349 addInstanceToVisu(instance.id());
351 else if (input.actionPath == ActionPath{
"rem"})
353 removeInstanceFromVisu(instance.id());
360 [
this, &input](
const auto& instance)
362 if (input.actionPath == ActionPath{
"vis"})
364 addInstanceToVisu(instance.id());
366 else if (input.actionPath == ActionPath{
"rem"})
368 removeInstanceFromVisu(instance.id());
374 if (input.actionPath == ActionPath{
"rem"})
376 std::unique_lock lock(
gui.visualizationMutex);
377 gui.visibleInstanceIds.clear();
379 for (std::string& layer :
gui.activeLayers)
381 arviz.commitDeleteLayer(layer +
"_reachable");
382 arviz.commitDeleteLayer(layer +
"_unreachable");
384 gui.activeLayers.clear();
386 else if (input.actionPath == ActionPath{
"vis"})
391 .forEachInstance([
this](
const auto& instance)
392 { addInstanceToVisu(instance.id()); });
396 visualizeGraspCandidates();
397 outputs.emplace_back(
true,
"");
403 std::stringstream sstream;
404 sstream <<
"MemoryID " << memoryID
405 <<
" does not refer to a valid Grasp Memory Part.";
406 outputs.emplace_back(
false, sstream.str());
409 else if (input.actionPath == ActionPath{
"track"} ||
410 input.actionPath == ActionPath{
"untrack"})
412 std::vector<armem::MemoryID> entityIDs;
415 entityIDs.emplace_back(memoryID);
420 [&entityIDs](
const auto& entity) { entityIDs.emplace_back(entity.id()); });
427 .forEachEntity([&entityIDs](
const auto& entity)
428 { entityIDs.emplace_back(entity.id()); });
430 for (
auto& entityID : entityIDs)
432 if (input.actionPath == ActionPath{
"track"})
436 [
this](
const auto& instance) { addInstanceToVisu(instance.id()); });
437 gui.trackedEntityIds.push_back(entityID);
439 outputs.emplace_back(
true,
"");
441 else if (input.actionPath == ActionPath{
"untrack"})
443 auto pos = std::find(
444 gui.trackedEntityIds.begin(),
gui.trackedEntityIds.end(), entityID);
445 if (pos !=
gui.trackedEntityIds.end())
447 gui.trackedEntityIds.erase(pos);
450 outputs.emplace_back(
true,
"");
454 else if (input.actionPath.front() ==
"high")
456 addToHighlightLayer(memoryID, input.actionPath.back());
458 else if (input.actionPath == ActionPath{
"reset"})
460 arviz.commit(
arviz.layer(
"HighlightedGrasps"));
464 std::stringstream sstream;
465 sstream <<
"Action path " << input.actionPath <<
" is not defined.";
466 outputs.emplace_back(
false, sstream.str());
480 gui.tab.selectAll.setLabel(
"Select All");
481 gui.tab.deselectAll.setLabel(
"Deselect All");
482 gui.tab.showUnlimitedInstances.setValue(
gui.unlimitedInstances);
483 gui.tab.maxInstances.setRange(0, 1000);
484 gui.tab.maxInstances.setValue(
gui.maxInstances);
510 std::vector<std::string> options =
514 options.push_back(
"<None>");
518 options.insert(options.begin(),
"<All>");
521 gui.tab.selectProvider.setOptions(options);
523 if (
gui.providerIndex >= 0 &&
524 gui.providerIndex <
static_cast<int>(options.size()))
526 gui.tab.selectProvider.setIndex(
gui.providerIndex);
527 gui.provider = options[
gui.providerIndex];
529 root.
add(
gui.tab.selectProvider,
Pos{row, 0});
534 .getCoreSegment(
gui.coreSegment)
535 .hasProviderSegment(
gui.provider))
537 std::vector<MemoryID> providers;
541 std::vector<std::string> options;
543 if (
gui.provider ==
"<All>")
547 .forEachProviderSegment([&providers](
const auto& provider)
548 { providers.push_back(provider.id()); });
555 for (
MemoryID& provider : providers)
557 for (std::string& entity :
558 workingMemory().getProviderSegment(provider).getEntityNames())
560 options.push_back(entity);
565 options.push_back(
"<None>");
569 options.insert(options.begin(),
"<All>");
571 gui.tab.selectEntity.setOptions(options);
572 if (
gui.entityIndex >= 0 &&
573 gui.entityIndex <
static_cast<int>(options.size()))
575 gui.tab.selectEntity.setIndex(
gui.entityIndex);
576 gui.entity = options[
gui.entityIndex];
578 root.
add(
gui.tab.selectEntity,
Pos{row, 0});
582 if (
gui.entity ==
"<All>" ||
583 (
gui.provider ==
"<All>" &&
586 .getCoreSegment(
gui.coreSegment)
587 .getProviderSegment(
gui.provider)
588 .hasEntity(
gui.entity))
590 std::vector<MemoryID> entities;
594 std::vector<std::string> options;
595 for (
MemoryID& provider : providers)
597 if (
gui.entity ==
"<All>")
600 [&entities](
auto& entity)
601 { entities.push_back(entity.id()); });
610 provider.providerSegmentName,
619 [
this, &options](
const auto& snapshot)
623 gui.timeMap[time] = snapshot.time();
624 options.push_back(time);
630 options.push_back(
"<None>");
634 options.insert(options.begin(),
"<All>");
636 gui.tab.selectSnapshot.setOptions(options);
637 if (
gui.snapshotIndex >= 0 &&
638 gui.snapshotIndex <
static_cast<int>(options.size()))
640 gui.tab.selectSnapshot.setIndex(
gui.snapshotIndex);
641 if (options[
gui.snapshotIndex] !=
"<None>")
643 gui.snapshot = options[
gui.snapshotIndex];
646 root.
add(
gui.tab.selectSnapshot,
Pos{row, 0});
650 if (
gui.snapshot ==
"<All>")
659 gui.timeMap.at(
gui.snapshot)))
669 root.
add(
Label(
"Show all Instances"),
Pos{row, 0});
670 root.
add(
gui.tab.showUnlimitedInstances,
Pos{row, 1});
672 root.
add(
Label(
"Limit for shown Instances"),
Pos{row, 0});
673 root.
add(
gui.tab.maxInstances,
Pos{row, 1});
675 root.
add(
gui.tab.selectAll,
Pos{row, 0});
677 root.
add(
gui.tab.deselectAll,
Pos{row, 0});
679 gui.tab.checkInstances.clear();
680 std::vector<MemoryID> snapshots;
683 if (
gui.snapshot ==
"<All>")
686 [&snapshots](
auto& snapshot)
687 { snapshots.push_back(snapshot.id()); });
692 gui.timeMap.at(
gui.snapshot)))
697 .getSnapshot(
gui.timeMap.at(
gui.snapshot))
703 for (
MemoryID& snapshot : snapshots)
706 [
this, &row, &root, &instances](
const auto& instance)
708 if (
gui.unlimitedInstances || instances <
gui.maxInstances)
710 std::unique_lock lock(
gui.visualizationMutex);
712 gui.tab.checkInstances[instance.id().str()] =
714 if (std::find(
gui.visibleInstanceIds.begin(),
715 gui.visibleInstanceIds.end(),
717 gui.visibleInstanceIds.end())
719 gui.tab.checkInstances.at(instance.id().str())
722 root.
add(
gui.tab.checkInstances[instance.id().str()],
734 root.
add(
Label(
"Show all Instances"),
Pos{row, 0});
735 root.
add(
gui.tab.showUnlimitedInstances,
Pos{row, 1});
737 root.
add(
Label(
"Limit for shown Instances"),
Pos{row, 0});
738 root.
add(
gui.tab.maxInstances,
Pos{row, 1});
740 root.
add(
gui.tab.selectAll,
Pos{row, 0});
742 root.
add(
gui.tab.deselectAll,
Pos{row, 0});
744 gui.tab.checkInstances.clear();
749 gui.tab.checkInstances.clear();
751 std::vector<std::string> options = {
"<None>"};
753 gui.tab.selectSnapshot.setOptions(options);
757 root.
add(
gui.tab.selectSnapshot,
Pos{row, 0});
759 root.
add(
Label(
"Show all Instances"),
Pos{row, 0});
760 root.
add(
gui.tab.showUnlimitedInstances,
Pos{row, 1});
762 root.
add(
Label(
"Limit for shown Instances"),
Pos{row, 0});
763 root.
add(
gui.tab.maxInstances,
Pos{row, 1});
765 root.
add(
gui.tab.selectAll,
Pos{row, 0});
767 root.
add(
gui.tab.deselectAll,
Pos{row, 0});
773 gui.tab.checkInstances.clear();
775 std::vector<std::string> options = {
"<None>"};
777 gui.tab.selectEntity.setOptions(options);
781 root.
add(
gui.tab.selectEntity,
Pos{row, 0});
784 gui.tab.selectSnapshot.setOptions(options);
788 root.
add(
gui.tab.selectSnapshot,
Pos{row, 0});
790 root.
add(
Label(
"Show all Instances"),
Pos{row, 0});
791 root.
add(
gui.tab.showUnlimitedInstances,
Pos{row, 1});
793 root.
add(
Label(
"Limit for shown Instances"),
Pos{row, 0});
794 root.
add(
gui.tab.maxInstances,
Pos{row, 1});
796 root.
add(
gui.tab.selectAll,
Pos{row, 0});
798 root.
add(
gui.tab.deselectAll,
Pos{row, 0});
804 gui.tab.checkInstances.clear();
806 std::vector<std::string> options = {
"<None>"};
807 gui.tab.selectProvider.setOptions(options);
811 root.
add(
gui.tab.selectProvider,
Pos{row, 0});
814 gui.tab.selectEntity.setOptions(options);
818 root.
add(
gui.tab.selectEntity,
Pos{row, 0});
821 gui.tab.selectSnapshot.setOptions(options);
825 root.
add(
gui.tab.selectSnapshot,
Pos{row, 0});
827 root.
add(
Label(
"Show all Instances"),
Pos{row, 0});
828 root.
add(
gui.tab.showUnlimitedInstances,
Pos{row, 1});
830 root.
add(
Label(
"Limit for shown Instances"),
Pos{row, 0});
831 root.
add(
gui.tab.maxInstances,
Pos{row, 1});
833 root.
add(
gui.tab.selectAll,
Pos{row, 0});
835 root.
add(
gui.tab.deselectAll,
Pos{row, 0});
842 gui.tab.rebuild =
false;
846 [](
const armarx::armem::grasping::arondto::KnownGraspSet& graspSet) -> std::string
848 ARMARX_VERBOSE <<
"Grasping with " << graspSet.robot <<
" and with the endeffector named"
849 << graspSet.endeffector;
851 if (graspSet.robot ==
"Armar6" or graspSet.robot ==
"ArmarDE" or graspSet.robot ==
"Armar7")
853 if (graspSet.endeffector ==
"TCP_R")
857 if (graspSet.endeffector ==
"TCP_L")
861 if (graspSet.endeffector ==
"Hand_R_EEF")
865 if (graspSet.endeffector ==
"Hand_L_EEF")
869 ARMARX_ERROR <<
"Unknown TCP `" << graspSet.endeffector <<
"` for robot `"
870 << graspSet.robot <<
"`!";
873 if (graspSet.robot ==
"Armar3")
875 if (graspSet.endeffector ==
"Hand R")
879 if (graspSet.endeffector ==
"Hand L")
883 ARMARX_ERROR <<
"Unknown TCP `" << graspSet.endeffector <<
"` for robot `"
884 << graspSet.robot <<
"`!";
887 ARMARX_ERROR <<
"Unknown TCP `" << graspSet.endeffector <<
"` for robot `" << graspSet.robot
889 throw std::exception();
893 armarx::armem::server::grasp::GraspMemory::visualizeKnownGraspCandidates()
895 if (not enableVisualizeKnownGraspCandidates)
902 while (not taskVisuKnownGrasps->isStopped())
906 const std::vector<robot_state::description::RobotDescription> robotDescriptions =
910 std::map<std::string, robot_state::description::RobotDescription>
912 for (
const auto& robotDescription : robotDescriptions)
914 robotDescriptionMap.emplace(robotDescription.name, robotDescription);
918 for (
const auto& robotDescription : robotDescriptions)
920 if (robots.count(robotDescription.name) > 0)
927 if (
auto robot = VirtualRobot::RobotIO::loadRobot(
928 robotDescription.xml.toSystemPath(), VirtualRobot::BaseIO::eStructure))
930 ARMARX_INFO <<
"Loaded robot `" << robotDescription.name <<
"`";
931 robots.emplace(robotDescription.name, robot);
935 ARMARX_INFO <<
"Failed to load robot `" << robotDescription.name
936 <<
"` from file `" << robotDescription.xml.toSystemPath()
942 std::map<std::string, std::vector<armarx::armem::grasping::arondto::KnownGraspInfo>>
947 .getCoreSegment(
"KnownGraspCandidate")
949 [&graspsForObject](
const auto& entityInstance)
951 const armarx::armem::grasping::arondto::KnownGraspInfo dto =
952 armarx::armem::grasping::arondto::KnownGraspInfo::FromAron(
953 entityInstance.data());
955 const MemoryID memoryId = entityInstance.id();
958 graspsForObject[memoryId.entityName].push_back(dto);
963 for (
auto& [_, layer] : graspVisuPerObject)
970 const auto objects = getObjectPoses();
972 for (
const auto&
object : objects)
974 const std::string layerName =
object.objectID.str();
975 auto layer = arviz.layer(layerName);
978 const std::string objectClassName =
object.objectID.getClassID().str();
980 if (graspsForObject.count(objectClassName) == 0)
985 const auto& graspInfos = graspsForObject.at(objectClassName);
987 for (
const auto& graspInfo : graspInfos)
989 for (
const auto& [_, graspSet] : graspInfo.graspSets)
992 if (robotDescriptionMap.count(graspSet.robot) == 0)
997 const std::string side =
GetSide(graspSet);
998 const std::string bodyPartName = side +
"Hand";
1000 const auto& robotDescription = robotDescriptionMap.at(graspSet.robot);
1001 const auto& visuPart =
1002 robotDescription.visualization.body_parts.at(bodyPartName);
1004 const armarx::PackagePath visuRobotPartXML{visuPart.xml.package,
1007 for (
const auto& grasp : graspSet.grasps)
1009 const std::string visuName = graspSet.robot +
"::" + graspSet.name +
1010 "::" +
object.providerName +
1011 "::" +
object.objectID.str() +
1015 if (robots.count(graspSet.robot) == 0)
1020 const auto robot = robots.at(graspSet.robot);
1022 const auto handRootNode =
1023 robot->getRobotNode(visuPart.root_node_name);
1024 if (handRootNode ==
nullptr)
1026 ARMARX_INFO <<
"Node `" << visuPart.root_node_name
1027 <<
"` not available for robot `" << graspSet.robot
1032 const auto eefNode = robot->getEndEffector(graspSet.endeffector);
1033 if (eefNode ==
nullptr)
1035 ARMARX_INFO <<
"End-effector `" << graspSet.endeffector
1036 <<
"` not available for robot `" << graspSet.robot
1041 const auto tcp = eefNode->getTcp();
1044 ARMARX_INFO <<
"End-effector `" << graspSet.endeffector
1045 <<
"` does not provide a TCP";
1049 const Eigen::Isometry3f eef_T_hand_root{
1050 handRootNode->getPoseInFrame(tcp)};
1052 const Eigen::Isometry3f global_T_grasp_pose =
1053 Eigen::Isometry3f{
object.objectPoseGlobal} *
1054 Eigen::Isometry3f{grasp.pose}.inverse();
1058 viz::Robot graspHandVisu(visuName +
"_grasp");
1059 graspHandVisu.useCollisionModel()
1060 .file(visuRobotPartXML)
1062 Eigen::Isometry3f{global_T_grasp_pose * eef_T_hand_root}
1065 layer.add(graspHandVisu);
1069 if (grasp.prepose.has_value())
1071 const Eigen::Isometry3f global_T_prepose =
1072 Eigen::Isometry3f{
object.objectPoseGlobal} *
1073 Eigen::Isometry3f{grasp.prepose.value()}.inverse();
1076 if (enableVisualizeKnownGraspCandidatesPreposes)
1078 viz::Robot graspHandVisuPrepose(visuName +
"_prepose");
1079 graspHandVisuPrepose.useCollisionModel()
1080 .file(visuRobotPartXML)
1081 .pose(Eigen::Isometry3f{global_T_prepose *
1084 .overrideColor(viz::Color::blue());
1086 layer.add(graspHandVisuPrepose);
1090 if (enableVisualizeKnownGraspCandidatesApproach)
1092 viz::Arrow arrow(visuName +
"_approach");
1094 .fromTo(global_T_prepose.translation(),
1095 global_T_grasp_pose.translation())
1096 .color(viz::Color::green());
1105 graspVisuPerObject[layerName] = layer;
1108 arviz.commit(simox::alg::get_values(graspVisuPerObject));
1111 metronome.waitForNextTick();
1116 armarx::armem::server::grasp::GraspMemory::visualizeGraspCandidates()
1118 std::unique_lock lock(gui.visualizationMutex);
1119 armarx::grasping::GraspCandidateVisu visu;
1120 std::map<std::string, viz::Layer> reachableLayers;
1121 std::map<std::string, viz::Layer> unreachableLayers;
1125 for (
auto& element : gui.visibleInstanceIds)
1127 std::string entityName = element.entityName;
1129 if (reachableLayers.find(entityName) == reachableLayers.end())
1131 reachableLayers[entityName] = arviz.layer(entityName +
"_reachable");
1132 unreachableLayers[entityName] = arviz.layer(entityName +
"_unreachable");
1133 gui.activeLayers.push_back(entityName);
1136 armarx::grasping::GraspCandidate candidate;
1138 armarx::grasping::arondto::GraspCandidate aronTransform;
1140 aronTransform.fromAron(workingMemory().getInstance(element).
data());
1142 fromAron(aronTransform, candidate);
1146 reachableLayers.at(entityName),
1147 unreachableLayers.at(entityName));
1151 std::vector<viz::Layer> layers;
1152 for (
auto& [entityName, layer] : reachableLayers)
1154 layers.push_back(layer);
1155 layers.push_back(unreachableLayers.at(entityName));
1157 arviz.commit(layers);
1161 armarx::armem::server::grasp::GraspMemory::addInstanceToVisu(
1162 const armarx::armem::MemoryID& instance)
1164 std::unique_lock lock(gui.visualizationMutex);
1166 std::find(gui.visibleInstanceIds.begin(), gui.visibleInstanceIds.end(), instance);
1168 if (position == gui.visibleInstanceIds.end())
1170 gui.visibleInstanceIds.push_back(instance);
1175 armarx::armem::server::grasp::GraspMemory::removeInstanceFromVisu(
1176 const armarx::armem::MemoryID& instance)
1178 std::unique_lock lock(gui.visualizationMutex);
1180 std::find(gui.visibleInstanceIds.begin(), gui.visibleInstanceIds.end(), instance);
1182 if (position != gui.visibleInstanceIds.end())
1184 gui.visibleInstanceIds.erase(position);
1188 std::string entityName = instance.
entityName;
1190 if (std::none_of(gui.visibleInstanceIds.begin(),
1191 gui.visibleInstanceIds.end(),
1192 [&entityName](
const armem::MemoryID&
id)
1193 { return id.entityName == entityName; }))
1195 arviz.commitDeleteLayer(entityName +
"_reachable");
1196 arviz.commitDeleteLayer(entityName +
"_unreachable");
1199 auto layerPos = std::find(gui.activeLayers.begin(), gui.activeLayers.end(), entityName);
1201 if (layerPos != gui.activeLayers.end())
1203 gui.activeLayers.erase(layerPos);
1208 GraspMemory::addToHighlightLayer(
const MemoryID& memoryID,
const std::string color)
1210 viz::Color handColor;
1212 if (color ==
"pink")
1214 handColor = viz::Color::pink();
1216 else if (color ==
"red")
1218 handColor = viz::Color::red();
1220 else if (color ==
"blue")
1222 handColor = viz::Color::blue();
1224 else if (color ==
"yellow")
1226 handColor = viz::Color::yellow();
1228 else if (color ==
"purple")
1230 handColor = viz::Color::purple();
1233 viz::Layer highlightLayer =
arviz.layer((
"HighlightedGrasps"));
1234 armarx::grasping::GraspCandidateVisu visu;
1236 std::vector<armem::MemoryID> instances;
1240 instances.push_back(memoryID);
1245 [&instances](
const auto& instance) { instances.push_back(instance.id()); });
1250 [&instances](
const auto& instance) { instances.push_back(instance.id()); });
1255 [&instances](
const auto& instance) { instances.push_back(instance.id()); });
1262 .forEachInstance([&instances](
const auto& instance)
1263 { instances.push_back(instance.id()); });
1266 armarx::grasping::GraspCandidate candidate;
1268 armarx::grasping::arondto::GraspCandidate aronTransform;
1270 for (armem::MemoryID& instance : instances)
1274 fromAron(aronTransform, candidate);
1278 hand.color(handColor);
1279 highlightLayer.
add(hand);
1282 arviz.commit(highlightLayer);
1298 if (
gui.tab.selectProvider.hasValueChanged())
1300 gui.provider =
gui.tab.selectProvider.getValue();
1301 gui.providerIndex =
gui.tab.selectProvider.getIndex();
1302 gui.entityIndex = 0;
1303 gui.snapshotIndex = 0;
1304 gui.tab.rebuild =
true;
1307 if (
gui.tab.selectEntity.hasValueChanged())
1309 gui.entity =
gui.tab.selectEntity.getValue();
1310 gui.entityIndex =
gui.tab.selectEntity.getIndex();
1311 gui.snapshotIndex = 0;
1312 gui.tab.rebuild =
true;
1315 if (
gui.tab.selectSnapshot.hasValueChanged())
1317 gui.snapshot =
gui.tab.selectSnapshot.getValue();
1318 gui.snapshotIndex =
gui.tab.selectSnapshot.getIndex();
1319 gui.tab.rebuild =
true;
1322 if (
gui.tab.showUnlimitedInstances.hasValueChanged())
1324 gui.unlimitedInstances =
gui.tab.showUnlimitedInstances.getValue();
1325 gui.tab.rebuild =
true;
1328 if (
gui.tab.maxInstances.hasValueChanged())
1330 gui.maxInstances =
gui.tab.maxInstances.getValue();
1331 gui.tab.rebuild =
true;
1334 if (
gui.tab.selectAll.wasClicked())
1336 for (
auto& element :
gui.tab.checkInstances)
1338 element.second.setValue(
true);
1342 if (
gui.tab.deselectAll.wasClicked())
1344 for (
auto& element :
gui.tab.checkInstances)
1346 element.second.setValue(
false);
1350 for (
auto& element :
gui.tab.checkInstances)
1352 if (element.second.hasValueChanged())
1354 if (element.second.getValue())
1365 visualizeGraspCandidates();
1367 if (
gui.tab.rebuild)