33 putAwayLocation(PredicateInfo {
"putAwayLocation", 2})
44 usingProxy(getProperty<std::string>(
"CommonPlacesLearnerName").getValue());
46 cplSegmentName = getProperty<std::string>(
"CPLSegmentName").getValue();
47 sceneName = getProperty<std::string>(
"PlatformGraphSceneName").getValue();
55 getProxy(psr,
"GraphNodePoseResolver");
56 getProxy(cpl, getProperty<std::string>(
"CommonPlacesLearnerName").getValue());
58 cpl->setLTMSegmentName(cplSegmentName);
59 objectInstances = wm->getObjectInstancesSegment();
60 graphSegment = prior->getGraphSegment();
65 return "PutAwayLocationPredicateProvider";
70 return {putAwayLocation};
75 PredicateInstanceList result;
76 const std::string predicateName = putAwayLocation.name;
78 for (
const auto& entity : objectInstances->getAllEntities())
80 auto entry = getCacheEntry(ObjectInstancePtr::dynamicCast(entity)->getMostProbableClass());
81 if (entry.putAwayNodeRef)
83 result.push_back(PredicateInstance {predicateName, {objectInstances->getEntityRefById(entity->getId()), entry.putAwayNodeRef},
true});
90 PutAwayLocationPredicateProvider::CachedCommonPlace PutAwayLocationPredicateProvider::getCacheEntry(
const std::string& className)
92 auto it = cpCache.find(className);
93 if (it != cpCache.end())
98 if (cplObjects.empty())
100 cplObjectsSegment = ltm->getCustomInstancesSegment(cplSegmentName,
false);
101 if (!cplObjectsSegment)
103 throw armarx::LocalException(
"No LTM segment named '") << cplSegmentName <<
"'";
106 auto entities = cplObjectsSegment->getAllEntities();
107 std::transform(entities.cbegin(), entities.cend(), std::back_inserter(cplObjects), [](
const EntityBasePtr & e)
109 return ObjectInstancePtr::dynamicCast(e);
113 EntityRefBasePtr nodeRef;
114 for (
const auto& cplInstance : cplObjects)
116 if (cplInstance->getMostProbableClass() == className)
118 memoryx::Cluster3DList clusterList = cpl->getPositionClustersByComponentCount(cplInstance->getName(), 1);
119 if (!clusterList.empty())
121 auto cluster = clusterList.front();
122 nodeRef = graphSegment->getEntityRefById(psr->getNearestNodeIdToPosition(sceneName,
"putdownlocation", cluster.center.x, cluster.center.y));
130 ARMARX_IMPORTANT <<
"caching putaway location for '" << className <<
"': '" << nodeRef->entityName <<
"'";
133 CachedCommonPlace result {className, nodeRef};
134 cpCache.insert({className, result});