Skip to content

Commit 656c717

Browse files
committed
debugging sipp, not sure. this commit is mostly garbo
1 parent 7d5b85c commit 656c717

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

PathPlanning/TimeBasedPathPlanning/ConflictBasedSearch.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def main():
101101
grid_side_length = 21
102102

103103
# start_and_goals = [StartAndGoal(i, Position(1, i), Position(19, 19-i)) for i in range(1, 16)]
104-
start_and_goals = [StartAndGoal(i, Position(1, 8+i), Position(19, 19-i)) for i in range(5)]
104+
start_and_goals = [StartAndGoal(i, Position(1, 8+i), Position(19, 19-i)) for i in range(4)]
105105
obstacle_avoid_points = [pos for item in start_and_goals for pos in (item.start, item.goal)]
106106

107107
grid = Grid(
@@ -114,7 +114,8 @@ def main():
114114
)
115115

116116
start_time = time.time()
117-
start_and_goals, paths = ConflictBasedSearch.plan(grid, start_and_goals, SpaceTimeAStar, verbose)
117+
start_and_goals, paths = ConflictBasedSearch.plan(grid, start_and_goals, SafeIntervalPathPlanner, verbose)
118+
# start_and_goals, paths = ConflictBasedSearch.plan(grid, start_and_goals, SpaceTimeAStar, verbose)
118119

119120
runtime = time.time() - start_time
120121
print(f"\nPlanning took: {runtime:.5f} seconds")

PathPlanning/TimeBasedPathPlanning/GridWithDynamicObstacles.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def __init__(
8181
self.obstacle_paths = self.generate_narrow_corridor_obstacles(num_obstacles)
8282

8383
for i, path in enumerate(self.obstacle_paths):
84+
# TODO: i think this is a bug. obstacle indices will overlap with robot indices
8485
obs_idx = i + 1 # avoid using 0 - that indicates free space in the grid
8586
for t, position in enumerate(path):
8687
# Reserve old & new position at this time step
@@ -282,20 +283,36 @@ def get_obstacle_positions_at_time(self, t: int) -> tuple[list[int], list[int]]:
282283
"""
283284
Returns safe intervals for each cell.
284285
"""
285-
def get_safe_intervals(self) -> np.ndarray:
286+
def get_safe_intervals(self, agent_idx: int) -> np.ndarray:
286287
intervals = empty_2d_array_of_lists(self.grid_size[0], self.grid_size[1])
287288
for x in range(intervals.shape[0]):
288289
for y in range(intervals.shape[1]):
289-
intervals[x, y] = self.get_safe_intervals_at_cell(Position(x, y))
290+
intervals[x, y] = self.get_safe_intervals_at_cell(Position(x, y), agent_idx)
290291

291292
return intervals
292293

293294
"""
294295
Generate the safe intervals for a given cell. The intervals will be in order of start time.
295296
ex: Interval (2, 3) will be before Interval (4, 5)
296297
"""
297-
def get_safe_intervals_at_cell(self, cell: Position) -> list[Interval]:
298+
def get_safe_intervals_at_cell(self, cell: Position, agent_idx: int) -> list[Interval]:
298299
vals = self.reservation_matrix[cell.x, cell.y, :]
300+
301+
had_constraints = False
302+
# ct: AppliedConstraint
303+
for constraint_set in self.constraint_points[cell.x, cell.y]:
304+
for constraint in constraint_set:
305+
if constraint.constrained_agent != agent_idx:
306+
continue
307+
if constraint.constraint.position != cell:
308+
continue
309+
had_constraints = True
310+
vals[constraint.constraint.time] = 99999 # TODO: no magic numbers
311+
312+
# TODO: hack
313+
# if constraint.constraint.time + 1 < self.time_limit:
314+
# vals[constraint.constraint.time + 1] = 99999 # TODO: no magic numbers
315+
299316
# Find where the array is zero
300317
zero_mask = (vals == 0)
301318

@@ -321,6 +338,10 @@ def get_safe_intervals_at_cell(self, cell: Position) -> list[Interval]:
321338
# move into and out of the cell each take 1 time step, and the cell is considered occupied during
322339
# both the time step when it is entering the cell, and the time step when it is leaving the cell.
323340
intervals = [interval for interval in intervals if interval.start_time != interval.end_time]
341+
342+
# if had_constraints:
343+
# print("\t\tconstraints: ", self.constraint_points[cell.x, cell.y])
344+
# print("\t\tintervals: ", intervals)
324345
return intervals
325346

326347
"""

PathPlanning/TimeBasedPathPlanning/SafeInterval.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class SafeIntervalPathPlanner(SingleAgentPlanner):
4949
@staticmethod
5050
def plan(grid: Grid, start: Position, goal: Position, agent_idx: int, verbose: bool = False) -> NodePath:
5151

52-
safe_intervals = grid.get_safe_intervals()
52+
safe_intervals = grid.get_safe_intervals(agent_idx)
5353

5454
open_set: list[SIPPNode] = []
5555
first_node_interval = safe_intervals[start.x, start.y][0]

0 commit comments

Comments
 (0)