7 #include <Eigen/Geometry>
9 #include <SimoxUtility/algorithm/get_map_keys_values.h>
10 #include <SimoxUtility/algorithm/string.h>
11 #include <VirtualRobot/XML/BaseIO.h>
26 #include <RobotAPI/libraries/GraspingUtility/aron/GraspCandidate.aron.generated.h>
32 #include <RobotAPI/libraries/armem_grasping/aron/KnownGraspCandidate.aron.generated.h>
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();
123 taskVisuKnownGrasps =
125 taskVisuKnownGrasps->start();
131 if (taskVisuKnownGrasps)
133 taskVisuKnownGrasps->stop();
134 taskVisuKnownGrasps =
nullptr;
139 for (
auto& [_, layer] : graspVisuPerObject)
142 layer.markForDeletion();
145 arviz.
commit(simox::alg::get_values(graspVisuPerObject));
146 graspVisuPerObject.clear();
157 armem::data::CommitResult
160 std::vector<armem::MemoryID> trackedEntityIds;
162 std::unique_lock lock(gui.visualizationMutex);
163 trackedEntityIds = gui.trackedEntityIds;
166 if (!trackedEntityIds.empty())
172 if (
std::find(trackedEntityIds.begin(), trackedEntityIds.end(), entityID) !=
173 trackedEntityIds.end())
176 [
this](
const auto& instance) { removeInstanceFromVisu(instance.id()); });
181 if (gui.trackNewEntities)
189 std::unique_lock lock(gui.visualizationMutex);
190 gui.trackedEntityIds.emplace_back(entityID);
191 trackedEntityIds.emplace_back(entityID);
198 gui.tab.rebuild =
true;
201 if (!trackedEntityIds.empty())
207 if (
std::find(trackedEntityIds.begin(), trackedEntityIds.end(), entityID) !=
208 trackedEntityIds.end())
211 [
this](
const auto& instance) { addInstanceToVisu(instance.id()); });
222 armem::actions::data::GetActionsOutputSeq
225 using namespace armem::actions;
227 GetActionsOutputSeq outputs;
228 for (
const auto&
input : inputs)
239 std::vector<MenuEntry> actions;
245 if (
std::find(gui.trackedEntityIds.begin(),
246 gui.trackedEntityIds.end(),
247 memoryID) == gui.trackedEntityIds.end())
249 actions.push_back(Action{
"track",
"Track this entity in arviz"});
254 Action{
"untrack",
"Stop tracking this entity in arviz"});
260 Action{
"track",
"Track all underlying entities in arviz"});
262 Action{
"untrack",
"Stop tracking all underlying entities in arviz"});
266 actions.push_back(Action{
"vis",
"Visualize all contained grasp candidates"});
268 Action{
"rem",
"Remove all contained grasp candidates from visualization"});
269 actions.push_back(SubMenu{
"high",
270 "Highlight all contain grasp candidates",
271 {Action{
"pink",
"in pink"},
272 Action{
"red",
"in red"},
273 Action{
"blue",
"in blue"},
274 Action{
"yellow",
"in yellow"},
275 Action{
"purple",
"in purple"}}});
276 actions.push_back(Action{
"reset",
"Reset highlight layer"});
279 outputs.push_back({menu.toIce()});
286 armem::actions::data::ExecuteActionOutputSeq
289 using namespace armem::actions;
290 ExecuteActionOutputSeq outputs;
292 for (
const auto&
input : inputs)
295 if (
input.actionPath == ActionPath{
"vis"} ||
input.actionPath == ActionPath{
"rem"})
305 std::stringstream sstream;
306 sstream <<
"Currently visualization for CoreSegment "
308 outputs.emplace_back(
false, sstream.str());
314 if (
input.actionPath == ActionPath{
"vis"})
318 else if (
input.actionPath == ActionPath{
"rem"})
326 [
this, &
input](
const auto& instance)
328 if (
input.actionPath == ActionPath{
"vis"})
330 addInstanceToVisu(instance.id());
332 else if (
input.actionPath == ActionPath{
"rem"})
334 removeInstanceFromVisu(instance.id());
341 [
this, &
input](
const auto& instance)
343 if (
input.actionPath == ActionPath{
"vis"})
345 addInstanceToVisu(instance.id());
347 else if (
input.actionPath == ActionPath{
"rem"})
349 removeInstanceFromVisu(instance.id());
356 [
this, &
input](
const auto& instance)
358 if (
input.actionPath == ActionPath{
"vis"})
360 addInstanceToVisu(instance.id());
362 else if (
input.actionPath == ActionPath{
"rem"})
364 removeInstanceFromVisu(instance.id());
370 if (
input.actionPath == ActionPath{
"rem"})
372 std::unique_lock lock(gui.visualizationMutex);
373 gui.visibleInstanceIds.clear();
375 for (std::string& layer : gui.activeLayers)
380 gui.activeLayers.clear();
382 else if (
input.actionPath == ActionPath{
"vis"})
387 .forEachInstance([
this](
const auto& instance)
388 { addInstanceToVisu(instance.id()); });
392 visualizeGraspCandidates();
393 outputs.emplace_back(
true,
"");
399 std::stringstream sstream;
401 <<
" does not refer to a valid Grasp Memory Part.";
402 outputs.emplace_back(
false, sstream.str());
405 else if (
input.actionPath == ActionPath{
"track"} ||
406 input.actionPath == ActionPath{
"untrack"})
408 std::vector<armem::MemoryID> entityIDs;
416 [&entityIDs](
const auto& entity) { entityIDs.emplace_back(entity.id()); });
423 .forEachEntity([&entityIDs](
const auto& entity)
424 { entityIDs.emplace_back(entity.id()); });
426 for (
auto& entityID : entityIDs)
428 if (
input.actionPath == ActionPath{
"track"})
432 [
this](
const auto& instance) { addInstanceToVisu(instance.id()); });
433 gui.trackedEntityIds.push_back(entityID);
435 outputs.emplace_back(
true,
"");
437 else if (
input.actionPath == ActionPath{
"untrack"})
440 gui.trackedEntityIds.begin(), gui.trackedEntityIds.end(), entityID);
441 if (pos != gui.trackedEntityIds.end())
443 gui.trackedEntityIds.erase(pos);
446 outputs.emplace_back(
true,
"");
450 else if (
input.actionPath.front() ==
"high")
454 else if (
input.actionPath == ActionPath{
"reset"})
460 std::stringstream sstream;
461 sstream <<
"Action path " <<
input.actionPath <<
" is not defined.";
462 outputs.emplace_back(
false, sstream.str());
476 gui.tab.selectAll.setLabel(
"Select All");
477 gui.tab.deselectAll.setLabel(
"Deselect All");
478 gui.tab.showUnlimitedInstances.setValue(gui.unlimitedInstances);
479 gui.tab.maxInstances.setRange(0, 1000);
480 gui.tab.maxInstances.setValue(gui.maxInstances);
506 std::vector<std::string> options =
510 options.push_back(
"<None>");
514 options.insert(options.begin(),
"<All>");
517 gui.tab.selectProvider.setOptions(options);
519 if (gui.providerIndex >= 0 &&
520 gui.providerIndex <
static_cast<int>(options.size()))
522 gui.tab.selectProvider.setIndex(gui.providerIndex);
523 gui.provider = options[gui.providerIndex];
525 root.
add(gui.tab.selectProvider,
Pos{row, 0});
530 .getCoreSegment(gui.coreSegment)
533 std::vector<MemoryID> providers;
537 std::vector<std::string> options;
539 if (gui.provider ==
"<All>")
543 .forEachProviderSegment([&providers](
const auto& provider)
544 { providers.push_back(provider.id()); });
551 for (
MemoryID& provider : providers)
553 for (std::string& entity :
554 workingMemory().getProviderSegment(provider).getEntityNames())
556 options.push_back(entity);
561 options.push_back(
"<None>");
565 options.insert(options.begin(),
"<All>");
567 gui.tab.selectEntity.setOptions(options);
568 if (gui.entityIndex >= 0 &&
569 gui.entityIndex <
static_cast<int>(options.size()))
571 gui.tab.selectEntity.setIndex(gui.entityIndex);
572 gui.entity = options[gui.entityIndex];
574 root.
add(gui.tab.selectEntity,
Pos{row, 0});
578 if (gui.entity ==
"<All>" ||
579 (gui.provider ==
"<All>" &&
582 .getCoreSegment(gui.coreSegment)
584 .hasEntity(gui.entity))
586 std::vector<MemoryID> entities;
590 std::vector<std::string> options;
591 for (
MemoryID& provider : providers)
593 if (gui.entity ==
"<All>")
596 [&entities](
auto& entity)
597 { entities.push_back(entity.id()); });
606 provider.providerSegmentName,
615 [
this, &options](
const auto& snapshot)
619 gui.timeMap[time] = snapshot.time();
620 options.push_back(time);
626 options.push_back(
"<None>");
630 options.insert(options.begin(),
"<All>");
632 gui.tab.selectSnapshot.setOptions(options);
633 if (gui.snapshotIndex >= 0 &&
634 gui.snapshotIndex <
static_cast<int>(options.size()))
636 gui.tab.selectSnapshot.setIndex(gui.snapshotIndex);
637 if (options[gui.snapshotIndex] !=
"<None>")
639 gui.snapshot = options[gui.snapshotIndex];
642 root.
add(gui.tab.selectSnapshot,
Pos{row, 0});
646 if (gui.snapshot ==
"<All>")
655 gui.timeMap.at(gui.snapshot)))
665 root.
add(
Label(
"Show all Instances"),
Pos{row, 0});
666 root.
add(gui.tab.showUnlimitedInstances,
Pos{row, 1});
668 root.
add(
Label(
"Limit for shown Instances"),
Pos{row, 0});
669 root.
add(gui.tab.maxInstances,
Pos{row, 1});
671 root.
add(gui.tab.selectAll,
Pos{row, 0});
673 root.
add(gui.tab.deselectAll,
Pos{row, 0});
675 gui.tab.checkInstances.clear();
676 std::vector<MemoryID> snapshots;
679 if (gui.snapshot ==
"<All>")
682 [&snapshots](
auto& snapshot)
683 { snapshots.push_back(snapshot.id()); });
688 gui.timeMap.at(gui.snapshot)))
693 .getSnapshot(gui.timeMap.at(gui.snapshot))
699 for (
MemoryID& snapshot : snapshots)
702 [
this, &row, &root, &instances](
const auto& instance)
704 if (gui.unlimitedInstances || instances < gui.maxInstances)
706 std::unique_lock lock(gui.visualizationMutex);
707 root.add(Label(instance.id().str()), Pos{row, 0});
708 gui.tab.checkInstances[instance.id().str()] =
710 if (
std::find(gui.visibleInstanceIds.begin(),
711 gui.visibleInstanceIds.end(),
713 gui.visibleInstanceIds.end())
715 gui.tab.checkInstances.at(instance.id().str())
718 root.
add(gui.tab.checkInstances[instance.id().str()],
730 root.
add(
Label(
"Show all Instances"),
Pos{row, 0});
731 root.
add(gui.tab.showUnlimitedInstances,
Pos{row, 1});
733 root.
add(
Label(
"Limit for shown Instances"),
Pos{row, 0});
734 root.
add(gui.tab.maxInstances,
Pos{row, 1});
736 root.
add(gui.tab.selectAll,
Pos{row, 0});
738 root.
add(gui.tab.deselectAll,
Pos{row, 0});
740 gui.tab.checkInstances.clear();
745 gui.tab.checkInstances.clear();
747 std::vector<std::string> options = {
"<None>"};
749 gui.tab.selectSnapshot.setOptions(options);
753 root.
add(gui.tab.selectSnapshot,
Pos{row, 0});
755 root.
add(
Label(
"Show all Instances"),
Pos{row, 0});
756 root.
add(gui.tab.showUnlimitedInstances,
Pos{row, 1});
758 root.
add(
Label(
"Limit for shown Instances"),
Pos{row, 0});
759 root.
add(gui.tab.maxInstances,
Pos{row, 1});
761 root.
add(gui.tab.selectAll,
Pos{row, 0});
763 root.
add(gui.tab.deselectAll,
Pos{row, 0});
769 gui.tab.checkInstances.clear();
771 std::vector<std::string> options = {
"<None>"};
773 gui.tab.selectEntity.setOptions(options);
777 root.
add(gui.tab.selectEntity,
Pos{row, 0});
780 gui.tab.selectSnapshot.setOptions(options);
784 root.
add(gui.tab.selectSnapshot,
Pos{row, 0});
786 root.
add(
Label(
"Show all Instances"),
Pos{row, 0});
787 root.
add(gui.tab.showUnlimitedInstances,
Pos{row, 1});
789 root.
add(
Label(
"Limit for shown Instances"),
Pos{row, 0});
790 root.
add(gui.tab.maxInstances,
Pos{row, 1});
792 root.
add(gui.tab.selectAll,
Pos{row, 0});
794 root.
add(gui.tab.deselectAll,
Pos{row, 0});
800 gui.tab.checkInstances.clear();
802 std::vector<std::string> options = {
"<None>"};
803 gui.tab.selectProvider.setOptions(options);
807 root.
add(gui.tab.selectProvider,
Pos{row, 0});
810 gui.tab.selectEntity.setOptions(options);
814 root.
add(gui.tab.selectEntity,
Pos{row, 0});
817 gui.tab.selectSnapshot.setOptions(options);
821 root.
add(gui.tab.selectSnapshot,
Pos{row, 0});
823 root.
add(
Label(
"Show all Instances"),
Pos{row, 0});
824 root.
add(gui.tab.showUnlimitedInstances,
Pos{row, 1});
826 root.
add(
Label(
"Limit for shown Instances"),
Pos{row, 0});
827 root.
add(gui.tab.maxInstances,
Pos{row, 1});
829 root.
add(gui.tab.selectAll,
Pos{row, 0});
831 root.
add(gui.tab.deselectAll,
Pos{row, 0});
837 RemoteGui_createTab(getName(), root, &gui.tab);
838 gui.tab.rebuild =
false;
842 [](
const armarx::armem::grasping::arondto::KnownGraspSet& graspSet) -> std::string
844 ARMARX_VERBOSE <<
"Grasping with " << graspSet.robot <<
" and with the endeffector named"
845 << graspSet.endeffector;
847 if (graspSet.robot ==
"Armar6" or graspSet.robot ==
"ArmarDE" or graspSet.robot ==
"Armar7")
849 if (graspSet.endeffector ==
"TCP_R")
853 if (graspSet.endeffector ==
"TCP_L")
857 if (graspSet.endeffector ==
"Hand_R_EEF")
861 if (graspSet.endeffector ==
"Hand_L_EEF")
865 ARMARX_ERROR <<
"Unknown TCP `" << graspSet.endeffector <<
"` for robot `"
866 << graspSet.robot <<
"`!";
869 if (graspSet.robot ==
"Armar3")
871 if (graspSet.endeffector ==
"Hand R")
875 if (graspSet.endeffector ==
"Hand L")
879 ARMARX_ERROR <<
"Unknown TCP `" << graspSet.endeffector <<
"` for robot `"
880 << graspSet.robot <<
"`!";
883 ARMARX_ERROR <<
"Unknown TCP `" << graspSet.endeffector <<
"` for robot `" << graspSet.robot
885 throw std::exception();
889 armarx::armem::server::grasp::GraspMemory::visualizeKnownGraspCandidates()
891 if (not enableVisualizeKnownGraspCandidates)
898 while (not taskVisuKnownGrasps->isStopped())
902 const std::vector<robot_state::description::RobotDescription> robotDescriptions =
906 std::map<std::string, robot_state::description::RobotDescription>
908 for (
const auto& robotDescription : robotDescriptions)
910 robotDescriptionMap.emplace(robotDescription.name, robotDescription);
914 for (
const auto& robotDescription : robotDescriptions)
916 if (
robots.count(robotDescription.name) > 0)
923 if (
auto robot = VirtualRobot::RobotIO::loadRobot(
924 robotDescription.xml.toSystemPath(), VirtualRobot::BaseIO::eStructure))
926 ARMARX_INFO <<
"Loaded robot `" << robotDescription.name <<
"`";
927 robots.emplace(robotDescription.name, robot);
931 ARMARX_INFO <<
"Failed to load robot `" << robotDescription.name
932 <<
"` from file `" << robotDescription.xml.toSystemPath()
938 std::map<std::string, std::vector<armarx::armem::grasping::arondto::KnownGraspInfo>>
943 .getCoreSegment(
"KnownGraspCandidate")
945 [&graspsForObject](
const auto& entityInstance)
947 const armarx::armem::grasping::arondto::KnownGraspInfo dto =
948 armarx::armem::grasping::arondto::KnownGraspInfo::FromAron(
949 entityInstance.data());
951 const MemoryID memoryId = entityInstance.id();
954 graspsForObject[memoryId.entityName].push_back(dto);
959 for (
auto& [_, layer] : graspVisuPerObject)
966 const auto objects = getObjectPoses();
968 for (
const auto&
object : objects)
970 const std::string layerName =
object.objectID.str();
971 auto layer = arviz.layer(layerName);
974 const std::string objectClassName =
object.objectID.getClassID().str();
976 if (graspsForObject.count(objectClassName) == 0)
981 const auto& graspInfos = graspsForObject.at(objectClassName);
983 for (
const auto& graspInfo : graspInfos)
985 for (
const auto& [_, graspSet] : graspInfo.graspSets)
988 if (robotDescriptionMap.count(graspSet.robot) == 0)
993 const std::string side =
GetSide(graspSet);
994 const std::string bodyPartName = side +
"Hand";
996 const auto& robotDescription = robotDescriptionMap.at(graspSet.robot);
997 const auto& visuPart =
998 robotDescription.visualization.body_parts.at(bodyPartName);
1003 for (
const auto& grasp : graspSet.grasps)
1005 const std::string visuName = graspSet.robot +
"::" + graspSet.name +
1006 "::" +
object.providerName +
1007 "::" +
object.objectID.str() +
1011 if (
robots.count(graspSet.robot) == 0)
1016 const auto robot =
robots.at(graspSet.robot);
1018 const auto handRootNode =
1019 robot->getRobotNode(visuPart.root_node_name);
1020 if (handRootNode ==
nullptr)
1022 ARMARX_INFO <<
"Node `" << visuPart.root_node_name
1023 <<
"` not available for robot `" << graspSet.robot
1028 const auto eefNode = robot->getEndEffector(graspSet.endeffector);
1029 if (eefNode ==
nullptr)
1031 ARMARX_INFO <<
"End-effector `" << graspSet.endeffector
1032 <<
"` not available for robot `" << graspSet.robot
1037 const auto tcp = eefNode->getTcp();
1040 ARMARX_INFO <<
"End-effector `" << graspSet.endeffector
1041 <<
"` does not provide a TCP";
1045 const Eigen::Isometry3f eef_T_hand_root{
1046 handRootNode->getPoseInFrame(tcp)};
1048 const Eigen::Isometry3f global_T_grasp_pose =
1049 Eigen::Isometry3f{
object.objectPoseGlobal} *
1050 Eigen::Isometry3f{grasp.pose}.inverse();
1054 viz::Robot graspHandVisu(visuName +
"_grasp");
1055 graspHandVisu.useCollisionModel()
1056 .file(visuRobotPartXML)
1058 Eigen::Isometry3f{global_T_grasp_pose * eef_T_hand_root}
1061 layer.add(graspHandVisu);
1065 if (grasp.prepose.has_value())
1067 const Eigen::Isometry3f global_T_prepose =
1068 Eigen::Isometry3f{
object.objectPoseGlobal} *
1069 Eigen::Isometry3f{grasp.prepose.value()}.inverse();
1072 if (enableVisualizeKnownGraspCandidatesPreposes)
1074 viz::Robot graspHandVisuPrepose(visuName +
"_prepose");
1075 graspHandVisuPrepose.useCollisionModel()
1076 .file(visuRobotPartXML)
1077 .pose(Eigen::Isometry3f{global_T_prepose *
1082 layer.add(graspHandVisuPrepose);
1086 if (enableVisualizeKnownGraspCandidatesApproach)
1090 .fromTo(global_T_prepose.translation(),
1091 global_T_grasp_pose.translation())
1101 graspVisuPerObject[layerName] = layer;
1104 arviz.commit(simox::alg::get_values(graspVisuPerObject));
1107 metronome.waitForNextTick();
1112 armarx::armem::server::grasp::GraspMemory::visualizeGraspCandidates()
1114 std::unique_lock lock(gui.visualizationMutex);
1116 std::map<std::string, viz::Layer> reachableLayers;
1117 std::map<std::string, viz::Layer> unreachableLayers;
1121 for (
auto& element : gui.visibleInstanceIds)
1123 std::string entityName = element.entityName;
1125 if (reachableLayers.find(entityName) == reachableLayers.end())
1127 reachableLayers[entityName] = arviz.layer(entityName +
"_reachable");
1128 unreachableLayers[entityName] = arviz.layer(entityName +
"_unreachable");
1129 gui.activeLayers.push_back(entityName);
1132 armarx::grasping::GraspCandidate candidate;
1134 armarx::grasping::arondto::GraspCandidate aronTransform;
1136 aronTransform.fromAron(workingMemory().getInstance(element).
data());
1138 fromAron(aronTransform, candidate);
1142 reachableLayers.at(entityName),
1143 unreachableLayers.at(entityName));
1147 std::vector<viz::Layer> layers;
1148 for (
auto& [entityName, layer] : reachableLayers)
1150 layers.push_back(layer);
1151 layers.push_back(unreachableLayers.at(entityName));
1153 arviz.commit(layers);
1157 armarx::armem::server::grasp::GraspMemory::addInstanceToVisu(
1160 std::unique_lock lock(gui.visualizationMutex);
1162 std::find(gui.visibleInstanceIds.begin(), gui.visibleInstanceIds.end(), instance);
1164 if (position == gui.visibleInstanceIds.end())
1166 gui.visibleInstanceIds.push_back(instance);
1171 armarx::armem::server::grasp::GraspMemory::removeInstanceFromVisu(
1174 std::unique_lock lock(gui.visualizationMutex);
1176 std::find(gui.visibleInstanceIds.begin(), gui.visibleInstanceIds.end(), instance);
1178 if (position != gui.visibleInstanceIds.end())
1180 gui.visibleInstanceIds.erase(position);
1184 std::string entityName = instance.
entityName;
1186 if (std::none_of(gui.visibleInstanceIds.begin(),
1187 gui.visibleInstanceIds.end(),
1189 { return id.entityName == entityName; }))
1191 arviz.commitDeleteLayer(entityName +
"_reachable");
1192 arviz.commitDeleteLayer(entityName +
"_unreachable");
1195 auto layerPos =
std::find(gui.activeLayers.begin(), gui.activeLayers.end(), entityName);
1197 if (layerPos != gui.activeLayers.end())
1199 gui.activeLayers.erase(layerPos);
1204 GraspMemory::addToHighlightLayer(
const MemoryID&
memoryID,
const std::string color)
1208 if (color ==
"pink")
1212 else if (color ==
"red")
1216 else if (color ==
"blue")
1220 else if (color ==
"yellow")
1224 else if (color ==
"purple")
1229 viz::Layer highlightLayer = arviz.layer((
"HighlightedGrasps"));
1232 std::vector<armem::MemoryID> instances;
1240 workingMemory().getSnapshot(
memoryID).forEachInstance(
1241 [&instances](
const auto& instance) { instances.push_back(instance.id()); });
1245 workingMemory().getEntity(
memoryID).forEachInstance(
1246 [&instances](
const auto& instance) { instances.push_back(instance.id()); });
1250 workingMemory().getProviderSegment(
memoryID).forEachInstance(
1251 [&instances](
const auto& instance) { instances.push_back(instance.id()); });
1257 .getCoreSegment(
"GraspCandidate")
1258 .forEachInstance([&instances](
const auto& instance)
1259 { instances.push_back(instance.id()); });
1262 armarx::grasping::GraspCandidate candidate;
1264 armarx::grasping::arondto::GraspCandidate aronTransform;
1268 aronTransform.fromAron(workingMemory().getInstance(instance).
data());
1270 fromAron(aronTransform, candidate);
1274 hand.color(handColor);
1275 highlightLayer.
add(hand);
1278 arviz.commit(highlightLayer);
1282 GraspMemory::RemoteGui_update()
1294 if (gui.tab.selectProvider.hasValueChanged())
1296 gui.provider = gui.tab.selectProvider.getValue();
1297 gui.providerIndex = gui.tab.selectProvider.getIndex();
1298 gui.entityIndex = 0;
1299 gui.snapshotIndex = 0;
1300 gui.tab.rebuild =
true;
1303 if (gui.tab.selectEntity.hasValueChanged())
1305 gui.entity = gui.tab.selectEntity.getValue();
1306 gui.entityIndex = gui.tab.selectEntity.getIndex();
1307 gui.snapshotIndex = 0;
1308 gui.tab.rebuild =
true;
1311 if (gui.tab.selectSnapshot.hasValueChanged())
1313 gui.snapshot = gui.tab.selectSnapshot.getValue();
1314 gui.snapshotIndex = gui.tab.selectSnapshot.getIndex();
1315 gui.tab.rebuild =
true;
1318 if (gui.tab.showUnlimitedInstances.hasValueChanged())
1320 gui.unlimitedInstances = gui.tab.showUnlimitedInstances.getValue();
1321 gui.tab.rebuild =
true;
1324 if (gui.tab.maxInstances.hasValueChanged())
1326 gui.maxInstances = gui.tab.maxInstances.getValue();
1327 gui.tab.rebuild =
true;
1330 if (gui.tab.selectAll.wasClicked())
1332 for (
auto& element : gui.tab.checkInstances)
1334 element.second.setValue(
true);
1338 if (gui.tab.deselectAll.wasClicked())
1340 for (
auto& element : gui.tab.checkInstances)
1342 element.second.setValue(
false);
1346 for (
auto& element : gui.tab.checkInstances)
1348 if (element.second.hasValueChanged())
1350 if (element.second.getValue())
1361 visualizeGraspCandidates();
1363 if (gui.tab.rebuild)
1366 createRemoteGuiTab();