diff --git a/opendbc_repo/opendbc/car/hyundai/carstate.py b/opendbc_repo/opendbc/car/hyundai/carstate.py index 79fcc3bbeb..6733627f94 100644 --- a/opendbc_repo/opendbc/car/hyundai/carstate.py +++ b/opendbc_repo/opendbc/car/hyundai/carstate.py @@ -28,6 +28,8 @@ GearShifter = structs.CarState.GearShifter +READY_COUNT_OK = 200 + NUMERIC_TO_TZ = { 840: "America/New_York", # 미국 (US) → 동부 시간대 @@ -165,9 +167,10 @@ def __init__(self, CP): self.controls_ready_count = 0 def monitor_fingerprint(self, can_parsers, canfd): - if self.controls_ready_count <= 200: + if self.controls_ready_count <= READY_COUNT_OK: if Params().get_bool("ControlsReady"): self.controls_ready_count += 1 + self.cp = can_parsers[Bus.pt] self.cp_cam = can_parsers[Bus.cam] self.cp_alt = can_parsers[Bus.alt] if Bus.alt in can_parsers else None @@ -224,6 +227,8 @@ def add_and_cache(parser, name: str, attr: str, ignore_counter: bool = False): cp_cruise = self.cp_cam if self.CP.flags & HyundaiFlags.CANFD_CAMERA_SCC else self.cp add_and_cache(cp_cruise, "SCC_CONTROL", "scc_control") elif self.controls_ready_count == 121: + add_and_cache(self.cp, "TCS", "tcs") + add_and_cache(self.cp, "MDPS", "mdps") add_and_cache(self.cp_cam, "LFA", "lfa") add_and_cache(self.cp_cam, "LFA_ALT", "lfa_alt") add_and_cache(self.cp_cam, "LFAHDA_CLUSTER", "lfahda_cluster") @@ -235,8 +240,6 @@ def add_and_cache(parser, name: str, attr: str, ignore_counter: bool = False): add_and_cache(self.cp_cam, "CCNC_0x162", "ccnc_0x162") elif self.controls_ready_count == 123: add_and_cache(self.cp, "HDA_INFO_4A3", "hda_info_4a3") - add_and_cache(self.cp, "TCS", "tcs") - add_and_cache(self.cp, "MDPS", "mdps") add_and_cache(self.cp, "STEER_TOUCH_2AF", "steer_touch_2af") elif self.controls_ready_count == 124: add_and_cache(self.cp, self.cruise_btns_msg_canfd, "cruise_buttons_msg") @@ -313,7 +316,7 @@ def update(self, can_parsers) -> structs.CarState: # cruise state if self.CP.openpilotLongitudinalControl: # These are not used for engage/disengage since openpilot keeps track of state using the buttons - ret.cruiseState.available = self.main_enabled #cp.vl["TCS13"]["ACCEnable"] == 0 + ret.cruiseState.available = self.main_enabled and self.controls_ready_count >= READY_COUNT_OK #cp.vl["TCS13"]["ACCEnable"] == 0 ret.cruiseState.enabled = cp.vl["TCS13"]["ACC_REQ"] == 1 ret.cruiseState.standstill = False ret.cruiseState.nonAdaptive = False @@ -563,7 +566,7 @@ def update_canfd(self, can_parsers) -> structs.CarState: if cruise_button in [Buttons.RES_ACCEL, Buttons.SET_DECEL] and self.CP.openpilotLongitudinalControl: self.main_enabled = True # CAN FD cars enable on main button press, set available if no TCS faults preventing engagement - ret.cruiseState.available = self.main_enabled #cp.vl["TCS"]["ACCEnable"] == 0 + ret.cruiseState.available = self.main_enabled and self.controls_ready_count >= READY_COUNT_OK #cp.vl["TCS"]["ACCEnable"] == 0 if self.CP.flags & HyundaiFlags.CAMERA_SCC.value: self.MainMode_ACC = cp_cam.vl["SCC_CONTROL"]["MainMode_ACC"] == 1 self.ACCMode = cp_cam.vl["SCC_CONTROL"]["ACCMode"] diff --git a/opendbc_repo/opendbc/car/hyundai/hyundaicanfd.py b/opendbc_repo/opendbc/car/hyundai/hyundaicanfd.py index c71b89e153..86d5340651 100644 --- a/opendbc_repo/opendbc/car/hyundai/hyundaicanfd.py +++ b/opendbc_repo/opendbc/car/hyundai/hyundaicanfd.py @@ -154,7 +154,7 @@ def create_steering_messages_camera_scc(frame, packer, CP, CAN, CC, lat_active, values["NEW_SIGNAL_1"] = 10 ret.append(packer.make_can_msg("LFA", CAN.ECAN, values, rx_counter = rx_counter)) - else: + elif CS.lfa is not None: values = {} values["LKA_MODE"] = 2 values["LKA_ICON"] = 2 if lat_active else 1 diff --git a/selfdrive/modeld/modeld.py b/selfdrive/modeld/modeld.py index 1caced2c9c..cb3f7601d1 100755 --- a/selfdrive/modeld/modeld.py +++ b/selfdrive/modeld/modeld.py @@ -56,7 +56,7 @@ def get_lat_smooth_seconds_dynamic(model_output: dict[str, np.ndarray], except Exception: y_std_1s = 0.0 - extra_smooth_seconds = float(np.interp(y_std_1s, [0.15, 0.25], [0.0, base_lat_smooth_seconds])) + extra_smooth_seconds = float(np.interp(y_std_1s, [0.15, 0.25], [0.0, base_lat_smooth_seconds * 2])) dynamic_lat_smooth_seconds = float(np.clip(base_lat_smooth_seconds + extra_smooth_seconds, 0.0, 0.60))