Go to the documentation of this file.
3 #include <SimoxUtility/algorithm/get_map_keys_values.h>
4 #include <SimoxUtility/algorithm/string/fuzzy_multi_match.hpp>
8 #include <RobotAPI/interface/armem/memory.h>
18 #include <armarx/navigation/core/aron/Graph.aron.generated.h>
19 #include <armarx/navigation/core/aron/Location.aron.generated.h>
28 return "mem.nav.graph.";
38 std::map<std::string, core::Location>
41 std::map<std::string, core::Location>
locations;
44 for (
const auto& [
id, location] : locs)
46 const std::string locationName =
id.providerSegmentName +
"/" +
id.entityName;
53 loc.
name = locationName;
60 std::vector<armarx::navigation::core::Graph>
65 std::map<armem::MemoryID, armarx::navigation::core::Graph>
graphs;
68 graphSegment.forEachEntity(
74 navigation::core::arondto::Graph aron;
75 aron.fromAron(instance->data());
76 fromAron(aron, graph);
84 for (
auto& [_, graph] :
graphs)
89 return simox::get_values(
graphs);
111 if (not qResult.success)
117 const auto& locSegment =
141 if (not qResult.success)
147 const auto& graphSegment =
152 std::map<armem::MemoryID, location::arondto::Location>
170 if (not qResult.success)
175 std::map<armem::MemoryID, location::arondto::Location>
locations;
177 const auto& locSegment =
179 locSegment.forEachEntity(
184 locations[entity.id()].fromAron(instance->data());
196 return locs.at(locationId);
201 double minMatchRatio,
210 const std::map<armem::MemoryID, location::arondto::Location>& locations,
211 const std::string& locationName,
212 double minMatchRatio,
215 std::map<armarx::armem::MemoryID, std::vector<std::string>> locationIdsToWords;
216 for (
const auto& [
id, location] :
locations)
218 if (location.names.has_value())
220 locationIdsToWords[id] = location.names->recognized;
222 locationIdsToWords[id].push_back(
id.entityName);
228 if (locationIdsToWords.empty())
230 std::stringstream msg;
231 msg <<
"Found no locations in core segment "
233 <<
"' could be matched against.";
239 auto match = log ? simox::alg::fuzzy_multi_match(locationName, locationIdsToWords, *log)
240 : simox::alg::fuzzy_multi_match(locationName, locationIdsToWords);
243 if (match->ratio < minMatchRatio)
245 std::stringstream msg;
246 msg <<
"Match ratio " << match->ratio <<
" of best match '" << *match->word
247 <<
"' (location ID " << match->option
248 <<
") is below the requested minimum match ratio (" << minMatchRatio <<
").";
256 .locationName = *match->word,
257 .matchRatio = match->ratio,
EntitySelector & all() override
const armem::MemoryID coreSegmentID
SnapshotSelector & latest()
void resolveLocations(Graph &graph, const MemoryContainerT &locationContainer)
EntitySelector & entities()
Start specifying entities.
ResolveLocationNameResult resolveLocationName(const std::string &locationName, double minMatchRatio, std::ostream *log=nullptr)
Resolve a location by human-readable name.
armem::wm::CoreSegment allLocations()
Client-side working entity instance.
static ResolveLocationNameResult ResolveLocationName(const std::map< armem::MemoryID, location::arondto::Location > &locations, const std::string &locationName, double minMatchRatio, std::ostream *log=nullptr)
Resolve a location by human-readable name.
QueryInput buildQueryInput() const
SnapshotSelector & snapshots()
Start specifying entity snapshots.
std::map< armem::MemoryID, location::arondto::Location > queryLocations()
std::string coreSegmentName
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
CoreSegmentSelector & coreSegments()
Start specifying core segments.
armarx::armem::MemoryID locationId
std::string propertyPrefix() const override
Client-side working memory core segment.
CoreSegmentSelector & withName(const std::string &name) override
Reader useReader(const MemoryID &memoryID)
Use a memory server and get a reader for it.
auto * findLatestInstance(int instanceIndex=0)
std::optional< ResolvedLocationName > resolved
This file is part of ArmarX.
void connect(armarx::armem::client::MemoryNameSystem &mns) override
std::map< std::string, core::Location > locations()
std::vector< armarx::navigation::core::Graph > graphs()
const std::string memoryName
armem::wm::CoreSegment allGraphs()
void fromAron(const arondto::PackagePath &dto, PackageFileLocation &bo)
The memory name system (MNS) client.
Properties defaultProperties() const override
Indicates that a query to the Memory Name System failed.
The query::Builder class provides a fluent-style specification of hierarchical queries.
const armem::MemoryID coreSegmentID
ProviderSegmentSelector & providerSegments()
Start specifying provider segments.
Client-side working memory entity.
core::Location resolveLocationId(const std::string &locationId)
std::optional< std::string > errorMessage
armarx::FramedPose framedPose
ProviderSegmentSelector & all() override
QueryResult query(const QueryInput &input) const
Perform a query.