From 0b37a23c75759bfa389eb708686931639484e559 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Sun, 21 Jun 2026 17:00:32 -0500 Subject: [PATCH] new stuf --- opendbc_repo/opendbc/car/gm/carcontroller.py | 6 +++- .../car/gm/tests/test_carcontroller.py | 33 ++++++++++++++++++- selfdrive/controls/lib/latcontrol_torque.py | 8 ++--- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/opendbc_repo/opendbc/car/gm/carcontroller.py b/opendbc_repo/opendbc/car/gm/carcontroller.py index 3a42641077..2a41b05690 100644 --- a/opendbc_repo/opendbc/car/gm/carcontroller.py +++ b/opendbc_repo/opendbc/car/gm/carcontroller.py @@ -321,6 +321,10 @@ def get_bolt_acc_pedal_planner_brake_switch(v_ego: float, params, tire_radius: f return int(round(planner_torque + params.ZERO_GAS)) +def get_bolt_acc_pedal_effective_brake_switch(stock_switch: int, planner_switch: int) -> int: + return max(stock_switch, planner_switch) + + def get_bolt_acc_pedal_friction_command_state(apply_brake: int, cruise_main_on: bool, release_frames: int): command_brake = apply_brake if cruise_main_on else 0 @@ -868,7 +872,7 @@ class CarController(CarControllerBase): planner_brake_switch = get_bolt_acc_pedal_planner_brake_switch( CS.out.vEgo, self.params, self.tireRadius, self.mass, self.coeffDrag, self.frontalArea, self.airDensity, ) - brake_switch = min(brake_switch, planner_brake_switch) + brake_switch = get_bolt_acc_pedal_effective_brake_switch(brake_switch, planner_brake_switch) brake_accel = min((scaled_torque - brake_switch) / (self.tireRadius * self.mass), 0) self.apply_gas = int(round(apply_gas_torque)) self.apply_brake = int(round(np.interp(brake_accel, self.params.BRAKE_LOOKUP_BP, self.params.BRAKE_LOOKUP_V))) diff --git a/opendbc_repo/opendbc/car/gm/tests/test_carcontroller.py b/opendbc_repo/opendbc/car/gm/tests/test_carcontroller.py index d991472a57..d24fe7f34a 100644 --- a/opendbc_repo/opendbc/car/gm/tests/test_carcontroller.py +++ b/opendbc_repo/opendbc/car/gm/tests/test_carcontroller.py @@ -44,6 +44,7 @@ from opendbc.car.gm.carcontroller import ( get_auto_hold_stop_threshold, get_bolt_acc_pedal_friction_brake, get_bolt_acc_pedal_friction_command_state, + get_bolt_acc_pedal_effective_brake_switch, get_bolt_acc_pedal_planner_brake_switch, get_bolt_pedal_long_accel_limit, get_lka_steering_cmd_counter, @@ -165,7 +166,7 @@ def test_bolt_pedal_long_accel_limit_matches_planner_regen_envelope(): assert get_bolt_pedal_long_accel_limit(3.0) == pytest.approx(-1.70, abs=1e-3) -def test_bolt_acc_pedal_planner_brake_switch_delays_friction_vs_stock_switch(): +def test_bolt_acc_pedal_planner_brake_switch_is_lower_than_stock_switch(): params = SimpleNamespace(ZERO_GAS=6150, BRAKE_SWITCH_LOOKUP_BP=[0.5, 10.0], BRAKE_SWITCH_LOOKUP_V=[6150, 5500]) v_ego = 6.66 @@ -177,6 +178,36 @@ def test_bolt_acc_pedal_planner_brake_switch_delays_friction_vs_stock_switch(): assert planner_switch < stock_switch +def test_bolt_acc_pedal_effective_brake_switch_never_suppresses_stock_friction(): + params = SimpleNamespace(ZERO_GAS=6150, BRAKE_SWITCH_LOOKUP_BP=[0.5, 10.0], BRAKE_SWITCH_LOOKUP_V=[6150, 5500]) + v_ego = 5.434 + mass = 1805.0 + tire_radius = 0.075 * 2.63779 + 0.1453 + frontal_area = 1.05 * 2.63779 + 0.0679 + coeff_drag = 0.30 + air_density = 1.225 + accel_cmd = -1.399 + + aero_drag_force = 0.5 * coeff_drag * frontal_area * air_density * v_ego ** 2 + torque = tire_radius * ((mass * accel_cmd) + aero_drag_force) + scaled_torque = torque + params.ZERO_GAS + + stock_switch = int(round(np.interp(v_ego, params.BRAKE_SWITCH_LOOKUP_BP, params.BRAKE_SWITCH_LOOKUP_V))) + planner_switch = get_bolt_acc_pedal_planner_brake_switch( + v_ego, params, tire_radius=tire_radius, mass=mass, + coeff_drag=coeff_drag, frontal_area=frontal_area, air_density=air_density, + ) + effective_switch = get_bolt_acc_pedal_effective_brake_switch(stock_switch, planner_switch) + + stock_brake_accel = min((scaled_torque - stock_switch) / (tire_radius * mass), 0) + effective_brake_accel = min((scaled_torque - effective_switch) / (tire_radius * mass), 0) + + assert planner_switch < stock_switch + assert effective_switch == stock_switch + assert stock_brake_accel < 0 + assert effective_brake_accel == stock_brake_accel + + def test_bolt_acc_pedal_friction_command_state_requires_cruise_main_for_positive_brake(): command_brake, release_frames, should_send = get_bolt_acc_pedal_friction_command_state(120, False, 0) diff --git a/selfdrive/controls/lib/latcontrol_torque.py b/selfdrive/controls/lib/latcontrol_torque.py index b079f5b307..eaa30e6caa 100644 --- a/selfdrive/controls/lib/latcontrol_torque.py +++ b/selfdrive/controls/lib/latcontrol_torque.py @@ -573,12 +573,12 @@ IONIQ_6_HIGH_SPEED_RIGHT_TURN_IN_FF_LAT_START = 0.06 IONIQ_6_HIGH_SPEED_RIGHT_TURN_IN_FF_LAT_END = 0.22 IONIQ_6_HIGH_SPEED_RIGHT_TURN_IN_FF_LAT_WIDTH = 0.035 IONIQ_6_LOW_SPEED_PID_RESET_SPEED = 0.1 * CV.MPH_TO_MS -IONIQ_6_HEAVY_DIRECTIONAL_TAPER_LAT_START = 0.82 -IONIQ_6_HEAVY_DIRECTIONAL_TAPER_LAT_WIDTH = 0.12 +IONIQ_6_HEAVY_DIRECTIONAL_TAPER_LAT_START = 0.90 +IONIQ_6_HEAVY_DIRECTIONAL_TAPER_LAT_WIDTH = 0.18 IONIQ_6_HEAVY_DIRECTIONAL_TAPER_BASE_LEFT = 0.06 IONIQ_6_HEAVY_DIRECTIONAL_TAPER_BASE_RIGHT = 0.17 -IONIQ_6_HEAVY_DIRECTIONAL_TAPER_UNWIND_LEFT = 0.84 -IONIQ_6_HEAVY_DIRECTIONAL_TAPER_UNWIND_RIGHT = 1.18 +IONIQ_6_HEAVY_DIRECTIONAL_TAPER_UNWIND_LEFT = 0.78 +IONIQ_6_HEAVY_DIRECTIONAL_TAPER_UNWIND_RIGHT = 1.10 IONIQ_6_OUTPUT_TAPER_SPEED = 8.5 IONIQ_6_OUTPUT_TAPER_SPEED_WIDTH = 2.5 IONIQ_6_OUTPUT_CENTER_TAPER_BLEND = 0.90