Skip to content

Commit d25d15c

Browse files
authored
Fixed the sampling function
When creating a simple square of obstacles, the sampled points are not inside of it, if it is centered around (0, 0)
1 parent f0749b6 commit d25d15c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

PathPlanning/ProbabilisticRoadMap/probabilistic_road_map.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ def sample_points(sx, sy, gx, gy, rr, ox, oy, obkdtree):
249249
sample_x, sample_y = [], []
250250

251251
while len(sample_x) <= N_SAMPLE:
252-
tx = (random.random() - minx) * (maxx - minx)
253-
ty = (random.random() - miny) * (maxy - miny)
252+
tx = (random.random() * (maxx - minx)) + minx
253+
ty = (random.random() * (maxy - miny)) + miny
254254

255255
index, dist = obkdtree.search(np.array([tx, ty]).reshape(2, 1))
256256

0 commit comments

Comments
 (0)