Validate diagonal edges during airborne path recovery
This commit is contained in:
1 parent
0ea7b855be
commit
838bac6680
3 files changed
+42
-29
No files matched your search
+1
-5
@@ -137,13 +137,9 @@ def _recover_invalid_path(g, now=None):
|
||||
g.navigation_retry_at = 0.0
|
||||
if now >= g.get('path_validation_at', 0.0):
|
||||
g.path_validation_at = now + PATH_VALIDATION_INTERVAL
|
||||
start = utils.pint(g.pos)
|
||||
skip_start_edge = (not g.get('on_ground', True) or
|
||||
bool(g.get('y_v')))
|
||||
try:
|
||||
valid, invalid_node = path.Pathfinder(g).path_prefix_is_valid(
|
||||
route, steps=2, start=start,
|
||||
skip_start_edge=skip_start_edge)
|
||||
route, steps=2)
|
||||
except path.AStarTimeout:
|
||||
valid, invalid_node = True, None
|
||||
if not valid:
|
||||
|
||||
+9
-12
@@ -302,25 +302,22 @@ class Pathfinder(AStar):
|
||||
return self.check_parkour(start, offset)
|
||||
return False
|
||||
|
||||
def path_prefix_is_valid(self, route, steps=2, start=None,
|
||||
skip_start_edge=False):
|
||||
"""Check upcoming route nodes without treating midair start as blocked."""
|
||||
previous = tuple(start) if start is not None else None
|
||||
first_edge = True
|
||||
def path_prefix_is_valid(self, route, steps=2):
|
||||
"""Check upcoming route edges without treating its start as blocked."""
|
||||
previous = None
|
||||
for point in route[:steps]:
|
||||
node = tuple(point)
|
||||
if previous is not None and node == previous:
|
||||
# A* includes its start in the reconstructed route. The bot
|
||||
# may currently be jumping/falling through that cell.
|
||||
if previous is None:
|
||||
# A* includes its start in the route. The bot may be airborne
|
||||
# or have moved into this cell since planning; still validate
|
||||
# its outgoing edge so new diagonal obstacles are detected.
|
||||
previous = node
|
||||
continue
|
||||
if not self._can_stand_at(node):
|
||||
return False, node
|
||||
if (previous is not None and
|
||||
not (first_edge and skip_start_edge) and
|
||||
not self._path_edge_is_valid(previous, node)):
|
||||
if not self._path_edge_is_valid(previous, node):
|
||||
return False, node
|
||||
previous = node
|
||||
first_edge = False
|
||||
return True, None
|
||||
|
||||
def neighbors(self, node):
|
||||
|
||||
Reference in new issue
Block a user