mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 03:03:41 +08:00
Add guarded 2026 Hyundai i30 stock cruise steering
This commit is contained in:
@@ -387,6 +387,9 @@ class CarController(CarControllerBase):
|
||||
if self.CP.carFingerprint == CAR.KIA_RAY_EV:
|
||||
self._ray_lkas11_active = True
|
||||
|
||||
if self.CP.carFingerprint == CAR.HYUNDAI_I30_2026:
|
||||
return can_sends if CC.enabled and CC.latActive and CS.out.cruiseState.enabled else []
|
||||
|
||||
# Button messages
|
||||
if not self.CP.openpilotLongitudinalControl or self._ray_pedal:
|
||||
if self._ray_pedal and CC.enabled and CS.out.cruiseState.enabled:
|
||||
|
||||
@@ -37,6 +37,16 @@ def create_lkas11(packer, frame, CP, apply_torque, steer_req,
|
||||
torque_fault, lkas11, sys_warning, sys_state, enabled,
|
||||
left_lane, right_lane,
|
||||
left_lane_depart, right_lane_depart, ray_lka_icon=None, aol_lka_icon=None):
|
||||
if CP.carFingerprint == CAR.HYUNDAI_I30_2026:
|
||||
values = dict(lkas11)
|
||||
values["CR_Lkas_StrToqReq"] = apply_torque
|
||||
values["CF_Lkas_ActToi"] = steer_req
|
||||
values["CF_Lkas_ToiFlt"] = torque_fault or lkas11["CF_Lkas_ToiFlt"]
|
||||
values["CF_Lkas_MsgCount"] = frame % 16
|
||||
data = packer.make_can_msg("LKAS11", 0, values)[1]
|
||||
values["CF_Lkas_Chksum"] = hyundai_checksum(data[:6] + data[7:])
|
||||
return packer.make_can_msg("LKAS11", 0, values)
|
||||
|
||||
values = {s: lkas11[s] for s in [
|
||||
"CF_Lkas_LdwsActivemode",
|
||||
"CF_Lkas_LdwsSysState",
|
||||
|
||||
@@ -4,6 +4,7 @@ from opendbc.car.pedal import supported_pedal_detected
|
||||
from opendbc.car.hyundai.classic_scc_aol import CLASSIC_SCC_IDS
|
||||
from opendbc.car import Bus, get_safety_config, structs, uds
|
||||
from opendbc.car.hyundai.discovery import kona_electric_se_candidate
|
||||
from opendbc.car.hyundai.fingerprints import FW_VERSIONS
|
||||
from opendbc.car.hyundai.hyundaicanfd import CanBus
|
||||
from opendbc.car.hyundai.non_scc_aol import NON_SCC_IDS
|
||||
from opendbc.car.hyundai.values import (is_blended, is_blended_alpha, HyundaiFlags, CAR, DBC, HyundaiSafetyFlags, CANFD_ANGLE_MODEL_BITS,
|
||||
@@ -140,7 +141,18 @@ class CarInterface(CarInterfaceBase):
|
||||
def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, alpha_long, is_release, docs) -> structs.CarParams:
|
||||
ret.brand = "hyundai"
|
||||
|
||||
if candidate == CAR.HYUNDAI_I30_2026:
|
||||
i30 = candidate == CAR.HYUNDAI_I30_2026
|
||||
if i30:
|
||||
expected = FW_VERSIONS[candidate]
|
||||
exact = {(fw.ecu.raw, fw.address, None): bytes(fw.fwVersion) for fw in car_fw
|
||||
if fw.subAddress == 0 and bytes(fw.fwVersion).startswith(b"\xf1\x00")}
|
||||
qualified = (not is_release and all(exact.get(key) in versions for key, versions in expected.items()) and
|
||||
fingerprint[0].get(0x421) == 8 and fingerprint[2].get(0x340) == 8 and
|
||||
fingerprint[2].get(0x485) == 8)
|
||||
if qualified:
|
||||
ret.flags |= HyundaiFlags.CHECKSUM_CRC8.value
|
||||
|
||||
if i30 and not qualified:
|
||||
# Controls may construct a PID for this profile. Keep it inert with valid gains.
|
||||
ret.lateralTuning.pid.kpBP = ret.lateralTuning.pid.kiBP = [0.0]
|
||||
ret.lateralTuning.pid.kpV = ret.lateralTuning.pid.kiV = [0.0]
|
||||
@@ -336,7 +348,7 @@ class CarInterface(CarInterfaceBase):
|
||||
from opendbc.car.hyundai.legacy_long_aol import CARS as legacy_long_cars
|
||||
if candidate == CAR.KIA_CARNIVAL_2025 and any(fw.ecu == Ecu.fwdCamera and fw.fwVersion == CARNIVAL_2027_CAMERA_FW for fw in car_fw):
|
||||
ret.alphaLongitudinalAvailable = False
|
||||
ret.openpilotLongitudinalControl = alpha_long and ret.alphaLongitudinalAvailable and candidate not in legacy_long_cars
|
||||
ret.openpilotLongitudinalControl = not i30 and alpha_long and ret.alphaLongitudinalAvailable and candidate not in legacy_long_cars
|
||||
if (candidate in (CAR.KIA_CARNIVAL_2025, CAR.KIA_CARNIVAL_HEV_4TH_GEN) and
|
||||
ret.flags & HyundaiFlags.CANFD_ALT_BUTTONS and 0x1aa in fingerprint[CAN.ECAN] and
|
||||
not ret.openpilotLongitudinalControl):
|
||||
@@ -423,6 +435,16 @@ class CarInterface(CarInterfaceBase):
|
||||
from opendbc.car.hyundai.gv60_startup import select_profile as gv60_select_profile
|
||||
gv60_select_profile(ret, is_release=is_release)
|
||||
|
||||
if i30:
|
||||
ret.alphaLongitudinalAvailable = False
|
||||
ret.openpilotLongitudinalControl = False
|
||||
ret.pcmCruise = True
|
||||
ret.radarUnavailable = True
|
||||
ret.autoResumeSng = False
|
||||
ret.flags &= ~HyundaiFlags.SEND_LFA.value
|
||||
ret.minSteerSpeed = 5.0
|
||||
ret.safetyConfigs = [get_safety_config(structs.CarParams.SafetyModel.hyundai, 0x6200)]
|
||||
|
||||
return ret
|
||||
|
||||
def update(self, can_packets):
|
||||
|
||||
@@ -53,6 +53,11 @@ class CarControllerParams:
|
||||
self.STEER_DELTA_UP = 2
|
||||
self.STEER_DELTA_DOWN = 3
|
||||
|
||||
elif CP.carFingerprint == CAR.HYUNDAI_I30_2026:
|
||||
self.STEER_MAX = 90
|
||||
self.STEER_DELTA_UP = 2
|
||||
self.STEER_DELTA_DOWN = 3
|
||||
|
||||
elif CP.flags & HyundaiFlags.ALT_LIMITS_2:
|
||||
self.STEER_MAX = 170
|
||||
self.STEER_DELTA_UP = 2
|
||||
|
||||
@@ -386,6 +386,46 @@ static void hyundai_rx_hook(const CANPacket_t *msg) {
|
||||
}
|
||||
}
|
||||
|
||||
static const uint16_t HYUNDAI_I30_2026_STOCK = 0x6200U;
|
||||
static bool hyundai_i30_2026 = false;
|
||||
static bool hyundai_i30_topology_conflict = false;
|
||||
static bool hyundai_i30_camera_idle = false;
|
||||
static bool hyundai_i30_host_steering = false;
|
||||
static bool hyundai_i30_camera_seen = false;
|
||||
static uint8_t hyundai_i30_camera_counter = 0U;
|
||||
static uint32_t hyundai_i30_camera_ts = 0U;
|
||||
static uint32_t hyundai_i30_host_ts = 0U;
|
||||
|
||||
static bool hyundai_i30_lkas_checksum_valid(const CANPacket_t *msg) {
|
||||
uint8_t crc = 0xFDU ^ 0xDFU;
|
||||
for (unsigned int i = 0U; i < 6U; i++) {
|
||||
crc = crc8_update(crc, msg->data[i], 0x1DU);
|
||||
}
|
||||
crc = crc8_update(crc, msg->data[7], 0x1DU);
|
||||
return (GET_LEN(msg) == 8U) && ((crc ^ 0xDFU) == msg->data[6]);
|
||||
}
|
||||
|
||||
static bool hyundai_i30_camera_is_idle(const CANPacket_t *msg) {
|
||||
return hyundai_i30_lkas_checksum_valid(msg) && ((msg->data[3] & 0x1FU) == 4U) && (msg->data[2] == 0U);
|
||||
}
|
||||
|
||||
static bool hyundai_i30_can_steer(uint32_t now) {
|
||||
return !hyundai_i30_topology_conflict && hyundai_i30_camera_idle &&
|
||||
(safety_get_ts_elapsed(now, hyundai_i30_camera_ts) <= 30000U) &&
|
||||
controls_allowed && cruise_engaged_prev && vehicle_moving && !brake_pressed &&
|
||||
!relay_malfunction && !safety_rx_checks_invalid && aol_rx_healthy();
|
||||
}
|
||||
|
||||
static bool hyundai_i30_fwd_packet(const CANPacket_t *msg) {
|
||||
if (hyundai_i30_2026 && (msg->bus == 2U) && (msg->addr == 0x340U)) {
|
||||
const uint32_t now = microsecond_timer_get();
|
||||
return hyundai_i30_camera_is_idle(msg) && hyundai_i30_host_steering &&
|
||||
(safety_get_ts_elapsed(now, hyundai_i30_host_ts) <= 30000U) &&
|
||||
hyundai_i30_can_steer(now);
|
||||
}
|
||||
return hyundai_daw_fwd(msg);
|
||||
}
|
||||
|
||||
static bool hyundai_tx_hook(const CANPacket_t *msg) {
|
||||
static int hyundai_blended_mirror_torque = 0;
|
||||
static bool hyundai_blended_mirror_request = false;
|
||||
@@ -536,6 +576,26 @@ static bool hyundai_tx_hook(const CANPacket_t *msg) {
|
||||
hyundai_alt_limits_2 ? HYUNDAI_STEERING_LIMITS_ALT_2 :
|
||||
hyundai_alt_limits ? HYUNDAI_STEERING_LIMITS_ALT : HYUNDAI_STEERING_LIMITS;
|
||||
|
||||
if (hyundai_i30_2026) {
|
||||
const uint32_t now = microsecond_timer_get();
|
||||
const TorqueSteeringLimits i30_limits = HYUNDAI_LIMITS(90, 2, 3);
|
||||
if (!hyundai_i30_can_steer(now) || !hyundai_i30_lkas_checksum_valid(msg)) {
|
||||
desired_torque_last = 0;
|
||||
rt_torque_last = 0;
|
||||
valid_steer_req_count = 0;
|
||||
invalid_steer_req_count = 0;
|
||||
ts_torque_check_last = now;
|
||||
ts_steer_req_mismatch_last = now;
|
||||
hyundai_i30_host_steering = false;
|
||||
return false;
|
||||
}
|
||||
tx = !steer_torque_cmd_checks(desired_torque, steer_req, i30_limits);
|
||||
if (tx) {
|
||||
hyundai_i30_host_steering = true;
|
||||
hyundai_i30_host_ts = now;
|
||||
}
|
||||
return tx;
|
||||
}
|
||||
if (steer_torque_cmd_checks(desired_torque, steer_req, limits) ||
|
||||
(hyundai_kona_ev_label_cruise && ((desired_torque != 0) || steer_req) &&
|
||||
(!hyundai_kona_ev_label_fresh() || !aol_rx_healthy()))) {
|
||||
@@ -655,6 +715,14 @@ static const CanMsg HYUNDAI_LONG_TX_MSGS[] = {
|
||||
#endif
|
||||
|
||||
static safety_config hyundai_init(uint16_t safety_param) {
|
||||
hyundai_i30_2026 = safety_param == HYUNDAI_I30_2026_STOCK;
|
||||
hyundai_i30_topology_conflict = false;
|
||||
hyundai_i30_camera_idle = false;
|
||||
hyundai_i30_host_steering = false;
|
||||
hyundai_i30_camera_seen = false;
|
||||
hyundai_i30_camera_counter = 0U;
|
||||
hyundai_i30_camera_ts = 0U;
|
||||
hyundai_i30_host_ts = 0U;
|
||||
hyundai_non_scc_software_cruise = hyundai_non_scc_software_cruise_param(safety_param) &&
|
||||
((alternative_experience == 0) || (alternative_experience == 32));
|
||||
const uint16_t param = hyundai_non_scc_software_cruise ? (safety_param & ~0x0020U) : safety_param;
|
||||
@@ -968,10 +1036,18 @@ static safety_config hyundai_init(uint16_t safety_param) {
|
||||
const safety_config denied = {0};
|
||||
ret = denied;
|
||||
}
|
||||
if (hyundai_i30_2026) {
|
||||
static const CanMsg i30_tx[] = {
|
||||
{0x340, 0, 8, .check_relay = true, .disable_static_blocking = true, .check_relay_immediately = true},
|
||||
};
|
||||
SET_TX_MSGS(i30_tx, ret);
|
||||
return ret;
|
||||
}
|
||||
return hyundai_daw_configure(ret, false, !hyundai_blended_stock && !hyundai_blended_alpha);
|
||||
}
|
||||
|
||||
static safety_config hyundai_legacy_init(uint16_t param) {
|
||||
hyundai_i30_2026 = false;
|
||||
hyundai_non_scc_software_cruise = false;
|
||||
// older hyundai models have less checks due to missing counters and checksums
|
||||
static const RxCheck hyundai_legacy_rx_checks[] = {
|
||||
@@ -1024,6 +1100,25 @@ static safety_config hyundai_legacy_init(uint16_t param) {
|
||||
}
|
||||
|
||||
static void hyundai_optional_rx_hook(const CANPacket_t *msg) {
|
||||
if (hyundai_i30_2026 && (msg->bus == 2U)) {
|
||||
if (msg->addr == 0x421U) {
|
||||
hyundai_i30_topology_conflict = true;
|
||||
} else if (msg->addr == 0x340U) {
|
||||
const uint32_t now = microsecond_timer_get();
|
||||
const uint8_t counter = msg->data[4] >> 4U;
|
||||
const bool valid = hyundai_i30_lkas_checksum_valid(msg);
|
||||
hyundai_i30_camera_idle = valid && hyundai_i30_camera_seen && hyundai_i30_camera_is_idle(msg) &&
|
||||
(counter == ((hyundai_i30_camera_counter + 1U) & 0xFU)) &&
|
||||
(safety_get_ts_elapsed(now, hyundai_i30_camera_ts) <= 30000U);
|
||||
hyundai_i30_camera_seen = valid;
|
||||
hyundai_i30_camera_counter = counter;
|
||||
hyundai_i30_camera_ts = now;
|
||||
if (!hyundai_i30_camera_idle) {
|
||||
hyundai_i30_host_steering = false;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
hyundai_daw_rx(msg);
|
||||
if ((msg->addr == 0x391U) || (msg->addr == 0x50CU)) {
|
||||
blended_aol_rx(msg);
|
||||
@@ -1037,7 +1132,7 @@ static void hyundai_optional_rx_hook(const CANPacket_t *msg) {
|
||||
}
|
||||
|
||||
const safety_hooks hyundai_hooks = {
|
||||
.fwd_packet = hyundai_daw_fwd,
|
||||
.fwd_packet = hyundai_i30_fwd_packet,
|
||||
.fwd = blended_aol_fwd,
|
||||
.init = hyundai_init,
|
||||
.optional_rx = hyundai_optional_rx_hook,
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
extern const uint8_t gitversion[29];
|
||||
const uint8_t gitversion[29] = "DEV-828391fd-Pf38f504f-DEBUG";
|
||||
const uint8_t gitversion[29] = "DEV-6edec473-Pf38f504f-DEBUG";
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
DEV-828391fd-Pf38f504f-DEBUG
|
||||
DEV-6edec473-Pf38f504f-DEBUG
|
||||
Binary file not shown.
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "2b54056a0a0c5c5c98df43b417ccabcac4f483f074bc4fa12145b80bfeb8da30", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "09b3db9e9bbaa0819271a21e76d2595c9dd243b567d14f0f44fa7a958186426f", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user