From 965415135ac7db4c67ea248ac52535eac537f3bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Sch=C3=A4fer?= Date: Mon, 10 Jun 2024 22:29:17 -0700 Subject: [PATCH] Long control: Double delay is super complicated (#32694) * Double delay is super complicated * No more upper bound * DEAD * Update ref --- cereal/car.capnp | 4 ++-- selfdrive/car/gm/interface.py | 2 +- selfdrive/car/honda/interface.py | 2 +- selfdrive/car/hyundai/interface.py | 3 +-- selfdrive/car/interfaces.py | 3 +-- selfdrive/car/tesla/interface.py | 2 +- selfdrive/controls/lib/longcontrol.py | 12 +++--------- selfdrive/test/process_replay/ref_commit | 2 +- 8 files changed, 11 insertions(+), 19 deletions(-) diff --git a/cereal/car.capnp b/cereal/car.capnp index 8d76f0ead8de51..7f3f64c911eddb 100644 --- a/cereal/car.capnp +++ b/cereal/car.capnp @@ -490,8 +490,7 @@ struct CarParams { startingState @70 :Bool; # Does this car make use of special starting state steerActuatorDelay @36 :Float32; # Steering wheel actuator delay in seconds - longitudinalActuatorDelayLowerBound @61 :Float32; # Gas/Brake actuator delay in seconds, lower bound - longitudinalActuatorDelayUpperBound @58 :Float32; # Gas/Brake actuator delay in seconds, upper bound + longitudinalActuatorDelay @58 :Float32; # Gas/Brake actuator delay in seconds openpilotLongitudinalControl @37 :Bool; # is openpilot doing the longitudinal control? carVin @38 :Text; # VIN number queried during fingerprinting dashcamOnly @41: Bool; @@ -703,4 +702,5 @@ struct CarParams { brakeMaxVDEPRECATED @16 :List(Float32); directAccelControlDEPRECATED @30 :Bool; maxSteeringAngleDegDEPRECATED @54 :Float32; + longitudinalActuatorDelayLowerBoundDEPRECATEDDEPRECATED @61 :Float32; } diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index 358bc9e5ba32bb..2e194b12f2fa90 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -148,7 +148,7 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs): ret.steerLimitTimer = 0.4 ret.radarTimeStep = 0.0667 # GM radar runs at 15Hz instead of standard 20Hz - ret.longitudinalActuatorDelayUpperBound = 0.5 # large delay to initially start braking + ret.longitudinalActuatorDelay = 0.5 # large delay to initially start braking if candidate == CAR.CHEVROLET_VOLT: ret.lateralTuning.pid.kpBP = [0., 40.] diff --git a/selfdrive/car/honda/interface.py b/selfdrive/car/honda/interface.py index 2026c385c24a7c..43a4454b90ab4d 100755 --- a/selfdrive/car/honda/interface.py +++ b/selfdrive/car/honda/interface.py @@ -74,7 +74,7 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs): if candidate in HONDA_BOSCH: ret.longitudinalTuning.kpV = [0.25] ret.longitudinalTuning.kiV = [0.05] - ret.longitudinalActuatorDelayUpperBound = 0.5 # s + ret.longitudinalActuatorDelay = 0.5 # s if candidate in HONDA_BOSCH_RADARLESS: ret.stopAccel = CarControllerParams.BOSCH_ACCEL_MIN # stock uses -4.0 m/s^2 once stopped but limited by safety model else: diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index 22c54bce6b5179..0ba4dcb5e3766b 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -94,8 +94,7 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs): ret.startingState = True ret.vEgoStarting = 0.1 ret.startAccel = 1.0 - ret.longitudinalActuatorDelayLowerBound = 0.5 - ret.longitudinalActuatorDelayUpperBound = 0.5 + ret.longitudinalActuatorDelay = 0.5 # *** feature detection *** if candidate in CANFD_CAR: diff --git a/selfdrive/car/interfaces.py b/selfdrive/car/interfaces.py index a3572238bab5af..5eac6062aa53cf 100644 --- a/selfdrive/car/interfaces.py +++ b/selfdrive/car/interfaces.py @@ -210,8 +210,7 @@ def get_std_params(candidate): ret.longitudinalTuning.kiBP = [0.] ret.longitudinalTuning.kiV = [1.] # TODO estimate car specific lag, use .15s for now - ret.longitudinalActuatorDelayLowerBound = 0.15 - ret.longitudinalActuatorDelayUpperBound = 0.15 + ret.longitudinalActuatorDelay = 0.15 ret.steerLimitTimer = 1.0 return ret diff --git a/selfdrive/car/tesla/interface.py b/selfdrive/car/tesla/interface.py index e039859263f59f..09de10b54d6caf 100755 --- a/selfdrive/car/tesla/interface.py +++ b/selfdrive/car/tesla/interface.py @@ -23,7 +23,7 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs): ret.longitudinalTuning.kpV = [0] ret.longitudinalTuning.kiBP = [0] ret.longitudinalTuning.kiV = [0] - ret.longitudinalActuatorDelayUpperBound = 0.5 # s + ret.longitudinalActuatorDelay = 0.5 # s ret.radarTimeStep = (1.0 / 8) # 8Hz # Check if we have messages on an auxiliary panda, and that 0x2bf (DAS_control) is present on the AP powertrain bus diff --git a/selfdrive/controls/lib/longcontrol.py b/selfdrive/controls/lib/longcontrol.py index d08ee05035215f..a619c47634cd11 100644 --- a/selfdrive/controls/lib/longcontrol.py +++ b/selfdrive/controls/lib/longcontrol.py @@ -73,16 +73,10 @@ def update(self, active, CS, long_plan, accel_limits, t_since_plan): v_target_now = interp(t_since_plan, CONTROL_N_T_IDX, speeds) a_target_now = interp(t_since_plan, CONTROL_N_T_IDX, long_plan.accels) - v_target_lower = interp(self.CP.longitudinalActuatorDelayLowerBound + t_since_plan, CONTROL_N_T_IDX, speeds) - a_target_lower = 2 * (v_target_lower - v_target_now) / self.CP.longitudinalActuatorDelayLowerBound - a_target_now + v_target = interp(self.CP.longitudinalActuatorDelay + t_since_plan, CONTROL_N_T_IDX, speeds) + a_target = 2 * (v_target - v_target_now) / self.CP.longitudinalActuatorDelay - a_target_now - v_target_upper = interp(self.CP.longitudinalActuatorDelayUpperBound + t_since_plan, CONTROL_N_T_IDX, speeds) - a_target_upper = 2 * (v_target_upper - v_target_now) / self.CP.longitudinalActuatorDelayUpperBound - a_target_now - - v_target = min(v_target_lower, v_target_upper) - a_target = min(a_target_lower, a_target_upper) - - v_target_1sec = interp(self.CP.longitudinalActuatorDelayUpperBound + t_since_plan + 1.0, CONTROL_N_T_IDX, speeds) + v_target_1sec = interp(self.CP.longitudinalActuatorDelay + t_since_plan + 1.0, CONTROL_N_T_IDX, speeds) else: v_target = 0.0 v_target_now = 0.0 diff --git a/selfdrive/test/process_replay/ref_commit b/selfdrive/test/process_replay/ref_commit index 70178b8ea366ce..eaf61ccb813541 100644 --- a/selfdrive/test/process_replay/ref_commit +++ b/selfdrive/test/process_replay/ref_commit @@ -1 +1 @@ -e536df5586a71b22baa789dc584d7eab67f1fbbb +0ba779ec9f624872b1d038acb15095b726ff8983