11#include <SimoxUtility/algorithm/get_map_keys_values.h>
12#include <SimoxUtility/algorithm/string/fuzzy_multi_match.hpp>
25#include <RobotAPI/libraries/armem_locations/aron/Location.aron.generated.h>
30#include <armarx/navigation/core/aron/Graph.aron.generated.h>
35#include <range/v3/range/conversion.hpp>
42 return "mem.nav.graph.";
52 std::vector<core::Location>
58 for (
const auto& [
id,
location] : locs)
60 const std::string locationName =
id.entityName;
67 .provider =
id.providerSegmentName,
77 std::vector<armarx::navigation::core::Graph>
82 std::map<armem::MemoryID, armarx::navigation::core::Graph>
graphs;
85 graphSegment.forEachEntity(
91 navigation::core::arondto::Graph
aron;
92 aron.fromAron(instance->data());
106 return simox::get_values(
graphs);
134 const auto& locSegment =
164 const auto& graphSegment =
169 std::map<armem::MemoryID, location::arondto::Location>
192 std::map<armem::MemoryID, location::arondto::Location>
locations;
194 const auto& locSegment =
196 locSegment.forEachEntity(
209 std::vector<core::Location>
211 const std::optional<std::string>& provider)
218 double minMatchRatio,
227 const std::map<armem::MemoryID, location::arondto::Location>&
locations,
228 const std::string& locationName,
229 double minMatchRatio,
232 std::map<armarx::armem::MemoryID, std::vector<std::string>> locationIdsToWords;
237 locationIdsToWords[id] =
location.names->recognized;
239 locationIdsToWords[id].push_back(
id.entityName);
245 if (locationIdsToWords.empty())
247 std::stringstream msg;
248 msg <<
"Found no locations in core segment "
250 <<
"' could be matched against.";
256 auto match = log ? simox::alg::fuzzy_multi_match(locationName, locationIdsToWords, *log)
257 : simox::alg::fuzzy_multi_match(locationName, locationIdsToWords);
260 if (match->ratio < minMatchRatio)
262 std::stringstream msg;
263 msg <<
"Match ratio " << match->ratio <<
" of best match '" << *match->word
264 <<
"' (location ID " << match->option
265 <<
") is below the requested minimum match ratio (" << minMatchRatio <<
").";
272 .locationId = *match->option,
273 .locationName = *match->word,
274 .matchRatio = match->ratio,
293 memoryReaderGraphs = mns.useReader(
297 memoryReaderLocations = mns.useReader(
auto * findLatestInstance(int instanceIndex=0)
CoreSegmentT & getCoreSegment(const std::string &name)
The memory name system (MNS) client.
The query::Builder class provides a fluent-style specification of hierarchical queries.
QueryInput buildQueryInput() const
CoreSegmentSelector & coreSegments()
Start specifying core segments.
CoreSegmentSelector & withName(const std::string &name) override
ProviderSegmentSelector & providerSegments()
Start specifying provider segments.
EntitySelector & all() override
SnapshotSelector & snapshots()
Start specifying entity snapshots.
EntitySelector & entities()
Start specifying entities.
ProviderSegmentSelector & all() override
SnapshotSelector & latest()
Indicates that a query to the Memory Name System failed.
Client-side working memory core segment.
Client-side working entity instance.
Client-side working memory entity.
std::vector< armarx::navigation::core::Graph > graphs()
std::vector< core::Location > locations()
std::map< armem::MemoryID, location::arondto::Location > queryLocations()
std::string propertyPrefix() const override
Properties defaultProperties() const override
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.
void connect(armarx::armem::client::MemoryNameSystem &mns) override
armem::wm::CoreSegment allGraphs()
std::vector< core::Location > resolveLocation(const std::string &locationName, const std::optional< std::string > &provider)
armem::wm::CoreSegment allLocations()
ResolveLocationNameResult resolveLocationName(const std::string &locationName, double minMatchRatio, std::ostream *log=nullptr)
Resolve a location by human-readable name.
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
#define ARMARX_INFO
The normal logging level.
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
#define ARMARX_VERBOSE
The logging level for verbose information.
std::vector< core::Location > findMatchingLocations(const std::vector< core::Location > &locations, const std::string &locationName, const std::optional< std::string > &provider)
void resolveLocations(Graph &graph, const MemoryContainerT &locationContainer)
const armem::MemoryID coreSegmentID
This file is part of ArmarX.
const armem::MemoryID coreSegmentID
This file is part of ArmarX.
void fromAron(const arondto::Circle &dto, Circle &bo)
void fromAron(const arondto::PackagePath &dto, PackageFileLocation &bo)
wm::Memory memory
The slice of the memory that matched the query.
std::optional< std::string > errorMessage
std::optional< ResolvedLocationName > resolved