Skip to content
This repository has been archived by the owner on Jan 9, 2022. It is now read-only.

Commit

Permalink
run without constraint for a frame
Browse files Browse the repository at this point in the history
  • Loading branch information
sshane committed Jan 2, 2022
1 parent 073b75a commit ff36d25
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion selfdrive/controls/lib/longitudinal_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(self, CP, init_v=0.0, init_a=0.0):
self.v_desired = init_v
self.a_desired = init_a
self.alpha = np.exp(-DT_MDL / 2.0)
self.last_active = False

self.v_desired_trajectory = np.zeros(CONTROL_N)
self.a_desired_trajectory = np.zeros(CONTROL_N)
Expand All @@ -68,11 +69,14 @@ def update(self, sm):
force_slow_decel = sm['controlsState'].forceDecel

prev_accel_constraint = True
if long_control_state == LongCtrlState.off or sm['carState'].gasPressed:
active = long_control_state != LongCtrlState.off and not sm['carState'].gasPressed
if not active:
self.v_desired = v_ego
self.a_desired = a_ego
if not active or (active and not self.last_activeand):
# Smoothly changing between accel trajectory is only relevant when OP is driving
prev_accel_constraint = False
self.last_active = active

# Prevent divergence, smooth in current v_ego
self.v_desired = self.alpha * self.v_desired + (1 - self.alpha) * v_ego
Expand Down

0 comments on commit ff36d25

Please sign in to comment.