From 521e3d843b0127474fa2d6e105dc1c8e8d0abd67 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Wed, 5 Jan 2022 21:23:08 +0800 Subject: [PATCH] longcontrol: check if speeds is empty (#23410) * check if speeds is empty * move into existing check Co-authored-by: Willem Melching old-commit-hash: a2e762e0b96c7ff271dcfd41c0ca7c12018444f0 --- selfdrive/controls/lib/longcontrol.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/selfdrive/controls/lib/longcontrol.py b/selfdrive/controls/lib/longcontrol.py index 646b40c26b..f49a4e6f3b 100644 --- a/selfdrive/controls/lib/longcontrol.py +++ b/selfdrive/controls/lib/longcontrol.py @@ -68,8 +68,10 @@ class LongControl(): 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 @@ -91,7 +93,7 @@ class LongControl(): # 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