3 #include <SimoxUtility/algorithm/string.h>
14 LocationLoader::LoadFramedLocation(
const std::string&
source,
15 const std::string& locationName,
16 const nlohmann::json& j)
20 const auto framedPose = j.at(
"framedPose").get<std::map<std::string, nlohmann::json>>();
22 std::string frame = framedPose.at(
"frame");
23 std::string agent = framedPose.at(
"agent");
31 ARMARX_WARNING <<
"Got empty frame for location '" + locationName +
37 ARMARX_WARNING <<
"Got empty frame for location '" + locationName +
38 "'. Sanitizing it to 'root' because "
47 ARMARX_WARNING <<
"Got an empty agent name but a set frame '" + frame +
48 "' for location '" + locationName +
49 "'. This may lead to problems...";
56 framedPose.at(
"pose").get<std::vector<std::vector<float>>>());
58 std::optional<Names>
names;
59 if (
auto it = j.find(
"names"); it != j.end())
61 it->get_to(
names.emplace());
74 LocationLoader::LoadBoxedLocation(
const std::string&
source,
75 const std::string& locationName,
76 const nlohmann::json& j)
80 const auto framedOrientedBox =
81 j.at(
"framedOrientedBox").get<std::map<std::string, nlohmann::json>>();
83 std::string frame = framedOrientedBox.at(
"frame");
84 std::string agent = framedOrientedBox.at(
"agent");
86 Eigen::Vector3f extents;
93 ARMARX_WARNING <<
"Got empty frame for location '" + locationName +
99 ARMARX_WARNING <<
"Got empty frame for location '" + locationName +
100 "'. Sanitizing it to 'root' because "
102 agent +
"' was set.";
109 ARMARX_WARNING <<
"Got an empty agent name but a set frame '" + frame +
110 "' for location '" + locationName +
111 "'. This may lead to problems...";
118 framedOrientedBox.at(
"pose")
119 .get<std::vector<std::vector<float>>>());
124 framedOrientedBox.at(
"extents").get<std::vector<float>>());
126 std::optional<Names>
names;
127 if (
auto it = j.find(
"names"); it != j.end())
129 it->get_to(
names.emplace());
142 std::vector<LocationPtr>
144 const nlohmann::json& js)
146 std::vector<LocationPtr>
ret;
147 if (not js.contains(
"locations"))
150 <<
"The locations file has the wrong structure. Missing key 'locations'.";
154 for (
const auto& [locationName, j] :
155 js.at(
"locations").get<std::map<std::string, nlohmann::json>>())
157 if (j.find(
"framedPose") != j.end())
159 ret.push_back(LocationLoader::LoadFramedLocation(
source, locationName, j));
161 else if (j.find(
"framedOrientedBox") != j.end())
163 ret.push_back(LocationLoader::LoadBoxedLocation(
source, locationName, j));
168 <<
"The element '" << locationName
169 <<
"' has no 'framedPose' member or no 'framedOrientedBox' member. Skipping "