@@ -309,7 +309,7 @@ def is_expandable(self, point: tuple, src_point: tuple = None) -> bool:
309309 if not self .within_bounds (point ):
310310 return False
311311 if src_point is not None :
312- if self ._esdf [point ] < self ._esdf [src_point ]:
312+ if self ._esdf [point ] >= self ._esdf [src_point ]:
313313 return True
314314 return not self .type_map [point ] == TYPES .OBSTACLE and not self .type_map [point ] == TYPES .INFLATION
315315
@@ -369,9 +369,6 @@ def line_of_sight(self, p1: tuple, p2: tuple) -> list:
369369 Returns:
370370 points: List of point on the line of sight.
371371 """
372- if not self .is_expandable (p1 , p2 ) or not self .is_expandable (p2 , p1 ):
373- return []
374-
375372 p1 = np .array (p1 )
376373 p2 = np .array (p2 )
377374
@@ -423,7 +420,7 @@ def in_collision(self, p1: tuple, p2: tuple) -> bool:
423420 Returns:
424421 in_collision: True if the line of sight is in collision, False otherwise.
425422 """
426- if not self .is_expandable (p1 , p2 ) or not self .is_expandable (p2 , p1 ):
423+ if not self .is_expandable (p1 ) or not self .is_expandable (p2 , p1 ):
427424 return True
428425
429426 # Corner Case: Start and end points are the same
@@ -449,11 +446,12 @@ def in_collision(self, p1: tuple, p2: tuple) -> bool:
449446 steps = abs_delta [primary_axis ]
450447 current = p1
451448
452- # Check the start point
453- if not self .is_expandable (tuple ( current ), tuple (current )):
454- return True
449+ # # Check the start point
450+ # if not self.is_expandable(tuple(current)):
451+ # return True
455452
456453 for _ in range (steps ):
454+ last_point = current .copy ()
457455 current [primary_axis ] += primary_step
458456
459457 # Update the error for the primary dimension
@@ -467,7 +465,7 @@ def in_collision(self, p1: tuple, p2: tuple) -> bool:
467465 error [d ] -= delta2 [primary_axis ]
468466
469467 # Check the current point
470- if not self .is_expandable (tuple (current ), tuple (current )):
468+ if not self .is_expandable (tuple (current ), tuple (last_point )):
471469 return True
472470
473471 return False
@@ -488,15 +486,19 @@ def inflate_obstacles(self, radius: float = 1.0) -> None:
488486 Args:
489487 radius: Radius of the inflation.
490488 """
489+ self .update_esdf ()
491490 for i in range (self .shape [0 ]):
492491 for j in range (self .shape [1 ]):
493- if self .type_map [i , j ] == TYPES .OBSTACLE :
494- for k in range (round (i - radius ), round (i + radius + 1 )):
495- for l in range (round (j - radius ), round (j + radius + 1 )):
496- if k < 0 or k >= self .shape [0 ] or l < 0 or l >= self .shape [1 ]:
497- continue
498- if self .type_map [k , l ] == TYPES .FREE and (k - i )** 2 + (l - j )** 2 <= radius ** 2 :
499- self .type_map [k , l ] = TYPES .INFLATION
492+ if self .esdf [i , j ] <= radius and self .type_map [i , j ] == TYPES .FREE :
493+ self .type_map [i , j ] = TYPES .INFLATION
494+
495+ # if self.type_map[i, j] == TYPES.OBSTACLE:
496+ # for k in range(round(i-radius), round(i+radius+1)):
497+ # for l in range(round(j-radius), round(j+radius+1)):
498+ # if k < 0 or k >= self.shape[0] or l < 0 or l >= self.shape[1]:
499+ # continue
500+ # if self.type_map[k, l] == TYPES.FREE and (k - i)**2 + (l - j)**2 <= radius**2:
501+ # self.type_map[k, l] = TYPES.INFLATION
500502
501503 def fill_expands (self , expands : List [Node ]) -> None :
502504 """
0 commit comments