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)
This commit is contained in:
AfroDisco
2019-05-22 14:19:29 +02:00
committed by GitHub
parent f0749b6150
commit d25d15ccc7

View File

@@ -249,8 +249,8 @@ def sample_points(sx, sy, gx, gy, rr, ox, oy, obkdtree):
sample_x, sample_y = [], []
while len(sample_x) <= N_SAMPLE:
tx = (random.random() - minx) * (maxx - minx)
ty = (random.random() - miny) * (maxy - miny)
tx = (random.random() * (maxx - minx)) + minx
ty = (random.random() * (maxy - miny)) + miny
index, dist = obkdtree.search(np.array([tx, ty]).reshape(2, 1))