当前位置: 首页>>代码示例>>Python>>正文


Python OccupancyGrid.data[j+(width*i)]方法代码示例

本文整理汇总了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
开发者ID:jbmorse,项目名称:catkin_ws,代码行数:48,代码来源:ObstacleExpansion.py


注:本文中的nav_msgs.msg.OccupancyGrid.data[j+(width*i)]方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。