From bb3b1429eb5c261c3e38e0abfdbdc43ff3452b1b Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Wed, 2 Sep 2026 22:07:29 -0500 Subject: [PATCH] I thought you said weast --- opendbc_repo/opendbc/car/hyundai/carstate.py | 12 +++++++--- .../opendbc/car/hyundai/tests/test_hyundai.py | 22 ++++++++++++++++++- .../opendbc/car/subaru/carcontroller.py | 3 ++- .../opendbc/car/subaru/tests/test_subaru.py | 18 ++------------- .../opendbc/dbc/hyundai_kia_generic.dbc | 1 + .../controls/lib/latcontrol_vehicle_tunes.py | 4 ++-- 6 files changed, 37 insertions(+), 23 deletions(-) diff --git a/opendbc_repo/opendbc/car/hyundai/carstate.py b/opendbc_repo/opendbc/car/hyundai/carstate.py index eb34a3576..525fdd2bd 100644 --- a/opendbc_repo/opendbc/car/hyundai/carstate.py +++ b/opendbc_repo/opendbc/car/hyundai/carstate.py @@ -36,6 +36,8 @@ CLASSIC_MEDIA_BUTTON_CARS = frozenset({ def get_non_scc_cruise_signals(CP) -> tuple[str, str, str, str, str, str]: + if CP.carFingerprint == CAR.KIA_RAY_EV: + return "LABEL11", "CC_React", "LABEL11", "CC_Engaged", "E_EMS11", "Cruise_Limit_Target" if CP.flags & HyundaiFlags.EV: return "LABEL11", "CC_React", "EMS12", "ACC_ACT", "E_EMS11", "Cruise_Limit_Target" if CP.flags & HyundaiFlags.HYBRID: @@ -348,9 +350,7 @@ class CarState(CarStateBase): # cruise state no_scc = bool(self.CP.flags & HyundaiFlags.NON_SCC) - if self.CP.carFingerprint == CAR.KIA_RAY_EV: - pass - elif no_scc: + if no_scc: cruise_available_msg, cruise_available_sig, cruise_enabled_msg, cruise_enabled_sig, cruise_speed_msg, cruise_speed_sig = get_non_scc_cruise_signals(self.CP) ret.cruiseState.available = cp.vl[cruise_available_msg][cruise_available_sig] != 0 ret.cruiseState.enabled = cp.vl[cruise_enabled_msg][cruise_enabled_sig] != 0 @@ -725,6 +725,12 @@ class CarState(CarStateBase): ("BCM_PO_11", 0), ("CLU13", 0), ] + if CP.carFingerprint == CAR.KIA_RAY_EV: + msgs += [ + ("LABEL11", 10), + ("E_EMS11", 100), + ("ELECT_GEAR", 100), + ] if CP.carFingerprint in CLASSIC_MEDIA_BUTTON_CARS: # Steering-wheel media switches are event-driven on the refresh Elantra. msgs.append(("GW_SWRC_PE", 0)) diff --git a/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py b/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py index 2515a5c13..6fcd7e784 100644 --- a/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py +++ b/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py @@ -926,7 +926,7 @@ class TestHyundaiFingerprint: (CAR.HYUNDAI_ELANTRA_2022_NON_SCC, ("EMS16", "LVR12"), ()), (CAR.HYUNDAI_ELANTRA_HEV_2022_NON_SCC, ("E_CRUISE_CONTROL", "ELECT_GEAR"), ("EMS16",)), (CAR.HYUNDAI_KONA_EV_NON_SCC, ("LABEL11", "EMS12", "E_EMS11"), ()), - (CAR.KIA_RAY_EV, ("E_EMS11",), ("LABEL11", "EMS12", "SCC11", "SCC12")), + (CAR.KIA_RAY_EV, ("LABEL11", "E_EMS11", "ELECT_GEAR"), ("EMS12", "SCC11", "SCC12")), ]) def test_non_scc_cruise_message_selection(self, candidate, expected_msgs, unexpected_msgs): toggles = get_test_toggles() @@ -945,6 +945,26 @@ class TestHyundaiFingerprint: assert not ret.cruiseState.enabled assert ret.cruiseState.speed == 0 + def test_kia_ray_ev_decodes_cruise_state(self): + toggles = get_test_toggles() + CP = CarInterface.get_params(CAR.KIA_RAY_EV, gen_empty_fingerprint(), [], True, False, False, toggles) + FPCP = CarInterface.get_starpilot_params(CAR.KIA_RAY_EV, gen_empty_fingerprint(), [], CP, toggles) + car_state = CarState(CP, FPCP) + can_parsers = car_state.get_can_parsers(CP) + packer = CANPacker(DBC[CP.carFingerprint][Bus.pt]) + + can_parsers[Bus.pt].update([(1_000_000_000, [ + packer.make_can_msg("LABEL11", 0, {"CC_React": 1, "CC_Engaged": 1}), + packer.make_can_msg("E_EMS11", 0, {"Cruise_Limit_Target": 10, "Accel_Pedal_Pos": 0}), + packer.make_can_msg("ELECT_GEAR", 0, {"Elect_Gear_Shifter": 5}), + ])]) + + ret, _ = car_state.update(can_parsers, toggles) + + assert ret.cruiseState.available + assert ret.cruiseState.enabled + assert ret.cruiseState.speed == pytest.approx(10 * 0.2777778) + def test_hyundai_redneck_cruise_availability(self, monkeypatch): class FakeParams: def __init__(self, *args, **kwargs): diff --git a/opendbc_repo/opendbc/car/subaru/carcontroller.py b/opendbc_repo/opendbc/car/subaru/carcontroller.py index 6a714bf76..6cff58869 100644 --- a/opendbc_repo/opendbc/car/subaru/carcontroller.py +++ b/opendbc_repo/opendbc/car/subaru/carcontroller.py @@ -149,7 +149,7 @@ class CarController(CarControllerBase): return msg def _avh_on_request(self, CC, CS, starpilot_toggles): - """Maintain a bounded Subaru AVH ON request after ignition. + """Send one bounded Subaru AVH ON request after ignition. The AVH button frame was identified on the 2025 Legacy only. Keep this independent from Stop/Start so the existing Outback request is unchanged. @@ -185,6 +185,7 @@ class CarController(CarControllerBase): if counter == self.avh_last_counter: return None + self.avh_attempted = True msg = subarucan.create_avh_control( self.packer, avh_msg, raw_dat=avh_dat, counter=counter, bus=CanBus.alt_for_cp(self.CP), diff --git a/opendbc_repo/opendbc/car/subaru/tests/test_subaru.py b/opendbc_repo/opendbc/car/subaru/tests/test_subaru.py index fc04be7d8..a15298887 100644 --- a/opendbc_repo/opendbc/car/subaru/tests/test_subaru.py +++ b/opendbc_repo/opendbc/car/subaru/tests/test_subaru.py @@ -292,7 +292,7 @@ def test_stop_start_request_is_bounded_and_uses_live_dashlights(platform, expect assert controller.stop_start_acknowledged -def test_avh_request_sets_observed_bit_and_holds_until_deadline(): +def test_avh_request_sets_observed_bit_and_is_bounded(): CP = CarInterface.get_non_essential_params(CAR.SUBARU_LEGACY_2025) controller = CarController({}, CP) controller.frame = 101 @@ -341,21 +341,7 @@ def test_avh_request_sets_observed_bit_and_holds_until_deadline(): assert parser.vl["AVH"]["AVH"] == 1 assert parser.vl["AVH"]["COUNTER"] == 0 - for counter in range(1, 4): - CS.avh_msg["COUNTER"] = counter - raw_dat = bytearray.fromhex("14001c4208800000") - raw_dat[1] = counter - raw_dat[0] = ((0x32B & 0xFF) + ((0x32B >> 8) & 0xFF) + sum(raw_dat[1:])) & 0xFF - CS.avh_dat = bytes(raw_dat) - controller.frame = 103 + (counter * 10) - _, can_sends = controller.update(CC, CS, 0, toggles) - avh_msgs = [msg for msg in can_sends if msg[0] == 0x32b] - assert len(avh_msgs) == 1 - assert avh_msgs[0][1][1] & 0x0F == counter - assert avh_msgs[0][1][5] & 0x20 - assert not controller.avh_attempted - - controller.frame = 1001 + controller.frame = 131 _, can_sends = controller.update(CC, CS, 0, toggles) assert not any(msg[0] == 0x32b for msg in can_sends) assert controller.avh_attempted diff --git a/opendbc_repo/opendbc/dbc/hyundai_kia_generic.dbc b/opendbc_repo/opendbc/dbc/hyundai_kia_generic.dbc index befafd0f1..de6ee7d89 100644 --- a/opendbc_repo/opendbc/dbc/hyundai_kia_generic.dbc +++ b/opendbc_repo/opendbc/dbc/hyundai_kia_generic.dbc @@ -1500,6 +1500,7 @@ BO_ 913 BCM_PO_11: 8 Vector__XXX BO_ 1426 LABEL11: 8 XXX SG_ CC_React : 34|1@1+ (1,0) [0|1] "" XXX + SG_ CC_Engaged : 35|1@1+ (1,0) [0|1] "" XXX BO_ 910 WHL_SPD12_FS: 5 iBAU SG_ CRC : 0|8@1+ (1,0) [0|0] "" Vector__XXX diff --git a/selfdrive/controls/lib/latcontrol_vehicle_tunes.py b/selfdrive/controls/lib/latcontrol_vehicle_tunes.py index 075ede4b8..669bf1f7e 100644 --- a/selfdrive/controls/lib/latcontrol_vehicle_tunes.py +++ b/selfdrive/controls/lib/latcontrol_vehicle_tunes.py @@ -388,8 +388,8 @@ BOLT_2022_2023_LOW_SPEED_CENTER_OUTPUT_LAT = 0.17 BOLT_2022_2023_LOW_SPEED_CENTER_OUTPUT_LAT_WIDTH = 0.04 BOLT_2022_2023_LOW_SPEED_CENTER_OUTPUT_SPEED = 2.5 BOLT_2022_2023_LOW_SPEED_CENTER_OUTPUT_SPEED_WIDTH = 0.7 -BOLT_2022_2023_LOW_SPEED_CENTER_OUTPUT_SPEED_MAX = 7.2 -BOLT_2022_2023_LOW_SPEED_CENTER_OUTPUT_SPEED_MAX_WIDTH = 0.5 +BOLT_2022_2023_LOW_SPEED_CENTER_OUTPUT_SPEED_MAX = 8.2 +BOLT_2022_2023_LOW_SPEED_CENTER_OUTPUT_SPEED_MAX_WIDTH = 0.6 BOLT_2022_2023_LOW_SPEED_CENTER_OUTPUT_SCALE_MIN = 0.62 BOLT_2022_2023_LOW_SPEED_CENTER_OUTPUT_ALPHA_MIN = 0.28 BOLT_2022_2023_CENTER_FRICTION_THRESHOLD_BUMP = 0.080