Reader.h
Go to the documentation of this file.
1/**
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @author Fabian Reister ( fabian dot reister at kit dot edu )
17 * @date 2021
18 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19 * GNU General Public License
20 */
21
22#pragma once
23
24#include <map>
25#include <optional>
26#include <ostream>
27#include <string>
28#include <vector>
29
34#include <RobotAPI/libraries/armem_locations/aron/Location.aron.generated.h>
35
38
40{
41
48
50 {
51 std::optional<ResolvedLocationName> resolved;
52 std::optional<std::string> errorMessage;
53 };
54
56 {
57 public:
59
60 std::string propertyPrefix() const override;
61 Properties defaultProperties() const override;
62
63 std::vector<core::Location> locations();
64
65 std::vector<armarx::navigation::core::Graph> graphs();
66
67 std::vector<core::Location> resolveLocation(const std::string& locationName,
68 const std::optional<std::string>& provider);
69
70
71 /**
72 * @brief Resolve a location by human-readable name.
73 *
74 * Queries location names from the navigation memory, matches the given name to the
75 * locations' names, and returns the ID of the location with the best match.
76 *
77 * @param locationName The human-readable name.
78 * @param minMatchRatio The minimum match ratio required to accept a match.
79 * @param log Optional out-stream for logging about the matching.
80 * @return Resolved location name or error message.
81 */
82 ResolveLocationNameResult resolveLocationName(const std::string& locationName,
83 double minMatchRatio,
84 std::ostream* log = nullptr);
85 /**
86 * @brief Resolve a location by human-readable name.
87 *
88 * Matches the given name to the locations' names, and returns the ID of the location with
89 * the best match.
90 *
91 * @param locations Locations, e.g. as returned by `Reader::queryLocations()`.
92 * @param locationName The human-readable name.
93 * @param minMatchRatio The minimum match ratio required to accept a match.
94 * @param log Optional out-stream for logging about the matching.
95 * @return Resolved location name or error message.
96 */
98 ResolveLocationName(const std::map<armem::MemoryID, location::arondto::Location>& locations,
99 const std::string& locationName,
100 double minMatchRatio,
101 std::ostream* log = nullptr);
102
104
105
106 protected:
107 std::map<armem::MemoryID, location::arondto::Location> queryLocations();
108
111
112 private:
113 armem::client::Reader memoryReaderLocations;
114 armem::client::Reader memoryReaderGraphs;
115 };
116
117} // namespace armarx::navigation::memory::client::graph
The memory name system (MNS) client.
Reads data from a memory server.
Definition Reader.h:25
Client-side working memory core segment.
std::vector< armarx::navigation::core::Graph > graphs()
Definition Reader.cpp:78
std::vector< core::Location > locations()
Definition Reader.cpp:53
std::map< armem::MemoryID, location::arondto::Location > queryLocations()
Definition Reader.cpp:170
std::string propertyPrefix() const override
Definition Reader.cpp:40
Properties defaultProperties() const override
Definition Reader.cpp:46
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.
Definition Reader.cpp:226
void connect(armarx::armem::client::MemoryNameSystem &mns) override
Definition Reader.cpp:281
std::vector< core::Location > resolveLocation(const std::string &locationName, const std::optional< std::string > &provider)
Definition Reader.cpp:210
ResolveLocationNameResult resolveLocationName(const std::string &locationName, double minMatchRatio, std::ostream *log=nullptr)
Resolve a location by human-readable name.
Definition Reader.cpp:217
This file is part of ArmarX.
Definition Reader.cpp:38