diff --git a/openpilot/starpilot/lateral/ioniq6_policy.py b/openpilot/starpilot/lateral/ioniq6_policy.py index d8eb939bb5..56ed3d56ad 100644 --- a/openpilot/starpilot/lateral/ioniq6_policy.py +++ b/openpilot/starpilot/lateral/ioniq6_policy.py @@ -133,6 +133,7 @@ IONIQ_6_HIGHWAY_OUTPUT_TAPER_SPEED = 23.5 IONIQ_6_HIGHWAY_OUTPUT_TAPER_SPEED_WIDTH = 2.0 IONIQ_6_HIGHWAY_TRANSITION_OUTPUT_TAPER_MAX = 0.18 +IONIQ_6_STANDARD_HIGHWAY_TRANSITION_EXTRA_TAPER = 0.10 IONIQ_6_HIGHWAY_TRANSITION_OUTPUT_TAPER_LAT = 1.05 @@ -673,13 +674,17 @@ def get_ioniq_6_highway_output_taper_scale(desired_lateral_accel: float, v_ego: reduction = IONIQ_6_HIGHWAY_OUTPUT_TAPER_MAX * speed_weight * center_weight return 1.0 - reduction -def get_ioniq_6_highway_transition_output_taper_scale(desired_lateral_accel: float, desired_lateral_jerk: float, v_ego: float) -> float: +def get_ioniq_6_highway_transition_output_taper_scale(desired_lateral_accel: float, desired_lateral_jerk: float, v_ego: float, + *, damp_standard_highway: bool = False) -> float: speed_weight = _ioniq_6_sigmoid((v_ego - IONIQ_6_HIGHWAY_OUTPUT_TAPER_SPEED) / IONIQ_6_HIGHWAY_OUTPUT_TAPER_SPEED_WIDTH) center_weight = _ioniq_6_sigmoid((IONIQ_6_HIGHWAY_TRANSITION_OUTPUT_TAPER_LAT - abs(desired_lateral_accel)) / IONIQ_6_HIGHWAY_TRANSITION_OUTPUT_TAPER_LAT_WIDTH) jerk_weight = _ioniq_6_sigmoid((abs(desired_lateral_jerk) - IONIQ_6_HIGHWAY_TRANSITION_OUTPUT_TAPER_JERK) / IONIQ_6_HIGHWAY_TRANSITION_OUTPUT_TAPER_JERK_WIDTH) - reduction = IONIQ_6_HIGHWAY_TRANSITION_OUTPUT_TAPER_MAX * speed_weight * center_weight * jerk_weight + max_reduction = IONIQ_6_HIGHWAY_TRANSITION_OUTPUT_TAPER_MAX + if damp_standard_highway: + max_reduction += IONIQ_6_STANDARD_HIGHWAY_TRANSITION_EXTRA_TAPER * np.interp(v_ego, [25.0, 30.0], [0.0, 1.0]) + reduction = max_reduction * speed_weight * center_weight * jerk_weight return 1.0 - reduction def get_ioniq_6_low_speed_angle_assist_torque(desired_angle_deg: float, actual_angle_deg: float, @@ -925,7 +930,9 @@ class Ioniq6TorquePolicy: output_torque = self.surface_math.low_speed_output(self.surface, self.surface_math.SurfaceInput( CS.vEgo, setpoint, desired_lateral_jerk, desired_angle, actual_angle, output_torque, False, directional_taper)) output_torque *= get_ioniq_6_highway_output_taper_scale(setpoint, CS.vEgo) - output_torque *= get_ioniq_6_highway_transition_output_taper_scale(setpoint, desired_lateral_jerk, CS.vEgo) + output_torque *= get_ioniq_6_highway_transition_output_taper_scale( + setpoint, desired_lateral_jerk, CS.vEgo, + damp_standard_highway=not (self.is_2025 or CS.steeringPressed or self.prev_steering_pressed)) if self.is_2025: output_torque *= get_ioniq_6_2025_center_output_scale(setpoint, CS.vEgo) output_limit = get_ioniq_6_2025_low_speed_output_limit(setpoint, desired_lateral_jerk, CS.vEgo) diff --git a/openpilot/starpilot/lateral/tests/test_ioniq6_policy.py b/openpilot/starpilot/lateral/tests/test_ioniq6_policy.py index c418236d98..509a8eefd5 100644 --- a/openpilot/starpilot/lateral/tests/test_ioniq6_policy.py +++ b/openpilot/starpilot/lateral/tests/test_ioniq6_policy.py @@ -65,6 +65,18 @@ def _rows(car, sequence, *, profile='2023', matched_frozen_cp=False, passive=Fal class Ioniq6PolicyTests(unittest.TestCase): + def test_highway_transition_taper_is_scoped_to_standard_assisted_steering(self): + fn = tune.get_ioniq_6_highway_transition_output_taper_scale + self.assertEqual(fn(0.15, 0.6, 25.0), fn(0.15, 0.6, 25.0, damp_standard_highway=True)) + self.assertGreater(fn(0.15, 0.6, 34.0) - fn(0.15, 0.6, 34.0, damp_standard_highway=True), 0.08) + self.assertLess(fn(2.0, 0.6, 34.0) - fn(2.0, 0.6, 34.0, damp_standard_highway=True), 0.002) + sequence = [(True, 34.0, 0.2, 0.0002, pressed) for pressed in [False] * 80 + [True, False, False]] + for profile in ('2023', '2025'): + with self.subTest(profile=profile), mock.patch.object(tune, fn.__name__, wraps=fn) as taper: + _rows(HYUNDAI.HYUNDAI_IONIQ_6, sequence, profile=profile, matched_frozen_cp=True) + calls = [call.kwargs['damp_standard_highway'] for call in taper.call_args_list] + self.assertEqual(calls[-4:], [True, False, False, True] if profile == '2023' else [False] * 4) + def test_ioniq_drive_loop_uses_original_flat_proportional_gain(self): cp = interfaces[HYUNDAI.HYUNDAI_IONIQ_6].get_non_essential_params(HYUNDAI.HYUNDAI_IONIQ_6) cp.lateralTuning.torque.latAccelFactor = 3.0 diff --git a/prebuilt.json b/prebuilt.json index c8d44be83c..1e56d1f2b6 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "4aa69c8ccd4db6c592aa7626e1c75533788b1c35fbbb2724d76cef24538d8303", "schema_version": 1} +{"protected_inventory_sha256": "167f0e5159b94b878faf96c30505f35697f53ccf0a8176c73fe6c35aa759de6d", "schema_version": 1}