From d08da1ff22e2574dfc4ada45b61acf665f043848 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Wed, 24 Jun 2026 22:31:44 -0500 Subject: [PATCH] volt opd adjust --- opendbc_repo/opendbc/car/gm/carcontroller.py | 22 ++++++++++++++++++++ opendbc_repo/opendbc/car/gm/tests/test_gm.py | 6 ++++++ 2 files changed, 28 insertions(+) diff --git a/opendbc_repo/opendbc/car/gm/carcontroller.py b/opendbc_repo/opendbc/car/gm/carcontroller.py index 2784fac51..946feba92 100644 --- a/opendbc_repo/opendbc/car/gm/carcontroller.py +++ b/opendbc_repo/opendbc/car/gm/carcontroller.py @@ -59,6 +59,9 @@ VOLT_ONE_PEDAL_DECEL_RATE_LIMIT_DOWN = 0.8 * DT_CTRL * 4 VOLT_ONE_PEDAL_ACCEL_PITCH_FACTOR_BP = [4.0, 8.0] VOLT_ONE_PEDAL_ACCEL_PITCH_FACTOR_V = [0.4, 1.0] VOLT_ONE_PEDAL_ACCEL_PITCH_FACTOR_INCLINE_V = [0.2, 1.0] +VOLT_ONE_PEDAL_LIFT_BRAKE_BP = [0.0, CarControllerParams.NEAR_STOP_BRAKE_PHASE, 2.0 * CV.MPH_TO_MS] +VOLT_ONE_PEDAL_LIFT_BRAKE_V = [AUTO_HOLD_MIN_BRAKE, AUTO_HOLD_MIN_BRAKE, 20.0] +VOLT_ONE_PEDAL_LIFT_BRAKE_FRAMES = 8 TRUCK_LONG_SMOOTH_CARS = { CAR.CHEVROLET_SILVERADO, CAR.CHEVROLET_SILVERADO_CC, @@ -253,6 +256,13 @@ def get_volt_one_pedal_target_decel(v_ego: float) -> float: return float(np.interp(v_ego, VOLT_ONE_PEDAL_DECEL_BP, VOLT_ONE_PEDAL_DECEL_V)) +def get_volt_one_pedal_lift_brake(v_ego: float) -> int: + if v_ego > VOLT_ONE_PEDAL_LIFT_BRAKE_BP[-1]: + return 0 + + return int(round(np.interp(v_ego, VOLT_ONE_PEDAL_LIFT_BRAKE_BP, VOLT_ONE_PEDAL_LIFT_BRAKE_V))) + + def should_activate_volt_one_pedal(one_pedal_ready: bool, cruise_main: bool, long_active: bool, gas_pressed: bool, brake_pressed: bool, regen_braking: bool, single_pedal_mode: bool, gear_shifter, drive_time_s: float) -> bool: @@ -419,6 +429,8 @@ class CarController(CarControllerBase): ) self.volt_one_pedal_decel = 0.0 self.volt_one_pedal_brake = 0 + self.volt_one_pedal_lift_frames = 0 + self.volt_one_pedal_gas_pressed_last = False try: self.gm_auto_hold_enabled = self.params_.get_bool("GMAutoHold") except UnknownKeyName: @@ -429,6 +441,7 @@ class CarController(CarControllerBase): self.volt_one_pedal_pid.reset() self.volt_one_pedal_decel = min(0.0, float(self.aego)) self.volt_one_pedal_brake = 0 + self.volt_one_pedal_lift_frames = 0 def _update_volt_one_pedal_brake(self, CC, CS): pitch_accel = 0.0 @@ -456,6 +469,9 @@ class CarController(CarControllerBase): 0, self.params.MAX_BRAKE, ))) + if self.volt_one_pedal_lift_frames > 0: + self.volt_one_pedal_brake = max(self.volt_one_pedal_brake, get_volt_one_pedal_lift_brake(CS.out.vEgo)) + self.volt_one_pedal_lift_frames -= 1 def calc_pedal_command(self, accel: float, long_active: bool, v_ego: float): if not long_active: @@ -623,6 +639,11 @@ class CarController(CarControllerBase): CS.out.gearShifter, float(getattr(CS, "one_pedal_drive_time", 0.0)), ) + if volt_one_pedal_active and self.volt_one_pedal_gas_pressed_last and not CS.out.gasPressed: + if CS.out.vEgo < VOLT_ONE_PEDAL_LIFT_BRAKE_BP[-1]: + self.volt_one_pedal_lift_frames = VOLT_ONE_PEDAL_LIFT_BRAKE_FRAMES + elif CS.out.gasPressed or not volt_one_pedal_active: + self.volt_one_pedal_lift_frames = 0 if self.frame % 4 == 0: if volt_one_pedal_active: @@ -632,6 +653,7 @@ class CarController(CarControllerBase): if not self.CP.openpilotLongitudinalControl: self.apply_gas = 0 self.apply_brake = self.volt_one_pedal_brake if volt_one_pedal_active else 0 + self.volt_one_pedal_gas_pressed_last = CS.out.gasPressed stock_hold_apply_brake = max(self.apply_brake if self.CP.openpilotLongitudinalControl else 0, self.volt_one_pedal_brake) diff --git a/opendbc_repo/opendbc/car/gm/tests/test_gm.py b/opendbc_repo/opendbc/car/gm/tests/test_gm.py index 1e9af8b93..30fe9c455 100644 --- a/opendbc_repo/opendbc/car/gm/tests/test_gm.py +++ b/opendbc_repo/opendbc/car/gm/tests/test_gm.py @@ -12,6 +12,7 @@ from opendbc.car.gm.carstate import CarState as GMCarState, get_hard_cruise_butt from opendbc.car.gm.carcontroller import ( VisualAlert, get_acc_dashboard_fcw_alert, + get_volt_one_pedal_lift_brake, should_send_acc_dashboard_status, should_send_cc_button_spam, should_spoof_dash_speed, @@ -350,6 +351,11 @@ class TestGMCarController: assert should_spoof_dash_speed(cp, SimpleNamespace(disable_openpilot_long=False)) + def test_volt_one_pedal_lift_brake_seeds_low_speed_braking(self): + assert get_volt_one_pedal_lift_brake(2.1 * CV.MPH_TO_MS) == 0 + assert get_volt_one_pedal_lift_brake(2.0 * CV.MPH_TO_MS) == 20 + assert get_volt_one_pedal_lift_brake(0.10) == 80 + def test_volt_camera_no_camera_sends_acc_dashboard_without_dash_spoof(self): cp = SimpleNamespace(carFingerprint=CAR.CHEVROLET_VOLT_CAMERA, flags=GMFlags.NO_CAMERA.value)