资源简介
Full Coverage Path Planning,简单实现,往复式的单区域路径规划
代码片段和文件信息
#!/usr/bin/python
# -----------
#
# ----------
import numpy as np
import math
import matplotlib.pyplot as plt
import sys pygame
from pygame.locals import *
rows = 10
columns = 10
rows_space = 40
columns_space = 40
# Grid specs
WIDTH = 5
ROWS = 20
COLUMNS = 20
SQUARE_SIDE = 30
EXT_GRID = SQUARE_SIDE * ROWS
GRID_THICK = 1
SCREEN_SIDE = SQUARE_SIDE * ROWS
SCREEN_OFFSET = 20
SCREEN_SIZE = (ROWS * (SQUARE_SIDE) + 2 * SCREEN_OFFSET COLUMNS * (SQUARE_SIDE) + 2 * SCREEN_OFFSET)
# COLORS
green = 0 255 0
red = 255 0 0
blue = 0 0 255
white = 255 255 255
# 2 obstacles
# 0 free
# 1 free cleaned
grid = np.zeros([ROWS COLUMNS])
# OBSTACLES
# Fig. 5
‘‘‘
grid[4][5] = 2
grid[4][6] = 2
grid[4][7] = 2
grid[4][8] = 2
grid[4][9] = 2
grid[4][10] = 2
grid[4][11] = 2
grid[4][12] = 2
grid[4][13] = 2
grid[4][14] = 2
grid[4][15] = 2
grid[4][16] = 2
grid[4][17] = 2
grid[4][18] = 2
grid[4][19] = 2
‘‘‘
grid[4][5] = 2
grid[4][6] = 2
grid_shape = grid.shape
print
“ grid shape “ + str(grid.shape)
# print len(grid) # n = 5
# print len(grid[0]) # m = 6
# print grid[1][0]
# TODO: initial point heading
#
initial = [0 0]
init = [0 0]
goal = [len(grid) - 1 len(grid[0]) - 1]
cost = 1
delta = [[-1 0] # go up
[0 -1] # go left
[1 0] # go down
[0 1]] # go right
backtracking_list = []
class Node:
def __init__(self column row cost pind):
self.column = column
self.row = row
self.cost = cost
self.pind = pind # parent indice
def __str__(self):
return str(self.x) + ““ + str(self.y) + ““ + str(self.cost) + ““ + str(self.pind)
# def path(grid initial_point):
def verify(direction row column):
if direction == ‘north‘:
if row <= 0:
return False
elif grid[row - 1][column] == 1 or grid[row - 1][column] == 2:
return False
else:
return True
elif direction == ‘south‘:
if row >= (grid.shape[0] - 1):
return False
elif grid[row + 1][column] == 1 or grid[row + 1][column] == 2:
return False
else:
return True
elif direction == ‘west‘:
if column <= 0:
return False
elif grid[row][column - 1] == 1 or grid[row][column - 1] == 2:
return False
else:
return True
elif direction == ‘east‘:
if column >= (grid.shape[1] - 1):
return False
elif grid[row][column + 1] == 1 or grid[row][column + 1] == 2:
return False
else:
return True
def valid_cell(grid row column):
“““ Verify is the cell is valid. “““
if (row < grid.shape[0] and row >= 0) and (column < grid.shape[1] and column >= 0):
return True
else:
return False
def backtracking_points(grid row
相关资源
- python实现SGBM图像匹配算法
- python实现灰度直方图均衡化
- scrapy_qunar_one
- Python学习全系列教程永久可用
- python简明教程.chm
- 抽奖大转盘python的图形化界面
- 双边滤波器实验报告及代码python
- python +MYSQL+HTML实现21蛋糕网上商城
- Python-直播答题助手自动检测出题搜索
- OpenCV入门教程+OpenCV官方教程中文版
- Python 串口工具源码+.exe文件
- Python开发的全栈股票系统.zip
- Python操作Excel表格并将其中部分数据写
- python书籍 PDF
- 利用python绘制散点图
- python+labview+No1.vi
- 老男孩python项目实战
- python源码制作whl文件.rar
- python3.5可用的scipy
- PYTHON3 经典50案例.pptx
- 计算机科学导论-python.pdf
- python模拟鼠标点击屏幕
- windows鼠标自动点击py脚本
- 鱼c小甲鱼零基础学python全套课后题和
- Python 练习题100道
- Practical Programming 2nd Edition
- wxPython Application Development Cookbook
- python 3.6
- Python 3.5.2 中文文档 互联网唯一CHM版本
- python3.5.2.chm官方文档
评论
共有 条评论