34 putAwayLocation(PredicateInfo{
"putAwayLocation", 2})
45 usingProxy(getProperty<std::string>(
"CommonPlacesLearnerName").getValue());
47 cplSegmentName = getProperty<std::string>(
"CPLSegmentName").getValue();
48 sceneName = getProperty<std::string>(
"PlatformGraphSceneName").getValue();
57 getProxy(psr,
"GraphNodePoseResolver");
58 getProxy(cpl, getProperty<std::string>(
"CommonPlacesLearnerName").getValue());
60 cpl->setLTMSegmentName(cplSegmentName);
61 objectInstances = wm->getObjectInstancesSegment();
62 graphSegment = prior->getGraphSegment();
68 return "PutAwayLocationPredicateProvider";
74 return {putAwayLocation};
80 PredicateInstanceList result;
81 const std::string predicateName = putAwayLocation.name;
83 for (
const auto& entity : objectInstances->getAllEntities())
85 auto entry = getCacheEntry(ObjectInstancePtr::dynamicCast(entity)->getMostProbableClass());
86 if (entry.putAwayNodeRef)
88 result.push_back(PredicateInstance{
90 {objectInstances->getEntityRefById(entity->getId()), entry.putAwayNodeRef},
98 PutAwayLocationPredicateProvider::CachedCommonPlace
99 PutAwayLocationPredicateProvider::getCacheEntry(
const std::string& className)
101 auto it = cpCache.find(className);
102 if (it != cpCache.end())
107 if (cplObjects.empty())
109 cplObjectsSegment = ltm->getCustomInstancesSegment(cplSegmentName,
false);
110 if (!cplObjectsSegment)
112 throw armarx::LocalException(
"No LTM segment named '") << cplSegmentName <<
"'";
115 auto entities = cplObjectsSegment->getAllEntities();
118 std::back_inserter(cplObjects),
119 [](
const EntityBasePtr& e) { return ObjectInstancePtr::dynamicCast(e); });
122 EntityRefBasePtr nodeRef;
123 for (
const auto& cplInstance : cplObjects)
125 if (cplInstance->getMostProbableClass() == className)
127 memoryx::Cluster3DList clusterList =
128 cpl->getPositionClustersByComponentCount(cplInstance->getName(), 1);
129 if (!clusterList.empty())
131 auto cluster = clusterList.front();
132 nodeRef = graphSegment->getEntityRefById(psr->getNearestNodeIdToPosition(
133 sceneName,
"putdownlocation", cluster.center.x, cluster.center.y));
142 << nodeRef->entityName <<
"'";
145 CachedCommonPlace result{className, nodeRef};
146 cpCache.insert({className, result});