本文整理汇总了C++中AbstractNode::getConnection方法的典型用法代码示例。如果您正苦于以下问题:C++ AbstractNode::getConnection方法的具体用法?C++ AbstractNode::getConnection怎么用?C++ AbstractNode::getConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AbstractNode
的用法示例。
在下文中一共展示了AbstractNode::getConnection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getRandomNode
/**
* \brief Plans a path on a grid map using RRT.
* \param[in] startNode The start node of the path.
* \param[in] goalNode The goal node where the path should end up.
* \param[in] map The occupancy grid map of the environment.
* \param[in] maxIterations The maximum number of iterations.
* \return The planned path, or an empty path in case the algorithm exceeds the maximum number of iterations.
*/
std::deque<AbstractNode *> RRT::planPath(AbstractNode * const startNode, AbstractNode * const goalNode, const GridMap& map, const size_t& maxIterations) {
std::deque<AbstractNode *> result;
std::vector<AbstractNode *> startList;
std::vector<AbstractNode *> goalList;
// Add the start and goal nodes to the corresponding lists:
startList.push_back(startNode);
goalList.push_back(goalNode);
/* TODO: Expand trees from both the start node and the goal node at the same time
* until they meet. When extendClosestNode() returns a connection node, then call
* constructPath() to find the complete path and return it. */
int iter = 0;
while(iter < maxIterations)
{
AbstractNode * Qrand;
Qrand = getRandomNode(map,startList,goalList.back() );
AbstractNode * Qclosest= getClosestNodeInList(Qrand,startList);
AbstractNode * Qconnection = extendClosestNode(Qrand,Qclosest,startList,map,goalList);
if (Qconnection->getConnection() !=goalNode) {
startList.push_back(Qconnection);
startList.swap(goalList);
iter++;
}
else {
result = constructPath(Qconnection,startNode,goalNode);
return result;
}
}
return result;
}