From a89ba13130f71d4d3059f690464c3a088dad007b Mon Sep 17 00:00:00 2001 From: firestar4430 Date: Sat, 23 Nov 2024 15:59:42 -0600 Subject: [PATCH] New Bolt Pedal Tune --- panda/board/safety/safety_gm.h | 2 +- selfdrive/car/gm/carcontroller.py | 15 +++++++-------- selfdrive/car/gm/carstate.py | 2 +- selfdrive/car/gm/interface.py | 8 ++++---- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/panda/board/safety/safety_gm.h b/panda/board/safety/safety_gm.h index c7ae19b7def0c2..eec13181eb8498 100644 --- a/panda/board/safety/safety_gm.h +++ b/panda/board/safety/safety_gm.h @@ -43,7 +43,7 @@ const int GM_STANDSTILL_THRSLD = 10; // 0.311kph // panda interceptor threshold needs to be equivalent to openpilot threshold to avoid controls mismatches // If thresholds are mismatched then it is possible for panda to see the gas fall and rise while openpilot is in the pre-enabled state -const int GM_GAS_INTERCEPTOR_THRESHOLD = 515; // (675 + 355) / 2 ratio between offset and gain from dbc file +const int GM_GAS_INTERCEPTOR_THRESHOLD = 550; // (675 + 355) / 2 ratio between offset and gain from dbc file #define GM_GET_INTERCEPTOR(msg) (((GET_BYTE((msg), 0) << 8) + GET_BYTE((msg), 1) + (GET_BYTE((msg), 2) << 8) + GET_BYTE((msg), 3)) / 2U) // avg between 2 tracks const CanMsg GM_ASCM_TX_MSGS[] = {{0x180, 0, 4}, {0x409, 0, 7}, {0x40A, 0, 7}, {0x2CB, 0, 8}, {0x370, 0, 6}, {0x200, 0, 6}, // pt bus diff --git a/selfdrive/car/gm/carcontroller.py b/selfdrive/car/gm/carcontroller.py index b77a8e8f1697e7..92fe2a3d8dbba3 100644 --- a/selfdrive/car/gm/carcontroller.py +++ b/selfdrive/car/gm/carcontroller.py @@ -57,17 +57,16 @@ def __init__(self, dbc_name, CP, VM): self.accel_g = 0.0 @staticmethod - def calc_pedal_command(accel: float, long_active: bool) -> float: + def calc_pedal_command(accel: float, long_active: bool, car_velocity) -> float: if not long_active: return 0. - zero = 0.15625 # 40/256 - if accel > 0.: - # Scales the accel from 0-1 to 0.156-1 - pedal_gas = clip(((1 - zero) * accel + zero), 0., 1.) + if accel < -0.5: + pedal_gas = 0 else: - # if accel is negative, -0.1 -> 0.015625 - pedal_gas = clip(zero + accel, 0., zero) # Make brake the same size as gas, but clip to regen + pedaloffset = interp(car_velocity, [0., 3, 6, 30], [0.10, 0.175, 0.240, 0.240]) + pedal_gas = clip((pedaloffset + accel * 0.6), 0.0, 1.0) + return pedal_gas @@ -160,7 +159,7 @@ def update(self, CC, CS, now_nanos, frogpilot_toggles): self.apply_gas = self.params.INACTIVE_REGEN if self.CP.carFingerprint in CC_ONLY_CAR: # gas interceptor only used for full long control on cars without ACC - interceptor_gas_cmd = self.calc_pedal_command(actuators.accel, CC.longActive) + interceptor_gas_cmd = self.calc_pedal_command(actuators.accel, CC.longActive, CS.out.vEgo) if self.CP.enableGasInterceptor and self.apply_gas > self.params.INACTIVE_REGEN and CS.out.cruiseState.standstill: # "Tap" the accelerator pedal to re-engage ACC diff --git a/selfdrive/car/gm/carstate.py b/selfdrive/car/gm/carstate.py index b1728bd396dfec..dec2b30186dbb8 100644 --- a/selfdrive/car/gm/carstate.py +++ b/selfdrive/car/gm/carstate.py @@ -96,7 +96,7 @@ def update(self, pt_cp, cam_cp, loopback_cp, frogpilot_toggles): if self.CP.enableGasInterceptor: ret.gas = (pt_cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS"] + pt_cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS2"]) / 2. - threshold = 10 if self.CP.carFingerprint in CAMERA_ACC_CAR else 4 # Panda 515 threshold = 10.88. Set lower to avoid panda blocking messages and GasInterceptor faulting. + threshold = 20 if self.CP.carFingerprint in CAMERA_ACC_CAR else 4 # Panda 515 threshold = 10.88. Set lower to avoid panda blocking messages and GasInterceptor faulting. ret.gasPressed = ret.gas > threshold else: ret.gas = pt_cp.vl["AcceleratorPedal2"]["AcceleratorPedal2"] / 254. diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index 337f268523c71c..49dfeed9e67024 100644 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -118,7 +118,7 @@ def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, exp ret.vEgoStarting = 0.15 if use_new_api: - ret.longitudinalTuning.kiBP = [5., 35.] + ret.longitudinalTuning.kiBP = [5., 35., 60.] else: ret.longitudinalTuning.deadzoneBP = [0.] ret.longitudinalTuning.deadzoneV = [0.15] @@ -299,14 +299,14 @@ def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, exp ret.safetyConfigs[0].safetyParam |= Panda.FLAG_GM_PEDAL_LONG # Note: Low speed, stop and go not tested. Should be fairly smooth on highway if use_new_api: - ret.longitudinalTuning.kiBP = [0.0, 5., 35.] - ret.longitudinalTuning.kiV = [0.0, 0.35, 0.5] + ret.longitudinalTuning.kiBP = [0., 3., 6., 35.] + ret.longitudinalTuning.kiV = [0.125, 0.175, 0.225, 0.33] else: ret.longitudinalTuning.kpBP = [5., 35.] ret.longitudinalTuning.kpV = [0.35, 0.5] ret.longitudinalTuning.kiBP = [0., 35.0] ret.longitudinalTuning.kiV = [0.1, 0.1] - ret.longitudinalTuning.kf = 0.15 + ret.longitudinalTuning.kf = 0.25 ret.stoppingDecelRate = 0.8 else: # Pedal used for SNG, ACC for longitudinal control otherwise ret.safetyConfigs[0].safetyParam |= Panda.FLAG_GM_HW_CAM_LONG