|
|
The longterm memory is a segmented memory and provides methods to store the current WorkingMemory into a snapshot and to fill the WorkingMemory with previously stored snapshots.
The working memory is a SegmentedMemory, which means that the data is organized in segments. By default there are the following segments available:
Following properties are supported:
See List of Application & Component Properties for an overview of properties.
An exemplary application can be found in the applications/SimoxSceneImporter folder of the MemoryX sources.
The following code snippet shows how to save the current content of the WorkingMemory as a snapshot to the LongtermMemory.
void LongtermMemoryExample::onConnectComponent()
{
// ...
WorkingMemoryInterfacePrx memoryPrx = getProxy<WorkingMemoryInterfacePrx>("WorkingMemory");
LongtermMemoryInterfacePrx longtermMemoryPrx = getProxy<LongtermMemoryInterfacePrx>("LongtermMemory");
// now the working memory can be filled
// e.g.
ObjectInstanceMemorySegmentBasePrx objectInstancesMemoryPrx = memoryPrx->getObjectInstancesSegment();
ObjectInstanceBasePtr object = new ObjectInstance("myObject");
Eigen::Vector3f pos;
pos << 100.0f , 0 , 0;
FramedPositionBasePtr entityPos = new FramedPosition(pos, "");
object->setPosition(entityPos);
objectInstancesMemoryPrx->addEntity(object);
// get snapshot name from property definition
const std::string snapshotName = getProperty<std::string>("SnapshotName").getValue();
if (!snapshotName.empty())
{
// save snapshot
longtermMemoryPrx->saveWorkingMemorySnapshot(snapshotName, memoryPrx);
ARMARX_INFO << "Snapshot succcessfully stored: " << snapshotName << flush;
}
else
ARMARX_ERROR << "SnapshotName parameter must be specified!" << flush;
// ...
}