Smooth tight-curve steering on Ioniq 5 HDA II

This commit is contained in:
firestar5683
2026-11-23 22:33:32 -06:00
parent 026ce00b72
commit 855dfb3a17
3 changed files with 42 additions and 2 deletions
@@ -86,7 +86,13 @@ class HKGVehicleTorquePolicy(HKGShapedTorquePolicy):
def feedforward_context(self, value, setpoint, jerk, measurement, speed):
if self.profile == 'ioniq_5':
return value * shaping.get_ioniq_5_ff_scale(setpoint, jerk, speed) * shaping.get_ioniq_5_center_taper_scale(setpoint, speed)
ff_scale = shaping.get_ioniq_5_ff_scale(setpoint, jerk, speed)
if (self.ioniq_5_hda2 and 17.0 < speed < 23.0 and 1.25 < abs(setpoint) < 2.65
and jerk != 0.0 and not (self.steering_pressed or self.previous_pressed)):
ramp_speed = float(np.interp(speed, [17.0, 18.5, 21.0, 23.0], [0.0, 1.0, 1.0, 0.0]))
tight_arc = float(np.interp(abs(setpoint), [1.25, 1.6, 2.25, 2.65], [0.0, 1.0, 1.0, 0.0]))
ff_scale += 0.25 * ramp_speed * tight_arc * (shaping.get_ioniq_5_ff_scale(setpoint, 0.0, speed) - ff_scale)
return value * ff_scale * shaping.get_ioniq_5_center_taper_scale(setpoint, speed)
if self.profile == 'ioniq_ev_old':
return value * shaping.get_ioniq_ev_old_ff_scale(setpoint, jerk, speed) * shaping.get_ioniq_ev_old_center_taper_scale(setpoint, speed)
if self.profile == 'sonata':
@@ -148,3 +148,37 @@ def test_ioniq5_hda2_highway_arc_friction(direction, op_long, hda2, speed, later
assert threshold == pytest.approx(shaping.get_ioniq_5_friction_threshold(speed, setpoint, jerk) + expected)
assert scale == pytest.approx(1 + (shaping.get_ioniq_5_friction_scale(speed, setpoint, jerk) - 1) *
shaping.get_ioniq_5_center_taper_scale(setpoint, speed))
@pytest.mark.parametrize('op_long', [False, True])
@pytest.mark.parametrize('direction', [-1.0, 1.0])
@pytest.mark.parametrize('hda2,speed,accel,jerk,pressed,prior_pressed,blend', [
(True, 19.5, 1.95, 0.5, False, False, 0.25),
(True, 22.0, 1.95, 0.5, False, False, 0.125),
(True, 19.5, 1.95, 0.0, False, False, 0.0),
(True, 19.5, 0.9, 0.5, False, False, 0.0),
(True, 19.5, 2.65, 0.5, False, False, 0.0),
(True, 16.0, 1.95, 0.5, False, False, 0.0),
(True, 29.0, 1.95, 0.5, False, False, 0.0),
(True, 19.5, 1.95, 0.5, True, False, 0.0),
(True, 19.5, 1.95, 0.5, False, True, 0.0),
(False, 19.5, 1.95, 0.5, False, False, 0.0),
])
def test_ioniq5_hda2_tight_curve_feedforward(op_long, direction, hda2, speed, accel, jerk, pressed, prior_pressed, blend):
vehicle = CAR.HYUNDAI_IONIQ_5
cp = interfaces[vehicle].get_non_essential_params(vehicle)
cp.openpilotLongitudinalControl = op_long
cp.pcmCruise = not op_long
if hda2:
cp.flags |= int(HyundaiFlags.CANFD_LKA_STEER_MSG)
else:
cp.flags &= ~int(HyundaiFlags.CANFD_LKA_STEER_MSG)
controller = LatControlTorque(cp.as_reader(), interfaces[vehicle](cp), 0.01, controller_mode=ControllerMode.STARPILOT)
policy = controller.starpilot_extension.policy
policy.steering_pressed, policy.previous_pressed = pressed, prior_pressed
setpoint = accel * direction
jerk *= -direction
original = shaping.get_ioniq_5_ff_scale(setpoint, jerk, speed)
steady = shaping.get_ioniq_5_ff_scale(setpoint, 0.0, speed)
expected = (original + blend * (steady - original)) * shaping.get_ioniq_5_center_taper_scale(setpoint, speed)
assert policy.feedforward_context(1.0, setpoint, jerk, setpoint, speed) == pytest.approx(expected)
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "961ac9c36c3ad789a64d4e9b42fadf47236626274500ff05bff8712732e55450", "schema_version": 1}
{"protected_inventory_sha256": "5602b0f7f4a8059ffb07dbce31e32c7ea776c96a6868dc1072d1ad669097ac05", "schema_version": 1}