From 469480faf25d610474e1d43093800a368637dcff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Sch=C3=A4fer?= Date: Sat, 28 Nov 2026 11:09:35 -0600 Subject: [PATCH] Smooth cruise acceleration with a 1-second filter (#39266) --- openpilot/selfdrive/controls/lib/longitudinal_planner.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openpilot/selfdrive/controls/lib/longitudinal_planner.py b/openpilot/selfdrive/controls/lib/longitudinal_planner.py index c0e2b7b936..9c9e941b31 100755 --- a/openpilot/selfdrive/controls/lib/longitudinal_planner.py +++ b/openpilot/selfdrive/controls/lib/longitudinal_planner.py @@ -20,7 +20,7 @@ from openpilot.selfdrive.controls.lib.longcontrol import LongCtrlState from openpilot.selfdrive.controls.lib.longitudinal_mpc_lib.long_mpc import (LongitudinalMpc, LongitudinalPlanSource, get_T_FOLLOW, get_jerk_factor, qualified_model_leads, ModelLeadHistory, should_trigger_planner_fcw) from openpilot.selfdrive.controls.lib.longitudinal_mpc_lib.long_mpc import T_IDXS as T_IDXS_MPC -from openpilot.selfdrive.controls.lib.drive_helpers import CONTROL_N, get_accel_from_plan, should_stop +from openpilot.selfdrive.controls.lib.drive_helpers import CONTROL_N, get_accel_from_plan, should_stop, smooth_value from openpilot.selfdrive.car.cruise import V_CRUISE_MAX, V_CRUISE_UNSET from openpilot.common.swaglog import cloudlog from openpilot.starpilot.navigation.intent import NAVIGATION_BRAKE_MAGNITUDE, cruise_ceiling as navigation_ceiling @@ -117,6 +117,8 @@ def get_cruise_accel(e2e, v_cruise, v_ego, a_cruise_prev, angle_steers, CP, dt, speed_error /= np.interp(speed_error, [.5, 1.5], [CRUISE_ACCEL_RESPONSE_TIME, 1.0]) elif ease_slc_braking and speed_error < 0.: speed_error /= CRUISE_ACCEL_RESPONSE_TIME # correct an SLC overshoot as gradually as an approach + if e2e and not (faster_takeoffs or speed_step or ease_slc_braking or gentle_settle or downhill_error is not None): + speed_error = smooth_value(speed_error, a_cruise_prev, tau=1.0, dt=dt) target_accel = np.clip(speed_error, cruise_min, max_accel) j_cruise = np.interp(v_ego, A_CRUISE_MAX_BP, J_CRUISE_VALS) if speed_step and (v_cruise > v_ego or a_cruise_prev <= MODEL_Y_SPEED_STEP_LIFT_ACCEL):