From b72042042f52caa10ece85a8044c44af3f079cd8 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Thu, 23 Jul 2026 14:37:54 -0500 Subject: [PATCH] Sip-smiling away --- opendbc_repo/opendbc/car/hyundai/interface.py | 4 +- .../opendbc/car/hyundai/tests/test_hyundai.py | 8 +++- .../controls/lib/latcontrol_vehicle_tunes.py | 38 ++++++++++++++----- selfdrive/controls/tests/test_latcontrol.py | 12 ++++++ .../the_galaxy/assets/components/router.js | 2 +- .../components/tools/device_settings.js | 2 +- .../system/the_galaxy/templates/index.html | 2 +- 7 files changed, 53 insertions(+), 15 deletions(-) diff --git a/opendbc_repo/opendbc/car/hyundai/interface.py b/opendbc_repo/opendbc/car/hyundai/interface.py index 3db138b24..5d79baaaf 100644 --- a/opendbc_repo/opendbc/car/hyundai/interface.py +++ b/opendbc_repo/opendbc/car/hyundai/interface.py @@ -28,6 +28,7 @@ ENABLE_BUTTONS = (ButtonType.accelCruise, ButtonType.decelCruise, ButtonType.can # Track when ECU disable happened - used to permanently suppress CAN errors from disabled ECU ECU_DISABLE_TIMESTAMP = 0.0 KONA_NON_SCC_FCA_RADAR_ADDR = 0x602 +KIA_EV9_ACCEL_MAX = 2.5 def apply_platform_longitudinal_params(ret: structs.CarParams) -> None: @@ -80,7 +81,8 @@ class CarInterface(CarInterfaceBase): @staticmethod def get_pid_accel_limits(CP, current_speed, cruise_speed): - return ACCEL_MIN, CarControllerParams.ACCEL_MAX + accel_max = KIA_EV9_ACCEL_MAX if CP.carFingerprint == CAR.KIA_EV9 else CarControllerParams.ACCEL_MAX + return ACCEL_MIN, accel_max @staticmethod def apply_post_fingerprint_params(CP: structs.CarParams, candidate, fingerprint, car_fw) -> None: diff --git a/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py b/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py index 8161b78ba..d523b7b4b 100644 --- a/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py +++ b/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py @@ -17,7 +17,7 @@ from opendbc.car.hyundai.carcontroller import CarController, Ioniq6LongitudinalT direct_angle_request_allowed, get_angle_smoothing_alpha, \ should_use_ev6_gt_line_stop_direct_tracking from opendbc.car.hyundai.carstate import CarState, decode_canfd_camera_lead, decode_ioniq_6_blindspot_radar_state -from opendbc.car.hyundai.interface import CarInterface +from opendbc.car.hyundai.interface import CarInterface, KIA_EV9_ACCEL_MAX from opendbc.car.hyundai import hyundaican, hyundaicanfd from opendbc.car.hyundai.hyundaicanfd import CanBus from opendbc.car.hyundai.radar_interface import MRREVO14F_RADAR_START_ADDR, MRR30_RADAR_START_ADDR, MRR35_RADAR_START_ADDR, \ @@ -26,7 +26,7 @@ from opendbc.car.hyundai.values import CAMERA_SCC_CAR, CANFD_CAR, CAN_GEARS, CAR HYBRID_CAR, EV_CAR, FW_QUERY_CONFIG, LEGACY_SAFETY_MODE_CAR, CANFD_FUZZY_WHITELIST, \ UNSUPPORTED_LONGITUDINAL_CAR, PLATFORM_CODE_ECUS, HYUNDAI_VERSION_REQUEST_LONG, \ LEGACY_LONGITUDINAL_CAR, DBC, HyundaiFlags, get_platform_codes, HyundaiSafetyFlags, \ - HyundaiStarPilotSafetyFlags, Buttons, kia_ev6_gt_line_longitudinal_tuning + HyundaiStarPilotSafetyFlags, Buttons, CarControllerParams, kia_ev6_gt_line_longitudinal_tuning LongCtrlState = CarControl.Actuators.LongControlState from opendbc.car.hyundai.fingerprints import FW_VERSIONS @@ -1117,6 +1117,10 @@ class TestHyundaiFingerprint: assert CP.startAccel == pytest.approx(0.2) assert CP.vEgoStarting == pytest.approx(0.5) assert CP.longitudinalActuatorDelay == pytest.approx(0.3) + assert CarInterface.get_pid_accel_limits(CP, 0.0, 0.0)[1] == pytest.approx(KIA_EV9_ACCEL_MAX) + + ioniq_6_cp = CarInterface.get_params(CAR.HYUNDAI_IONIQ_6, gen_empty_fingerprint(), [], True, False, False, toggles) + assert CarInterface.get_pid_accel_limits(ioniq_6_cp, 0.0, 0.0)[1] == pytest.approx(CarControllerParams.ACCEL_MAX) def test_ioniq_6_longitudinal_tuning_helper_matches_dynamic_profile(self): state = Ioniq6LongitudinalTuningState() diff --git a/selfdrive/controls/lib/latcontrol_vehicle_tunes.py b/selfdrive/controls/lib/latcontrol_vehicle_tunes.py index 29878918e..6489a2af6 100644 --- a/selfdrive/controls/lib/latcontrol_vehicle_tunes.py +++ b/selfdrive/controls/lib/latcontrol_vehicle_tunes.py @@ -671,10 +671,15 @@ KIA_EV6_UNWIND_TAPER_LEFT = 0.56 KIA_EV6_UNWIND_TAPER_RIGHT = 0.54 KIA_EV6_BASE_UNWIND_TAPER_LEFT = 0.06 KIA_EV6_BASE_UNWIND_TAPER_RIGHT = 0.05 -KIA_EV6_JWARM_BASE_TURN_IN_BOOST_LEFT = 0.12 -KIA_EV6_JWARM_BASE_TURN_IN_BOOST_RIGHT = 0.14 -KIA_EV6_JWARM_BASE_UNWIND_TAPER_LEFT = 0.15 -KIA_EV6_JWARM_BASE_UNWIND_TAPER_RIGHT = 0.16 +KIA_EV6_JWARM_BASE_TURN_IN_BOOST_LEFT = 0.13 +KIA_EV6_JWARM_BASE_TURN_IN_BOOST_RIGHT = 0.15 +KIA_EV6_JWARM_BASE_UNWIND_TAPER_LEFT = 0.17 +KIA_EV6_JWARM_BASE_UNWIND_TAPER_RIGHT = 0.18 +KIA_EV6_JWARM_PHASE_STABILITY_MAX_REDUCTION = 0.55 +KIA_EV6_JWARM_PHASE_STABILITY_SPEED = 10.0 +KIA_EV6_JWARM_PHASE_STABILITY_SPEED_WIDTH = 1.8 +KIA_EV6_JWARM_PHASE_STABILITY_JERK = 0.70 +KIA_EV6_JWARM_PHASE_STABILITY_JERK_WIDTH = 0.18 KIA_EV6_FRICTION_MULT = 1.01 KIA_EV6_FRICTION_LAT_RISE = 0.18 KIA_EV6_FRICTION_JERK_RISE = 0.22 @@ -2433,6 +2438,16 @@ def _kia_ev6_transition_envelope(v_ego: float, desired_lateral_accel: float, des return _kia_ev6_low_speed_factor(v_ego) * lat_factor * jerk_factor +def get_kia_ev6_jwarm_phase_confidence(v_ego: float, desired_lateral_jerk: float) -> float: + low_speed_weight = _kia_ev6_sigmoid( + (KIA_EV6_JWARM_PHASE_STABILITY_SPEED - v_ego) / KIA_EV6_JWARM_PHASE_STABILITY_SPEED_WIDTH + ) + abrupt_transition_weight = _kia_ev6_sigmoid( + (abs(desired_lateral_jerk) - KIA_EV6_JWARM_PHASE_STABILITY_JERK) / KIA_EV6_JWARM_PHASE_STABILITY_JERK_WIDTH + ) + return 1.0 - (KIA_EV6_JWARM_PHASE_STABILITY_MAX_REDUCTION * low_speed_weight * abrupt_transition_weight) + + def get_kia_ev6_ff_scale(desired_lateral_accel: float, desired_lateral_jerk: float, v_ego: float) -> float: if desired_lateral_accel == 0.0: return 1.0 @@ -2463,17 +2478,22 @@ def get_kia_ev6_ff_scale(desired_lateral_accel: float, desired_lateral_jerk: flo ) * unwind_weight * (0.35 + 0.65 * low_speed_factor)) jwarm_tune = kia_ev6_lateral_testing_ground_active() + jwarm_phase_confidence = get_kia_ev6_jwarm_phase_confidence(v_ego, desired_lateral_jerk) if jwarm_tune else 0.0 base_turn_in_boost = 1.0 + ((_kia_ev6_side_value( desired_lateral_accel, KIA_EV6_JWARM_BASE_TURN_IN_BOOST_LEFT, KIA_EV6_JWARM_BASE_TURN_IN_BOOST_RIGHT, - ) if jwarm_tune else 0.0) * turn_in_weight * onset * cutoff) + ) if jwarm_tune else 0.0) * + jwarm_phase_confidence * turn_in_weight * onset * cutoff) + base_unwind_taper_left = _flm_vehicle_knob("hyundai_kia_ev6.base_unwind_taper_left", KIA_EV6_BASE_UNWIND_TAPER_LEFT) + base_unwind_taper_right = _flm_vehicle_knob("hyundai_kia_ev6.base_unwind_taper_right", KIA_EV6_BASE_UNWIND_TAPER_RIGHT) + if jwarm_tune: + base_unwind_taper_left += (KIA_EV6_JWARM_BASE_UNWIND_TAPER_LEFT - base_unwind_taper_left) * jwarm_phase_confidence + base_unwind_taper_right += (KIA_EV6_JWARM_BASE_UNWIND_TAPER_RIGHT - base_unwind_taper_right) * jwarm_phase_confidence base_unwind_taper = 1.0 - (_kia_ev6_side_value( desired_lateral_accel, - KIA_EV6_JWARM_BASE_UNWIND_TAPER_LEFT if jwarm_tune else - _flm_vehicle_knob("hyundai_kia_ev6.base_unwind_taper_left", KIA_EV6_BASE_UNWIND_TAPER_LEFT), - KIA_EV6_JWARM_BASE_UNWIND_TAPER_RIGHT if jwarm_tune else - _flm_vehicle_knob("hyundai_kia_ev6.base_unwind_taper_right", KIA_EV6_BASE_UNWIND_TAPER_RIGHT), + base_unwind_taper_left, + base_unwind_taper_right, ) * unwind_weight * onset * cutoff) return (base_unwind_taper * base_turn_in_boost) + (extra_scale * turn_in_boost * max(unwind_taper, 0.0)) diff --git a/selfdrive/controls/tests/test_latcontrol.py b/selfdrive/controls/tests/test_latcontrol.py index 35d43b9de..4b447bb27 100644 --- a/selfdrive/controls/tests/test_latcontrol.py +++ b/selfdrive/controls/tests/test_latcontrol.py @@ -90,6 +90,7 @@ from openpilot.selfdrive.controls.lib.latcontrol_torque import ( get_kia_ev6_ff_scale, get_kia_ev6_friction_scale, get_kia_ev6_friction_threshold, + get_kia_ev6_jwarm_phase_confidence, get_sonata_center_taper_scale, get_sonata_ff_scale, get_sonata_hybrid_center_taper_scale, @@ -1203,6 +1204,17 @@ class TestLatControl: assert get_kia_ev6_ff_scale(0.45, -0.7, 10.0) < normal_unwind_left - 0.07 assert get_kia_ev6_ff_scale(-0.45, 0.7, 10.0) < normal_unwind_right - 0.08 + def test_kia_ev6_jwarm_abrupt_low_speed_phase_correction_is_bounded(self): + calm_low_speed = get_kia_ev6_jwarm_phase_confidence(6.0, 0.25) + abrupt_low_speed = get_kia_ev6_jwarm_phase_confidence(6.0, 1.40) + abrupt_high_speed = get_kia_ev6_jwarm_phase_confidence(18.0, 1.40) + + assert abrupt_low_speed < calm_low_speed + assert abrupt_low_speed < abrupt_high_speed + assert 0.45 <= abrupt_low_speed < 0.60 + assert calm_low_speed > 0.90 + assert abrupt_high_speed > 0.98 + def test_kia_ev6_center_taper_curve(self): assert get_kia_ev6_center_taper_scale(0.0, 25.0) < get_kia_ev6_center_taper_scale(0.0, 10.0) assert get_kia_ev6_center_taper_scale(0.0, 25.0) < get_kia_ev6_center_taper_scale(0.20, 25.0) <= 1.0 diff --git a/starpilot/system/the_galaxy/assets/components/router.js b/starpilot/system/the_galaxy/assets/components/router.js index 8a14db9ad..d09ef9849 100644 --- a/starpilot/system/the_galaxy/assets/components/router.js +++ b/starpilot/system/the_galaxy/assets/components/router.js @@ -1,7 +1,7 @@ import { html, reactive } from "/assets/vendor/arrow-core.js" import { createBrowserHistory, createRouter } from "/assets/vendor/remix-router-1.3.1.js" import { hideSidebar } from "/assets/js/utils.js" -import { DeviceSettings } from "/assets/components/tools/device_settings.js?v=favorite-actions-1" +import { DeviceSettings } from "/assets/components/tools/device_settings.js?v=favorite-c4-hint-1" import { ErrorLogs } from "/assets/components/tools/error_logs.js" import { VehicleFeatures } from "/assets/components/tools/vehicle_features.js" import { GalaxyPairing } from "/assets/components/tools/galaxy.js" diff --git a/starpilot/system/the_galaxy/assets/components/tools/device_settings.js b/starpilot/system/the_galaxy/assets/components/tools/device_settings.js index cdef0643b..09916e757 100644 --- a/starpilot/system/the_galaxy/assets/components/tools/device_settings.js +++ b/starpilot/system/the_galaxy/assets/components/tools/device_settings.js @@ -1376,7 +1376,7 @@ function renderFavoriteSlotsPanel() {