mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-05 16:26:14 +08:00
HKG CAN-FD: set cruise state available with car signal (#26812)
* HKG CAN-FD: set cruise state available with car signal
* Whoops
* Check this signal
* No should be in SCC_CONTROL
* use TCS
* add back
* match CAN
* think these are missing
Co-authored-by: Shane Smiskol <shane@smiskol.com>
old-commit-hash: ccb4327197
This commit is contained in:
@@ -156,6 +156,9 @@ class CarState(CarStateBase):
|
||||
def update_canfd(self, cp, cp_cam):
|
||||
ret = car.CarState.new_message()
|
||||
|
||||
self.is_metric = cp.vl["CRUISE_BUTTONS_ALT"]["DISTANCE_UNIT"] != 1
|
||||
speed_factor = CV.KPH_TO_MS if self.is_metric else CV.MPH_TO_MS
|
||||
|
||||
if self.CP.carFingerprint in (EV_CAR | HYBRID_CAR):
|
||||
if self.CP.carFingerprint in EV_CAR:
|
||||
ret.gas = cp.vl["ACCELERATOR"]["ACCELERATOR_PEDAL"] / 255.
|
||||
@@ -197,14 +200,18 @@ class CarState(CarStateBase):
|
||||
ret.leftBlindspot = cp.vl["BLINDSPOTS_REAR_CORNERS"]["FL_INDICATOR"] != 0
|
||||
ret.rightBlindspot = cp.vl["BLINDSPOTS_REAR_CORNERS"]["FR_INDICATOR"] != 0
|
||||
|
||||
ret.cruiseState.available = True
|
||||
self.is_metric = cp.vl["CRUISE_BUTTONS_ALT"]["DISTANCE_UNIT"] != 1
|
||||
if not self.CP.openpilotLongitudinalControl:
|
||||
speed_factor = CV.KPH_TO_MS if self.is_metric else CV.MPH_TO_MS
|
||||
# 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 = cp.vl["TCS"]["ACCEnable"] == 0
|
||||
ret.cruiseState.enabled = cp.vl["TCS"]["ACC_REQ"] == 1
|
||||
ret.cruiseState.standstill = False
|
||||
else:
|
||||
cp_cruise_info = cp_cam if self.CP.flags & HyundaiFlags.CANFD_CAMERA_SCC else cp
|
||||
ret.cruiseState.speed = cp_cruise_info.vl["SCC_CONTROL"]["VSetDis"] * speed_factor
|
||||
ret.cruiseState.standstill = cp_cruise_info.vl["SCC_CONTROL"]["CRUISE_STANDSTILL"] == 1
|
||||
ret.cruiseState.available = cp_cruise_info.vl["SCC_CONTROL"]["MainMode_ACC"] == 1
|
||||
ret.cruiseState.enabled = cp_cruise_info.vl["SCC_CONTROL"]["ACCMode"] in (1, 2)
|
||||
ret.cruiseState.standstill = cp_cruise_info.vl["SCC_CONTROL"]["CRUISE_STANDSTILL"] == 1
|
||||
ret.cruiseState.speed = cp_cruise_info.vl["SCC_CONTROL"]["VSetDis"] * speed_factor
|
||||
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"
|
||||
@@ -435,6 +442,7 @@ class CarState(CarStateBase):
|
||||
|
||||
("DriverBraking", "TCS"),
|
||||
("ACCEnable", "TCS"),
|
||||
("ACC_REQ", "TCS"),
|
||||
|
||||
("COUNTER", cruise_btn_msg),
|
||||
("CRUISE_BUTTONS", cruise_btn_msg),
|
||||
@@ -476,6 +484,7 @@ class CarState(CarStateBase):
|
||||
("ACCMode", "SCC_CONTROL"),
|
||||
("VSetDis", "SCC_CONTROL"),
|
||||
("CRUISE_STANDSTILL", "SCC_CONTROL"),
|
||||
("MainMode_ACC", "SCC_CONTROL"),
|
||||
]
|
||||
checks += [
|
||||
("SCC_CONTROL", 50),
|
||||
|
||||
Reference in New Issue
Block a user