Calm standard Ioniq 6 friction feedback

This commit is contained in:
firestar5683
2026-11-11 20:42:33 -06:00
parent df785f59f7
commit 207eaec128
4 changed files with 52 additions and 1 deletions
@@ -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"):
@@ -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)
@@ -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)
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "49d243b0ab4795a37c92c37ab90f3eb83bf05aef744c0b1811bffb343a6369d9", "schema_version": 1}
{"protected_inventory_sha256": "9cfb810c7b4ae391c5f8e202be180c67d288ecc97bbafbdeea7ed27551cc0134", "schema_version": 1}