Go to the documentation of this file.
    9 #include <SimoxUtility/algorithm/get_map_keys_values.h> 
   10 #include <SimoxUtility/algorithm/string/fuzzy_multi_match.hpp> 
   23 #include <RobotAPI/libraries/armem_locations/aron/Location.aron.generated.h> 
   28 #include <armarx/navigation/core/aron/Graph.aron.generated.h> 
   38         return "mem.nav.graph.";
 
   48     std::map<std::string, core::Location>
 
   51         std::map<std::string, core::Location> 
locations;
 
   54         for (
const auto& [
id, location] : locs)
 
   56             const std::string locationName = 
id.providerSegmentName + 
"/" + 
id.entityName;
 
   63             loc.
name = locationName;
 
   70     std::vector<armarx::navigation::core::Graph>
 
   75         std::map<armem::MemoryID, armarx::navigation::core::Graph> 
graphs;
 
   78         graphSegment.forEachEntity(
 
   84                     navigation::core::arondto::Graph aron;
 
   85                     aron.fromAron(instance->data());
 
   86                     fromAron(aron, graph);
 
   94         for (
auto& [_, graph] : 
graphs)
 
   99         return simox::get_values(
graphs);
 
  121         if (not qResult.success)
 
  127         const auto& locSegment =
 
  151         if (not qResult.success)
 
  157         const auto& graphSegment =
 
  162     std::map<armem::MemoryID, location::arondto::Location>
 
  180         if (not qResult.success)
 
  185         std::map<armem::MemoryID, location::arondto::Location> 
locations;
 
  187         const auto& locSegment =
 
  189         locSegment.forEachEntity(
 
  194                     locations[entity.id()].fromAron(instance->data());
 
  207         ARMARX_CHECK(locs.count(locationId) > 0) << 
"Location `" << locationId << 
"` unknown!";
 
  209         return locs.at(locationId);
 
  214                                 double minMatchRatio,
 
  223         const std::map<armem::MemoryID, location::arondto::Location>& locations,
 
  224         const std::string& locationName,
 
  225         double minMatchRatio,
 
  228         std::map<armarx::armem::MemoryID, std::vector<std::string>> locationIdsToWords;
 
  229         for (
const auto& [
id, location] : 
locations)
 
  231             if (location.names.has_value())
 
  233                 locationIdsToWords[id] = location.names->recognized;
 
  235             locationIdsToWords[id].push_back(
id.entityName);
 
  241         if (locationIdsToWords.empty())
 
  243             std::stringstream msg;
 
  244             msg << 
"Found no locations in core segment " 
  246                 << 
"' could be matched against.";
 
  252         auto match = log ? simox::alg::fuzzy_multi_match(locationName, locationIdsToWords, *log)
 
  253                          : simox::alg::fuzzy_multi_match(locationName, locationIdsToWords);
 
  256         if (match->ratio < minMatchRatio)
 
  258             std::stringstream msg;
 
  259             msg << 
"Match ratio " << match->ratio << 
" of best match '" << *match->word
 
  260                 << 
"' (location ID " << match->option
 
  261                 << 
") is below the requested minimum match ratio (" << minMatchRatio << 
").";
 
  269             .locationName = *match->word,
 
  270             .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 on the WM.