Skip to content
Open
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
5 changes: 3 additions & 2 deletions PathPlanning/BidirectionalAStar/bidirectional_a_star.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def planning(self, sx, sy, gx, gy):
output:
rx: x position list of the final path
ry: y position list of the final path
Both lists are empty when the goal cannot be reached.
"""

start_node = self.Node(self.calc_xy_index(sx, self.min_x),
Expand All @@ -78,11 +79,11 @@ def planning(self, sx, sy, gx, gy):
while True:
if len(open_set_A) == 0:
print("Open set A is empty..")
break
return [], []

if len(open_set_B) == 0:
print("Open set B is empty..")
break
return [], []

c_id_A = min(
open_set_A,
Expand Down
26 changes: 26 additions & 0 deletions tests/test_bidirectional_a_star.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import conftest
from PathPlanning.BidirectionalAStar import bidirectional_a_star as m


def test_1():
m.show_animation = False
m.main()


def test_unreachable_goal_returns_empty_path():
m.show_animation = False
# Square boundary from 0 to 10 with an inner wall at x = 5.
ox, oy = [], []
for i in range(11):
ox.extend([0.0, 10.0, float(i), float(i), 5.0])
oy.extend([float(i), float(i), 0.0, 10.0, float(i)])
planner = m.BidirectionalAStarPlanner(ox, oy, 1.0, 0.5)

rx, ry = planner.planning(2.0, 5.0, 8.0, 5.0)

assert rx == []
assert ry == []


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