forked from AtsushiSakai/PythonRobotics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_elastic_bands.py
More file actions
23 lines (19 loc) · 788 Bytes
/
test_elastic_bands.py
File metadata and controls
23 lines (19 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import conftest
import numpy as np
from PathPlanning.ElasticBands.elastic_bands import ElasticBands
def test_1():
path = np.load("PathPlanning/ElasticBands/path.npy")
obstacles_points = np.load("PathPlanning/ElasticBands/obstacles.npy")
obstacles = np.zeros((500, 500))
for x, y in obstacles_points:
size = 30 # Side length of the square
half_size = size // 2
x_start = max(0, x - half_size)
x_end = min(obstacles.shape[0], x + half_size)
y_start = max(0, y - half_size)
y_end = min(obstacles.shape[1], y + half_size)
obstacles[x_start:x_end, y_start:y_end] = 1
elastic_bands = ElasticBands(path, obstacles)
elastic_bands.update_bubbles()
if __name__ == "__main__":
conftest.run_this_test(__file__)