From 122efe3a89d71408e4af2c34ccafc461fe65d797 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Sat, 1 Jul 2023 05:49:16 -0400 Subject: [PATCH 1/2] Use `spFlags` for sunnypilot specific features (pub) (#189) * Use spFlags for sunnypilot specific features (pub) * add remaining --- selfdrive/car/hyundai/carcontroller.py | 4 ++-- selfdrive/car/hyundai/carstate.py | 16 ++++++++-------- selfdrive/car/hyundai/interface.py | 12 ++++++------ selfdrive/car/hyundai/radar_interface.py | 6 +++--- selfdrive/car/hyundai/values.py | 9 ++++++--- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index 4541a90f3c..b4fc30283e 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -6,7 +6,7 @@ from opendbc.can.packer import CANPacker from selfdrive.car import apply_driver_steer_torque_limits from selfdrive.car.hyundai import hyundaicanfd, hyundaican from selfdrive.car.hyundai.hyundaicanfd import CanBus -from selfdrive.car.hyundai.values import HyundaiFlags, Buttons, CarControllerParams, CANFD_CAR, CAR +from selfdrive.car.hyundai.values import HyundaiFlags, HyundaiFlagsSP, Buttons, CarControllerParams, CANFD_CAR, CAR VisualAlert = car.CarControl.HUDControl.VisualAlert LongCtrlState = car.CarControl.Actuators.LongControlState @@ -78,7 +78,7 @@ class CarController: sys_warning, sys_state, left_lane_warning, right_lane_warning = process_hud_alert(CC.enabled, self.car_fingerprint, hud_control) - escc = self.CP.flags & HyundaiFlags.SP_ENHANCED_SCC.value + escc = self.CP.spFlags & HyundaiFlagsSP.SP_ENHANCED_SCC.value can_sends = [] diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index e421a1b340..467f37f554 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -7,7 +7,7 @@ from common.conversions import Conversions as CV from opendbc.can.parser import CANParser from opendbc.can.can_define import CANDefine from selfdrive.car.hyundai.hyundaicanfd import CanBus -from selfdrive.car.hyundai.values import HyundaiFlags, CAR, DBC, CAN_GEARS, CAMERA_SCC_CAR, CANFD_CAR, EV_CAR, HYBRID_CAR, Buttons, CarControllerParams +from selfdrive.car.hyundai.values import HyundaiFlags, HyundaiFlagsSP, CAR, DBC, CAN_GEARS, CAMERA_SCC_CAR, CANFD_CAR, EV_CAR, HYBRID_CAR, Buttons, CarControllerParams from selfdrive.car.interfaces import CarStateBase PREV_BUTTON_SAMPLES = 8 @@ -148,7 +148,7 @@ class CarState(CarStateBase): aeb_braking = cp_cruise.vl[aeb_src]["CF_VSM_DecCmdAct"] != 0 or cp_cruise.vl[aeb_src][aeb_sig] != 0 ret.stockFcw = aeb_warning and not aeb_braking ret.stockAeb = aeb_warning and aeb_braking - elif self.CP.flags & HyundaiFlags.SP_ENHANCED_SCC: + elif self.CP.spFlags & HyundaiFlagsSP.SP_ENHANCED_SCC: aeb_src = "ESCC" aeb_sig = "FCA_CmdAct" if self.CP.flags & HyundaiFlags.USE_FCA.value else "AEB_CmdAct" aeb_warning_sig = "CF_VSM_Warn_FCA11" if self.CP.flags & HyundaiFlags.USE_FCA.value else "CF_VSM_Warn_SCC12" @@ -175,7 +175,7 @@ class CarState(CarStateBase): self.cruise_buttons.extend(cp.vl_all["CLU11"]["CF_Clu_CruiseSwState"]) self.main_buttons.extend(cp.vl_all["CLU11"]["CF_Clu_CruiseSwMain"]) - if self.CP.flags & HyundaiFlags.SP_NAV_MSG: + if self.CP.spFlags & HyundaiFlagsSP.SP_NAV_MSG: self._update_traffic_signals(self.CP, cp, cp_cam) ret.cruiseState.speedLimit = self._calculate_speed_limit() * speed_conv @@ -252,7 +252,7 @@ class CarState(CarStateBase): if self.CP.flags & HyundaiFlags.CANFD_HDA2: self.cam_0x2a4 = copy.copy(cp_cam.vl["CAM_0x2a4"]) - if self.CP.flags & HyundaiFlags.SP_NAV_MSG: + if self.CP.spFlags & HyundaiFlagsSP.SP_NAV_MSG: self._update_traffic_signals(self.CP, cp, cp_cam) ret.cruiseState.speedLimit = self._calculate_speed_limit() * speed_factor @@ -404,7 +404,7 @@ class CarState(CarStateBase): signals.append(("CF_Lvr_Gear", "LVR12")) checks.append(("LVR12", 100)) - if CP.flags & HyundaiFlags.SP_ENHANCED_SCC.value: + if CP.spFlags & HyundaiFlagsSP.SP_ENHANCED_SCC.value: if CP.flags & HyundaiFlags.USE_FCA.value: signals += [ ("FCA_CmdAct", "ESCC"), @@ -421,7 +421,7 @@ class CarState(CarStateBase): ] checks.append(("ESCC", 50)) - if CP.flags & HyundaiFlags.SP_NAV_MSG: + if CP.spFlags & HyundaiFlagsSP.SP_NAV_MSG: signals.append(("SpeedLim_Nav_Clu", "Navi_HU")) checks.append(("Navi_HU", 5)) @@ -577,7 +577,7 @@ class CarState(CarStateBase): ("ACCELERATOR_BRAKE_ALT", 100), ] - if CP.flags & HyundaiFlags.CANFD_HDA2 and CP.flags & HyundaiFlags.SP_NAV_MSG: + if CP.flags & HyundaiFlags.CANFD_HDA2 and CP.spFlags & HyundaiFlagsSP.SP_NAV_MSG: signals.append(("SPEED_LIMIT_1", "CLUSTER_SPEED_LIMIT")) checks.append(("CLUSTER_SPEED_LIMIT", 10)) @@ -609,7 +609,7 @@ class CarState(CarStateBase): ("SCC_CONTROL", 50), ] - if not (CP.flags & HyundaiFlags.CANFD_HDA2) and CP.flags & HyundaiFlags.SP_NAV_MSG: + if not (CP.flags & HyundaiFlags.CANFD_HDA2) and CP.spFlags & HyundaiFlagsSP.SP_NAV_MSG: signals.append(("SPEED_LIMIT_1", "CLUSTER_SPEED_LIMIT")) checks.append(("CLUSTER_SPEED_LIMIT", 10)) diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index ddcf09ecf6..bdc29471af 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -3,7 +3,7 @@ from cereal import car from panda import Panda from common.conversions import Conversions as CV from selfdrive.car.hyundai.hyundaicanfd import CanBus -from selfdrive.car.hyundai.values import HyundaiFlags, CAR, DBC, CANFD_CAR, CAMERA_SCC_CAR, CANFD_RADAR_SCC_CAR, EV_CAR, HYBRID_CAR, LEGACY_SAFETY_MODE_CAR, NON_SCC_CAR, Buttons +from selfdrive.car.hyundai.values import HyundaiFlags, HyundaiFlagsSP, CAR, DBC, CANFD_CAR, CAMERA_SCC_CAR, CANFD_RADAR_SCC_CAR, EV_CAR, HYBRID_CAR, LEGACY_SAFETY_MODE_CAR, NON_SCC_CAR, Buttons from selfdrive.car.hyundai.radar_interface import RADAR_START_ADDR from selfdrive.car import STD_CARGO_KG, create_button_event, scale_tire_stiffness, get_safety_config from selfdrive.car.interfaces import CarInterfaceBase @@ -58,7 +58,7 @@ class CarInterface(CarInterfaceBase): ret.flags |= HyundaiFlags.USE_FCA.value if 0x2AB in fingerprint[0]: - ret.flags |= HyundaiFlags.SP_ENHANCED_SCC.value + ret.spFlags |= HyundaiFlagsSP.SP_ENHANCED_SCC.value ret.steerActuatorDelay = 0.1 # Default delay ret.steerLimitTimer = 0.4 @@ -263,12 +263,12 @@ class CarInterface(CarInterfaceBase): ret.enableBsm = 0x1e5 in fingerprint[CAN.ECAN] if 0x1fa in fingerprint[CAN.ECAN]: - ret.flags |= HyundaiFlags.SP_NAV_MSG.value + ret.spFlags |= HyundaiFlagsSP.SP_NAV_MSG.value else: ret.enableBsm = 0x58b in fingerprint[0] if 0x544 in fingerprint[0]: - ret.flags |= HyundaiFlags.SP_NAV_MSG.value + ret.spFlags |= HyundaiFlagsSP.SP_NAV_MSG.value # *** panda safety config *** if candidate in CANFD_CAR: @@ -293,7 +293,7 @@ class CarInterface(CarInterfaceBase): if candidate in CAMERA_SCC_CAR: ret.safetyConfigs[0].safetyParam |= Panda.FLAG_HYUNDAI_CAMERA_SCC - if ret.flags & HyundaiFlags.SP_ENHANCED_SCC: + if ret.spFlags & HyundaiFlagsSP.SP_ENHANCED_SCC: ret.safetyConfigs[0].safetyParam |= Panda.FLAG_HYUNDAI_ESCC if ret.openpilotLongitudinalControl: @@ -322,7 +322,7 @@ class CarInterface(CarInterfaceBase): @staticmethod def init(CP, logcan, sendcan): - if CP.openpilotLongitudinalControl and not ((CP.flags & HyundaiFlags.CANFD_CAMERA_SCC.value) or (CP.flags & HyundaiFlags.SP_ENHANCED_SCC)): + if CP.openpilotLongitudinalControl and not ((CP.flags & HyundaiFlags.CANFD_CAMERA_SCC.value) or (CP.spFlags & HyundaiFlagsSP.SP_ENHANCED_SCC)): addr, bus = 0x7d0, 0 if CP.flags & HyundaiFlags.CANFD_HDA2.value: addr, bus = 0x730, CanBus(CP).ECAN diff --git a/selfdrive/car/hyundai/radar_interface.py b/selfdrive/car/hyundai/radar_interface.py index 55c07502e3..85517cb1be 100644 --- a/selfdrive/car/hyundai/radar_interface.py +++ b/selfdrive/car/hyundai/radar_interface.py @@ -4,14 +4,14 @@ import math from cereal import car from opendbc.can.parser import CANParser from selfdrive.car.interfaces import RadarInterfaceBase -from selfdrive.car.hyundai.values import DBC, HyundaiFlags +from selfdrive.car.hyundai.values import DBC, HyundaiFlagsSP RADAR_START_ADDR = 0x500 RADAR_MSG_COUNT = 32 def get_radar_can_parser(CP): - if (CP.flags & HyundaiFlags.SP_ENHANCED_SCC) and DBC[CP.carFingerprint]['radar'] is None: + if (CP.spFlags & HyundaiFlagsSP.SP_ENHANCED_SCC) and DBC[CP.carFingerprint]['radar'] is None: msg = "ESCC" signals = [ ("ObjValid", msg), @@ -47,7 +47,7 @@ def get_radar_can_parser(CP): class RadarInterface(RadarInterfaceBase): def __init__(self, CP): super().__init__(CP) - self.enhanced_scc = (CP.flags & HyundaiFlags.SP_ENHANCED_SCC) and DBC[CP.carFingerprint]['radar'] is None + self.enhanced_scc = (CP.spFlags & HyundaiFlagsSP.SP_ENHANCED_SCC) and DBC[CP.carFingerprint]['radar'] is None self.updated_messages = set() self.trigger_msg = 0x2AB if self.enhanced_scc else RADAR_START_ADDR + RADAR_MSG_COUNT - 1 self.track_id = 0 diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index 5c2bdb4a90..42a51ed0a3 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -63,9 +63,12 @@ class HyundaiFlags(IntFlag): CANFD_ALT_GEARS_2 = 64 SEND_LFA = 128 USE_FCA = 256 - SP_ENHANCED_SCC = 512 - SP_CAN_LFA_BTN = 1024 - SP_NAV_MSG = 2048 + + +class HyundaiFlagsSP(IntFlag): + SP_ENHANCED_SCC = 1 + SP_CAN_LFA_BTN = 2 + SP_NAV_MSG = 4 class CAR: From 7ec767f53fbc18fa6b45f72dc478f24196a124c6 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Sun, 9 Jul 2023 01:38:20 -0400 Subject: [PATCH 2/2] Update CHANGELOGS.md --- CHANGELOGS.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOGS.md b/CHANGELOGS.md index 608a70d9f6..b3db892af1 100644 --- a/CHANGELOGS.md +++ b/CHANGELOGS.md @@ -1,4 +1,4 @@ -sunnypilot - 0.9.3.1 (2023-07-xx) +sunnypilot - 0.9.3.1 (2023-07-09) ======================== * UPDATED: Synced with commaai's 0.9.3 release * NEW❗: Display Temperature on Sidebar toggle @@ -10,9 +10,9 @@ sunnypilot - 0.9.3.1 (2023-07-xx) * This is only applicable to HKG CAN platforms using openpilot longitudinal control * NEW❗: Toyota: TSS2 longitudinal: Custom Tuning * Smoother longitudinal performance for Toyota/Lexus TSS2/LSS2 cars thanks to dragonpilot-community! +* NEW❗: Enable Screen Recorder toggle + * Enable this will display a button on the onroad screen to toggle on or off real-time screen recording with UI elements. * IMPROVED: Dynamic Lane Profile: when using Laneline planner via Laneline Mode or Auto Mode, enforce Laneless planner while traveling below 10 MPH or 16 km/h -* DISABLED: Screen Recorder - * UI sometimes crashes on startup along with screen recorder, will reimplement in future updates * REMOVED: Display CPU Temperature on Sidebar sunnypilot - 0.9.2.3 (2023-06-18)