59 auto poseMatToLandmarkPose =
60 [
this](Eigen::Matrix4f poseMat,
const std::string& landmarkName)
63 VirtualRobot::MathTools::eigen4f2rpy(poseMat, rpy);
64 const float goalYaw = rpy[2];
67 ARMARX_INFO <<
"Landmark: '" << landmarkName <<
"' => position: ["
68 << goalPose->toEigen().transpose() <<
"]";
73 auto lookupLandmarkNamesWithNavigationMemory =
74 [
this, poseMatToLandmarkPose, context](
const std::string& sceneName,
75 const std::vector<std::string>& landmarkNames,
76 std::map<std::string, Vector3Ptr>& outPoseMap,
77 std::vector<Vector3Ptr>& outPoseList) ->
bool
82 mns.setComponent(getContext<armarx::PlatformContext>());
86 ARMARX_INFO <<
"Got " << locations.size() <<
" locations";
88 std::vector<std::string> locationNames;
89 for (
const auto& [n, l] : locations)
92 locationNames.push_back(n);
95 for (
const std::string& landmarkName : landmarkNames)
97 const std::string landmarkMemoryName = sceneName +
"/" + landmarkName;
98 if (locations.count(landmarkMemoryName) == 0)
100 std::stringstream ss;
101 ss <<
"Could not find location with name '" << landmarkMemoryName
102 <<
"'. Available are: ";
103 for (
const auto& location : locations)
105 ss <<
"'" << location.first <<
"', \n";
110 auto location = locations.at(landmarkMemoryName);
112 poseMatToLandmarkPose(location.framedPose.pose, landmarkName);
113 outPoseMap[landmarkName] = landmarkPose;
114 outPoseList.push_back(landmarkPose);
121 const std::string sceneName = in.getSceneName();
124 std::vector<std::string> landmarkNames;
125 if (in.isLandmarkNamesSet())
127 landmarkNames = in.getLandmarkNames();
131 landmarkNames = {in.getLandmarkName()};
134 ARMARX_INFO <<
"landmark names: " << landmarkNames;
136 std::map<std::string, Vector3Ptr> poseMap;
137 std::vector<Vector3Ptr> poseList;
142 ARMARX_INFO <<
"Calling function lookupLandmarkNamesWithNavigationMemory()";
143 success = lookupLandmarkNamesWithNavigationMemory(
144 sceneName, landmarkNames, poseMap, poseList);
145 ARMARX_INFO <<
"Calling function lookupLandmarkNamesWithNavigationMemory() Success? "
152 auto graphSegment = priorKnowledge->getGraphSegment();
154 auto resolveLandmark = [
this, sceneName, poseMatToLandmarkPose](
155 ::memoryx::GraphMemorySegmentBasePrx graphSegment,
156 const std::string& landmarkName) ->
Vector3Ptr
158 if (!graphSegment->hasNodeWithName(sceneName, landmarkName))
161 <<
"' doesn't exist in graph " << sceneName;
162 auto nodes = graphSegment->getNodesByScene(sceneName);
163 for (
auto& node : nodes)
170 auto node = graphSegment->getNodeFromSceneByName(sceneName, landmarkName);
174 PosePtr pose = PosePtr::dynamicCast(node->getPose());
178 Eigen::Matrix4f poseMat = pose->toEigen();
179 Vector3Ptr goalPose = poseMatToLandmarkPose(poseMat, landmarkName);
185 for (
const std::string& landmarkName : landmarkNames)
187 Vector3Ptr pose = resolveLandmark(graphSegment, landmarkName);
190 poseMap[landmarkName] = pose;
191 poseList.push_back(pose);
202 if (in.isLandmarkNamesSet())
206 out.setLandmarkPoseMap(poseMap);
207 out.setLandmarkPoseList(poseList);
213 out.setlandmarkPosition(poseList.front());