40 usingProxy(
"WorkingMemory");
46 workingMemoryProxy = getProxy<WorkingMemoryInterfacePrx>(
"WorkingMemory");
47 objectInstancesProxy = workingMemoryProxy->getObjectInstancesSegment();
52 return "OnTopPredicateProvider";
57 return PredicateInfo {
"ontop", 2};
63 PredicateInstanceList returnPIList;
65 const float maxDistanceXY = 50;
66 const float minDistanceZ = 40;
67 const float maxDistanceZ = 200;
70 std::map<std::string, armarx::FramedPositionPtr> objectPositions;
71 EntityIdList objectIds = objectInstancesProxy->getAllEntityIds();
73 for (EntityIdList::const_iterator it = objectIds.begin(); it != objectIds.end(); it++)
75 const EntityBasePtr entityBase = objectInstancesProxy->getEntityById(*it);
81 objectPositions[
object->getName()] =
object->getPosition();
85 ARMARX_WARNING <<
"Something went wrong when getting the object with id " << *it <<
" from working memory";
90 for (std::map<std::string, armarx::FramedPositionPtr>::iterator i = objectPositions.begin(); i != objectPositions.end(); i++)
92 Eigen::Vector3f pos1 = i->second->toEigen();
93 ARMARX_IMPORTANT <<
"Object " << i->first <<
" at position " << i->second->toEigen();
94 std::map<std::string, armarx::FramedPositionPtr>::iterator j = i;
97 for (; j != objectPositions.end(); j++)
99 Eigen::Vector3f pos2 = j->second->toEigen();
102 if (sqrtf((pos1(0) - pos2(0)) * (pos1(0) - pos2(0)) + (pos1(1) - pos2(1)) * (pos1(1) - pos2(1))) < maxDistanceXY)
105 if (fabs(pos1(2) - pos2(2)) > minDistanceZ && fabs(pos1(2) - pos2(2)) < maxDistanceZ)
107 if (pos1(2) > pos2(2))