Skip to content

Commit d7fe083

Browse files
committed
remove np.matrix from histogram_filter.py
1 parent c9a9e48 commit d7fe083

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

Localization/histogram_filter/histogram_filter.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,23 +94,23 @@ def observation_update(gmap, z, std):
9494
def calc_input():
9595
v = 1.0 # [m/s]
9696
yawrate = 0.1 # [rad/s]
97-
u = np.matrix([v, yawrate]).T
97+
u = np.array([v, yawrate]).reshape(2, 1)
9898
return u
9999

100100

101101
def motion_model(x, u):
102102

103-
F = np.matrix([[1.0, 0, 0, 0],
104-
[0, 1.0, 0, 0],
105-
[0, 0, 1.0, 0],
106-
[0, 0, 0, 0]])
103+
F = np.array([[1.0, 0, 0, 0],
104+
[0, 1.0, 0, 0],
105+
[0, 0, 1.0, 0],
106+
[0, 0, 0, 0]])
107107

108-
B = np.matrix([[DT * math.cos(x[2, 0]), 0],
109-
[DT * math.sin(x[2, 0]), 0],
110-
[0.0, DT],
111-
[1.0, 0.0]])
108+
B = np.array([[DT * math.cos(x[2, 0]), 0],
109+
[DT * math.sin(x[2, 0]), 0],
110+
[0.0, DT],
111+
[1.0, 0.0]])
112112

113-
x = F * x + B * u
113+
x = F @ x + B @ u
114114

115115
return x
116116

@@ -125,7 +125,7 @@ def observation(xTrue, u, RFID):
125125

126126
xTrue = motion_model(xTrue, u)
127127

128-
z = np.matrix(np.zeros((0, 3)))
128+
z = np.zeros((0, 3))
129129

130130
for i in range(len(RFID[:, 0])):
131131

@@ -135,7 +135,7 @@ def observation(xTrue, u, RFID):
135135
if d <= MAX_RANGE:
136136
# add noise to range observation
137137
dn = d + np.random.randn() * NOISE_RANGE
138-
zi = np.matrix([dn, RFID[i, 0], RFID[i, 1]])
138+
zi = np.array([dn, RFID[i, 0], RFID[i, 1]])
139139
z = np.vstack((z, zi))
140140

141141
# add noise to speed
@@ -225,7 +225,7 @@ def main():
225225

226226
time = 0.0
227227

228-
xTrue = np.matrix(np.zeros((4, 1)))
228+
xTrue = np.zeros((4, 1))
229229
gmap = init_gmap(XY_RESO, MINX, MINY, MAXX, MAXY)
230230
mx, my = calc_grid_index(gmap) # for grid map visualization
231231

0 commit comments

Comments
 (0)