mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-30 11:02:19 +08:00
HKG And GM
This commit is contained in:
@@ -86,6 +86,17 @@ def should_send_cc_button_spam(CP, CC, CS):
|
||||
)
|
||||
|
||||
|
||||
def get_adas_keepalive_step(CP, is_kaofui_car):
|
||||
if CP.networkLocation == NetworkLocation.gateway:
|
||||
base_step = CarControllerParams.ADAS_KEEPALIVE_STEP
|
||||
return base_step if is_kaofui_car else base_step * 2
|
||||
|
||||
if CP.networkLocation == NetworkLocation.fwdCamera and bool(getattr(CP, "flags", 0) & GMFlags.NO_CAMERA.value):
|
||||
return CarControllerParams.CAMERA_KEEPALIVE_STEP
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def get_testing_ground_1_brake_switch_bias(v_ego: float) -> int:
|
||||
return int(round(np.interp(v_ego, [0.0, 6.0, 15.0, 30.0], [40.0, 85.0, 130.0, 170.0])))
|
||||
|
||||
@@ -600,8 +611,8 @@ class CarController(CarControllerBase):
|
||||
can_sends.append(gmcan.create_adas_steering_status(CanBus.OBSTACLE, idx))
|
||||
can_sends.append(gmcan.create_adas_accelerometer_speed_status(CanBus.OBSTACLE, CS.out.vEgo, idx))
|
||||
|
||||
keepalive_step = self.params.ADAS_KEEPALIVE_STEP if self.CP.carFingerprint in kaofui_cars else self.params.ADAS_KEEPALIVE_STEP * 2
|
||||
if self.CP.networkLocation == NetworkLocation.gateway and self.frame % keepalive_step == 0:
|
||||
keepalive_step = get_adas_keepalive_step(self.CP, self.CP.carFingerprint in kaofui_cars)
|
||||
if keepalive_step is not None and self.frame % keepalive_step == 0:
|
||||
can_sends += gmcan.create_adas_keepalive(CanBus.POWERTRAIN)
|
||||
|
||||
pedal_cancel = bool(self.CP.flags & GMFlags.PEDAL_LONG.value) and CS.out.cruiseState.enabled
|
||||
|
||||
@@ -79,6 +79,18 @@ def _create_angle_lfa_msg(packer, CAN, values, apply_angle: float, lat_active: b
|
||||
return address, bytes(dat), CAN.ECAN
|
||||
|
||||
|
||||
def _create_angle_adas_cmd_msg(packer, CAN, apply_angle: float, lat_active: bool, torque_reduction_gain: float):
|
||||
values = {
|
||||
"ADAS_ActvACISta": 0,
|
||||
"ADAS_ActvACILvl2Sta": 2 if lat_active else 1,
|
||||
"ADAS_StrAnglReqVal": apply_angle,
|
||||
"ADAS_ACIAnglTqRedcGainVal": torque_reduction_gain if lat_active else 0.0,
|
||||
"FCA_ESA_ActvSta": 0,
|
||||
"FCA_ESA_TqBstGainVal": 0.0,
|
||||
}
|
||||
return packer.make_can_msg("ADAS_CMD_35_10ms", CAN.ECAN, values)
|
||||
|
||||
|
||||
def create_steering_messages(packer, CP, CAN, enabled, lat_active, apply_torque, apply_angle):
|
||||
common_values = {
|
||||
"LKA_MODE": 2,
|
||||
@@ -111,7 +123,10 @@ def create_steering_messages(packer, CP, CAN, enabled, lat_active, apply_torque,
|
||||
ret.append(packer.make_can_msg(lkas_msg, CAN.ACAN, lkas_values))
|
||||
else:
|
||||
if CP.flags & HyundaiFlags.CANFD_ANGLE_STEERING:
|
||||
ret.append(_create_angle_lfa_msg(packer, CAN, lfa_values, apply_angle, lat_active, apply_torque))
|
||||
if CP.flags & HyundaiFlags.SEND_LFA:
|
||||
ret.append(_create_angle_adas_cmd_msg(packer, CAN, apply_angle, lat_active, apply_torque))
|
||||
else:
|
||||
ret.append(_create_angle_lfa_msg(packer, CAN, lfa_values, apply_angle, lat_active, apply_torque))
|
||||
else:
|
||||
ret.append(packer.make_can_msg("LFA", CAN.ECAN, lfa_values))
|
||||
|
||||
|
||||
@@ -64,6 +64,8 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.flags |= HyundaiFlags.CANFD_ALT_BUTTONS.value
|
||||
if not ret.flags & HyundaiFlags.RADAR_SCC:
|
||||
ret.flags |= HyundaiFlags.CANFD_CAMERA_SCC.value
|
||||
if 0xCB in fingerprint[CAN.CAM]:
|
||||
ret.flags |= HyundaiFlags.SEND_LFA.value
|
||||
|
||||
# Some LKA steering cars have alternative messages for gear checks
|
||||
# ICE cars do not have 0x130; GEARS message on 0x40 or 0x70 instead
|
||||
|
||||
@@ -79,6 +79,12 @@ class TestHyundaiFingerprint:
|
||||
assert CP.steerControlType == CarParams.SteerControlType.angle
|
||||
assert CP.safetyConfigs[-1].safetyParam & HyundaiSafetyFlags.CANFD_ANGLE_STEERING
|
||||
|
||||
fingerprint = gen_empty_fingerprint()
|
||||
cam_can = CanBus(None, fingerprint).CAM
|
||||
fingerprint[cam_can][0xCB] = 24
|
||||
CP = CarInterface.get_params(CAR.KIA_SPORTAGE_HEV_2026, fingerprint, [], False, False, False, None)
|
||||
assert CP.flags & HyundaiFlags.SEND_LFA
|
||||
|
||||
def test_alternate_limits(self):
|
||||
# Alternate lateral control limits, for high torque cars, verify Panda safety mode flag is set
|
||||
fingerprint = gen_empty_fingerprint()
|
||||
|
||||
@@ -562,6 +562,7 @@ static safety_config gm_init(uint16_t param) {
|
||||
{0xBD, 0, 7, .check_relay = false}, {0x1F5, 0, 8, .check_relay = false}}; // pt bus
|
||||
|
||||
static const CanMsg GM_CAM_LONG_NO_CAMERA_TX_MSGS[] = {{0x180, 0, 4, .check_relay = false}, {0x315, 0, 5, .check_relay = false}, {0x2CB, 0, 8, .check_relay = false}, {0x370, 0, 6, .check_relay = false}, {0x3D1, 0, 8, .check_relay = false}, // pt bus
|
||||
{0x409, 0, 7, .check_relay = false}, {0x40A, 0, 7, .check_relay = false},
|
||||
{0x184, 2, 8, .check_relay = false}, // camera bus
|
||||
{0x200, 0, 6, .check_relay = false}, {0x1E1, 0, 7, .check_relay = false},
|
||||
{0xBD, 0, 7, .check_relay = false}, {0x1F5, 0, 8, .check_relay = false}}; // pt bus
|
||||
@@ -598,6 +599,7 @@ static safety_config gm_init(uint16_t param) {
|
||||
{0xBD, 0, 7, .check_relay = false}, {0x1F5, 0, 8, .check_relay = false}}; // pt bus
|
||||
|
||||
static const CanMsg GM_CAM_NO_CAMERA_TX_MSGS[] = {{0x180, 0, 4, .check_relay = false}, {0x370, 0, 6, .check_relay = false}, {0x3D1, 0, 8, .check_relay = false}, // pt bus
|
||||
{0x409, 0, 7, .check_relay = false}, {0x40A, 0, 7, .check_relay = false},
|
||||
{0x1E1, 2, 7, .check_relay = false}, {0x184, 2, 8, .check_relay = false}, // camera bus
|
||||
{0x200, 0, 6, .check_relay = false},
|
||||
{0x1E1, 0, 7, .check_relay = false},
|
||||
@@ -639,6 +641,7 @@ static safety_config gm_init(uint16_t param) {
|
||||
{0x184, 2, 8, .check_relay = true}, {0x1E1, 2, 7, .check_relay = false}}; // camera bus
|
||||
|
||||
static const CanMsg GM_CC_LONG_NO_CAMERA_TX_MSGS[] = {{0x180, 0, 4, .check_relay = false}, {0x370, 0, 6, .check_relay = false}, {0x1E1, 0, 7, .check_relay = false}, {0x3D1, 0, 8, .check_relay = false}, // pt bus
|
||||
{0x409, 0, 7, .check_relay = false}, {0x40A, 0, 7, .check_relay = false},
|
||||
{0xBD, 0, 7, .check_relay = false}, {0x1F5, 0, 8, .check_relay = false},
|
||||
{0x184, 2, 8, .check_relay = false}, {0x1E1, 2, 7, .check_relay = false}}; // camera bus
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#define HYUNDAI_CANFD_LFA_STEERING_COMMON_TX_MSGS(e_can) \
|
||||
{0x12A, e_can, 16, .check_relay = (e_can) == 0}, /* LFA */ \
|
||||
{0x1E0, e_can, 16, .check_relay = (e_can) == 0}, /* LFAHDA_CLUSTER */ \
|
||||
{0xCB, e_can, 24, .check_relay = (e_can) == 0}, /* ADAS_CMD_35_10ms */ \
|
||||
|
||||
#define HYUNDAI_CANFD_SCC_CONTROL_COMMON_TX_MSGS(e_can, longitudinal) \
|
||||
{0x1A0, e_can, 32, .check_relay = (longitudinal)}, /* SCC_CONTROL */ \
|
||||
@@ -174,6 +175,24 @@ static bool hyundai_canfd_tx_hook(const CANPacket_t *msg) {
|
||||
|
||||
bool tx = true;
|
||||
|
||||
if (msg->addr == 0xCBU) {
|
||||
if (!hyundai_canfd_angle_steering) {
|
||||
tx = false;
|
||||
} else {
|
||||
const int lfa_angle_active = (msg->data[3] >> 4U) & 0xFU;
|
||||
const bool steer_angle_req = lfa_angle_active == 2;
|
||||
|
||||
int desired_angle = (((uint32_t)(msg->data[5] & 0x3FU)) << 8) | (uint32_t)msg->data[4];
|
||||
desired_angle = to_signed(desired_angle, 14);
|
||||
|
||||
if (steer_angle_cmd_checks_vm(desired_angle, steer_angle_req,
|
||||
HYUNDAI_CANFD_ANGLE_STEERING_LIMITS,
|
||||
HYUNDAI_CANFD_ANGLE_STEERING_PARAMS)) {
|
||||
tx = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// steering
|
||||
const unsigned int steer_addr = (hyundai_canfd_lka_steering && !hyundai_longitudinal) ? hyundai_canfd_get_lka_addr() : 0x12aU;
|
||||
if (msg->addr == steer_addr) {
|
||||
|
||||
@@ -304,6 +304,7 @@ class TestGmCameraEVSafety(GmCameraAccEVRegenMixin, TestGmCameraSafety, TestGmEV
|
||||
|
||||
|
||||
class TestGmCameraNoCameraSafety(TestGmCameraSafety):
|
||||
TX_MSGS = TestGmCameraSafety.TX_MSGS + [[0x409, 0], [0x40A, 0]]
|
||||
RELAY_MALFUNCTION_ADDRS = {0: (), 2: ()}
|
||||
|
||||
def setUp(self):
|
||||
@@ -338,6 +339,7 @@ class TestGmCameraLongitudinalEVSafety(GmCameraAccEVRegenMixin, TestGmCameraLong
|
||||
|
||||
|
||||
class TestGmCameraLongitudinalNoCameraSafety(TestGmCameraLongitudinalSafety):
|
||||
TX_MSGS = TestGmCameraLongitudinalSafety.TX_MSGS + [[0x409, 0], [0x40A, 0]]
|
||||
RELAY_MALFUNCTION_ADDRS = {0: (), 2: ()}
|
||||
|
||||
def setUp(self):
|
||||
@@ -455,6 +457,7 @@ class TestGmCcLongitudinalSafety(TestGmCameraSafety):
|
||||
|
||||
|
||||
class TestGmCcLongitudinalNoCameraSafety(TestGmCcLongitudinalSafety):
|
||||
TX_MSGS = TestGmCcLongitudinalSafety.TX_MSGS + [[0x409, 0], [0x40A, 0]]
|
||||
RELAY_MALFUNCTION_ADDRS = {0: (), 2: ()}
|
||||
|
||||
def setUp(self):
|
||||
|
||||
@@ -127,8 +127,8 @@ class TestHyundaiCanfdBase(HyundaiButtonBase, common.CarSafetyTest, common.Drive
|
||||
class TestHyundaiCanfdLFASteeringBase(TestHyundaiCanfdBase):
|
||||
|
||||
TX_MSGS = [[0x12A, 0], [0x1A0, 1], [0x1CF, 0], [0x1E0, 0]]
|
||||
RELAY_MALFUNCTION_ADDRS = {0: (0x12A, 0x1E0)} # LFA, LFAHDA_CLUSTER
|
||||
FWD_BLACKLISTED_ADDRS = {2: [0x12A, 0x1E0]}
|
||||
RELAY_MALFUNCTION_ADDRS = {0: (0x12A, 0xCB, 0x1E0)} # LFA, ADAS_CMD_35_10ms, LFAHDA_CLUSTER
|
||||
FWD_BLACKLISTED_ADDRS = {2: [0x12A, 0xCB, 0x1E0]}
|
||||
|
||||
STEER_MSG = "LFA"
|
||||
BUTTONS_TX_BUS = 2
|
||||
@@ -151,9 +151,9 @@ class TestHyundaiCanfdLFASteeringBase(TestHyundaiCanfdBase):
|
||||
|
||||
class TestHyundaiCanfdAngleSteering(HyundaiButtonBase, common.CarSafetyTest):
|
||||
|
||||
TX_MSGS = [[0x12A, 0], [0x160, 0], [0x1A0, 0], [0x1CF, 2], [0x1E0, 0]]
|
||||
RELAY_MALFUNCTION_ADDRS = {0: (0x12A, 0x1E0)}
|
||||
FWD_BLACKLISTED_ADDRS = {2: [0x12A, 0x1E0]}
|
||||
TX_MSGS = [[0x12A, 0], [0xCB, 0], [0x160, 0], [0x1A0, 0], [0x1CF, 2], [0x1E0, 0]]
|
||||
RELAY_MALFUNCTION_ADDRS = {0: (0x12A, 0xCB, 0x1E0)}
|
||||
FWD_BLACKLISTED_ADDRS = {2: [0x12A, 0xCB, 0x1E0]}
|
||||
|
||||
PT_BUS = 0
|
||||
SCC_BUS = 2
|
||||
@@ -322,6 +322,24 @@ class TestHyundaiCanfdAngleSteering(HyundaiButtonBase, common.CarSafetyTest):
|
||||
self.assertTrue(self._tx(self._angle_cmd_msg(0, True, increment_timer=False)))
|
||||
|
||||
|
||||
class TestHyundaiCanfdAngleSteeringLfaAlt(TestHyundaiCanfdAngleSteering):
|
||||
|
||||
def _angle_cmd_msg(self, angle, enabled, increment_timer=True):
|
||||
if increment_timer:
|
||||
self.safety.set_timer(self.angle_cmd_cnt * int(1e6 / self.LATERAL_FREQUENCY))
|
||||
self.angle_cmd_cnt += 1
|
||||
|
||||
values = {
|
||||
"ADAS_ActvACISta": 0,
|
||||
"ADAS_ActvACILvl2Sta": 2 if enabled else 1,
|
||||
"ADAS_StrAnglReqVal": angle,
|
||||
"ADAS_ACIAnglTqRedcGainVal": 1.0 if enabled else 0.0,
|
||||
"FCA_ESA_ActvSta": 0,
|
||||
"FCA_ESA_TqBstGainVal": 0.0,
|
||||
}
|
||||
return self.packer.make_can_msg_safety("ADAS_CMD_35_10ms", 0, values)
|
||||
|
||||
|
||||
@parameterized_class(ALL_GAS_EV_HYBRID_COMBOS)
|
||||
class TestHyundaiCanfdLFASteering(TestHyundaiCanfdLFASteeringBase):
|
||||
pass
|
||||
@@ -462,9 +480,9 @@ class TestHyundaiCanfdLKASteeringLongEV(HyundaiLongitudinalBase, TestHyundaiCanf
|
||||
# Tests longitudinal for ICE, hybrid, EV cars with LFA steering
|
||||
class TestHyundaiCanfdLFASteeringLongBase(HyundaiLongitudinalBase, TestHyundaiCanfdLFASteeringBase):
|
||||
|
||||
FWD_BLACKLISTED_ADDRS = {2: [0x12a, 0x1e0, 0x1a0, 0x160]}
|
||||
FWD_BLACKLISTED_ADDRS = {2: [0x12a, 0xcb, 0x1e0, 0x1a0, 0x160]}
|
||||
|
||||
RELAY_MALFUNCTION_ADDRS = {0: (0x12A, 0x1E0, 0x1a0, 0x160)} # LFA, LFAHDA_CLUSTER, SCC_CONTROL, ADRV_0x160
|
||||
RELAY_MALFUNCTION_ADDRS = {0: (0x12A, 0xCB, 0x1E0, 0x1a0, 0x160)} # LFA, ADAS_CMD_35_10ms, LFAHDA_CLUSTER, SCC_CONTROL, ADRV_0x160
|
||||
|
||||
DISABLED_ECU_UDS_MSG = (0x7D0, 0)
|
||||
DISABLED_ECU_ACTUATION_MSG = (0x1a0, 0)
|
||||
|
||||
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,2 +1,2 @@
|
||||
extern const uint8_t gitversion[19];
|
||||
const uint8_t gitversion[19] = "DEV-39afadb9-DEBUG";
|
||||
const uint8_t gitversion[19] = "DEV-ece5f957-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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
DEV-39afadb9-DEBUG
|
||||
DEV-ece5f957-DEBUG
|
||||
Reference in New Issue
Block a user