Skip to content

Commit 4dbf642

Browse files
committed
remove np.matrix
1 parent bfc785c commit 4dbf642

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

PathPlanning/DynamicWindowApproach/dynamic_window_approach.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,17 @@ def main():
172172
# goal position [x(m), y(m)]
173173
goal = np.array([10, 10])
174174
# obstacles [x(m) y(m), ....]
175-
ob = np.matrix([[-1, -1],
176-
[0, 2],
177-
[4.0, 2.0],
178-
[5.0, 4.0],
179-
[5.0, 5.0],
180-
[5.0, 6.0],
181-
[5.0, 9.0],
182-
[8.0, 9.0],
183-
[7.0, 9.0],
184-
[12.0, 12.0]
185-
])
175+
ob = np.array([[-1, -1],
176+
[0, 2],
177+
[4.0, 2.0],
178+
[5.0, 4.0],
179+
[5.0, 5.0],
180+
[5.0, 6.0],
181+
[5.0, 9.0],
182+
[8.0, 9.0],
183+
[7.0, 9.0],
184+
[12.0, 12.0]
185+
])
186186

187187
u = np.array([0.0, 0.0])
188188
config = Config()

PathPlanning/ProbabilisticRoadMap/probabilistic_road_map.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ def is_collision(sx, sy, gx, gy, rr, okdtree):
106106
nstep = round(d / D)
107107

108108
for i in range(nstep):
109-
idxs, dist = okdtree.search(np.matrix([x, y]).T)
109+
idxs, dist = okdtree.search(np.array([x, y]).reshape(2, 1))
110110
if dist[0] <= rr:
111111
return True # collision
112112
x += D * math.cos(yaw)
113113
y += D * math.sin(yaw)
114114

115115
# goal point check
116-
idxs, dist = okdtree.search(np.matrix([gx, gy]).T)
116+
idxs, dist = okdtree.search(np.array([gx, gy]).reshape(2, 1))
117117
if dist[0] <= rr:
118118
return True # collision
119119

@@ -137,8 +137,8 @@ def generate_roadmap(sample_x, sample_y, rr, obkdtree):
137137
for (i, ix, iy) in zip(range(nsample), sample_x, sample_y):
138138

139139
index, dists = skdtree.search(
140-
np.matrix([ix, iy]).T, k=nsample)
141-
inds = index[0][0]
140+
np.array([ix, iy]).reshape(2, 1), k=nsample)
141+
inds = index[0]
142142
edge_id = []
143143
# print(index)
144144

@@ -252,7 +252,7 @@ def sample_points(sx, sy, gx, gy, rr, ox, oy, obkdtree):
252252
tx = (random.random() - minx) * (maxx - minx)
253253
ty = (random.random() - miny) * (maxy - miny)
254254

255-
index, dist = obkdtree.search(np.matrix([tx, ty]).T)
255+
index, dist = obkdtree.search(np.array([tx, ty]).reshape(2, 1))
256256

257257
if dist[0] >= rr:
258258
sample_x.append(tx)

PathPlanning/StateLatticePlanner/state_lattice_planner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def generate_path(target_states, k0):
5454
state[0], state[1], state[2], lookup_table)
5555

5656
target = motion_model.State(x=state[0], y=state[1], yaw=state[2])
57-
init_p = np.matrix(
58-
[math.sqrt(state[0] ** 2 + state[1] ** 2), bestp[4], bestp[5]]).T
57+
init_p = np.array(
58+
[math.sqrt(state[0] ** 2 + state[1] ** 2), bestp[4], bestp[5]]).reshape(3, 1)
5959

6060
x, y, yaw, p = planner.optimize_trajectory(target, k0, init_p)
6161

0 commit comments

Comments
 (0)