From 063d66c355402c752fd9f7e3b733d7d574785049 Mon Sep 17 00:00:00 2001 From: vanillagorillaa <31773928+vanillagorillaa@users.noreply.github.com> Date: Tue, 16 Apr 2024 18:28:27 -0700 Subject: [PATCH 1/3] init 23 Accord --- release/files_common | 1 + selfdrive/car/honda/carstate.py | 4 ++-- selfdrive/car/honda/fingerprints.py | 8 ++++++++ selfdrive/car/honda/hondacan.py | 10 +++++++--- selfdrive/car/honda/interface.py | 15 +++++++++++---- selfdrive/car/honda/values.py | 8 ++++++++ selfdrive/car/torque_data/substitute.toml | 1 + 7 files changed, 38 insertions(+), 9 deletions(-) diff --git a/release/files_common b/release/files_common index eaf54b0cd561ce..789c76f5948686 100644 --- a/release/files_common +++ b/release/files_common @@ -515,6 +515,7 @@ opendbc/honda_odyssey_extreme_edition_2018_china_can_generated.dbc opendbc/honda_insight_ex_2019_can_generated.dbc opendbc/acura_ilx_2016_nidec.dbc opendbc/honda_civic_ex_2022_can_generated.dbc +opendbc/honda_pilot_2023_can_generated.dbc opendbc/hyundai_canfd.dbc opendbc/hyundai_kia_generic.dbc diff --git a/selfdrive/car/honda/carstate.py b/selfdrive/car/honda/carstate.py index c98d1a72d3cc15..1eff65d612663e 100644 --- a/selfdrive/car/honda/carstate.py +++ b/selfdrive/car/honda/carstate.py @@ -65,7 +65,7 @@ def get_can_messages(CP, gearbox_msg): # TODO: clean this up if CP.carFingerprint in (CAR.HONDA_ACCORD, CAR.HONDA_CIVIC_BOSCH, CAR.HONDA_CIVIC_BOSCH_DIESEL, CAR.HONDA_CRV_HYBRID, CAR.HONDA_INSIGHT, - CAR.ACURA_RDX_3G, CAR.HONDA_E, CAR.HONDA_CIVIC_2022, CAR.HONDA_HRV_3G): + CAR.ACURA_RDX_3G, CAR.HONDA_E, CAR.HONDA_CIVIC_2022, CAR.HONDA_HRV_3G, CAR.HONDA_ACCORD_11G): pass elif CP.carFingerprint in (CAR.HONDA_ODYSSEY_CHN, CAR.HONDA_FREED, CAR.HONDA_HRV): pass @@ -126,7 +126,7 @@ def update(self, cp, cp_cam, cp_body): ret.standstill = cp.vl["ENGINE_DATA"]["XMISSION_SPEED"] < 1e-5 # TODO: find a common signal across all cars if self.CP.carFingerprint in (CAR.HONDA_ACCORD, CAR.HONDA_CIVIC_BOSCH, CAR.HONDA_CIVIC_BOSCH_DIESEL, CAR.HONDA_CRV_HYBRID, CAR.HONDA_INSIGHT, - CAR.ACURA_RDX_3G, CAR.HONDA_E, CAR.HONDA_CIVIC_2022, CAR.HONDA_HRV_3G): + CAR.ACURA_RDX_3G, CAR.HONDA_E, CAR.HONDA_CIVIC_2022, CAR.HONDA_HRV_3G, CAR.HONDA_ACCORD_11G): ret.doorOpen = bool(cp.vl["SCM_FEEDBACK"]["DRIVERS_DOOR_OPEN"]) elif self.CP.carFingerprint in (CAR.HONDA_ODYSSEY_CHN, CAR.HONDA_FREED, CAR.HONDA_HRV): ret.doorOpen = bool(cp.vl["SCM_BUTTONS"]["DRIVERS_DOOR_OPEN"]) diff --git a/selfdrive/car/honda/fingerprints.py b/selfdrive/car/honda/fingerprints.py index 18fe69dd1f5d03..9aef852a822b10 100644 --- a/selfdrive/car/honda/fingerprints.py +++ b/selfdrive/car/honda/fingerprints.py @@ -1120,4 +1120,12 @@ b'37805-64S-AA10\x00\x00', ], }, + CAR.HONDA_ACCORD_11G: { + (Ecu.fwdRadar, 0x18dab0f1, None): [ + b'8S302-30A-A040\x00\x00', + ], + (Ecu.fwdCamera, 0x18dab5f1, None): [ + b'8S102-30A-A050\x00\x00', + ], + }, } diff --git a/selfdrive/car/honda/hondacan.py b/selfdrive/car/honda/hondacan.py index 1be496d9511612..ccf03ea3eb5a75 100644 --- a/selfdrive/car/honda/hondacan.py +++ b/selfdrive/car/honda/hondacan.py @@ -1,6 +1,6 @@ from openpilot.common.conversions import Conversions as CV from openpilot.selfdrive.car import CanBusBase -from openpilot.selfdrive.car.honda.values import HondaFlags, HONDA_BOSCH, HONDA_BOSCH_RADARLESS, CAR, CarControllerParams +from openpilot.selfdrive.car.honda.values import HondaFlags, HONDA_BOSCH, HONDA_BOSCH_RADARLESS, HONDA_CANFD_CAR, CAR, CarControllerParams # CAN bus layout with relay # 0 = ACC-CAN - radar side @@ -14,7 +14,7 @@ def __init__(self, CP=None, fingerprint=None) -> None: # use fingerprint if specified super().__init__(CP if fingerprint is None else None, fingerprint) - if CP.carFingerprint in (HONDA_BOSCH - HONDA_BOSCH_RADARLESS): + if CP.carFingerprint in (HONDA_BOSCH - HONDA_BOSCH_RADARLESS - HONDA_CANFD_CAR): self._pt, self._radar = self.offset + 1, self.offset else: self._pt, self._radar = self.offset, self.offset + 1 @@ -34,7 +34,7 @@ def camera(self) -> int: def get_lkas_cmd_bus(CAN, car_fingerprint, radar_disabled=False): no_radar = car_fingerprint in HONDA_BOSCH_RADARLESS - if radar_disabled or no_radar: + if radar_disabled or no_radar or car_fingerprint in HONDA_CANFD_CAR: # when radar is disabled, steering commands are sent directly to powertrain bus return CAN.pt # normally steering commands are sent to radar, which forwards them to powertrain bus @@ -179,6 +179,10 @@ def create_ui_commands(packer, CAN, CP, enabled, pcm_speed, hud, is_metric, acc_ # car likely needs to see LKAS_PROBLEM fall within a specific time frame, so forward from camera lkas_hud_values['LKAS_PROBLEM'] = lkas_hud['LKAS_PROBLEM'] + if CP.carFingerprint in HONDA_CANFD_CAR: + lkas_hud_values['LANE_LINES'] = 3 + lkas_hud_values['DASHED_LANES'] = hud.lanes_visible + if not (CP.flags & HondaFlags.BOSCH_EXT_HUD): lkas_hud_values['SET_ME_X48'] = 0x48 diff --git a/selfdrive/car/honda/interface.py b/selfdrive/car/honda/interface.py index 2a5a07093d9732..065122c1f47859 100755 --- a/selfdrive/car/honda/interface.py +++ b/selfdrive/car/honda/interface.py @@ -5,7 +5,7 @@ from openpilot.common.numpy_fast import interp from openpilot.selfdrive.car.honda.hondacan import CanBus from openpilot.selfdrive.car.honda.values import CarControllerParams, CruiseButtons, CruiseSettings, HondaFlags, CAR, HONDA_BOSCH, \ - HONDA_NIDEC_ALT_SCM_MESSAGES, HONDA_BOSCH_RADARLESS + HONDA_NIDEC_ALT_SCM_MESSAGES, HONDA_BOSCH_RADARLESS, HONDA_CANFD_CAR from openpilot.selfdrive.car import create_button_events, get_safety_config from openpilot.selfdrive.car.interfaces import CarInterfaceBase from openpilot.selfdrive.car.disable_ecu import disable_ecu @@ -37,7 +37,14 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs): CAN = CanBus(ret, fingerprint) - if candidate in HONDA_BOSCH: + if candidate in HONDA_CANFD_CAR: + cfgs = [get_safety_config(car.CarParams.SafetyModel.hondaBosch)] + if CAN.pt >= 4: + cfgs.insert(0, get_safety_config(car.CarParams.SafetyModel.noOutput)) + ret.safetyConfigs = cfgs + ret.radarUnavailable = True + ret.openpilotLongitudinalControl = False + elif candidate in HONDA_BOSCH: ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.hondaBosch)] ret.radarUnavailable = True # Disable the radar and let openpilot control longitudinal @@ -107,7 +114,7 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs): ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]] - elif candidate == CAR.HONDA_ACCORD: + elif candidate in (CAR.HONDA_ACCORD, CAR.HONDA_ACCORD_11G): ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end if eps_modified: @@ -206,7 +213,7 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs): if ret.openpilotLongitudinalControl and candidate in HONDA_BOSCH: ret.safetyConfigs[0].safetyParam |= Panda.FLAG_HONDA_BOSCH_LONG - if candidate in HONDA_BOSCH_RADARLESS: + if candidate in (HONDA_BOSCH_RADARLESS| HONDA_CANFD_CAR): ret.safetyConfigs[0].safetyParam |= Panda.FLAG_HONDA_RADARLESS # min speed to enable ACC. if car can do stop and go, then set enabling speed diff --git a/selfdrive/car/honda/values.py b/selfdrive/car/honda/values.py index 79a76ee2ac1db6..94ec351f8a172e 100644 --- a/selfdrive/car/honda/values.py +++ b/selfdrive/car/honda/values.py @@ -59,6 +59,7 @@ class HondaFlags(IntFlag): NIDEC_ALT_PCM_ACCEL = 32 NIDEC_ALT_SCM_MESSAGES = 64 + CANFD_CAR = 128 # Car button codes class CruiseButtons: @@ -125,6 +126,12 @@ class CAR(Platforms): CarSpecs(mass=3279 * CV.LB_TO_KG, wheelbase=2.83, steerRatio=16.33, centerToFrontRatio=0.39, tireStiffnessFactor=0.8467), dbc_dict('honda_accord_2018_can_generated', None), ) + HONDA_ACCORD_11G = HondaBoschPlatformConfig( + [HondaCarDocs("Honda Accord 2023", "All")], + CarSpecs(mass=3279 * CV.LB_TO_KG, wheelbase=2.83, steerRatio=16.33, centerToFrontRatio=0.39, tireStiffnessFactor=0.8467), + dbc_dict('honda_pilot_2023_can_generated', None), + flags=HondaFlags.CANFD_CAR, + ) HONDA_CIVIC_BOSCH = HondaBoschPlatformConfig( [ HondaCarDocs("Honda Civic 2019-21", "All", video_link="https://www.youtube.com/watch?v=4Iz1Mz5LGF8", @@ -336,6 +343,7 @@ class CAR(Platforms): HONDA_NIDEC_ALT_SCM_MESSAGES = CAR.with_flags(HondaFlags.NIDEC_ALT_SCM_MESSAGES) HONDA_BOSCH = CAR.with_flags(HondaFlags.BOSCH) HONDA_BOSCH_RADARLESS = CAR.with_flags(HondaFlags.BOSCH_RADARLESS) +HONDA_CANFD_CAR = CAR.with_flags(HondaFlags.CANFD_CAR) DBC = CAR.create_dbc_map() diff --git a/selfdrive/car/torque_data/substitute.toml b/selfdrive/car/torque_data/substitute.toml index 8724a08010e3b0..8016cf1536469c 100644 --- a/selfdrive/car/torque_data/substitute.toml +++ b/selfdrive/car/torque_data/substitute.toml @@ -48,6 +48,7 @@ legend = ["LAT_ACCEL_FACTOR", "MAX_LAT_ACCEL_MEASURED", "FRICTION"] "HONDA_CIVIC_BOSCH_DIESEL" = "HONDA_CIVIC_BOSCH" "HONDA_E" = "HONDA_CIVIC_BOSCH" "HONDA_ODYSSEY_CHN" = "HONDA_ODYSSEY" +"HONDA_ACCORD_11G" = "HONDA_ACCORD" "BUICK_LACROSSE" = "CHEVROLET_VOLT" "BUICK_REGAL" = "CHEVROLET_VOLT" From f39ba73c43074b178cb67429a8ac5a516246de88 Mon Sep 17 00:00:00 2001 From: vanillagorillaa <31773928+vanillagorillaa@users.noreply.github.com> Date: Wed, 17 Apr 2024 18:32:36 -0700 Subject: [PATCH 2/3] test route --- selfdrive/car/honda/hondacan.py | 2 +- selfdrive/car/tests/routes.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/selfdrive/car/honda/hondacan.py b/selfdrive/car/honda/hondacan.py index ccf03ea3eb5a75..75ad20f32a3fae 100644 --- a/selfdrive/car/honda/hondacan.py +++ b/selfdrive/car/honda/hondacan.py @@ -181,7 +181,7 @@ def create_ui_commands(packer, CAN, CP, enabled, pcm_speed, hud, is_metric, acc_ if CP.carFingerprint in HONDA_CANFD_CAR: lkas_hud_values['LANE_LINES'] = 3 - lkas_hud_values['DASHED_LANES'] = hud.lanes_visible + lkas_hud_values['DASHED_LANES'] = hud.lanes_visible if not (CP.flags & HondaFlags.BOSCH_EXT_HUD): lkas_hud_values['SET_ME_X48'] = 0x48 diff --git a/selfdrive/car/tests/routes.py b/selfdrive/car/tests/routes.py index 35a9d8a8e70f68..9ec84bcd1452c4 100755 --- a/selfdrive/car/tests/routes.py +++ b/selfdrive/car/tests/routes.py @@ -97,6 +97,7 @@ class CarTestRoute(NamedTuple): CarTestRoute("54fd8451b3974762|2021-04-01--14-50-10", HONDA.HONDA_RIDGELINE), CarTestRoute("2d5808fae0b38ac6|2021-09-01--17-14-11", HONDA.HONDA_E), CarTestRoute("f44aa96ace22f34a|2021-12-22--06-22-31", HONDA.HONDA_CIVIC_2022), + CarTestRoute("4df2d9d0197e20e3/0000000c--a564a3f944", HONDA.HONDA_ACCORD_11G), CarTestRoute("87d7f06ade479c2e|2023-09-11--23-30-11", HYUNDAI.HYUNDAI_AZERA_6TH_GEN), CarTestRoute("66189dd8ec7b50e6|2023-09-20--07-02-12", HYUNDAI.HYUNDAI_AZERA_HEV_6TH_GEN), From f5d196b4b89df68d42ba51c70f482d68e4346cf7 Mon Sep 17 00:00:00 2001 From: vanillagorillaa <31773928+vanillagorillaa@users.noreply.github.com> Date: Sun, 28 Apr 2024 07:42:43 -0700 Subject: [PATCH 3/3] fix --- selfdrive/car/honda/hondacan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/car/honda/hondacan.py b/selfdrive/car/honda/hondacan.py index 75ad20f32a3fae..6dc7b96cb4c235 100644 --- a/selfdrive/car/honda/hondacan.py +++ b/selfdrive/car/honda/hondacan.py @@ -43,7 +43,7 @@ def get_lkas_cmd_bus(CAN, car_fingerprint, radar_disabled=False): def get_cruise_speed_conversion(car_fingerprint: str, is_metric: bool) -> float: # on certain cars, CRUISE_SPEED changes to imperial with car's unit setting - return CV.MPH_TO_MS if car_fingerprint in HONDA_BOSCH_RADARLESS and not is_metric else CV.KPH_TO_MS + return CV.MPH_TO_MS if car_fingerprint in (HONDA_BOSCH_RADARLESS | HONDA_CANFD_CAR) and not is_metric else CV.KPH_TO_MS def create_brake_command(packer, CAN, apply_brake, pump_on, pcm_override, pcm_cancel_cmd, fcw, car_fingerprint, stock_brake):