HKG CAN-FD: common distance unit signal (#26758)

* Check DISTANCE_UNIT on CRUISE_BUTTONS for all CAN-FD HKG

* update refs

* move down

Co-authored-by: Shane Smiskol <shane@smiskol.com>
pull/26776/head^2
Jason Wen 2 years ago committed by GitHub
parent 7bfb63b93c
commit c954634ac0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      selfdrive/car/hyundai/carstate.py
  2. 2
      selfdrive/test/process_replay/ref_commit

@ -199,9 +199,7 @@ class CarState(CarStateBase):
ret.rightBlindspot = cp.vl["BLINDSPOTS_REAR_CORNERS"]["FR_INDICATOR"] != 0 ret.rightBlindspot = cp.vl["BLINDSPOTS_REAR_CORNERS"]["FR_INDICATOR"] != 0
ret.cruiseState.available = True ret.cruiseState.available = True
cruise_btn_msg = "CRUISE_BUTTONS_ALT" if self.CP.flags & HyundaiFlags.CANFD_ALT_BUTTONS else "CRUISE_BUTTONS" self.is_metric = cp.vl["CRUISE_BUTTONS_ALT"]["DISTANCE_UNIT"] != 1
distance_unit_msg = cruise_btn_msg if self.CP.carFingerprint == CAR.KIA_SORENTO_PHEV_4TH_GEN else "CLUSTER_INFO"
self.is_metric = cp.vl[distance_unit_msg]["DISTANCE_UNIT"] != 1
if not self.CP.openpilotLongitudinalControl: if not self.CP.openpilotLongitudinalControl:
speed_factor = CV.KPH_TO_MS if self.is_metric else CV.MPH_TO_MS speed_factor = CV.KPH_TO_MS if self.is_metric else CV.MPH_TO_MS
cp_cruise_info = cp_cam if self.CP.flags & HyundaiFlags.CANFD_CAMERA_SCC else cp cp_cruise_info = cp_cam if self.CP.flags & HyundaiFlags.CANFD_CAMERA_SCC else cp
@ -210,6 +208,7 @@ class CarState(CarStateBase):
ret.cruiseState.enabled = cp_cruise_info.vl["SCC_CONTROL"]["ACCMode"] in (1, 2) ret.cruiseState.enabled = cp_cruise_info.vl["SCC_CONTROL"]["ACCMode"] in (1, 2)
self.cruise_info = copy.copy(cp_cruise_info.vl["SCC_CONTROL"]) self.cruise_info = copy.copy(cp_cruise_info.vl["SCC_CONTROL"])
cruise_btn_msg = "CRUISE_BUTTONS_ALT" if self.CP.flags & HyundaiFlags.CANFD_ALT_BUTTONS else "CRUISE_BUTTONS"
self.prev_cruise_buttons = self.cruise_buttons[-1] self.prev_cruise_buttons = self.cruise_buttons[-1]
self.cruise_buttons.extend(cp.vl_all[cruise_btn_msg]["CRUISE_BUTTONS"]) self.cruise_buttons.extend(cp.vl_all[cruise_btn_msg]["CRUISE_BUTTONS"])
self.main_buttons.extend(cp.vl_all[cruise_btn_msg]["ADAPTIVE_CRUISE_MAIN_BTN"]) self.main_buttons.extend(cp.vl_all[cruise_btn_msg]["ADAPTIVE_CRUISE_MAIN_BTN"])
@ -439,8 +438,7 @@ class CarState(CarStateBase):
("COUNTER", cruise_btn_msg), ("COUNTER", cruise_btn_msg),
("CRUISE_BUTTONS", cruise_btn_msg), ("CRUISE_BUTTONS", cruise_btn_msg),
("ADAPTIVE_CRUISE_MAIN_BTN", cruise_btn_msg), ("ADAPTIVE_CRUISE_MAIN_BTN", cruise_btn_msg),
("DISTANCE_UNIT", "CRUISE_BUTTONS_ALT"),
("DISTANCE_UNIT", "CLUSTER_INFO"),
("LEFT_LAMP", "BLINKERS"), ("LEFT_LAMP", "BLINKERS"),
("RIGHT_LAMP", "BLINKERS"), ("RIGHT_LAMP", "BLINKERS"),
@ -449,21 +447,20 @@ class CarState(CarStateBase):
("DRIVER_SEATBELT_LATCHED", "DOORS_SEATBELTS"), ("DRIVER_SEATBELT_LATCHED", "DOORS_SEATBELTS"),
] ]
if CP.carFingerprint == CAR.KIA_SORENTO_PHEV_4TH_GEN:
signals.append(("DISTANCE_UNIT", cruise_btn_msg))
checks = [ checks = [
("WHEEL_SPEEDS", 100), ("WHEEL_SPEEDS", 100),
(gear_msg, 100), (gear_msg, 100),
("STEERING_SENSORS", 100), ("STEERING_SENSORS", 100),
("MDPS", 100), ("MDPS", 100),
("TCS", 50), ("TCS", 50),
(cruise_btn_msg, 50), ("CRUISE_BUTTONS_ALT", 50),
("CLUSTER_INFO", 4),
("BLINKERS", 4), ("BLINKERS", 4),
("DOORS_SEATBELTS", 4), ("DOORS_SEATBELTS", 4),
] ]
if not (CP.flags & HyundaiFlags.CANFD_ALT_BUTTONS):
checks.append(("CRUISE_BUTTONS", 50))
if CP.enableBsm: if CP.enableBsm:
signals += [ signals += [
("FL_INDICATOR", "BLINDSPOTS_REAR_CORNERS"), ("FL_INDICATOR", "BLINDSPOTS_REAR_CORNERS"),

@ -1 +1 @@
2f83b9872fe991d21e07a95cc518f91f140a856a faa85c0cb3609fc43674b263ae885c60f136ba6c
Loading…
Cancel
Save