From 47ba1544d3ab43c03d846ecc454bbcfd1319e1a5 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Sat, 8 Aug 2026 22:43:47 -0500 Subject: [PATCH] ev6 --- selfdrive/controls/lib/latcontrol_vehicle_tunes.py | 13 +++++++++++++ selfdrive/controls/tests/test_latcontrol.py | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/selfdrive/controls/lib/latcontrol_vehicle_tunes.py b/selfdrive/controls/lib/latcontrol_vehicle_tunes.py index dd6fadf85..586317ab5 100644 --- a/selfdrive/controls/lib/latcontrol_vehicle_tunes.py +++ b/selfdrive/controls/lib/latcontrol_vehicle_tunes.py @@ -774,6 +774,11 @@ KIA_EV6_CENTER_TAPER_LAT = 0.16 KIA_EV6_CENTER_TAPER_LAT_WIDTH = 0.04 KIA_EV6_CENTER_TAPER_SPEED = 17.0 KIA_EV6_CENTER_TAPER_SPEED_WIDTH = 2.8 +KIA_EV6_CENTER_FRICTION_THRESHOLD_GAIN = 0.08 +KIA_EV6_CENTER_FRICTION_THRESHOLD_LAT = 0.30 +KIA_EV6_CENTER_FRICTION_THRESHOLD_LAT_WIDTH = 0.07 +KIA_EV6_CENTER_FRICTION_THRESHOLD_SPEED = 18.0 +KIA_EV6_CENTER_FRICTION_THRESHOLD_SPEED_WIDTH = 2.5 KIA_EV6_LOW_SPEED_CENTER_TAPER_MAX = 0.19 KIA_EV6_LOW_SPEED_CENTER_TAPER_LAT = 0.08 KIA_EV6_LOW_SPEED_CENTER_TAPER_LAT_WIDTH = 0.02 @@ -2942,6 +2947,13 @@ def get_kia_ev6_friction_threshold(v_ego: float, desired_lateral_accel: float = _flm_vehicle_knob("hyundai_kia_ev6.unwind_threshold_increase_right", KIA_EV6_UNWIND_THRESHOLD_INCREASE_RIGHT), ) * transition_envelope * unwind_weight) + center_speed_weight = _kia_ev6_sigmoid((v_ego - KIA_EV6_CENTER_FRICTION_THRESHOLD_SPEED) / + KIA_EV6_CENTER_FRICTION_THRESHOLD_SPEED_WIDTH) + center_lat_weight = _kia_ev6_sigmoid((KIA_EV6_CENTER_FRICTION_THRESHOLD_LAT - abs(desired_lateral_accel)) / + KIA_EV6_CENTER_FRICTION_THRESHOLD_LAT_WIDTH) + threshold_scale += (_flm_vehicle_knob("hyundai_kia_ev6.center_friction_threshold_gain", + KIA_EV6_CENTER_FRICTION_THRESHOLD_GAIN) * + center_speed_weight * center_lat_weight) return base_threshold * min(max(threshold_scale, 0.82), 1.16) @@ -3332,6 +3344,7 @@ FLM_SUPPORTED_VEHICLE_KNOBS = { "hyundai_kia_ev6.turn_in_threshold_reduction_right": {"profile": "hyundai_kia_ev6", "min": 0.0, "max": 0.40, "precision": 0.001, "deltaType": "absolute", "safeLiveTrial": True, "defaultValue": KIA_EV6_TURN_IN_THRESHOLD_REDUCTION_RIGHT}, "hyundai_kia_ev6.unwind_threshold_increase_left": {"profile": "hyundai_kia_ev6", "min": 0.0, "max": 0.80, "precision": 0.001, "deltaType": "absolute", "safeLiveTrial": True, "defaultValue": KIA_EV6_UNWIND_THRESHOLD_INCREASE_LEFT}, "hyundai_kia_ev6.unwind_threshold_increase_right": {"profile": "hyundai_kia_ev6", "min": 0.0, "max": 0.80, "precision": 0.001, "deltaType": "absolute", "safeLiveTrial": True, "defaultValue": KIA_EV6_UNWIND_THRESHOLD_INCREASE_RIGHT}, + "hyundai_kia_ev6.center_friction_threshold_gain": {"profile": "hyundai_kia_ev6", "min": 0.0, "max": 0.20, "precision": 0.001, "deltaType": "absolute", "safeLiveTrial": True, "defaultValue": KIA_EV6_CENTER_FRICTION_THRESHOLD_GAIN}, "toyota_prius.ff_gain_left": {"profile": "toyota_prius", "min": 0.0, "max": 0.25, "precision": 0.001, "deltaType": "absolute", "safeLiveTrial": True, "defaultValue": PRIUS_FF_GAIN_LEFT}, "toyota_prius.ff_gain_right": {"profile": "toyota_prius", "min": 0.0, "max": 0.25, "precision": 0.001, "deltaType": "absolute", "safeLiveTrial": True, "defaultValue": PRIUS_FF_GAIN_RIGHT}, "toyota_prius.turn_in_boost_left": {"profile": "toyota_prius", "min": -0.10, "max": 0.60, "precision": 0.001, "deltaType": "absolute", "safeLiveTrial": True, "defaultValue": PRIUS_TURN_IN_BOOST_LEFT}, diff --git a/selfdrive/controls/tests/test_latcontrol.py b/selfdrive/controls/tests/test_latcontrol.py index ce6dc1dd4..c3fec9921 100644 --- a/selfdrive/controls/tests/test_latcontrol.py +++ b/selfdrive/controls/tests/test_latcontrol.py @@ -1074,6 +1074,15 @@ class TestLatControl: assert right_turn_in == left_turn_in < base < right_unwind == left_unwind assert get_kia_ev6_friction_threshold(25.0, 0.0, 0.0) >= get_hkg_canfd_base_friction_threshold(25.0) + def test_kia_ev6_center_friction_threshold_is_high_speed_only(self): + low_speed = get_kia_ev6_friction_threshold(10.0, 0.0, 0.0) + high_speed_center = get_kia_ev6_friction_threshold(34.0, 0.0, 0.0) + high_speed_curve = get_kia_ev6_friction_threshold(34.0, 0.55, 0.0) + + assert low_speed == pytest.approx(get_hkg_canfd_base_friction_threshold(10.0), abs=0.002) + assert high_speed_center > get_hkg_canfd_base_friction_threshold(34.0) + assert high_speed_curve < high_speed_center + def test_kia_ev6_friction_scale_curve(self): base = get_kia_ev6_friction_scale(25.0, 0.5, 0.8) left_turn_in = get_kia_ev6_friction_scale(6.0, 0.5, 0.8)