Skip to content

Commit b21bb65

Browse files
committed
add logic to avoid unnecessary yielding
1 parent 0831c67 commit b21bb65

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

GEMstack/onboard/planning/longitudinal_planning.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ def detect_collision(curr_x: float, curr_y: float, curr_v: float, obj: AgentStat
2828
vehicle_buffer_x = 3.0
2929
vehicle_buffer_y = 1.5
3030

31-
vehicle_front = curr_x + vehicle_length / 2
32-
vehicle_back = curr_x - vehicle_length / 2
31+
yield_buffer_y = 1.0
32+
33+
vehicle_front = curr_x + vehicle_length
34+
vehicle_back = curr_x
3335
vehicle_left = curr_y + vehicle_width / 2
3436
vehicle_right = curr_y - vehicle_width / 2
3537

@@ -75,6 +77,13 @@ def detect_collision(curr_x: float, curr_y: float, curr_v: float, obj: AgentStat
7577
return False, 0.0
7678

7779
print(relative_v, distance)
80+
81+
if obj_v_y > 0 and ((obj_y - curr_y) / relative_v) < ((vehicle_right - vehicle_buffer_y - yield_buffer_y - pedestrian_left) / abs(obj_v_y)):
82+
# The object is to the right of the vehicle and moving towards it, but the vehicle will pass before the object reaches the vehicle
83+
return False, 0.0
84+
if obj_v_y < 0 and ((obj_y - curr_y) / relative_v) < ((pedestrian_right - vehicle_left - vehicle_buffer_y - yield_buffer_y) / abs(obj_v_y)):
85+
# The object is to the left of the vehicle and moving towards it, but the vehicle will pass before the object reaches the vehicle
86+
return False, 0.0
7887

7988
deceleration = relative_v ** 2 / (2 * distance)
8089
if deceleration > max_deceleration:

0 commit comments

Comments
 (0)