30 #include <VirtualRobot/MathTools.h>
36 #include <RobotAPI/libraries/armem_locations/aron/Location.aron.generated.h>
54 auto poseMatToLandmarkPose =
58 VirtualRobot::MathTools::eigen4f2rpy(poseMat, rpy);
59 const float goalYaw = rpy[2];
62 ARMARX_INFO <<
"Landmark: '" << landmarkName <<
"' => position: ["
63 << goalPose->toEigen().transpose() <<
"]";
68 auto lookupLandmarkNamesWithNavigationMemory =
69 [
this, poseMatToLandmarkPose, context](
const std::string& sceneName,
70 const std::vector<std::string>& landmarkNames,
71 std::map<std::string, Vector3Ptr>& outPoseMap,
72 std::vector<Vector3Ptr>& outPoseList) ->
bool
81 ARMARX_INFO <<
"Got " << locations.size() <<
" locations";
83 std::vector<std::string> locationNames;
84 for (
const auto& [n, l] : locations)
87 locationNames.push_back(n);
90 for (
const std::string& landmarkName : landmarkNames)
92 const std::string landmarkMemoryName = sceneName +
"/" + landmarkName;
93 if (locations.count(landmarkMemoryName) == 0)
96 ss <<
"Could not find location with name '" << landmarkMemoryName
97 <<
"'. Available are: ";
98 for (
const auto& location : locations)
100 ss <<
"'" << location.first <<
"', \n";
105 auto location = locations.at(landmarkMemoryName);
107 poseMatToLandmarkPose(location.framedPose.pose, landmarkName);
108 outPoseMap[landmarkName] = landmarkPose;
109 outPoseList.push_back(landmarkPose);
116 const std::string sceneName = in.getSceneName();
119 std::vector<std::string> landmarkNames;
120 if (in.isLandmarkNamesSet())
122 landmarkNames = in.getLandmarkNames();
126 landmarkNames = {in.getLandmarkName()};
129 ARMARX_INFO <<
"landmark names: " << landmarkNames;
131 std::map<std::string, Vector3Ptr> poseMap;
132 std::vector<Vector3Ptr> poseList;
137 ARMARX_INFO <<
"Calling function lookupLandmarkNamesWithNavigationMemory()";
138 success = lookupLandmarkNamesWithNavigationMemory(
139 sceneName, landmarkNames, poseMap, poseList);
140 ARMARX_INFO <<
"Calling function lookupLandmarkNamesWithNavigationMemory() Success? "
147 auto graphSegment = priorKnowledge->getGraphSegment();
149 auto resolveLandmark = [
this, sceneName, poseMatToLandmarkPose](
150 ::memoryx::GraphMemorySegmentBasePrx graphSegment,
151 const std::string& landmarkName) ->
Vector3Ptr
153 if (!graphSegment->hasNodeWithName(sceneName, landmarkName))
156 <<
"' doesn't exist in graph " << sceneName;
157 auto nodes = graphSegment->getNodesByScene(sceneName);
158 for (
auto& node : nodes)
165 auto node = graphSegment->getNodeFromSceneByName(sceneName, landmarkName);
169 PosePtr pose = PosePtr::dynamicCast(node->getPose());
174 Vector3Ptr goalPose = poseMatToLandmarkPose(poseMat, landmarkName);
180 for (
const std::string& landmarkName : landmarkNames)
182 Vector3Ptr pose = resolveLandmark(graphSegment, landmarkName);
185 poseMap[landmarkName] = pose;
186 poseList.push_back(pose);
197 if (in.isLandmarkNamesSet())
201 out.setLandmarkPoseMap(poseMap);
202 out.setLandmarkPoseList(poseList);
208 out.setlandmarkPosition(poseList.front());