From 207eaec128165791f1eb1967f658d48e5e27c21c Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Wed, 11 Nov 2026 20:42:33 -0600 Subject: [PATCH] Calm standard Ioniq 6 friction feedback --- .../flm/tests/test_controller_replay.py | 4 ++ openpilot/starpilot/lateral/ioniq6_policy.py | 3 ++ .../lateral/tests/test_ioniq6_policy.py | 44 +++++++++++++++++++ prebuilt.json | 2 +- 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/openpilot/starpilot/flm/tests/test_controller_replay.py b/openpilot/starpilot/flm/tests/test_controller_replay.py index b374f7b8dc..6b93890cff 100644 --- a/openpilot/starpilot/flm/tests/test_controller_replay.py +++ b/openpilot/starpilot/flm/tests/test_controller_replay.py @@ -113,6 +113,7 @@ SEQUENCE = ( class TestIoniq6ControllerReplay(unittest.TestCase): + @mock.patch("openpilot.starpilot.lateral.ioniq6_policy.IONIQ_6_STANDARD_FRICTION_THRESHOLD_INCREASE", 0.0) def test_frozen_stateful_controller_trace(self): self.assertEqual(_GOLDEN["sourceCommit"], "678af783") self.assertEqual(_GOLDEN["controllerSha256"], "3561d5ac43a72f9b68bc9e44042b8f5cbdca406dec940e7648c64607862a60f7") @@ -127,6 +128,7 @@ class TestIoniq6ControllerReplay(unittest.TestCase): _assert_rows(self, actual, expected) @mock.patch("openpilot.starpilot.lateral.ioniq6_policy.IONIQ_6_2025_HIGHWAY_FRICTION_THRESHOLD_INCREASE", 0.0) + @mock.patch("openpilot.starpilot.lateral.ioniq6_policy.IONIQ_6_STANDARD_FRICTION_THRESHOLD_INCREASE", 0.0) def test_extended_frozen_filter_limit_override_and_reset_trace(self): self.assertEqual(_EXTENDED["sourceCommit"], "678af783") self.assertEqual(_EXTENDED["controllerSha256"], _GOLDEN["controllerSha256"]) @@ -147,6 +149,7 @@ class TestIoniq6ControllerReplay(unittest.TestCase): _assert_rows(self, actual, expected) @mock.patch("openpilot.starpilot.lateral.ioniq6_policy.IONIQ_6_2025_HIGHWAY_FRICTION_THRESHOLD_INCREASE", 0.0) + @mock.patch("openpilot.starpilot.lateral.ioniq6_policy.IONIQ_6_STANDARD_FRICTION_THRESHOLD_INCREASE", 0.0) def test_actual_torque_parameter_update_recalculates_frozen_pid_limits(self): self.assertEqual(_LIVE["sourceControllerSha256"], _GOLDEN["controllerSha256"]) self.assertEqual(_LIVE["fields"], _GOLDEN["fields"]) @@ -166,6 +169,7 @@ class TestIoniq6ControllerReplay(unittest.TestCase): _assert_rows(self, actual, expected["rows"]) @mock.patch("openpilot.starpilot.lateral.ioniq6_policy.IONIQ_6_2025_HIGHWAY_FRICTION_THRESHOLD_INCREASE", 0.0) + @mock.patch("openpilot.starpilot.lateral.ioniq6_policy.IONIQ_6_STANDARD_FRICTION_THRESHOLD_INCREASE", 0.0) def test_guarded_extended_trace_preserves_model_pid_inputs_and_manual_surface(self): for firmware, fw in (("2023", False), ("2025", True)): for mode in ("default", "tuned"): diff --git a/openpilot/starpilot/lateral/ioniq6_policy.py b/openpilot/starpilot/lateral/ioniq6_policy.py index f4ecb65b77..e509e5a6ad 100644 --- a/openpilot/starpilot/lateral/ioniq6_policy.py +++ b/openpilot/starpilot/lateral/ioniq6_policy.py @@ -30,6 +30,7 @@ from openpilot.starpilot.lateral.torque_shaping import ( HKG_CANFD_BASE_FRICTION_THRESHOLD = 0.39 IONIQ_6_2025_HIGHWAY_FRICTION_THRESHOLD_INCREASE = 0.50 +IONIQ_6_STANDARD_FRICTION_THRESHOLD_INCREASE = 0.50 IONIQ_6_CARS = (CAR.HYUNDAI_IONIQ_6,) @@ -880,6 +881,8 @@ class Ioniq6TorquePolicy: friction_threshold = get_ioniq_6_friction_threshold(CS.vEgo, setpoint, desired_lateral_jerk) / max(center_taper, 1e-3) else: friction_threshold = self.surface_math.friction_threshold(self.surface, CS.vEgo, setpoint, desired_lateral_jerk) / max(center_taper, 1e-3) + if not self.is_2025 and not CS.steeringPressed and not self.prev_steering_pressed: + friction_threshold *= 1.0 + IONIQ_6_STANDARD_FRICTION_THRESHOLD_INCREASE * float(np.interp(CS.vEgo, [3.0, 12.0], [0.0, 1.0])) if self.surface is None and not self.is_2025 and not CS.steeringPressed and not self.prev_steering_pressed: friction_threshold += get_ioniq_6_2023_center_friction_increment( CS.vEgo, setpoint, measurement, desired_lateral_jerk, future_desired_lateral_accel) / max(center_taper, 1e-3) diff --git a/openpilot/starpilot/lateral/tests/test_ioniq6_policy.py b/openpilot/starpilot/lateral/tests/test_ioniq6_policy.py index 98677e3729..34794cbc2b 100644 --- a/openpilot/starpilot/lateral/tests/test_ioniq6_policy.py +++ b/openpilot/starpilot/lateral/tests/test_ioniq6_policy.py @@ -97,6 +97,7 @@ class Ioniq6PolicyTests(unittest.TestCase): controller.update_torque_parameters(3.2, 0.01, 0.10) self.assertEqual(controller.pid._k_p, [[0.0], [0.6]]) + @mock.patch.object(tune, "IONIQ_6_STANDARD_FRICTION_THRESHOLD_INCREASE", 0.0) def test_actual_frozen_controller_sequences_and_pure_calibration(self): sequence = ([(False, 0.3, 10.0, -0.001, False)] * 2 + [(True, 0.3, 10.0, -0.001, False)] * 4 + @@ -263,3 +264,46 @@ class Ioniq6HighwayFrictionTests(unittest.TestCase): _, tuned = self.trace(center=20.0) _, original = self.trace(center=20.0, tuning=False) self.assertEqual(tuned[100:], original[100:]) + + +class Ioniq6StandardFrictionTests(Ioniq6HighwayFrictionTests): + def controller(self, *, firmware_2025=False, long=False): + return super().controller(firmware_2025=firmware_2025, long=long) + + def trace(self, *, speed=32.0, firmware_2025=False, long=False, tuning=True, pressed=False, center=None): + if center is None: + _, vm = self.controller(firmware_2025=firmware_2025, long=long) + center = math.degrees(vm.get_steer_from_curvature(-.001, speed, 0.0)) + with mock.patch.object(tune, 'IONIQ_6_STANDARD_FRICTION_THRESHOLD_INCREASE', .50 if tuning else 0.0): + return super().trace(speed=speed, firmware_2025=firmware_2025, long=long, tuning=False, pressed=pressed, center=center) + + def test_low_speed_and_older_firmware_are_unchanged(self): + for kwargs in ({'speed': 3.0}, {'speed': .3}, {'firmware_2025': True}): + with self.subTest(**kwargs): + self.assertEqual(self.trace(**kwargs)[1], self.trace(tuning=False, **kwargs)[1]) + + def test_city_feedback_is_softer_without_changing_path_or_pid(self): + _, tuned = self.trace(speed=10.0) + _, baseline = self.trace(speed=10.0, tuning=False) + self.assertLess(max(row[1] for row in tuned[100:]) - min(row[1] for row in tuned[100:]), + max(row[1] for row in baseline[100:]) - min(row[1] for row in baseline[100:])) + for row, old in zip(tuned, baseline, strict=True): + self.assertEqual(row[2:], old[2:]) + + def test_constant_turn_strength_live_parameters_and_limits_are_preserved(self): + results = [] + for tuning in (False, True): + controller, vm = self.controller() + controller.update_torque_parameters(3.2, .01, .08) + self.assertAlmostEqual(controller.torque_params.latAccelFactor, 3.2 * 1.22, places=6) + self.assertAlmostEqual(controller.torque_params.friction, .08, places=6) + self.assertEqual(controller.pid.pos_limit, controller.lateral_accel_from_torque(1.0, controller.torque_params)) + cs = structs.CarState.new_message(vEgo=32.0, steeringAngleDeg=-3.0, + gearShifter=structs.CarState.GearShifter.drive) + curve = -vm.calc_curvature(math.radians(cs.steeringAngleDeg), cs.vEgo, 0.0) + with mock.patch.object(tune, 'IONIQ_6_STANDARD_FRICTION_THRESHOLD_INCREASE', .50 if tuning else 0.0): + for index in range(400): + output, _, _ = controller.update(index != 0, cs, vm, SimpleNamespace(angleOffsetDeg=0.0, roll=0.0), + True, curve, False, .322) + results.append(output) + self.assertAlmostEqual(*results, places=12) diff --git a/prebuilt.json b/prebuilt.json index d3e0fbfe3e..457a312d0d 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "49d243b0ab4795a37c92c37ab90f3eb83bf05aef744c0b1811bffb343a6369d9", "schema_version": 1} +{"protected_inventory_sha256": "9cfb810c7b4ae391c5f8e202be180c67d288ecc97bbafbdeea7ed27551cc0134", "schema_version": 1}