29 #include <MemoryX/interface/components/LongtermMemoryInterface.h>
30 #include <MemoryX/interface/components/WorkingMemoryInterface.h>
31 #include <MemoryX/interface/core/EntityBase.h>
43 #include <SimoxUtility/algorithm/string/string_tools.h>
46 LONGTERM_SNAPSHOT_PREFIX(
"Snapshot_")
52 if (this->workingMemoryController && this->workingMemoryController->getArmarXManager())
54 this->workingMemoryController->getArmarXManager()->removeObjectBlocking(this->workingMemoryController);
59 const memoryx::WorkingMemoryInterfacePrx& workingMemoryPrx,
60 const std::string& workingMemoryUpdatesTopic,
61 const std::string& objectInstancesSegmentName,
62 const memoryx::LongtermMemoryInterfacePrx& longtermMemoryPrx,
65 this->mainController = mainController;
67 workingMemoryController =
new WorkingMemoryController(workingMemoryPrx, workingMemoryUpdatesTopic, objectInstancesSegmentName, mainController->getMemoryXController());
68 this->longtermMemoryPrx = longtermMemoryPrx;
73 if (snapshotName.empty())
80 snapshotName = std::string(LONGTERM_SNAPSHOT_PREFIX) + snapshotName;
83 bool worked = this->workingMemoryController->saveSceneInSnapshot(snapshotName, this->longtermMemoryPrx);
90 if (snapshotName.empty())
97 snapshotName = std::string(LONGTERM_SNAPSHOT_PREFIX) + snapshotName;
100 bool worked = this->workingMemoryController->saveObjectsInSnapshot(snapshotName, this->longtermMemoryPrx, objectIds);
107 std::vector<std::string> addedIds;
109 if (!snapshotName.empty())
113 memoryx::WorkingMemorySnapshotInterfacePrx snapshot = longtermMemoryPrx->getWorkingMemorySnapshotListSegment()->openSnapshot(snapshotName);
114 memoryx::PersistentEntitySegmentBasePrx segObjects = snapshot->getSegment(
"objectInstances");
116 std::vector<memoryx::ObjectInstancePtr> objectInstances;
120 memoryx::EntityIdList ids = segObjects->getAllEntityIds();
122 for (memoryx::EntityIdList::const_iterator it = ids.begin(); it != ids.end(); ++it)
125 objectInstances.push_back(objectInstance);
129 addedIds = this->workingMemoryController->addObjectInstances(objectInstances);
131 catch (
const armarx::LocalException& e)
133 std::cout <<
"SnapshotName could not be loaded: " << snapshotName << std::endl;
142 return workingMemoryController;
147 return priorKnowledgeController;
152 return mainController.lock();
157 return longtermMemoryPrx->getSnapshotNames();