@@ -220,10 +220,12 @@ def __init__(self, vehicle=None, obstacles=None, actions=None):
220220 self ._vehicle = None
221221
222222 # settings
223- self .T = settings .get ("planning.dubins.integrator.time_step" , 1.5 )
224- self .dt = settings .get ("planning.dubins.integrator.time_step" , .25 )
225- self .max_v = settings .get ("planning.dubins.actions.max_velocity" , 0.75 )
226- self .max_turn_rate = settings .get ("planning.dubins.actions.max_turn_rate" , 0.3 )
223+ self .T = settings .get ("run.drive.planning.route_planning_component.dubins.integrator.time_step" , 1.5 )
224+ self .dt = settings .get ("run.drive.planning.route_planning_component.dubins.integrator.dt" , .25 )
225+ self .max_v = settings .get ("run.drive.planning.route_planning_component.dubins.actions.max_velocity" , 0.75 )
226+ self .max_turn_rate = settings .get ("run.drive.planning.route_planning_component.dubins.actions.max_turn_rate" , 0.3 )
227+ self .tolerance = settings .get ("run.drive.planning.route_planning_component.dubins.tolerance" , 0.5 )
228+ self .heuristic_string = settings .get ("run.drive.planning.route_planning_component.astar.heuristic" , "reeds_shepp" )
227229
228230 self .vehicle = DubinsCar () #x = (tx,ty,theta) and u = (fwd_velocity,turnRate).
229231 self .vehicle_sim = DubinsCarIntegrator (self .vehicle , self .T , self .dt )
@@ -260,19 +262,24 @@ def is_goal_reached(self, current: List[float], goal: List[float]):
260262 # @TODO Currently, the threshold is just a random number, get rid of magic constants
261263 # print(f"Current Pose: {current}")
262264 # print(f"Goal Pose: {goal}")
263- # if np.abs(current[3]) > 1: return False # car must be stopped, this equality will only work in simulation
265+ # if np.abs(current[3]) > 1: return False # car must be stopped, this equality will only work in simulation np.linalg.norm(np.array([current[0], current[1]]) - np.array([goal[0], goal[1]])) < 0.5
266+ # if np.abs(current[3] - goal[3]) > .25: return False
264267 return np .linalg .norm (np .array ([current [0 ], current [1 ]]) - np .array ([goal [0 ], goal [1 ]])) < 0.5
265268
266269 def heuristic_cost_estimate (self , state_1 , state_2 ):
267- """computes the 'direct' distance between two (x,y) tuples"""
268- # Extract position and orientation from states
269- (x1 , y1 , theta1 , t ) = state_1
270- (x2 , y2 , theta2 , t ) = state_2
271-
272- return self .reed_shepp (state_1 , state_2 ) # Using turning radius of 1.0
270+ """run the correct heuristic function based on the heuristic_string"""
273271
274- return self .approx_reeds_shepp (state_1 , state_2 ) # Using turning radius of 1.0
275- return math .hypot (x2 - x1 , y2 - y1 , theta2 - theta1 )
272+ if self .heuristic_string == "reeds_shepp" :
273+ return self .reed_shepp (state_1 , state_2 ) # Using turning radius of 1.0
274+
275+ elif self .heuristic_string == "approx_reeds_shepp" :
276+ return self .approx_reeds_shepp (state_1 , state_2 ) # Using turning radius of 1.0
277+
278+ elif self .heuristic_string == "euclidian" :
279+ return self .euclidian_cost_esimate (state_1 , state_2 )
280+
281+ else :
282+ raise Exception (f"Unknown heuristic function: { self .heuristic_string } " )
276283
277284 def euclidian_cost_esimate (self , state_1 , state_2 ):
278285 """computes the 'direct' distance between two (x,y) tuples"""
@@ -432,7 +439,7 @@ def __init__(self):
432439 # self.planner = ParkingSolverSecondOrderDubins()
433440 self .planner = ParkingSolverFirstOrderDubins ()
434441
435- self .iterations = settings .get ("planning.astar.iterations" , 200 )
442+ self .iterations = settings .get ("run.drive. planning.route_planning_component. astar.iterations" , 50000 )
436443
437444 def state_inputs (self ):
438445 return ['all' ]
@@ -479,6 +486,22 @@ def vehicle_state_to_first_order(self, vehicle_state: VehicleState) -> Tuple[flo
479486 t = 0
480487
481488 return (x ,y ,theta ,t )
489+
490+ def pose_to_first_order (self , pose : ObjectPose ) -> Tuple [float , float ]:
491+ """Takes a vehicle state and outputs the state of a second order dubins car
492+
493+ Args:
494+ vehicle_state (VehicleState): _description_
495+
496+ Returns:
497+ Tuple[float, float]: _description_
498+ """
499+ x = pose .x
500+ y = pose .y
501+ theta = pose .yaw # check that this is correct
502+ t = 0
503+
504+ return (x ,y ,theta ,t )
482505
483506 def update (self , state : AllState ) -> Route :
484507 """_summary_
@@ -496,34 +519,36 @@ def update(self, state : AllState) -> Route:
496519 all_obstacles = {** agents , ** obstacles }
497520 # print(f"Obstacles {obstacles}")
498521 print (f"Agents { agents } " )
499- # goal= state.goal
500- # print(goal.frame)
501- # assert goal.frame == ObjectFrameEnum.ABSOLUTE_CARTESIAN
502- # assert goal.v == 0
503- # print(f"Goal {goal}")
504- goal_pose = ObjectPose (frame = ObjectFrameEnum .CURRENT , t = 15 , x = state .mission_plan .goal_x ,y = state .mission_plan .goal_y ,z = 0 ,yaw = state .mission_plan .goal_orientation )
522+ goal_pose = state .goal
523+ assert goal_pose .frame == ObjectFrameEnum .CURRENT
505524 print ("Checking VALUE: " , state .start_vehicle_pose )
506- start_pose = state .vehicle .pose .to_frame (ObjectFrameEnum .CURRENT , current_pose = state .vehicle .pose ,start_pose_abs = state .start_vehicle_pose )
507- start_cur = VehicleState .zero ()
508- start_cur .pose = start_pose
509- goal = VehicleState .zero ()
510- goal .pose = goal_pose
511- goal .v = 0
525+ print ("Checking VALUE: " , state .vehicle )
526+ start_state = state .vehicle .to_frame (ObjectFrameEnum .CURRENT , current_pose = state .vehicle .pose ,start_pose_abs = state .start_vehicle_pose )
527+ # start_pose = state.vehicle.pose.to_frame(ObjectFrameEnum.CURRENT, current_pose = state.vehicle.pose,start_pose_abs = state.start_vehicle_pose)
528+ # start_cur = VehicleState.zero()
529+ # start_cur.pose = start_pose # goal.pose = goal_pose
530+ # goal.v = 0
531+ print ("Checking VALUE: " , start_state )
532+
533+
534+
512535
513536 # # Need to parse and create second order dubin car states
514537 # start_state = self.vehicle_state_to_dynamics(vehicle)
515538 # goal_state = self.vehicle_state_to_dynamics(goal)
516539
517540 # Need to parse and create second order dubin car states
518- start_state = self .vehicle_state_to_first_order (start_cur )
519- goal_state = self .vehicle_state_to_first_order (goal )
541+ start = self .vehicle_state_to_first_order (start_state )
542+ # goal = self.vehicle_state_to_first_order(goal_state)
543+ goal = self .pose_to_first_order (goal_pose )
520544
521545 # Update the planner
522546 self .planner .obstacles = list (all_obstacles .values ())
523547 self .planner .vehicle = vehicle
524548
525549 # Compute the new trajectory and return it
526- res = list (self .planner .astar (start_state , goal_state , reversePath = False , iterations = self .iterations ))
550+ print (f"Iteartions ------------------------------ { self .iterations } " )
551+ res = list (self .planner .astar (start , goal , reversePath = False , iterations = self .iterations ))
527552 # points = [state[:2] for state in res] # change here to return the theta as well
528553 points = []
529554 for state in res :
0 commit comments