From ea5143fe2cc8afcbfedd6d66377dabd0e6b03443 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Thu, 26 Nov 2026 11:10:44 -0600 Subject: [PATCH] Smooth the final rolling stop on Kona CCNC --- .../opendbc/car/hyundai/carcontroller.py | 4 +++ .../hyundai/tests/test_kona_ccnc_long_aol.py | 31 +++++++++++++++++++ prebuilt.json | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/opendbc_repo/opendbc/car/hyundai/carcontroller.py b/opendbc_repo/opendbc/car/hyundai/carcontroller.py index 73ac90a0c5..04be226f96 100644 --- a/opendbc_repo/opendbc/car/hyundai/carcontroller.py +++ b/opendbc_repo/opendbc/car/hyundai/carcontroller.py @@ -695,6 +695,10 @@ class CarController(CarControllerBase): if self.torque_ev_lead_inputs is not None else fallback_lead(CS.torque_ev_camera_lead, hud_control.leadVisible, self.torque_ev_floor_boot_ns)) acc_options = torque_ev_scc_options(CS.out.cruiseState.available, CC.actuators.longControlState, lead) + if (kona_handoff and CC.longActive and not CC.cruiseControl.override and stopping and + not (CS.out.standstill or CS.out.brakePressed or CS.out.gasPressed or hud_control.leadVisible or lead.visible) and + 0.0 < CS.out.vEgo < CV.MPH_TO_MS and -0.5 <= accel < 0.0 and accel >= self.accel_last - 0.02): + acc_options["jerk_lower"] = 1.2 elif is_gv70(self.CP): request = scc_request(CC.enabled, CC.cruiseControl.override, stopping, accel, self.accel_last) accel = request.accel diff --git a/opendbc_repo/opendbc/car/hyundai/tests/test_kona_ccnc_long_aol.py b/opendbc_repo/opendbc/car/hyundai/tests/test_kona_ccnc_long_aol.py index b4ffba321c..e65057b296 100644 --- a/opendbc_repo/opendbc/car/hyundai/tests/test_kona_ccnc_long_aol.py +++ b/opendbc_repo/opendbc/car/hyundai/tests/test_kona_ccnc_long_aol.py @@ -263,3 +263,34 @@ def test_kona_handoff_cruise_main_display_follows_star_long_engagement(handoff, assert display['DISTANCE_SPACING'] == 0 assert parser.vl['CCNC_0x162']['FAULT_LSS'] == 2 assert parser.vl['CCNC_0x162']['FAULT_FCA'] == 1 + + +@pytest.mark.parametrize('speed,accel,previous,standstill,lead,word,cap', [ + (0.3, -0.27, -0.26, False, False, 0x1C0C, 1.2), + (0.5, -0.27, -0.26, False, False, 0x1C0C, 5.0), + (0.3, -0.80, -0.79, False, False, 0x1C0C, 5.0), + (0.3, -0.45, -0.20, False, False, 0x1C0C, 5.0), + (0.1, -0.27, -0.26, True, False, 0x1C0C, 5.0), + (0.3, -0.27, -0.26, False, True, 0x1C0C, 5.0), + (0.3, -0.27, -0.26, False, False, 0x0C0C, 5.0), +]) +def test_kona_final_braking_jerk(speed, accel, previous, standstill, lead, word, cap): + from opendbc.can import CANParser + + cp = kona_params(CARS[0]) + cp.safetyConfigs[0].safetyParam = word + cp.alternativeExperience = 32 + ci = CarInterface(cp) + ci.CS.out = structs.CarState(vEgo=speed, standstill=standstill, cruiseState={'available': True}).as_reader() + ci.CC.accel_last = previous + command = structs.CarControl(enabled=True, longActive=True, + actuators={'accel': accel, 'longControlState': 'stopping'}, + hudControl={'leadVisible': lead}) + _, frames = ci.apply(command.as_reader(), 1_000_000_000) + parser = CANParser('hyundai_canfd_generated', [('SCC_CONTROL', 0)], 0) + assert 0x1A0 in parser.update((1_000_000_000, frames)) + values = parser.vl['SCC_CONTROL'] + assert values['aReqValue'] == pytest.approx(accel) + assert values['aReqRaw'] == pytest.approx(accel) + assert values['ACCMode'] == values['StopReq'] == 1 + assert values['JerkLowerLimit'] == pytest.approx(cap) diff --git a/prebuilt.json b/prebuilt.json index 9bd0a6d3d7..42d5714b32 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "e7d731705f8a1b4efa84efe9aa934301f1ae9e1d543ee13c009f8fdac799ddec", "schema_version": 1} +{"protected_inventory_sha256": "4f231e5a0476cf7eeae651eca98b8d0b1c871e36feab3d5fea00831707b5ca8c", "schema_version": 1}