-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathframework_ogm.py
More file actions
46 lines (38 loc) · 1.18 KB
/
framework_ogm.py
File metadata and controls
46 lines (38 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import numpy as np
import matplotlib.pyplot as plt
import scipy.io as spio
from ogm import OGM
plot_movement = True
if __name__ == '__main__':
mat = spio.loadmat('state_meas_data.mat')
thk = mat['thk']
X = mat['X']
z = mat['z']
ogm = OGM(thk)
plt.figure(0)
plt.axis([0, 100, 0, 100])
plt.ion()
for i in range(X.shape[1]):
mes = z[:,:,i]
sta = X[:,i:i+1] - np.array([[1],[1],[0]])
ogm.update_map(sta,mes[0:1,:])
if plot_movement and i%25 == 0:
plt.figure(0)
plt.clf()
plt.axis([0, 100, 0, 100])
[[x],[y],[t]] = sta
plt.scatter(x, y)
plt.scatter(x + 0.5*np.cos(t), y + 0.5*np.sin(t), color='r')
for j in range(11):
r = mes[0,j]
b = mes[1,j]
# b = thk[0,j]
if not np.isnan(r):
plt.scatter(x + r*np.cos(t+b), y + r*np.sin(t+b), color='g')
plt.figure(1)
plt.imshow(1 - np.flip(ogm.get_map().T,0), cmap='gray')
plt.pause(0.00001)
plt.ioff()
plt.figure(1)
plt.imshow(1 - np.flip(ogm.get_map().T,0), cmap='gray')
plt.show()