@@ -233,9 +233,10 @@ def __init__(self, start, goal, map_file, *,
233233 self .y_range = np .arange (y_min , y_max , self .resolution )
234234 self .rows , self .cols = self .grid .shape
235235
236- # SDF: distance (in cells) to nearest obstacle for every free cell
237- obstacle_mask = (self .grid >= 0.99 )
238- self .sdf = distance_transform_edt (~ obstacle_mask )
236+ # SDF: distance (in cells) to nearest impassable cell
237+ # (obstacles at >= 0.99 AND clearance zones at ~0.75)
238+ impassable_mask = (self .grid > 0 )
239+ self .sdf = distance_transform_edt (~ impassable_mask )
239240
240241 # A* initial path
241242 self .path = []
@@ -308,7 +309,7 @@ def _astar_search(self):
308309 nb = (current [0 ] + dx , current [1 ] + dy )
309310 if not (0 <= nb [0 ] < self .cols and 0 <= nb [1 ] < self .rows ):
310311 continue
311- if self .grid [nb [1 ], nb [0 ]] >= 0.99 :
312+ if self .grid [nb [1 ], nb [0 ]] > 0 :
312313 continue
313314 step = 1.414 if (dx != 0 and dy != 0 ) else 1.0
314315 nc = cost [current ] + step
@@ -456,17 +457,27 @@ def update(i, ax):
456457 ax .plot (self .start [0 ], self .start [1 ], 'go' , markersize = 8 , label = "Start" )
457458 ax .plot (self .goal [0 ], self .goal [1 ], 'ro' , markersize = 8 , label = "Goal" )
458459
459- # Draw bubbles during optimisation phase
460+ # Draw bubbles + path trace during optimisation phases
460461 if phase >= 3 :
461462 snap = (history [opt_indices [min (local , len (opt_indices ) - 1 )]]
462463 if phase == 3 else self ._optimiser .bubbles )
464+ # Bubble circles
463465 for bub in snap :
464466 wx = self .x_range [0 ] + bub .pos [0 ] * self .resolution
465467 wy = self .y_range [0 ] + bub .pos [1 ] * self .resolution
466468 r_world = bub .radius * self .resolution
467469 circ = Circle ((wx , wy ), r_world , fill = False ,
468470 color = 'green' , alpha = 0.25 , linewidth = 0.5 )
469471 ax .add_patch (circ )
472+ # Path line connecting bubble centers
473+ bx = [self .x_range [0 ] + b .pos [0 ] * self .resolution
474+ for b in snap ]
475+ by = [self .y_range [0 ] + b .pos [1 ] * self .resolution
476+ for b in snap ]
477+ ax .plot (bx , by , '-' , color = '#1565C0' , linewidth = 2.0 ,
478+ label = "EB Path" , zorder = 5 )
479+ ax .plot (bx , by , 'o' , color = '#1565C0' , markersize = 4 ,
480+ zorder = 6 )
470481
471482 ax .set_title (titles [phase ](local ), fontsize = 14 )
472483 ax .legend (loc = 'upper left' )
0 commit comments