Use physical clearance for fixed routes and terminal bounds
Use the same physical clearance rule for fixed-route admission and verification. Preserve imported vertices while clearing GEOS precision metadata. Count touching terminal faces as conflicts at zero clearance.
This commit is contained in:
parent
42e1de9884
commit
23d0a140c1
1 changed files with 127 additions and 28 deletions
|
|
@ -10,7 +10,7 @@ from inire.constants import TOLERANCE_LINEAR
|
|||
from inire.geometry.component_overlap import count_path_self_collisions
|
||||
from inire.geometry.components import check_path_geometry, path_within_board
|
||||
from inire.geometry.dynamic_path_index import DynamicPathIndex
|
||||
from inire.geometry.index_helpers import grid_cell_span
|
||||
from inire.geometry.index_helpers import floating_polygon, grid_cell_span
|
||||
from inire.geometry.primitives import rotate_cardinal
|
||||
from inire.results import RoutingReport
|
||||
from inire.geometry.static_obstacle_index import StaticObstacleIndex
|
||||
|
|
@ -52,11 +52,14 @@ def _has_non_touching_overlap(left: BaseGeometry, right: BaseGeometry) -> bool:
|
|||
return left.intersects(right) and not left.touches(right)
|
||||
|
||||
|
||||
def _clearance_limit(clearance: float) -> float:
|
||||
return clearance - TOLERANCE_LINEAR * min(1.0, clearance)
|
||||
|
||||
|
||||
def _violates_clearance(left: BaseGeometry, right: BaseGeometry, clearance: float) -> bool:
|
||||
if clearance <= 0:
|
||||
return _has_non_touching_overlap(left, right)
|
||||
tolerance = TOLERANCE_LINEAR * min(1.0, clearance)
|
||||
return left.distance(right) < clearance - tolerance
|
||||
return left.distance(right) < _clearance_limit(clearance)
|
||||
|
||||
|
||||
def _violates_net_clearance(left: BaseGeometry, right: BaseGeometry, clearance: float) -> bool:
|
||||
|
|
@ -118,7 +121,7 @@ class RoutingWorld:
|
|||
self.clearance = clearance
|
||||
self.self_clearance = self_clearance
|
||||
self.safety_zone_radius = safety_zone_radius
|
||||
self.board = board
|
||||
self.board = floating_polygon(board) if board is not None else None
|
||||
|
||||
self.grid_cell_size = 50.0
|
||||
self.metrics = None
|
||||
|
|
@ -308,17 +311,16 @@ class RoutingWorld:
|
|||
|
||||
clearance = self.clearance
|
||||
left, bottom, right, top = result.total_bounds
|
||||
reserved = not self.clearance and self._static_obstacles.owners
|
||||
if reserved:
|
||||
if self._static_obstacles.owners:
|
||||
x0, y0, x1, y1 = result.total_physical_bounds
|
||||
left, bottom, right, top = min(left, x0), min(bottom, y0), max(right, x1), max(top, y1)
|
||||
# Expand the whole proxy envelope, including the tangent faces of an arc.
|
||||
# The broad phase must include both the keepout proxy and the physical outline.
|
||||
hits = tree.query(box(left - clearance, bottom - clearance, right + clearance, top + clearance))
|
||||
obstacles = tree.geometries
|
||||
for hit_idx in hits:
|
||||
obstacle = obstacles[hit_idx]
|
||||
if reserved and self._static_obstacles.raw_owners[hit_idx] is not None:
|
||||
if any(polygon.intersects(obstacle) for polygon in result.physical_geometry):
|
||||
if self._static_obstacles.raw_owners[hit_idx] is not None:
|
||||
if any(_violates_net_clearance(polygon, obstacle, clearance) for polygon in result.physical_geometry):
|
||||
return True
|
||||
continue
|
||||
for polygon in result.collision_geometry:
|
||||
|
|
|
|||
Loading…
Reference in a new issue