當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。