32 #include <Inventor/nodes/SoNode.h>
35 #include <MemoryX/interface/components/PriorKnowledgeInterface.h>
36 #include <MemoryX/interface/components/CommonStorageInterface.h>
48 #include <VirtualRobot/Visualization/CoinVisualization/CoinVisualizationFactory.h>
49 #include <VirtualRobot/ManipulationObject.h>
56 this->priorKnowledgePrx = priorKnowledgePrx;
57 classesSegmentPrx = this->priorKnowledgePrx->getObjectClassesSegment();
58 databasePrx = this->priorKnowledgePrx->getCommonStorage();
64 catch (
const armarx::LocalException&)
72 std::unique_lock lock(mutexEntities);
73 this->classesSegmentPrx = other.classesSegmentPrx;
74 this->databasePrx = other.databasePrx;
75 this->memoryXController = other.memoryXController;
76 this->priorKnowledgePrx = other.priorKnowledgePrx;
77 this->fileManager = other.fileManager;
86 std::unique_lock lock(mutexEntities);
87 return classesSegmentPrx->getReadCollectionsNS();
92 std::vector<memoryx::ObjectClassPtr> classPtr;
93 std::unique_lock lock(mutexEntities);
97 memoryx::CollectionInterfacePrx collectionInterface = this->databasePrx->requestCollection(collection);
100 memoryx::EntityIdList ids = collectionInterface->findAllIds();
102 for (memoryx::EntityIdList::const_iterator it = ids.begin(); it != ids.end(); ++it)
106 const memoryx::EntityBasePtr entity = classesSegmentPrx->getEntityById(*it);
111 classPtr.push_back(objClass);
115 catch (
const memoryx::DBNotSpecifiedException&)
126 std::unique_lock lock(mutexEntities);
127 std::vector<memoryx::ObjectClassPtr> objectClasses = this->getAllObjectClassesPtr(collection);
129 if (!objectClasses.empty())
135 if (ptr->getName() == className)
147 std::unique_lock lock(mutexEntities);
152 VirtualRobot::VisualizationNodePtr visNode;
153 bool hasModel =
true;
157 VirtualRobot::CollisionModelPtr collisionModel = simoxWrapper->getCollisionModel();
165 visNode = collisionModel->getVisualization();
170 visNode = simoxWrapper->getVisualization();
178 return VirtualRobot::CoinVisualizationFactory::getCoinVisualization(visNode);
183 std::unique_lock lock(mutexEntities);
184 std::map<std::string, std::string> allAttributes;
188 return allAttributes;
191 memoryx::NameList attributeNames = objectClass->getAttributeNames();
195 for (memoryx::NameList::const_iterator it = attributeNames.begin(); it != attributeNames.end(); ++it)
197 memoryx::EntityAttributeBasePtr attrValue = objectClass->getAttribute(*it);
198 armarx::VariantPtr attributeValue = armarx::VariantPtr::dynamicCast(attrValue->getValue());
200 if (attributeValue && (attributeValue->getOutputValueOnly() !=
""))
202 if (*it ==
"ManipulationFile")
204 allAttributes.insert(std::pair<std::string, std::string>(*it, simoxWrapper->getManipulationObjectFileName()));
206 else if (*it ==
"IvFile" || *it ==
"IvFileCollision" || *it ==
"texFiles")
211 std::string maniPath = simoxWrapper->getManipulationObjectFileName();
213 const memoryx::GridFileInterfacePrx prx = databasePrx->getFileProxyById(mongoPtr->dbName, mongoPtr->docId);
216 ARMARX_WARNING_S <<
"Could not find IvFile of objectClass " << objectClass->getName() <<
VAROUT(mongoPtr->dbName) <<
VAROUT(mongoPtr->docId);
217 allAttributes.insert(std::pair<std::string, std::string>(*it,
""));
221 std::string ivFilePath = maniPath.substr(0, maniPath.rfind(
"/") + 1) + prx->getFilename();
223 allAttributes.insert(std::pair<std::string, std::string>(*it, ivFilePath));
225 catch (
const armarx::InvalidTypeException&)
227 ARMARX_WARNING_S <<
"Could not find IvFile of objectClass " << objectClass->getName();
228 allAttributes.insert(std::pair<std::string, std::string>(*it,
""));
231 else if (*it ==
"featureFile")
234 allAttributes.insert(std::pair<std::string, std::string>(*it, texturedRecognitionWrapper->getFeatureFile()));
238 allAttributes.insert(std::pair<std::string, std::string>(*it, attributeValue->getOutputValueOnly()));
243 allAttributes.insert(std::pair<std::string, std::string>(*it,
""));
247 return allAttributes;
252 std::unique_lock lock(mutexEntities);
254 memoryx::NameList collectionNames = this->getCollectionNames();
255 std::map<memoryx::ObjectClassPtr, std::string> possibleObjectClasses;
256 std::string className = objectInstance->getMostProbableClass();
258 for (std::vector<std::string>::const_iterator it = collectionNames.begin(); it != collectionNames.end(); ++it)
264 possibleObjectClasses.insert(std::pair<memoryx::ObjectClassPtr, std::string>(ptr, *it));
268 if (possibleObjectClasses.size() > 1)
273 return possibleObjectClasses.begin()->second;
275 else if (possibleObjectClasses.size() == 1)
277 return possibleObjectClasses.begin()->second;