Skip to content

fix: return False from Grid.valid_position for t outside time window - #1471

Closed
ErroujiOussama wants to merge 1 commit into
AtsushiSakai:masterfrom
ErroujiOussama:fix/space-time-astar-time-limit-index
Closed

ErroujiOussama wants to merge 1 commit into
AtsushiSakai:masterfrom
ErroujiOussama:fix/space-time-astar-time-limit-index

Conversation

@ErroujiOussama

Copy link
Copy Markdown

Fixes an IndexError in SpaceTimeAStar when the goal can't be reached within time_limit.

Cause

  • plan() skips a node only when time + 1 >= time_limit, so a node at time_limit - 2 still gets expanded.
  • generate_successors() then checks valid_position(pos, time + 2), which is t = time_limit.
  • valid_position() indexes reservation_matrix[x, y, t] → IndexError instead of "No path found".

Fix
Grid.valid_position() returns False for t outside [0, time_limit). This also guards the other planners that
use it.

Test
Added test_no_path_within_time_limit: 11x11 grid, no obstacles, time_limit=5, goal at distance 16. Before:
IndexError. After: raises "No path found".

SpaceTimeAStar.plan() still expands nodes at time_limit - 2, and
generate_successors() then checks valid_position(..., time + 2), which
indexes reservation_matrix at t = time_limit and raises IndexError
instead of "No path found" when the goal is unreachable in time.

Treat any t outside [0, time_limit) as invalid, and add a regression test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant