路径规划------RRT*算法
算法原理
RRT Star 算法是一种渐近最优的路径规划算法,它是 RRT 算法的优化版本。RRT Star 算法通过不断地迭代和优化,最终可以得到一条从起点到目标点的最优路径。
在学习RRT Star 算法之前最好先学习一下RRT原始算法:RRT算法
与RRT 算法相比,RRT Star 算法的主要不同之处在于它对已构建的路径进行优化,以提高搜索效率和精度。RRT Star算法与RRT算法的区别主要在于重新选择父节点和重新布线两个方面。
1.重新选择父节点过程
在新产生的节点node_new附近以定义的半径范围内寻找"近邻",作为替换父节点的备选。依次计算"近邻"节点到起点的路径代价加上到每个"近邻"的路径代价,具体过程如下图:

在上图中的这种情况下,以节点4作为node_new节点的父节点时路径代价是最小的,因此当前随机树的结构无需改动。
如果是下图的情况:
此时,以节点6作为node_new节点的父节点时的路径代价是最小的,因此进行随机树结构改动为如下图所示:

2.重新布线过程
在为node_new节点重新选择父节点后,为了进一步使随机树节点间的代价尽量小,为随机树重新布线。如果"近邻节点"的父节点改为node_new节点可以减小路径代价,则进行更改。如下图所示:

原来的路径情况:

将近邻节点的父节点改为node_new节点后的路径情况:

可以发现将节点6和8的父节点改为node_new后路径代价大于原来的路径代价,因此不需要改变节点6和8的父节点。
而对于节点4和7,将其父节点改为node_new后路径代价小于原来的路径代价,因此需要将节点4和7的父节点改为node_new,则新生成的随机树如下图所示:

这两部分的实现代码:
python
for node_n in node_list:
new_dist = self.distance(node_n,node_new)
if new_dist < self.search_r and not self.isCollision(node_n, node_new):
cost = node_n.cost + new_dist
if node_new.cost > cost:
# find who is the best parent of node_new
node_new.parent = node_n.position
node_new.cost = cost
else:
cost = node_new.cost + new_dist
if node_n.cost > cost:
# find whose best parent is node_new
node_n.parent = node_new.position
node_n.cost = cost
else:
continue
