Files
PythonRobotics/tests/test_elastic_bands.py
Aglargil c92aaf36d8 feat: add ElasticBands (#1156)
* feat: add ElasticBands

* feat: Elastic Bands update

* feat: ElasticBands update

* feat: ElasticBands add test

* feat: ElasticBands reduce occupation

* fix: ElasticBands test

* feat: ElasticBands remove tangential component

* feat: Elastic Bands update

* feat: Elastic Bands doc

* feat: Elastic Bands update

* feat: ElasticBands update
2025-02-17 19:47:04 +09:00

24 lines
788 B
Python

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__)