Skip to content

Commit 3952b9c

Browse files
committed
add figure
1 parent 1732e8d commit 3952b9c

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Mapping/grid_map/grid_map.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,49 @@
66
77
"""
88

9+
import numpy as np
10+
import matplotlib.pyplot as plt
11+
12+
AREA_WIDTH = 30.0
13+
14+
15+
def generate_ray_casting_grid_map(ox, oy, reso):
16+
17+
minx = min(ox) - AREA_WIDTH / 2.0
18+
miny = min(oy) - AREA_WIDTH / 2.0
19+
maxx = max(ox) + AREA_WIDTH / 2.0
20+
maxy = max(oy) + AREA_WIDTH / 2.0
21+
xw = round((maxx - minx) / reso)
22+
yw = round((maxy - miny) / reso)
23+
24+
# calc each potential
25+
pmap = [[0.0 for i in range(yw)] for i in range(xw)]
26+
27+
for ix in range(xw):
28+
x = ix * reso + minx
29+
30+
for iy in range(yw):
31+
y = iy * reso + miny
32+
pmap[ix][iy] = x + y
33+
34+
draw_heatmap(pmap)
35+
plt.show()
36+
37+
38+
def draw_heatmap(data):
39+
data = np.array(data).T
40+
plt.pcolor(data, vmax=100.0, cmap=plt.cm.Blues)
41+
942

1043
def main():
1144
print(__file__ + " start!!")
1245

46+
ox = [0.0]
47+
oy = [0.0]
48+
reso = 1.0
49+
50+
generate_ray_casting_grid_map(ox, oy, reso)
51+
1352

1453
if __name__ == '__main__':
1554
main()

0 commit comments

Comments
 (0)