Skip to content
Snippets Groups Projects
Commit c2850ac7 authored by Valerij Wittenbeck's avatar Valerij Wittenbeck
Browse files

MovePlatformToLandmark - added some error checking

parent 4c3d740c
No related branches found
No related tags found
No related merge requests found
...@@ -108,36 +108,6 @@ namespace armarx ...@@ -108,36 +108,6 @@ namespace armarx
void StateCalculatePath::onEnter() void StateCalculatePath::onEnter()
{ {
ARMARX_LOG << eVERBOSE << "Entering StateCalculatePath"; ARMARX_LOG << eVERBOSE << "Entering StateCalculatePath";
// std::string targetLandmark = getInput<std::string>("targetLandmark");
// SingleTypeVariantListPtr landmarkTags = getInput<SingleTypeVariantList>("landmarkTags");
// int targetIndex = -1;
// for (int i = 0; i < landmarkTags->getSize(); i++) {
// if (landmarkTags->getVariant(i)->getString() == targetLandmark) {
// targetIndex = i;
// break;
// }
// }
// SingleTypeVariantList targetPositions(VariantType::Vector3);
// if (targetIndex >= 0) {
// Vector3Ptr v = getInput<SingleTypeVariantList>("landmarkPositions")->getVariant(targetIndex)->get<Vector3>();
// Vector3 vv;
// vv.x = v->x;
// vv.y = v->y;
// vv.z = v->z;
// ARMARX_LOG << eVERBOSE << vv.x << " " << vv.y << " " << vv.z << flush;
// targetPositions.addVariant(Variant(vv));
//// targetPositions.addVariant(v);
// sendEvent<EvPathFound>();
// } else {
// ARMARX_LOG << eWARN << "Could not map from landmark tag to target position(s)";
// sendEvent<EvNoPathFound>();
// }
// setOutput("targetPositions", targetPositions);
//read the nodes into a tag to node map //read the nodes into a tag to node map
SingleTypeVariantListPtr landmarkNodes = getInput<SingleTypeVariantList>("landmarkNodes"); SingleTypeVariantListPtr landmarkNodes = getInput<SingleTypeVariantList>("landmarkNodes");
...@@ -192,23 +162,28 @@ namespace armarx ...@@ -192,23 +162,28 @@ namespace armarx
std::string landmark = getInput<std::string>("targetLandmark"); std::string landmark = getInput<std::string>("targetLandmark");
NodePtr goal = nameToNodeMap[landmark]; NodePtr goal = nameToNodeMap[landmark];
if (!goal) {
ARMARX_LOG << eWARN << "Target landmark doesn't exist in graph" << flush;
sendEvent<EvNoPathFound>();
return;
}
std::list<NodePtr> path = aStar(closest, goal); std::list<NodePtr> path = aStar(closest, goal);
SingleTypeVariantList targetPositions(VariantType::Vector3);
if (path.empty()) { if (path.empty()) {
ARMARX_LOG << eWARN << "No path found"; ARMARX_LOG << eWARN << "No path found" << flush;
sendEvent<EvNoPathFound>(); sendEvent<EvNoPathFound>();
} else { return;
const float goalAlpha = path.back()->framedPos->z; }
for (std::list<NodePtr>::iterator it = path.begin(); it != path.end(); it++) { SingleTypeVariantList targetPositions(VariantType::Vector3);
Vector3 v; const float goalAlpha = path.back()->framedPos->z;
v.x = (*it)->framedPos->x; for (std::list<NodePtr>::iterator it = path.begin(); it != path.end(); it++) {
v.y = (*it)->framedPos->y; Vector3 v;
v.z = goalAlpha; v.x = (*it)->framedPos->x;
targetPositions.addVariant(v); v.y = (*it)->framedPos->y;
} v.z = goalAlpha;
sendEvent<EvPathFound>(); targetPositions.addVariant(v);
setOutput("targetPositions", targetPositions);
} }
setOutput("targetPositions", targetPositions);
sendEvent<EvPathFound>();
ARMARX_LOG << eVERBOSE << "StateCalculatePath: Done onEnter()" << flush; ARMARX_LOG << eVERBOSE << "StateCalculatePath: Done onEnter()" << flush;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment