From b464cebff5bcad45267b8032decb4d053ed90198 Mon Sep 17 00:00:00 2001 From: chrispypatt Date: Fri, 18 Oct 2024 13:05:50 -0500 Subject: [PATCH 1/3] Add secoc ACC command --- opendbc/car/toyota/carcontroller.py | 12 ++++++++++++ opendbc/car/toyota/interface.py | 12 ++++++------ opendbc/car/toyota/toyotacan.py | 5 +++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/opendbc/car/toyota/carcontroller.py b/opendbc/car/toyota/carcontroller.py index d6bdd9782e..2499a13f9b 100644 --- a/opendbc/car/toyota/carcontroller.py +++ b/opendbc/car/toyota/carcontroller.py @@ -53,6 +53,7 @@ def __init__(self, dbc_name, CP): self.secoc_lka_message_counter = 0 self.secoc_lta_message_counter = 0 + self.secoc_acc_message_counter = 0 self.secoc_prev_reset_counter = 0 self.secoc_mismatch_counter = 0 @@ -70,6 +71,7 @@ def update(self, CC, CS, now_nanos): if CS.secoc_synchronization['RESET_CNT'] != self.secoc_prev_reset_counter: self.secoc_lka_message_counter = 0 self.secoc_lta_message_counter = 0 + self.secoc_acc_message_counter = 0 self.secoc_prev_reset_counter = CS.secoc_synchronization['RESET_CNT'] expected_mac = build_sync_mac(self.secoc_key, int(CS.secoc_synchronization['TRIP_CNT']), int(CS.secoc_synchronization['RESET_CNT'])) @@ -211,6 +213,16 @@ def update(self, CC, CS, now_nanos): can_sends.append(toyotacan.create_accel_command(self.packer, pcm_accel_cmd, pcm_cancel_cmd, self.permit_braking, self.standstill_req, lead, CS.acc_type, fcw_alert, self.distance_button)) + if self.CP.flags & ToyotaFlags.SECOC.value: + acc_cmd_2 = toyotacan.create_accel_command_2(self.packer, pcm_accel_cmd) + acc_cmd_2 = add_mac(self.secoc_key, + int(CS.secoc_synchronization['TRIP_CNT']), + int(CS.secoc_synchronization['RESET_CNT']), + self.secoc_acc_message_counter, + acc_cmd_2) + self.secoc_acc_message_counter += 1 + can_sends.append(acc_cmd_2) + self.accel = pcm_accel_cmd else: can_sends.append(toyotacan.create_accel_command(self.packer, 0, pcm_cancel_cmd, True, False, lead, CS.acc_type, False, self.distance_button)) diff --git a/opendbc/car/toyota/interface.py b/opendbc/car/toyota/interface.py index 3691f9f78c..98a7a86a5c 100644 --- a/opendbc/car/toyota/interface.py +++ b/opendbc/car/toyota/interface.py @@ -117,12 +117,12 @@ def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experime # openpilot longitudinal behind experimental long toggle: # - TSS2 radar ACC cars (disables radar) - if ret.flags & ToyotaFlags.SECOC.value: - ret.openpilotLongitudinalControl = False - else: - ret.openpilotLongitudinalControl = ret.enableDsu or \ - candidate in (TSS2_CAR - RADAR_ACC_CAR) or \ - bool(ret.flags & ToyotaFlags.DISABLE_RADAR.value) + # if ret.flags & ToyotaFlags.SECOC.value: + # ret.openpilotLongitudinalControl = False + # else: + ret.openpilotLongitudinalControl = ret.enableDsu or \ + candidate in (TSS2_CAR - RADAR_ACC_CAR) or \ + bool(ret.flags & ToyotaFlags.DISABLE_RADAR.value) ret.autoResumeSng = ret.openpilotLongitudinalControl and candidate in NO_STOP_TIMER_CAR diff --git a/opendbc/car/toyota/toyotacan.py b/opendbc/car/toyota/toyotacan.py index c4f27510d6..13ae8c11ec 100644 --- a/opendbc/car/toyota/toyotacan.py +++ b/opendbc/car/toyota/toyotacan.py @@ -55,6 +55,11 @@ def create_accel_command(packer, accel, pcm_cancel, permit_braking, standstill_r } return packer.make_can_msg("ACC_CONTROL", 0, values) +def create_accel_command_2(packer, accel): + values = { + "ACCEL_CMD": accel, + } + return packer.make_can_msg("ACC_CONTROL_2", 0, values) def create_pcs_commands(packer, accel, active, mass): values1 = { From ce6b289edad5296c8ad7f991888f61584bc5a90a Mon Sep 17 00:00:00 2001 From: chrispypatt Date: Fri, 18 Oct 2024 13:06:22 -0500 Subject: [PATCH 2/3] Remove commented out secoc long disable code --- opendbc/car/toyota/interface.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/opendbc/car/toyota/interface.py b/opendbc/car/toyota/interface.py index 98a7a86a5c..825e78db28 100644 --- a/opendbc/car/toyota/interface.py +++ b/opendbc/car/toyota/interface.py @@ -117,9 +117,6 @@ def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experime # openpilot longitudinal behind experimental long toggle: # - TSS2 radar ACC cars (disables radar) - # if ret.flags & ToyotaFlags.SECOC.value: - # ret.openpilotLongitudinalControl = False - # else: ret.openpilotLongitudinalControl = ret.enableDsu or \ candidate in (TSS2_CAR - RADAR_ACC_CAR) or \ bool(ret.flags & ToyotaFlags.DISABLE_RADAR.value) From 490067a5b35d2e71e967474bf4d2f9c24b0ada5f Mon Sep 17 00:00:00 2001 From: chrispypatt Date: Fri, 18 Oct 2024 23:01:57 -0500 Subject: [PATCH 3/3] Add Toyota 2021 SecOC route --- opendbc/car/tests/routes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/opendbc/car/tests/routes.py b/opendbc/car/tests/routes.py index 2e1eca29a0..4c595bdd1a 100644 --- a/opendbc/car/tests/routes.py +++ b/opendbc/car/tests/routes.py @@ -207,6 +207,7 @@ class CarTestRoute(NamedTuple): CarTestRoute("7e34a988419b5307|2019-12-18--19-13-30", TOYOTA.TOYOTA_RAV4_TSS2), # hybrid CarTestRoute("2475fb3eb2ffcc2e|2022-04-29--12-46-23", TOYOTA.TOYOTA_RAV4_TSS2_2022), # hybrid CarTestRoute("20ba9ade056a8c7b|2021-02-08--21-57-35", TOYOTA.TOYOTA_RAV4_PRIME), # SecOC + CarTestRoute("41ba5b181f29435d/00000075--b8cdba16c8", TOYOTA.TOYOTA_RAV4_PRIME), # SecOC CarTestRoute("8bfb000e03b2a257/00000004--f9eee5f52e", TOYOTA.TOYOTA_SIENNA_4TH_GEN), # SecOC CarTestRoute("7a31f030957b9c85|2023-04-01--14-12-51", TOYOTA.LEXUS_ES), CarTestRoute("37041c500fd30100|2020-12-30--12-17-24", TOYOTA.LEXUS_ES), # hybrid