Skip to content

Commit b9ad651

Browse files
Merge branch 'parking' of https://github.com/krishauser/GEMstack into parking
2 parents fe3cda8 + a21a79a commit b9ad651

2 files changed

Lines changed: 31 additions & 6 deletions

File tree

GEMstack/onboard/planning/parking_planning.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

scenes/parking_demo.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ agents:
33
ped1:
44
type: medium_truck
55
position: [20.0, 8.0]
6-
nominal_velocity: 0
6+
nominal_velocity: 0.0
77
target: [20.0, 8.0]
88
behavior: loop
99
yaw: 1.5708
1010

1111
ped2:
1212
type: medium_truck
1313
position: [30.0, 8.0]
14-
nominal_velocity: 0
14+
nominal_velocity: 0.0
1515
target: [15.0, 4.0]
1616
behavior: loop
1717
yaw: 1.5708

0 commit comments

Comments
 (0)