diff --git a/source/armarx/navigation/components/NavigationMemory/NavigationMemory.cpp b/source/armarx/navigation/components/NavigationMemory/NavigationMemory.cpp index e5eabda3ed298843e7df3ea23976d951f27c705d..9f70d948505d35446be2adac8f404c08467d0f9e 100644 --- a/source/armarx/navigation/components/NavigationMemory/NavigationMemory.cpp +++ b/source/armarx/navigation/components/NavigationMemory/NavigationMemory.cpp @@ -529,11 +529,11 @@ namespace armarx::navigation for (const auto& [memoryId, location] : locations) { - auto& j = js[memoryId.coreSegmentName]; + auto& j = js[memoryId.providerSegmentName]; if (j.count("locations") == 0) { - j["locations"] = nlohmann::json::array(); + j["locations"] = {}; } nlohmann::json jLoc; @@ -554,7 +554,7 @@ namespace armarx::navigation jLoc["relativeToObject"] = "null"; } - j["locations"].push_back(jLoc); + j["locations"][memoryId.getEntityID().str()] = jLoc; } // save to disk @@ -562,7 +562,11 @@ namespace armarx::navigation { const std::filesystem::path subDir = std::filesystem::path(providerId); const std::filesystem::path dir = baseDirectory / subDir; - std::filesystem::create_directories(dir); + + if(not std::filesystem::exists(dir)) + { + std::filesystem::create_directories(dir); + } const std::filesystem::path filename = dir / "locations.json"; ARMARX_VERBOSE << "Saving file `" << filename << "`.";