AffordanceLoader.cpp
Go to the documentation of this file.
1 #include "AffordanceLoader.h"
2 
5 
7 {
8  std::vector<StaticAffordance>
9  AffordanceLoader::LoadAffordances(const std::string& source, const nlohmann::json& js)
10  {
11  std::vector<StaticAffordance> ret;
12  if (not js.contains("affordances"))
13  {
14  ARMARX_WARNING << "The affordances file has the wrong structure. Missing key "
15  "'affordances'.";
16  return ret;
17  }
18 
19  for (const auto& affordance : js["affordances"].get<std::vector<std::string>>())
20  {
21  StaticAffordance a{{source, affordance}};
22  ret.push_back(a);
23  }
24  return ret;
25  }
26 
27  std::vector<LocationAffordance>
28  AffordanceLoader::LoadLocationAffordances(const std::string& source, const nlohmann::json& js)
29  {
30  std::vector<LocationAffordance> ret;
31  if (not js.contains("location_affordances"))
32  {
33  ARMARX_WARNING << "The affordances file has the wrong structure. Missing key "
34  "'location_affordances'.";
35  return ret;
36  }
37 
38  for (const auto& [locationName, affordances] :
39  js["location_affordances"].get<std::map<std::string, std::vector<std::string>>>())
40  {
41  for (const auto& affordance : affordances)
42  {
43  LocationAffordance a{{source, affordance}, locationName};
44  ret.push_back(a);
45  }
46  }
47  return ret;
48  }
49 } // namespace armarx::priorknowledge::util
armarx::priorknowledge::util::AffordanceLoader::LoadLocationAffordances
static std::vector< LocationAffordance > LoadLocationAffordances(const std::string &sourceId, const nlohmann::json &)
Definition: AffordanceLoader.cpp:28
armarx::aron::ret
ReaderT::InputType T & ret
Definition: rw.h:21
armarx::priorknowledge::util::LocationAffordance
Definition: Affordance.h:20
ice_conversions.h
armarx::ctrlutil::a
double a(double t, double a0, double j)
Definition: CtrlUtil.h:45
boost::source
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:681
armarx::priorknowledge::util::StaticAffordance
Definition: Affordance.h:15
armarx::priorknowledge::util::AffordanceLoader::LoadAffordances
static std::vector< StaticAffordance > LoadAffordances(const std::string &sourceId, const nlohmann::json &)
Definition: AffordanceLoader.cpp:9
Logging.h
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
armarx::priorknowledge::util
Definition: AffordanceLoader.cpp:6
AffordanceLoader.h