From ef7102a8ae2334d77ff4b0be512c073e81b01d18 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sat, 7 Sep 2024 16:32:53 -0700 Subject: [PATCH] Toyota: AEB actuation setup (#1227) * try this * cleanup * lil more --------- Co-authored-by: Shane Smiskol --- opendbc/car/toyota/toyotacan.py | 23 +++++++++++++++++++ opendbc/dbc/generator/toyota/_toyota_2017.dbc | 6 +++++ opendbc/dbc/toyota_new_mc_pt_generated.dbc | 6 +++++ opendbc/dbc/toyota_nodsu_pt_generated.dbc | 6 +++++ opendbc/dbc/toyota_tnga_k_pt_generated.dbc | 6 +++++ 5 files changed, 47 insertions(+) diff --git a/opendbc/car/toyota/toyotacan.py b/opendbc/car/toyota/toyotacan.py index 3d97a00db7..2ac1093ea7 100644 --- a/opendbc/car/toyota/toyotacan.py +++ b/opendbc/car/toyota/toyotacan.py @@ -49,6 +49,29 @@ def create_accel_command(packer, accel, pcm_cancel, standstill_req, lead, acc_ty return packer.make_can_msg("ACC_CONTROL", 0, values) +def create_pcs_commands(packer, accel, active, mass): + values1 = { + "COUNTER": 0, + "FORCE": round(min(accel, 0) * mass * 2), + "STATE": 3 if active else 0, + "BRAKE_STATUS": 0, + "PRECOLLISION_ACTIVE": 1 if active else 0, + } + msg1 = packer.make_can_msg("PRE_COLLISION", 0, values1) + + values2 = { + "DSS1GDRV": min(accel, 0), # accel + "PCSALM": 1 if active else 0, # goes high same time as PRECOLLISION_ACTIVE + "IBTRGR": 1 if active else 0, # unknown + "PBATRGR": 1 if active else 0, # noisy actuation bit? + "PREFILL": 1 if active else 0, # goes on and off before DSS1GDRV + "AVSTRGR": 1 if active else 0, + } + msg2 = packer.make_can_msg("PRE_COLLISION_2", 0, values2) + + return [msg1, msg2] + + def create_acc_cancel_command(packer): values = { "GAS_RELEASED": 0, diff --git a/opendbc/dbc/generator/toyota/_toyota_2017.dbc b/opendbc/dbc/generator/toyota/_toyota_2017.dbc index 10ed74fd08..c47884541c 100644 --- a/opendbc/dbc/generator/toyota/_toyota_2017.dbc +++ b/opendbc/dbc/generator/toyota/_toyota_2017.dbc @@ -199,6 +199,12 @@ BO_ 835 ACC_CONTROL: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 836 PRE_COLLISION_2: 8 DSU + SG_ DSS1GDRV : 7|10@0- (0.1,0) [0|0] "m/s^2" Vector__XXX + SG_ PCSALM : 17|1@0+ (1,0) [0|0] "" FCM + SG_ IBTRGR : 27|1@0+ (1,0) [0|0] "" FCM + SG_ PBATRGR : 30|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ PREFILL : 33|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ AVSTRGR : 36|1@0+ (1,0) [0|0] "" SCS SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 865 CLUTCH: 8 XXX diff --git a/opendbc/dbc/toyota_new_mc_pt_generated.dbc b/opendbc/dbc/toyota_new_mc_pt_generated.dbc index c29df54853..50d0da385e 100644 --- a/opendbc/dbc/toyota_new_mc_pt_generated.dbc +++ b/opendbc/dbc/toyota_new_mc_pt_generated.dbc @@ -203,6 +203,12 @@ BO_ 835 ACC_CONTROL: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 836 PRE_COLLISION_2: 8 DSU + SG_ DSS1GDRV : 7|10@0- (0.1,0) [0|0] "m/s^2" Vector__XXX + SG_ PCSALM : 17|1@0+ (1,0) [0|0] "" FCM + SG_ IBTRGR : 27|1@0+ (1,0) [0|0] "" FCM + SG_ PBATRGR : 30|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ PREFILL : 33|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ AVSTRGR : 36|1@0+ (1,0) [0|0] "" SCS SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 865 CLUTCH: 8 XXX diff --git a/opendbc/dbc/toyota_nodsu_pt_generated.dbc b/opendbc/dbc/toyota_nodsu_pt_generated.dbc index cd351a3967..c2281115bc 100644 --- a/opendbc/dbc/toyota_nodsu_pt_generated.dbc +++ b/opendbc/dbc/toyota_nodsu_pt_generated.dbc @@ -203,6 +203,12 @@ BO_ 835 ACC_CONTROL: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 836 PRE_COLLISION_2: 8 DSU + SG_ DSS1GDRV : 7|10@0- (0.1,0) [0|0] "m/s^2" Vector__XXX + SG_ PCSALM : 17|1@0+ (1,0) [0|0] "" FCM + SG_ IBTRGR : 27|1@0+ (1,0) [0|0] "" FCM + SG_ PBATRGR : 30|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ PREFILL : 33|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ AVSTRGR : 36|1@0+ (1,0) [0|0] "" SCS SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 865 CLUTCH: 8 XXX diff --git a/opendbc/dbc/toyota_tnga_k_pt_generated.dbc b/opendbc/dbc/toyota_tnga_k_pt_generated.dbc index 99a1e59055..66979c1b31 100644 --- a/opendbc/dbc/toyota_tnga_k_pt_generated.dbc +++ b/opendbc/dbc/toyota_tnga_k_pt_generated.dbc @@ -203,6 +203,12 @@ BO_ 835 ACC_CONTROL: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 836 PRE_COLLISION_2: 8 DSU + SG_ DSS1GDRV : 7|10@0- (0.1,0) [0|0] "m/s^2" Vector__XXX + SG_ PCSALM : 17|1@0+ (1,0) [0|0] "" FCM + SG_ IBTRGR : 27|1@0+ (1,0) [0|0] "" FCM + SG_ PBATRGR : 30|2@0+ (1,0) [0|0] "" Vector__XXX + SG_ PREFILL : 33|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ AVSTRGR : 36|1@0+ (1,0) [0|0] "" SCS SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 865 CLUTCH: 8 XXX