Skip to content

Commit 082bf53

Browse files
committed
feat: Elastic Bands update
1 parent 30116ef commit 082bf53

File tree

3 files changed

+4
-21
lines changed

3 files changed

+4
-21
lines changed

PathPlanning/ElasticBands/elastic_bands.py

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def __init__(self, initial_path, obstacles, rho0=RHO0, kc=0.05, kr=-0.1):
5353
self.kc = kc # Contraction force gain
5454
self.kr = kr # Repulsive force gain
5555
self.rho0 = rho0 # Maximum distance for applying repulsive force
56+
self._maintain_overlap()
5657

5758
def compute_rho(self, position):
5859
"""Compute the distance field value at the position"""
@@ -143,8 +144,7 @@ def _maintain_overlap(self):
143144
class ElasticBandsVisualizer:
144145
def __init__(self):
145146
self.obstacles = np.zeros((500, 500))
146-
self.start_point = None
147-
self.end_point = None
147+
self.path_points = []
148148
self.elastic_band = None
149149

150150
if ENABLE_PLOT:
@@ -158,24 +158,7 @@ def __init__(self):
158158
# Connect mouse events
159159
self.fig.canvas.mpl_connect("button_press_event", self.on_click)
160160
else:
161-
self.path_points = [
162-
[30, 136],
163-
[61, 214],
164-
[77, 256],
165-
[77, 309],
166-
[53, 366],
167-
[41, 422],
168-
[51, 453],
169-
[110, 471],
170-
[184, 437],
171-
[257, 388],
172-
[343, 353],
173-
[402, 331],
174-
[476, 273],
175-
[456, 206],
176-
[430, 160],
177-
[402, 107],
178-
]
161+
self.path_points = np.load(pathlib.Path(__file__).parent / "points.npy")
179162
self.obstacles = np.load(pathlib.Path(__file__).parent / "obstacles.npy")
180163
self.plan_path()
181164

@@ -257,6 +240,6 @@ def plan_path(self):
257240

258241

259242
if __name__ == "__main__":
260-
ElasticBandsVisualizer()
243+
_ = ElasticBandsVisualizer()
261244
if ENABLE_PLOT:
262245
plt.show()
0 Bytes
Binary file not shown.
224 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)