本文整理汇总了Python中nav_msgs.msg.OccupancyGrid.data[j+(width*i)]方法的典型用法代码示例。如果您正苦于以下问题:Python OccupancyGrid.data[j+(width*i)]方法的具体用法?Python OccupancyGrid.data[j+(width*i)]怎么用?Python OccupancyGrid.data[j+(width*i)]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nav_msgs.msg.OccupancyGrid
的用法示例。
在下文中一共展示了OccupancyGrid.data[j+(width*i)]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ExpandMap
# 需要导入模块: from nav_msgs.msg import OccupancyGrid [as 别名]
# 或者: from nav_msgs.msg.OccupancyGrid import data[j+(width*i)] [as 别名]
def ExpandMap(occupancyGrid):
lowerResGrid = OccupancyGrid(occupancyGrid.header, occupancyGrid.info, [])
oldWidth = occupancyGrid.info.width
lowerResGrid.info.resolution = .1
lowerResGrid.info.width = int(math.floor(float(occupancyGrid.info.width)/2))
lowerResGrid.info.height = int(math.floor(float(occupancyGrid.info.height)/2))
width = lowerResGrid.info.width
height = lowerResGrid.info.height
lowerResGrid.data = [-1]*width*height
for i in range (0, height):
for j in range (0, width):
if occupancyGrid.data[(j*2) + (oldWidth * i*2)] >= 1 or \
occupancyGrid.data[(j*2) + (oldWidth * ((i*2)+1))] >= 1 or \
occupancyGrid.data[(j*2)+1 + (oldWidth * i*2)] >= 1 or \
occupancyGrid.data[(j*2)+1 + (oldWidth * ((i*2)+1))] >= 1:
lowerResGrid.data[j + (width * i)] = 100
elif occupancyGrid.data[(j*2) + (oldWidth * i*2)] == 0 and \
occupancyGrid.data[(j*2) + (oldWidth * ((i*2)+1))] == 0 and \
occupancyGrid.data[(j*2)+1 + (oldWidth * i*2)] == 0 and \
occupancyGrid.data[(j*2)+1 + (oldWidth * ((i*2)+1))] == 0:
lowerResGrid.data[j + (width * i)] = 0
else:
lowerResGrid.data[j + (width * i)] = -1
expandedGrid = OccupancyGrid(lowerResGrid.header, lowerResGrid.info, lowerResGrid.data)
expandedData = list(lowerResGrid.data)
print "expanding"
for i in range (0, height):
for j in range (0, width):
if (lowerResGrid.data[j + (width * i)] >= 1):
for k in range (j - 2, j + 3):
for l in range (i - 2, i + 3):
if (k > 0 and k < width and l > 0 and l < height):
expandedData[k + (width * l)] = 100
expandedGrid.data = tuple(expandedData)
print "expanded"
return expandedGrid, lowerResGrid