Skip to content
Snippets Groups Projects
Commit d3d65518 authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Add snapshot loading

parent 727b04ca
No related branches found
No related tags found
1 merge request!2Location graph editor
This commit is part of merge request !2. Comments created here will be created in the context of that merge request.
...@@ -35,7 +35,11 @@ ...@@ -35,7 +35,11 @@
#include <RobotAPI/libraries/armem/server/query_proc/ltm.h> #include <RobotAPI/libraries/armem/server/query_proc/ltm.h>
#include <RobotAPI/libraries/armem/client/query.h> #include <RobotAPI/libraries/armem/client/query.h>
#include <RobotAPI/libraries/armem/core/operations.h> #include <RobotAPI/libraries/armem/core/operations.h>
#include <ArmarXCore/core/time/CycleUtil.h> #include <ArmarXCore/core/time/CycleUtil.h>
#include <ArmarXCore/core/system/ArmarXDataPath.h>
#include <filesystem>
namespace armarx::nav namespace armarx::nav
...@@ -58,6 +62,10 @@ namespace armarx::nav ...@@ -58,6 +62,10 @@ namespace armarx::nav
workingMemory().name() = "Navigation"; workingMemory().name() = "Navigation";
def->optional(properties.snapshotToLoad, "p.snapshotToLoad",
"Memory snapshot to load at start up \n"
"(e.g. 'PriorKnowledgeData/navigation-graphs/snapshot').");
def->optional(properties.locationGraph.visuLocations, "p.locationGraph.visuLocation", def->optional(properties.locationGraph.visuLocations, "p.locationGraph.visuLocation",
"Enable visualization of locations."); "Enable visualization of locations.");
def->optional(properties.locationGraph.visuGraphEdges, "p.locationGraph.visuGraphEdges", def->optional(properties.locationGraph.visuGraphEdges, "p.locationGraph.visuGraphEdges",
...@@ -69,6 +77,25 @@ namespace armarx::nav ...@@ -69,6 +77,25 @@ namespace armarx::nav
} }
std::optional<std::filesystem::path>
findSnapshotDirectory(const std::filesystem::path& specifiedPath, const std::string& memoryName)
{
std::vector<std::filesystem::path> candidates
{
specifiedPath,
specifiedPath / memoryName,
};
for (const auto& candidate : candidates)
{
if (candidate.filename() == memoryName and std::filesystem::is_directory(candidate))
{
return candidate;
}
}
return std::nullopt;
}
void void
NavigationMemory::onInitComponent() NavigationMemory::onInitComponent()
{ {
...@@ -98,6 +125,31 @@ namespace armarx::nav ...@@ -98,6 +125,31 @@ namespace armarx::nav
workingMemory().addCoreSegment(nav::graph::coreSegmentID.coreSegmentName, workingMemory().addCoreSegment(nav::graph::coreSegmentID.coreSegmentName,
nav::graph::arondto::Graph::toAronType()); nav::graph::arondto::Graph::toAronType());
if (not properties.snapshotToLoad.empty())
{
std::string resolved = ArmarXDataPath::resolvePath(properties.snapshotToLoad);
if (auto path = findSnapshotDirectory(resolved, workingMemory().name()))
{
const std::string key = path->filename();
armem::server::ltm::disk::MemoryManager manager;
manager.setName(key);
manager.setBasePath(path.value());
manager.reload();
armem::client::QueryBuilder builder;
builder.all();
armem::client::QueryInput queryInput = builder.buildQueryInput();
queryInput.addQueryTargetToAll(armem::query::data::QueryTarget::LTM);
armem::server::query_proc::ltm::MemoryQueryProcessor processor;
armem::wm::Memory memory = processor.process(queryInput.toIce(), manager.getCacheAndLutNotConverted());
manager.convert(memory);
ARMARX_INFO << "Loaded " << armem::print(memory);
workingMemory().update(armem::toCommit(memory));
}
}
} }
......
...@@ -95,6 +95,7 @@ namespace armarx::nav ...@@ -95,6 +95,7 @@ namespace armarx::nav
/// Properties shown in the Scenario GUI. /// Properties shown in the Scenario GUI.
struct Properties struct Properties
{ {
std::string snapshotToLoad = "";
struct LocationGraph struct LocationGraph
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment