From 5066d2c04c38ac1176573cf0e3a70bf0ab1ef265 Mon Sep 17 00:00:00 2001 From: Tim Wilson Date: Mon, 8 Aug 2022 14:55:40 -0600 Subject: [PATCH] GM: separate EV/ICE gas/brake lookup tables (#25354) * GM: separate EV/ICE gas/brake lookup tables * removed blank line * V are the same * comment better ordering comment comment * Add some delay for the laggy brakes Add some delay for the laggy brakes * move actuator to only acadia * start braking at 0 m/s/s * Revert "start braking at 0 m/s/s" This reverts commit 55c1dee733aab3dc037fb1705c9bd0ace55c849f. * add delay for escalade * revert EV changes * Update selfdrive/car/gm/carcontroller.py * comment * only ACADIA Co-authored-by: Shane Smiskol old-commit-hash: 2a4020da60b9c383efa75a5ffb54df3bc10756a0 --- selfdrive/car/gm/carcontroller.py | 10 +++++++--- selfdrive/car/gm/interface.py | 1 + selfdrive/car/gm/values.py | 16 ++++++++++++---- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/selfdrive/car/gm/carcontroller.py b/selfdrive/car/gm/carcontroller.py index 727c05efdd..0e74065143 100644 --- a/selfdrive/car/gm/carcontroller.py +++ b/selfdrive/car/gm/carcontroller.py @@ -5,7 +5,7 @@ from common.realtime import DT_CTRL from opendbc.can.packer import CANPacker from selfdrive.car import apply_std_steer_torque_limits from selfdrive.car.gm import gmcan -from selfdrive.car.gm.values import DBC, CanBus, CarControllerParams +from selfdrive.car.gm.values import DBC, CanBus, CarControllerParams, EV_CAR VisualAlert = car.CarControl.HUDControl.VisualAlert NetworkLocation = car.CarParams.NetworkLocation @@ -68,8 +68,12 @@ class CarController: self.apply_gas = self.params.MAX_ACC_REGEN self.apply_brake = 0 else: - self.apply_gas = int(round(interp(actuators.accel, self.params.GAS_LOOKUP_BP, self.params.GAS_LOOKUP_V))) - self.apply_brake = int(round(interp(actuators.accel, self.params.BRAKE_LOOKUP_BP, self.params.BRAKE_LOOKUP_V))) + if self.CP.carFingerprint in EV_CAR: + self.apply_gas = int(round(interp(actuators.accel, self.params.EV_GAS_LOOKUP_BP, self.params.GAS_LOOKUP_V))) + self.apply_brake = int(round(interp(actuators.accel, self.params.EV_BRAKE_LOOKUP_BP, self.params.BRAKE_LOOKUP_V))) + else: + self.apply_gas = int(round(interp(actuators.accel, self.params.GAS_LOOKUP_BP, self.params.GAS_LOOKUP_V))) + self.apply_brake = int(round(interp(actuators.accel, self.params.BRAKE_LOOKUP_BP, self.params.BRAKE_LOOKUP_V))) idx = (self.frame // 4) % 4 diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index ab6581201b..10ae670ac8 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -118,6 +118,7 @@ class CarInterface(CarInterfaceBase): ret.steerRatio = 14.4 # end to end is 13.46 ret.centerToFront = ret.wheelbase * 0.4 ret.lateralTuning.pid.kf = 1. # get_steer_feedforward_acadia() + ret.longitudinalActuatorDelayUpperBound = 0.5 # large delay to initially start braking elif candidate == CAR.BUICK_REGAL: ret.mass = 3779. * CV.LB_TO_KG + STD_CARGO_KG # (3849+3708)/2 diff --git a/selfdrive/car/gm/values.py b/selfdrive/car/gm/values.py index e4735524d3..016910a40f 100644 --- a/selfdrive/car/gm/values.py +++ b/selfdrive/car/gm/values.py @@ -39,13 +39,17 @@ class CarControllerParams: ACCEL_MAX = 2. # m/s^2 ACCEL_MIN = -4. # m/s^2 - GAS_LOOKUP_BP = [-1., 0., ACCEL_MAX] + EV_GAS_LOOKUP_BP = [-1., 0., ACCEL_MAX] + EV_BRAKE_LOOKUP_BP = [ACCEL_MIN, -1.] + + # ICE has much less engine braking force compared to regen in EVs, + # lower threshold removes some braking deadzone + GAS_LOOKUP_BP = [-0.1, 0., ACCEL_MAX] + BRAKE_LOOKUP_BP = [ACCEL_MIN, -0.1] + GAS_LOOKUP_V = [MAX_ACC_REGEN, ZERO_GAS, MAX_GAS] - BRAKE_LOOKUP_BP = [ACCEL_MIN, -1.] BRAKE_LOOKUP_V = [MAX_BRAKE, 0.] -STEER_THRESHOLD = 1.0 - class CAR: HOLDEN_ASTRA = "HOLDEN ASTRA RS-V BK 2017" @@ -57,6 +61,10 @@ class CAR: ESCALADE_ESV = "CADILLAC ESCALADE ESV 2016" +EV_CAR = {CAR.VOLT} +STEER_THRESHOLD = 1.0 + + class Footnote(Enum): OBD_II = CarFootnote( 'Requires a community built ASCM harness. ' +