mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-30 11:02:19 +08:00
HKG Long Tune
This commit is contained in:
@@ -383,18 +383,16 @@ class CarController(CarControllerBase):
|
||||
CC.leftBlinker,
|
||||
CC.rightBlinker))
|
||||
if self.frame % 2 == 0:
|
||||
acc_kwargs = {}
|
||||
acc_kwargs = {
|
||||
"main_mode_acc": int(CS.out.cruiseState.available),
|
||||
"direct_accel": True,
|
||||
"jerk_lower": 5.0,
|
||||
"jerk_upper": 3.0 if CC.actuators.longControlState == LongCtrlState.pid else 1.0,
|
||||
}
|
||||
if self.CP.carFingerprint == CAR.HYUNDAI_IONIQ_6:
|
||||
acc_kwargs = {
|
||||
"main_mode_acc": int(CS.out.cruiseState.available),
|
||||
"direct_accel": True,
|
||||
}
|
||||
if use_ioniq_6_smoothed_accel:
|
||||
acc_kwargs["jerk_lower"] = self._ioniq_6_long_tuning.jerk_lower
|
||||
acc_kwargs["jerk_upper"] = self._ioniq_6_long_tuning.jerk_upper
|
||||
else:
|
||||
acc_kwargs["jerk_lower"] = 5.0
|
||||
acc_kwargs["jerk_upper"] = 3.0
|
||||
can_sends.append(hyundaicanfd.create_acc_control(self.packer, self.CAN, CC.enabled, self.accel_last, accel, stopping, CC.cruiseControl.override,
|
||||
set_speed_in_units, hud_control, **acc_kwargs))
|
||||
self.accel_last = accel
|
||||
|
||||
@@ -22,6 +22,29 @@ ENABLE_BUTTONS = (ButtonType.accelCruise, ButtonType.decelCruise, ButtonType.can
|
||||
ECU_DISABLE_TIMESTAMP = 0.0
|
||||
|
||||
|
||||
def apply_platform_longitudinal_params(ret: structs.CarParams) -> None:
|
||||
ret.startingState = True
|
||||
ret.startAccel = 1.0
|
||||
ret.longitudinalActuatorDelay = 0.5
|
||||
|
||||
if ret.flags & HyundaiFlags.CANFD:
|
||||
ret.vEgoStopping = 0.3
|
||||
ret.vEgoStarting = 0.1
|
||||
ret.stoppingDecelRate = 0.4
|
||||
elif ret.flags & HyundaiFlags.EV:
|
||||
ret.vEgoStopping = 0.35
|
||||
ret.vEgoStarting = 0.1
|
||||
ret.stoppingDecelRate = 0.45
|
||||
elif ret.flags & HyundaiFlags.HYBRID:
|
||||
ret.vEgoStopping = 0.4
|
||||
ret.vEgoStarting = 0.15
|
||||
ret.stoppingDecelRate = 0.45
|
||||
else:
|
||||
ret.vEgoStopping = 0.3
|
||||
ret.vEgoStarting = 0.1
|
||||
ret.stoppingDecelRate = 0.4
|
||||
|
||||
|
||||
class CarInterface(CarInterfaceBase):
|
||||
CarState = CarState
|
||||
CarController = CarController
|
||||
@@ -155,17 +178,7 @@ class CarInterface(CarInterfaceBase):
|
||||
if ret.openpilotLongitudinalControl:
|
||||
ret.radarUnavailable = True
|
||||
ret.pcmCruise = not ret.openpilotLongitudinalControl
|
||||
ret.startingState = True
|
||||
ret.vEgoStarting = 0.1
|
||||
ret.startAccel = 1.0
|
||||
ret.longitudinalActuatorDelay = 0.5
|
||||
|
||||
if candidate == CAR.HYUNDAI_IONIQ_6:
|
||||
ret.startingState = True
|
||||
ret.vEgoStopping = 0.3
|
||||
ret.vEgoStarting = 0.1
|
||||
ret.stoppingDecelRate = 0.4
|
||||
ret.longitudinalActuatorDelay = 0.5
|
||||
apply_platform_longitudinal_params(ret)
|
||||
|
||||
if ret.openpilotLongitudinalControl:
|
||||
ret.safetyConfigs[-1].safetyParam |= HyundaiSafetyFlags.LONG.value
|
||||
|
||||
@@ -96,6 +96,22 @@ class TestHyundaiFingerprint:
|
||||
CP = CarInterface.get_params(CAR.KIA_SPORTAGE_HEV_2026, fingerprint, [], False, False, False, None)
|
||||
assert CP.flags & HyundaiFlags.SEND_LFA
|
||||
|
||||
@pytest.mark.parametrize(("candidate", "expected"), [
|
||||
(CAR.KIA_EV6, (0.3, 0.1, 0.4)),
|
||||
(CAR.HYUNDAI_KONA_EV, (0.35, 0.1, 0.45)),
|
||||
(CAR.HYUNDAI_SONATA_HYBRID, (0.4, 0.15, 0.45)),
|
||||
(CAR.GENESIS_G70, (0.3, 0.1, 0.4)),
|
||||
])
|
||||
def test_platform_longitudinal_params_match_family_tune(self, candidate, expected):
|
||||
toggles = get_test_toggles()
|
||||
CP = CarInterface.get_params(candidate, gen_empty_fingerprint(), [], True, False, False, toggles)
|
||||
|
||||
assert CP.vEgoStopping == pytest.approx(expected[0])
|
||||
assert CP.vEgoStarting == pytest.approx(expected[1])
|
||||
assert CP.stoppingDecelRate == pytest.approx(expected[2])
|
||||
assert CP.longitudinalActuatorDelay == pytest.approx(0.5)
|
||||
assert CP.startingState
|
||||
|
||||
def test_kia_forte_no_scc_fw_match(self):
|
||||
car_fw = [
|
||||
CarParams.CarFw(
|
||||
@@ -265,6 +281,27 @@ class TestHyundaiFingerprint:
|
||||
assert state.jerk_upper == pytest.approx(0.0)
|
||||
assert state.jerk_lower == pytest.approx(0.0)
|
||||
|
||||
def test_canfd_acc_control_uses_direct_accel(self):
|
||||
CP = CarParams.new_message()
|
||||
CP.carFingerprint = CAR.KIA_EV6
|
||||
CP.flags = int(HyundaiFlags.CANFD)
|
||||
|
||||
packer = CANPacker(DBC[CP.carFingerprint][Bus.pt])
|
||||
can_bus = CanBus(CP)
|
||||
parser = CANParser(DBC[CP.carFingerprint][Bus.pt], [("SCC_CONTROL", 0)], can_bus.ECAN)
|
||||
|
||||
msg = hyundaicanfd.create_acc_control(packer, can_bus, enabled=True, accel_last=1.5, accel=-1.2, stopping=False,
|
||||
gas_override=False, set_speed=42, hud_control=SimpleNamespace(leadDistanceBars=3),
|
||||
main_mode_acc=0, jerk_lower=5.0, jerk_upper=1.0, direct_accel=True)
|
||||
parser.update([(1, [msg])])
|
||||
|
||||
assert parser.can_valid
|
||||
assert parser.vl["SCC_CONTROL"]["MainMode_ACC"] == 0
|
||||
assert parser.vl["SCC_CONTROL"]["aReqRaw"] == pytest.approx(-1.2)
|
||||
assert parser.vl["SCC_CONTROL"]["aReqValue"] == pytest.approx(-1.2)
|
||||
assert parser.vl["SCC_CONTROL"]["JerkLowerLimit"] == pytest.approx(5.0)
|
||||
assert parser.vl["SCC_CONTROL"]["JerkUpperLimit"] == pytest.approx(1.0)
|
||||
|
||||
def test_sportage_angle_steering_uses_adas_cmd_with_send_lfa(self):
|
||||
fingerprint = gen_empty_fingerprint()
|
||||
cam_can = CanBus(None, fingerprint).CAM
|
||||
|
||||
Reference in New Issue
Block a user