@@ -212,7 +212,7 @@ def __init__(self, vehicle=None, obstacles=None, actions=None):
212212 self ._vehicle = None
213213
214214 self .vehicle = DubinsCar () #x = (tx,ty,theta) and u = (fwd_velocity,turnRate).
215- self .vehicle_sim = DubinsCarIntegrator (self .vehicle , 1 , 0.25 )
215+ self .vehicle_sim = DubinsCarIntegrator (self .vehicle , 2 , 0.25 )
216216 #@TODO create a more standardized way to define the actions
217217 self ._actions = generate_action_set ()
218218
@@ -258,14 +258,39 @@ def heuristic_cost_estimate(self, state_1, state_2):
258258 (x1 , y1 , theta1 , t ) = state_1
259259 (x2 , y2 , theta2 , t ) = state_2
260260
261+ return self .approx_reeds_shepp (state_1 , state_2 ) # Using turning radius of 1.0
261262 return math .hypot (x2 - x1 , y2 - y1 , theta2 - theta1 )
262263
263- def terminal_cost_estimate (self , state_1 , state_2 ):
264+ def euclidian_cost_esimate (self , state_1 , state_2 ):
264265 """computes the 'direct' distance between two (x,y) tuples"""
265266 # Extract position and orientation from states
266267 (x1 , y1 , theta1 , t ) = state_1
267268 (x2 , y2 , theta2 , t ) = state_2
269+
268270 return math .hypot (x2 - x1 , y2 - y1 , theta2 - theta1 )
271+
272+ def approx_reeds_shepp (self , state_1 , state_2 ):
273+ # Extract position and orientation from states
274+ (x1 , y1 , theta1 , t1 ) = state_1
275+ (x2 , y2 , theta2 , t2 ) = state_2
276+
277+ # Create start and goal configurations for Reeds-Shepp
278+ start = (x1 , y1 , theta1 )
279+ goal = (x2 , y2 , theta2 )
280+
281+ # Calculate Reeds-Shepp path length
282+ path_length_cost = path_length (start , goal , 1.0 ) # Using turning radius of 1.0
283+
284+ # # Add penalties for velocity and time differences
285+ # velocity_penalty = abs(v2 - v1) * 0.1
286+ # time_penalty = abs(t2 - t1) * 0.01
287+
288+ return path_length_cost # + velocity_penalty + time_penalty
289+
290+ def terminal_cost_estimate (self , state_1 , state_2 ):
291+ """computes the 'direct' distance between two (x,y) tuples"""
292+ # Extract position and orientation from states
293+ return self .approx_reeds_shepp (state_1 , state_2 )
269294
270295 def distance_between (self , state_1 , state_2 ):
271296 """
@@ -460,11 +485,11 @@ def update(self, state : AllState) -> Trajectory:
460485 self .planner .vehicle = vehicle
461486
462487 # Compute the new trajectory and return it
463- res = list (self .planner .astar (start_state , goal_state , reversePath = False , iterations = 100 ))
488+ res = list (self .planner .astar (start_state , goal_state , reversePath = False , iterations = 200 ))
464489 # points = [state[:2] for state in res] # change here to return the theta as well
465490 points = []
466491 for state in res :
467- points .append ((state [0 ], state [1 ], 0 , state [ 2 ] ))
492+ points .append ((state [0 ], state [1 ]))
468493 times = [state [3 ] for state in res ]
469494 path = Path (frame = vehicle .pose .frame , points = points )
470495 traj = Trajectory (path .frame ,points ,times )
0 commit comments