From 7df1c025ae2a1333b70ef967c4617f913f36dfd4 Mon Sep 17 00:00:00 2001 From: Igor Biletskyy Date: Mon, 4 Apr 2022 19:19:30 -0700 Subject: [PATCH] body: add crc and counter (#24120) * add crc and counter for body * add msg * move counter * whitespace * .. * bump opendbc * update_refs --- opendbc | 2 +- selfdrive/car/body/bodycan.py | 5 +++-- selfdrive/car/body/carcontroller.py | 4 +++- selfdrive/car/body/carstate.py | 7 +++++-- selfdrive/test/process_replay/ref_commit | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/opendbc b/opendbc index 08b1564ba9..cc45cc1bc0 160000 --- a/opendbc +++ b/opendbc @@ -1 +1 @@ -Subproject commit 08b1564ba9dac2d9748ab8610f90cf98cb581baa +Subproject commit cc45cc1bc045a98d12ffdfd9923b23ead9638b87 diff --git a/selfdrive/car/body/bodycan.py b/selfdrive/car/body/bodycan.py index 9abf5d8611..cc448d53d1 100644 --- a/selfdrive/car/body/bodycan.py +++ b/selfdrive/car/body/bodycan.py @@ -1,8 +1,9 @@ -def create_control(packer, torque_l, torque_r): +def create_control(packer, torque_l, torque_r, idx): can_bus = 0 values = { "TORQUE_L": torque_l, "TORQUE_R": torque_r, } - return packer.make_can_msg("TORQUE_CMD", can_bus, values) + + return packer.make_can_msg("TORQUE_CMD", can_bus, values, idx) diff --git a/selfdrive/car/body/carcontroller.py b/selfdrive/car/body/carcontroller.py index 6f5df7155e..57910746ee 100644 --- a/selfdrive/car/body/carcontroller.py +++ b/selfdrive/car/body/carcontroller.py @@ -14,6 +14,7 @@ MAX_TURN_INTEGRATOR = 0.1 # meters class CarController(): def __init__(self, dbc_name, CP, VM): + self.frame = 0 self.packer = CANPacker(dbc_name) self.i_speed = 0 @@ -102,10 +103,11 @@ class CarController(): # /////////////////////////////////////// can_sends = [] - can_sends.append(bodycan.create_control(self.packer, torque_l, torque_r)) + can_sends.append(bodycan.create_control(self.packer, torque_l, torque_r, self.frame // 2)) new_actuators = CC.actuators.copy() new_actuators.accel = torque_l new_actuators.steer = torque_r + self.frame += 1 return new_actuators, can_sends diff --git a/selfdrive/car/body/carstate.py b/selfdrive/car/body/carstate.py index 2ef93aa98c..c103936738 100644 --- a/selfdrive/car/body/carstate.py +++ b/selfdrive/car/body/carstate.py @@ -38,10 +38,13 @@ class CarState(CarStateBase): ("SPEED_R", "MOTORS_DATA"), ("ELEC_ANGLE_L", "MOTORS_DATA"), ("ELEC_ANGLE_R", "MOTORS_DATA"), - ("MOTOR_ERR_L", "MOTORS_DATA"), - ("MOTOR_ERR_R", "MOTORS_DATA"), + ("COUNTER", "MOTORS_DATA"), + ("CHECKSUM", "MOTORS_DATA"), ("IGNITION", "VAR_VALUES"), ("ENABLE_MOTORS", "VAR_VALUES"), + ("FAULT", "VAR_VALUES"), + ("MOTOR_ERR_L", "VAR_VALUES"), + ("MOTOR_ERR_R", "VAR_VALUES"), ("MCU_TEMP", "BODY_DATA"), ("BATT_VOLTAGE", "BODY_DATA"), ] diff --git a/selfdrive/test/process_replay/ref_commit b/selfdrive/test/process_replay/ref_commit index b9e38e7ae8..e835264cad 100644 --- a/selfdrive/test/process_replay/ref_commit +++ b/selfdrive/test/process_replay/ref_commit @@ -1 +1 @@ -f6c93d48d14fa7be45961f7325a7957f53126671 \ No newline at end of file +594f0e291d2a9720c854f6d0f074b7734ed3c741 \ No newline at end of file