Skip to content
Snippets Groups Projects
Commit b638760f authored by Fabian Tërnava's avatar Fabian Tërnava
Browse files

support new import in memory for prior data

parent f69b8bc2
No related branches found
No related tags found
1 merge request!16support new import in memory for prior data
......@@ -178,7 +178,69 @@ namespace armarx::navigation
if (std::filesystem::is_directory(graph))
{
// TODO:
armem::Commit c;
armem::MemoryID providerID = workingMemory().id();
providerID.coreSegmentName = "Graph";
providerID.providerSegmentName = providerName;
for (const auto& graphdir : std::filesystem::directory_iterator(graph))
{
const std::filesystem::path singleGraph = graphdir.path();
if (std::filesystem::is_directory(singleGraph))
{
navigation::core::arondto::Graph g;
for (const auto& subdir : std::filesystem::directory_iterator(singleGraph))
{
const std::filesystem::path vertice = subdir.path();
if (std::filesystem::is_regular_file(vertice))
{
std::ifstream ifs(vertice);
const std::string content((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
// parse graph
nlohmann::json j = nlohmann::json::parse(content);
std::string location = j["location"];
int id = std::stoi(vertice.filename());
auto split = simox::alg::split(location, "/");
ARMARX_CHECK_EQUAL(split.size(), 4);
armarx::navigation::core::arondto::Vertex v;
v.vertexID = id;
v.locationID.memoryName = split[0];
v.locationID.coreSegmentName = split[1];
v.locationID.providerSegmentName = split[2];
v.locationID.entityName = split[3];
v.locationID.timestamp = armem::Time::microSeconds(-1);
v.locationID.instanceIndex = 0;
g.vertices.push_back(v);
// load edges
std::vector<float> edges = j.at("outgoingEdges");
for (const auto edge_id : edges)
{
armarx::navigation::core::arondto::Edge e;
e.sourceVertexID = id;
e.targetVertexID = edge_id;
g.edges.push_back(e);
}
}
}
auto& up = c.add();
up.confidence = 1.0;
up.timeCreated = armem::Time::now();
up.timeSent = armem::Time::now();
up.timeArrived = armem::Time::now();
up.entityID = providerID.withEntityName(singleGraph.filename().string());
up.instancesData = {g.toAron()};
}
}
iceAdapter().commit(c);
}
// NOT WORKING since the ARON default export json changed
......
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