From 91d5b10426f20ac03edcb8a6ea96576098d3f090 Mon Sep 17 00:00:00 2001 From: HaraldSchafer Date: Mon, 12 Jul 2021 18:30:56 -0700 Subject: [PATCH] less accel (#21565) * less accel * new refs * Update longitudinal_planner.py * update refs old-commit-hash: a42d8f3a14132c3c0826ed106d61a617ce41936e --- selfdrive/car/honda/interface.py | 4 ++-- selfdrive/car/toyota/values.py | 3 ++- selfdrive/controls/lib/longitudinal_planner.py | 9 +++++++-- selfdrive/test/process_replay/ref_commit | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/selfdrive/car/honda/interface.py b/selfdrive/car/honda/interface.py index d265b1ed36..b4eef75cbc 100755 --- a/selfdrive/car/honda/interface.py +++ b/selfdrive/car/honda/interface.py @@ -8,7 +8,7 @@ from selfdrive.config import Conversions as CV from selfdrive.car.honda.values import CruiseButtons, CAR, HONDA_BOSCH, HONDA_BOSCH_ALT_BRAKE_SIGNAL from selfdrive.car.honda.hondacan import disable_radar from selfdrive.car import STD_CARGO_KG, CivicParams, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint -from selfdrive.controls.lib.longitudinal_planner import A_CRUISE_MAX as A_ACC_MAX +from selfdrive.controls.lib.longitudinal_planner import A_CRUISE_MAX_VALS from selfdrive.car.interfaces import CarInterfaceBase @@ -120,7 +120,7 @@ class CarInterface(CarInterfaceBase): # accelOverride is more or less the max throttle allowed to pcm: usually set to a constant # unless aTargetMax is very high and then we scale with it; this help in quicker restart - return float(max(max_accel, a_target / A_ACC_MAX)) * min(speedLimiter, accelLimiter) + return float(max(max_accel, a_target / A_CRUISE_MAX_VALS[0])) * min(speedLimiter, accelLimiter) @staticmethod def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # pylint: disable=dangerous-default-value diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index c60280e569..3896d40c0b 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -3,6 +3,7 @@ from cereal import car from selfdrive.car import dbc_dict from selfdrive.config import Conversions as CV +from selfdrive.controls.lib.longitudinal_planner import A_CRUISE_MAX_VALS Ecu = car.CarParams.Ecu MIN_ACC_SPEED = 19. * CV.MPH_TO_MS @@ -10,7 +11,7 @@ PEDAL_HYST_GAP = 3. * CV.MPH_TO_MS class CarControllerParams: ACCEL_HYST_GAP = 0.02 # don't change accel command for small oscilalitons within this value - ACCEL_MAX = 1.5 # 1.5 m/s2 + ACCEL_MAX = A_CRUISE_MAX_VALS[0] ACCEL_MIN = -3.0 # 3 m/s2 ACCEL_SCALE = max(ACCEL_MAX, -ACCEL_MIN) diff --git a/selfdrive/controls/lib/longitudinal_planner.py b/selfdrive/controls/lib/longitudinal_planner.py index 9f7c0016b5..d95f68b3eb 100755 --- a/selfdrive/controls/lib/longitudinal_planner.py +++ b/selfdrive/controls/lib/longitudinal_planner.py @@ -19,13 +19,18 @@ from selfdrive.swaglog import cloudlog LON_MPC_STEP = 0.2 # first step is 0.2s AWARENESS_DECEL = -0.2 # car smoothly decel at .2m/s^2 when user is distracted A_CRUISE_MIN = -1.2 -A_CRUISE_MAX = 1.2 +A_CRUISE_MAX_VALS = [1.2, 1.2, 0.8] +A_CRUISE_MAX_BP = [0., 15., 40.] # Lookup table for turns _A_TOTAL_MAX_V = [1.7, 3.2] _A_TOTAL_MAX_BP = [20., 40.] +def get_max_accel(v_ego): + return interp(v_ego, A_CRUISE_MAX_BP, A_CRUISE_MAX_VALS) + + def limit_accel_in_turns(v_ego, angle_steers, a_target, CP): """ This function returns a limited long acceleration allowed, depending on the existing lateral acceleration @@ -85,7 +90,7 @@ class Planner(): self.v_desired = self.alpha * self.v_desired + (1 - self.alpha) * v_ego self.v_desired = max(0.0, self.v_desired) - accel_limits = [A_CRUISE_MIN, A_CRUISE_MAX] + accel_limits = [A_CRUISE_MIN, get_max_accel(v_ego)] accel_limits_turns = limit_accel_in_turns(v_ego, sm['carState'].steeringAngleDeg, accel_limits, self.CP) if force_slow_decel: # if required so, force a smooth deceleration diff --git a/selfdrive/test/process_replay/ref_commit b/selfdrive/test/process_replay/ref_commit index c494d5cb3f..f9db78fd5b 100644 --- a/selfdrive/test/process_replay/ref_commit +++ b/selfdrive/test/process_replay/ref_commit @@ -1 +1 @@ -c59e46e21147ee1dc44b7fe2b5d1e4a16842c6c5 \ No newline at end of file +9837021bf19bf6cddd6ef737564158b05c7333ed \ No newline at end of file