日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python无人机路径规划算法_RRT算法在Python中的实现,快速,拓展,随机,树

發布時間:2025/3/8 python 51 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python无人机路径规划算法_RRT算法在Python中的实现,快速,拓展,随机,树 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

"""

《基于智能優化與RRT算法的無人機任務規劃方法研究》博士論文

《基于改進人工勢場法的路徑規劃算法研究》碩士論文

"""

import matplotlib.pyplot as plt

import random

import math

import copy

show_animation = True

class Node(object):

"""

RRT Node

"""

def __init__(self, x, y):

self.x = x

self.y = y

self.parent = None

class RRT(object):

"""

Class for RRT Planning

"""

def __init__(self, start, goal, obstacle_list, rand_area):

"""

Setting Parameter

start:Start Position [x,y]

goal:Goal Position [x,y]

obstacleList:obstacle Positions [[x,y,size],...]

randArea:random sampling Area [min,max]

"""

self.start = Node(start[0], start[1])

self.end = Node(goal[0], goal[1])

self.min_rand = rand_area[0]

self.max_rand = rand_area[1]

self.expandDis = 1.0

self.goalSampleRate = 0.05 # 選擇終點的概率是0.05

self.maxIter = 500

self.obstacleList = obstacle_list

self.nodeList = [self.start]

def random_node(self):

"""

產生隨機節點

:return:

"""

node_x = random.uniform(self.min_rand, self.max_rand)

node_y = random.uniform(self.min_rand, self.max_rand)

node = [node_x, node_y]

return node

@staticmethod

def get_nearest_list_index(node_list, rnd):

"""

:param node_list:

:param rnd:

:return:

"""

d_list = [(node.x - rnd[0]) ** 2 + (node.y - rnd[1]) ** 2 for node in node_list]

min_index = d_list.index(min(d_list))

return min_index

@staticmethod

def collision_check(new_node, obstacle_list):

a = 1

for (ox, oy, size) in obstacle_list:

dx = ox - new_node.x

dy = oy - new_node.y

d = math.sqrt(dx * dx + dy * dy)

if d <= size:

a = 0 # collision

return a # safe

def planning(self):

"""

Path planning

animation: flag for animation on or off

"""

while True:

# Random Sampling

if random.random() > self.goalSampleRate:

rnd = self.random_node()

else:

rnd = [self.end.x, self.end.y]

# Find nearest node

min_index = self.get_nearest_list_index(self.nodeList, rnd)

# print(min_index)

# expand tree

nearest_node = self.nodeList[min_index]

# 返回弧度制

theta = math.atan2(rnd[1] - nearest_node.y, rnd[0] - nearest_node.x)

new_node = copy.deepcopy(nearest_node)

new_node.x += self.expandDis * math.cos(theta)

new_node.y += self.expandDis * math.sin(theta)

new_node.parent = min_index

if not self.collision_check(new_node, self.obstacleList):

continue

self.nodeList.append(new_node)

# check goal

dx = new_node.x - self.end.x

dy = new_node.y - self.end.y

d = math.sqrt(dx * dx + dy * dy)

if d <= self.expandDis:

print("Goal!!")

break

if True:

self.draw_graph(rnd)

path = [[self.end.x, self.end.y]]

last_index = len(self.nodeList) - 1

while self.nodeList[last_index].parent is not None:

node = self.nodeList[last_index]

path.append([node.x, node.y])

last_index = node.parent

path.append([self.start.x, self.start.y])

return path

def draw_graph(self, rnd=None):

"""

Draw Graph

"""

print('aaa')

plt.clf() # 清除上次畫的圖

if rnd is not None:

plt.plot(rnd[0], rnd[1], "^g")

for node in self.nodeList:

if node.parent is not None:

plt.plot([node.x, self.nodeList[node.parent].x], [

node.y, self.nodeList[node.parent].y], "-g")

for (ox, oy, size) in self.obstacleList:

plt.plot(ox, oy, "sk", ms=10*size)

plt.plot(self.start.x, self.start.y, "^r")

plt.plot(self.end.x, self.end.y, "^b")

plt.axis([self.min_rand, self.max_rand, self.min_rand, self.max_rand])

plt.grid(True)

plt.pause(0.01)

def draw_static(self, path):

"""

畫出靜態圖像

:return:

"""

plt.clf() # 清除上次畫的圖

for node in self.nodeList:

if node.parent is not None:

plt.plot([node.x, self.nodeList[node.parent].x], [

node.y, self.nodeList[node.parent].y], "-g")

for (ox, oy, size) in self.obstacleList:

plt.plot(ox, oy, "sk", ms=10*size)

plt.plot(self.start.x, self.start.y, "^r")

plt.plot(self.end.x, self.end.y, "^b")

plt.axis([self.min_rand, self.max_rand, self.min_rand, self.max_rand])

plt.plot([data[0] for data in path], [data[1] for data in path], '-r')

plt.grid(True)

plt.show()

def main():

print("start RRT path planning")

obstacle_list = [

(5, 1, 1),

(3, 6, 2),

(3, 8, 2),

(1, 1, 2),

(3, 5, 2),

(9, 5, 2)]

# Set Initial parameters

rrt = RRT(start=[0, 0], goal=[8, 9], rand_area=[-2, 10], obstacle_list=obstacle_list)

path = rrt.planning()

print(path)

# Draw final path

if show_animation:

plt.close()

rrt.draw_static(path)

if __name__ == '__main__':

main()

總結

以上是生活随笔為你收集整理的python无人机路径规划算法_RRT算法在Python中的实现,快速,拓展,随机,树的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 久久久久久亚洲av无码专区 | 中文人妻av久久人妻18 | 日韩a级片| 性xxxx另类xxⅹ | 成人视品 | 97超碰资源站 | 性色av无码久久一区二区三区 | 丁香婷婷六月天 | 久久久久久久久久一区 | 日韩久久影视 | 久久久久免费精品 | 精品国产一 | 欧美a免费 | 中文字幕一区二区三区人妻四季 | 在线看亚洲 | 少女视频的播放方法 | 中文字幕乱码亚洲精品一区 | 成人动漫免费观看 | 99热偷拍| av观看免费在线 | 亚洲黄色网页 | 成人做爰免费视频免费看 | 色呦呦一区二区三区 | 自拍1区| 毛片一级视频 | 精品无码久久久久久久久果冻 | 另类小说婷婷 | 亚洲偷自 | 日韩精品电影在线 | 91丨九色丨蝌蚪丨老版 | 2022av视频 | 国产成人无码精品久在线观看 | 国产九九精品 | 中文字幕永久在线观看 | 免费看成人| 在线观看中文字幕一区二区 | 一级不卡毛片 | 瑟瑟综合网| 国产一区二区三区久久 | 天天干天天操av | 麻豆国产一区二区 | 精品人妻大屁股白浆无码 | 91精品免费 | 蜜桃精品视频在线 | 欧美黄色一级片视频 | 欧美熟妇精品一区二区蜜桃视频 | 日产精品久久久一区二区 | 中文字幕av网 | 樱井莉亚av| 日本黄色不卡 | 国产精品久久久久久亚洲色 | 欧美精品第一页 | 亚洲艹 | 亚洲精品粉嫩小泬 | 99自拍网 | 男人舔女人下部高潮全视频 | 亚洲国产精品毛片av不卡在线 | 欧美一区在线观看视频 | 高潮一区二区三区乱码 | 亚洲av乱码一区二区 | 重口另类| 久草福利免费 | 欧美精品一卡二卡 | 国产视频综合在线 | 国产精成人品免费观看 | 亚洲精品中文无码AV在线播放 | 欧美日韩中文字幕在线视频 | 亚洲一区偷拍 | 影音先锋日韩资源 | 99热免费精品 | 欧美黄片一区二区三区 | 成人综合在线观看 | 午夜aa| 一区二区精品视频在线观看 | 亚洲黄色小说视频 | 人人妻人人澡人人爽欧美一区 | 2018天天干天天操 | 修女也疯狂3免费观看完整版 | 色片免费看 | 日本黄色片网址 | 黄色91免费观看 | 国产精品久久久久久久久久久久久久久 | 国产小视频免费在线观看 | 激情91 | 日本美女影院 | 精品中文字幕在线播放 | 麻豆传媒网站在线观看 | 亚洲精品av中文字幕在线在线 | 免费观看高清在线 | 日韩一区二区三区在线播放 | 日韩有码第一页 | 精品亚洲永久免费 | 天天色成人网 | 国产高清视频免费 | 爱插美女网 | 精品肉丝脚一区二区三区 | 2一3sex性hd| 美国特色黄a大片 | 在线观看国产日韩 |