Skip to content

Commit

Permalink
longcontrol: check if speeds is empty (#23410)
Browse files Browse the repository at this point in the history
* check if speeds is empty

* move into existing check

Co-authored-by: Willem Melching <willem.melching@gmail.com>
  • Loading branch information
deanlee and pd0wm authored Jan 5, 2022
1 parent bafdb20 commit a2e762e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion selfdrive/controls/lib/longcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ def update(self, active, CS, CP, long_plan, accel_limits):
a_target_upper = 2 * (v_target_upper - speeds[0])/CP.longitudinalActuatorDelayUpperBound - long_plan.accels[0]
a_target = min(a_target_lower, a_target_upper)

v_target = speeds[0]
v_target_future = speeds[-1]
else:
v_target = 0.0
v_target_future = 0.0
a_target = 0.0

Expand All @@ -91,7 +93,7 @@ def update(self, active, CS, CP, long_plan, accel_limits):

# tracking objects and driving
elif self.long_control_state == LongCtrlState.pid:
self.v_pid = speeds[0]
self.v_pid = v_target

# Toyota starts braking more when it thinks you want to stop
# Freeze the integrator so we don't accelerate to compensate, and don't allow positive acceleration
Expand Down

0 comments on commit a2e762e

Please sign in to comment.