2020 ObstacleArrangement ,
2121 Position ,
2222)
23+ import time
24+
2325from PathPlanning .TimeBasedPathPlanning .BaseClasses import MultiAgentPlanner , StartAndGoal
2426from PathPlanning .TimeBasedPathPlanning .Node import NodePath
2527from PathPlanning .TimeBasedPathPlanning .BaseClasses import SingleAgentPlanner
2628from PathPlanning .TimeBasedPathPlanning .SafeInterval import SafeIntervalPathPlanner
2729from PathPlanning .TimeBasedPathPlanning .SpaceTimeAStar import SpaceTimeAStar
2830from PathPlanning .TimeBasedPathPlanning .Plotting import PlotNodePaths
29- from PathPlanning .TimeBasedPathPlanning .ConstraintTree import AgentId , AppliedConstraint , ConstraintTree , ConstraintTreeNode , ForkingConstraint
30- import time
31+ from PathPlanning .TimeBasedPathPlanning .ConstraintTree import AgentId , AppliedConstraint , ConstrainedAgent , ConstraintTree , ConstraintTreeNode , ForkingConstraint
3132
3233class ConflictBasedSearch (MultiAgentPlanner ):
3334
@@ -56,13 +57,16 @@ def plan(grid: Grid, start_and_goals: list[StartAndGoal], single_agent_planner_c
5657
5758 while constraint_tree .nodes_to_expand :
5859 constraint_tree_node = constraint_tree .get_next_node_to_expand ()
60+ if constraint_tree_node is None :
61+ raise RuntimeError ("No more nodes to expand in the constraint tree." )
62+
5963 ancestor_constraints = constraint_tree .get_ancestor_constraints (constraint_tree_node .parent_idx )
6064
6165 if verbose :
6266 print (f"Expanding node with constraint { constraint_tree_node .constraint } and parent { constraint_tree_node .parent_idx } " )
6367 print (f"\t COST: { constraint_tree_node .cost } " )
6468
65- if constraint_tree_node is None :
69+ if constraint_tree_node . constraint is None :
6670 raise RuntimeError ("No more nodes to expand in the constraint tree." )
6771 if not constraint_tree_node .constraint :
6872 # This means we found a solution!
@@ -83,7 +87,16 @@ def plan(grid: Grid, start_and_goals: list[StartAndGoal], single_agent_planner_c
8387 all_constraints = ancestor_constraints
8488 all_constraints .append (applied_constraint )
8589
86- new_path = ConflictBasedSearch .plan_for_agent (constrained_agent , all_constraints , constraint_tree , attempted_constraint_combos , grid , single_agent_planner_class , start_and_goals , verbose )
90+ new_path = ConflictBasedSearch .plan_for_agent (
91+ constrained_agent ,
92+ all_constraints ,
93+ constraint_tree ,
94+ attempted_constraint_combos ,
95+ grid ,
96+ single_agent_planner_class ,
97+ start_and_goals ,
98+ verbose
99+ )
87100 if not new_path :
88101 continue
89102
@@ -116,14 +129,14 @@ def get_agents_start_and_goal(start_and_goal_list: list[StartAndGoal], target_in
116129 raise RuntimeError (f"Could not find agent with index { target_index } in { start_and_goal_list } " )
117130
118131 @staticmethod
119- def plan_for_agent (constrained_agent : ConstraintTreeNode ,
132+ def plan_for_agent (constrained_agent : ConstrainedAgent ,
120133 all_constraints : list [AppliedConstraint ],
121134 constraint_tree : ConstraintTree ,
122135 attempted_constraint_combos : set ,
123136 grid : Grid ,
124137 single_agent_planner_class : SingleAgentPlanner ,
125138 start_and_goals : list [StartAndGoal ],
126- verbose : False ) -> tuple [ list [ StartAndGoal ], list [ NodePath ]] | None :
139+ verbose : bool ) -> NodePath | None :
127140 """
128141 Attempt to generate a path plan for a single agent
129142 """
0 commit comments