29 #include <SimoxUtility/algorithm/string/string_tools.h>
39 #include <MemoryX/interface/components/LongtermMemoryInterface.h>
40 #include <MemoryX/interface/components/WorkingMemoryInterface.h>
41 #include <MemoryX/interface/core/EntityBase.h>
50 if (this->workingMemoryController && this->workingMemoryController->getArmarXManager())
52 this->workingMemoryController->getArmarXManager()->removeObjectBlocking(
53 this->workingMemoryController);
59 const memoryx::PriorKnowledgeInterfacePrx& priorKnowledgePrx,
60 const memoryx::WorkingMemoryInterfacePrx& workingMemoryPrx,
61 const std::string& workingMemoryUpdatesTopic,
62 const std::string& objectInstancesSegmentName,
63 const memoryx::LongtermMemoryInterfacePrx& longtermMemoryPrx,
66 this->mainController = mainController;
69 workingMemoryUpdatesTopic,
70 objectInstancesSegmentName,
71 mainController->getMemoryXController());
72 this->longtermMemoryPrx = longtermMemoryPrx;
78 if (snapshotName.empty())
85 snapshotName = std::string(LONGTERM_SNAPSHOT_PREFIX) + snapshotName;
89 this->workingMemoryController->saveSceneInSnapshot(snapshotName, this->longtermMemoryPrx);
96 std::string& snapshotName,
97 const std::vector<std::string>& objectIds)
99 if (snapshotName.empty())
106 snapshotName = std::string(LONGTERM_SNAPSHOT_PREFIX) + snapshotName;
109 bool worked = this->workingMemoryController->saveObjectsInSnapshot(
110 snapshotName, this->longtermMemoryPrx, objectIds);
115 std::vector<std::string>
118 std::vector<std::string> addedIds;
120 if (!snapshotName.empty())
124 memoryx::WorkingMemorySnapshotInterfacePrx snapshot =
125 longtermMemoryPrx->getWorkingMemorySnapshotListSegment()->openSnapshot(
127 memoryx::PersistentEntitySegmentBasePrx segObjects =
128 snapshot->getSegment(
"objectInstances");
130 std::vector<memoryx::ObjectInstancePtr> objectInstances;
134 memoryx::EntityIdList ids = segObjects->getAllEntityIds();
136 for (memoryx::EntityIdList::const_iterator it = ids.begin(); it != ids.end(); ++it)
139 memoryx::ObjectInstancePtr::dynamicCast(segObjects->getEntityById(*it));
140 objectInstances.push_back(objectInstance);
144 addedIds = this->workingMemoryController->addObjectInstances(objectInstances);
146 catch (
const armarx::LocalException& e)
148 std::cout <<
"SnapshotName could not be loaded: " << snapshotName << std::endl;
158 return workingMemoryController;
161 std::shared_ptr<memoryxcontroller::PriorKnowledgeController>
164 return priorKnowledgeController;
170 return mainController.lock();
173 std::vector<std::string>
176 return longtermMemoryPrx->getSnapshotNames();