From d25d15ccc7539e9ad98ca42373b53b2c7af2f15d Mon Sep 17 00:00:00 2001 From: AfroDisco Date: Wed, 22 May 2019 14:19:29 +0200 Subject: [PATCH] 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) --- PathPlanning/ProbabilisticRoadMap/probabilistic_road_map.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PathPlanning/ProbabilisticRoadMap/probabilistic_road_map.py b/PathPlanning/ProbabilisticRoadMap/probabilistic_road_map.py index d42592a0..65a56097 100644 --- a/PathPlanning/ProbabilisticRoadMap/probabilistic_road_map.py +++ b/PathPlanning/ProbabilisticRoadMap/probabilistic_road_map.py @@ -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))