Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ def draw_graph(self, xCenter=None, cBest=None, cMin=None, eTheta=None,
plt.plot([start[0], start[1]], [end[0], end[1]], "-g")

for (ox, oy, size) in self.obstacleList:
plt.plot(ox, oy, "ok", ms=30 * size)
plt.gca().add_patch(plt.Circle((ox, oy), size, color="k"))

plt.plot(self.start[0], self.start[1], "xr")
plt.plot(self.goal[0], self.goal[1], "xr")
Expand Down
2 changes: 1 addition & 1 deletion PathPlanning/InformedRRTStar/informed_rrt_star.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def draw_graph(self, x_center=None, c_best=None, c_min=None, e_theta=None,
[node.y, self.node_list[node.parent].y], "-g")

for (ox, oy, size) in self.obstacle_list:
plt.plot(ox, oy, "ok", ms=30 * size)
plt.gca().add_patch(plt.Circle((ox, oy), size, color="k"))

plt.plot(self.start.x, self.start.y, "xr")
plt.plot(self.goal.x, self.goal.y, "xr")
Expand Down
2 changes: 1 addition & 1 deletion PathPlanning/LQRRRTStar/lqr_rrt_star.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def draw_graph(self, rnd=None):
plt.plot(node.path_x, node.path_y, "-g")

for (ox, oy, size) in self.obstacle_list:
plt.plot(ox, oy, "ok", ms=30 * size)
plt.gca().add_patch(plt.Circle((ox, oy), size, color="k"))

plt.plot(self.start.x, self.start.y, "xr")
plt.plot(self.end.x, self.end.y, "xr")
Expand Down
2 changes: 1 addition & 1 deletion PathPlanning/RRTDubins/rrt_dubins.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def draw_graph(self, rnd=None): # pragma: no cover
plt.plot(node.path_x, node.path_y, "-g")

for (ox, oy, size) in self.obstacle_list:
plt.plot(ox, oy, "ok", ms=30 * size)
plt.gca().add_patch(plt.Circle((ox, oy), size, color="k"))

plt.plot(self.start.x, self.start.y, "xr")
plt.plot(self.end.x, self.end.y, "xr")
Expand Down
2 changes: 1 addition & 1 deletion PathPlanning/RRTStarDubins/rrt_star_dubins.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def draw_graph(self, rnd=None):
plt.plot(node.path_x, node.path_y, "-g")

for (ox, oy, size) in self.obstacle_list:
plt.plot(ox, oy, "ok", ms=30 * size)
plt.gca().add_patch(plt.Circle((ox, oy), size, color="k"))

plt.plot(self.start.x, self.start.y, "xr")
plt.plot(self.end.x, self.end.y, "xr")
Expand Down
2 changes: 1 addition & 1 deletion PathPlanning/RRTStarReedsShepp/rrt_star_reeds_shepp.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def draw_graph(self, rnd=None):
plt.plot(node.path_x, node.path_y, "-g")

for (ox, oy, size) in self.obstacle_list:
plt.plot(ox, oy, "ok", ms=30 * size)
plt.gca().add_patch(plt.Circle((ox, oy), size, color="k"))

plt.plot(self.start.x, self.start.y, "xr")
plt.plot(self.end.x, self.end.y, "xr")
Expand Down
17 changes: 17 additions & 0 deletions tests/test_batch_informed_rrt_star.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,22 @@ def test_1():
m.main(maxIter=10)


def test_obstacles_are_drawn_with_their_radius_in_data_units(monkeypatch):
# Obstacles must be drawn as circles whose radius matches the
# collision radius, independent of the figure size (issue #1396).
monkeypatch.setattr(m.plt, "pause", lambda interval: None)
obstacle_list = [(5.0, 5.0, 1.0), (3.0, 6.0, 2.0)]
planner = m.BITStar(start=[0.0, 0.0], goal=[10.0, 10.0], obstacleList=obstacle_list, randArea=[-2.0, 15.0])

m.plt.figure(figsize=(12, 12))
planner.draw_graph(samples=[])

circles = [patch for patch in m.plt.gca().patches
if isinstance(patch, m.plt.Circle)]
m.plt.close("all")
assert [(circle.center, circle.radius) for circle in circles] == [
((ox, oy), size) for (ox, oy, size) in obstacle_list]


if __name__ == '__main__':
conftest.run_this_test(__file__)
18 changes: 18 additions & 0 deletions tests/test_informed_rrt_star.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,23 @@ def test1():
m.main()


def test_obstacles_are_drawn_with_their_radius_in_data_units(monkeypatch):
# Obstacles must be drawn as circles whose radius matches the
# collision radius, independent of the figure size (issue #1396).
monkeypatch.setattr(m.plt, "pause", lambda interval: None)
obstacle_list = [(5.0, 5.0, 1.0), (3.0, 6.0, 2.0)]
planner = m.InformedRRTStar([0.0, 0.0], [10.0, 10.0], obstacle_list, [-2.0, 15.0])
planner.node_list = [planner.start]

m.plt.figure(figsize=(12, 12))
planner.draw_graph()

circles = [patch for patch in m.plt.gca().patches
if isinstance(patch, m.plt.Circle)]
m.plt.close("all")
assert [(circle.center, circle.radius) for circle in circles] == [
((ox, oy), size) for (ox, oy, size) in obstacle_list]


if __name__ == '__main__':
conftest.run_this_test(__file__)
18 changes: 18 additions & 0 deletions tests/test_lqr_rrt_star.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,23 @@ def test1():
m.main(maxIter=5)


def test_obstacles_are_drawn_with_their_radius_in_data_units(monkeypatch):
# Obstacles must be drawn as circles whose radius matches the
# collision radius, independent of the figure size (issue #1396).
monkeypatch.setattr(m.plt, "pause", lambda interval: None)
obstacle_list = [(5.0, 5.0, 1.0), (3.0, 6.0, 2.0)]
planner = m.LQRRRTStar([0.0, 0.0], [10.0, 10.0], obstacle_list, [-2.0, 15.0])
planner.node_list = [planner.start]

m.plt.figure(figsize=(12, 12))
planner.draw_graph()

circles = [patch for patch in m.plt.gca().patches
if isinstance(patch, m.plt.Circle)]
m.plt.close("all")
assert [(circle.center, circle.radius) for circle in circles] == [
((ox, oy), size) for (ox, oy, size) in obstacle_list]


if __name__ == '__main__':
conftest.run_this_test(__file__)
18 changes: 18 additions & 0 deletions tests/test_rrt_dubins.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,23 @@ def test1():
m.main()


def test_obstacles_are_drawn_with_their_radius_in_data_units(monkeypatch):
# Obstacles must be drawn as circles whose radius matches the
# collision radius, independent of the figure size (issue #1396).
monkeypatch.setattr(m.plt, "pause", lambda interval: None)
obstacle_list = [(5.0, 5.0, 1.0), (3.0, 6.0, 2.0)]
planner = m.RRTDubins([0.0, 0.0, 0.0], [10.0, 10.0, 0.0], obstacle_list, [-2.0, 15.0])
planner.node_list = [planner.start]

m.plt.figure(figsize=(12, 12))
planner.draw_graph()

circles = [patch for patch in m.plt.gca().patches
if isinstance(patch, m.plt.Circle)]
m.plt.close("all")
assert [(circle.center, circle.radius) for circle in circles] == [
((ox, oy), size) for (ox, oy, size) in obstacle_list]


if __name__ == '__main__':
conftest.run_this_test(__file__)
18 changes: 18 additions & 0 deletions tests/test_rrt_star_dubins.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,23 @@ def test1():
m.main()


def test_obstacles_are_drawn_with_their_radius_in_data_units(monkeypatch):
# Obstacles must be drawn as circles whose radius matches the
# collision radius, independent of the figure size (issue #1396).
monkeypatch.setattr(m.plt, "pause", lambda interval: None)
obstacle_list = [(5.0, 5.0, 1.0), (3.0, 6.0, 2.0)]
planner = m.RRTStarDubins([0.0, 0.0, 0.0], [10.0, 10.0, 0.0], obstacle_list, [-2.0, 15.0])
planner.node_list = [planner.start]

m.plt.figure(figsize=(12, 12))
planner.draw_graph()

circles = [patch for patch in m.plt.gca().patches
if isinstance(patch, m.plt.Circle)]
m.plt.close("all")
assert [(circle.center, circle.radius) for circle in circles] == [
((ox, oy), size) for (ox, oy, size) in obstacle_list]


if __name__ == '__main__':
conftest.run_this_test(__file__)
18 changes: 18 additions & 0 deletions tests/test_rrt_star_reeds_shepp.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,23 @@ def test_too_big_step_size():
assert path is None


def test_obstacles_are_drawn_with_their_radius_in_data_units(monkeypatch):
# Obstacles must be drawn as circles whose radius matches the
# collision radius, independent of the figure size (issue #1396).
monkeypatch.setattr(m.plt, "pause", lambda interval: None)
obstacle_list = [(5.0, 5.0, 1.0), (3.0, 6.0, 2.0)]
planner = m.RRTStarReedsShepp([0.0, 0.0, 0.0], [10.0, 10.0, 0.0], obstacle_list, [-2.0, 15.0])
planner.node_list = [planner.start]

m.plt.figure(figsize=(12, 12))
planner.draw_graph()

circles = [patch for patch in m.plt.gca().patches
if isinstance(patch, m.plt.Circle)]
m.plt.close("all")
assert [(circle.center, circle.radius) for circle in circles] == [
((ox, oy), size) for (ox, oy, size) in obstacle_list]


if __name__ == '__main__':
conftest.run_this_test(__file__)