navigation
nav_core
navigation包里有一个nav_core,是一个纯粹的接口package,里面规定了核心的几个类应该有基本功能。BaseGlobalPlanner
是全局导航的接口,规定一个功能函数makePlan
,给定起始跟目标,输出路径(一系列pose)走过去;BaseLocalPlanner规定了一个核心函数computeVelocityCommands
,就是计算局部地图内的下一步控制指令(线速度,角速度);还有一个RecoveryBehavior
,规定一个runBehavior
,在小车卡住情况下执行运动恢复,回到正常的导航状态。
global_planner
在nav_core的global_planner中的继承关系:
可以知道在nav_core的接口上,又提供了carrot_planner::CarrotPlanner,navfn::NavfnROS
,这里介绍的是global_planner::GlobalPlanner
的实现。
在全局规划中,提供了例如A star和Dijstra算法;提供处理规划之后的路径的类型的算法。
expander规定了calculatePotentials的接口,根据costmap跟起始终止点计算网格的potential。关于算法,D..就不看了,A*的算法思想如下:
A* Algorithm
cost // the cost of every grid in the map
potential // the cost of every grid from the start node
OPEN // the set of nodes to be evaluated
CLOSED // the set of nodes already evaluated
add the start node to OPEN
loop
current = node in OPEN with the lowest f_cost // from cost list
remove current from OPEN
add current to CLOSED
if current is the target node // path has been found
return
foreach neighbor of the current node
if neighbour is not traversable or neighbor is