当前位置: 首页>>代码示例>>C++>>正文


C++ AbstractNode::getConnection方法代码示例

本文整理汇总了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;
}
开发者ID:CheHaoKang,项目名称:HumanoidRobotics,代码行数:45,代码来源:RRT.cpp


注:本文中的AbstractNode::getConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。