Skip to content

Commit

Permalink
Car interfaces: remove hard-coded signal definitions (commaai#27773)
Browse files Browse the repository at this point in the history
* What if: no signals! 🙅🤌🎆

* do hyundai

* honda!

* do gm

* and vw! (sorry comments)

* do those

* -500

* little more

* fix subie

* change back

* bumpopendbc

* oof lol

* messages

* some clean up

* here too

* clean up honda radar_interface.py

fix

rm

* bump opendbc to master

* add todo

* rename checks in tesla/radar_interface

---------

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
  • Loading branch information
sshane and adeebshihadeh authored Aug 11, 2023
1 parent 470b520 commit cbfcc40
Show file tree
Hide file tree
Showing 20 changed files with 200 additions and 1,458 deletions.
24 changes: 2 additions & 22 deletions selfdrive/car/body/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,9 @@ def update(self, cp):

@staticmethod
def get_can_parser(CP):
signals = [
# sig_name, sig_address
("SPEED_L", "MOTORS_DATA"),
("SPEED_R", "MOTORS_DATA"),
("ELEC_ANGLE_L", "MOTORS_DATA"),
("ELEC_ANGLE_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"),
("BATT_PERCENTAGE", "BODY_DATA"),
("CHARGER_CONNECTED", "BODY_DATA"),
]

checks = [
messages = [
("MOTORS_DATA", 100),
("VAR_VALUES", 10),
("BODY_DATA", 1),
]

return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 0)
return CANParser(DBC[CP.carFingerprint]["pt"], messages, 0)
82 changes: 12 additions & 70 deletions selfdrive/car/chrysler/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,51 +98,16 @@ def update(self, cp, cp_cam):
return ret

@staticmethod
def get_cruise_signals():
signals = [
("ACC_AVAILABLE", "DAS_3"),
("ACC_ACTIVE", "DAS_3"),
("ACC_FAULTED", "DAS_3"),
("ACC_STANDSTILL", "DAS_3"),
("COUNTER", "DAS_3"),
("ACC_SET_SPEED_KPH", "DAS_4"),
("ACC_STATE", "DAS_4"),
]
checks = [
def get_cruise_messages():
messages = [
("DAS_3", 50),
("DAS_4", 50),
]
return signals, checks
return messages

@staticmethod
def get_can_parser(CP):
signals = [
# sig_name, sig_address
("DOOR_OPEN_FL", "BCM_1"),
("DOOR_OPEN_FR", "BCM_1"),
("DOOR_OPEN_RL", "BCM_1"),
("DOOR_OPEN_RR", "BCM_1"),
("Brake_Pedal_State", "ESP_1"),
("Accelerator_Position", "ECM_5"),
("WHEEL_SPEED_FL", "ESP_6"),
("WHEEL_SPEED_RR", "ESP_6"),
("WHEEL_SPEED_RL", "ESP_6"),
("WHEEL_SPEED_FR", "ESP_6"),
("STEERING_ANGLE", "STEERING"),
("STEERING_ANGLE_HP", "STEERING"),
("STEERING_RATE", "STEERING"),
("TURN_SIGNALS", "STEERING_LEVERS"),
("HIGH_BEAM_PRESSED", "STEERING_LEVERS"),
("SEATBELT_DRIVER_UNLATCHED", "ORC_1"),
("COUNTER", "EPS_2",),
("COLUMN_TORQUE", "EPS_2"),
("EPS_TORQUE_MOTOR", "EPS_2"),
("LKAS_TEMPORARY_FAULT", "EPS_2"),
("LKAS_STATE", "EPS_2"),
("COUNTER", "CRUISE_BUTTONS"),
]

checks = [
messages = [
# sig_address, frequency
("ESP_1", 50),
("EPS_2", 100),
Expand All @@ -156,53 +121,30 @@ def get_can_parser(CP):
]

if CP.enableBsm:
signals += [
("RIGHT_STATUS", "BSM_1"),
("LEFT_STATUS", "BSM_1"),
]
checks.append(("BSM_1", 2))
messages.append(("BSM_1", 2))

if CP.carFingerprint in RAM_CARS:
signals += [
("DASM_FAULT", "EPS_3"),
("Vehicle_Speed", "ESP_8"),
("Gear_State", "Transmission_Status"),
]
checks += [
messages += [
("ESP_8", 50),
("EPS_3", 50),
("Transmission_Status", 50),
]
else:
signals += [
("PRNDL", "GEAR"),
("SPEED_LEFT", "SPEED_1"),
("SPEED_RIGHT", "SPEED_1"),
]
checks += [
messages += [
("GEAR", 50),
("SPEED_1", 100),
]
signals += CarState.get_cruise_signals()[0]
checks += CarState.get_cruise_signals()[1]
messages += CarState.get_cruise_messages()

return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 0)
return CANParser(DBC[CP.carFingerprint]["pt"], messages, 0)

@staticmethod
def get_cam_can_parser(CP):
signals = [
# sig_name, sig_address, default
("CAR_MODEL", "DAS_6"),
]
checks = [
messages = [
("DAS_6", 4),
]

if CP.carFingerprint in RAM_CARS:
signals += [
("AUTO_HIGH_BEAM_ON", "DAS_6"),
]
signals += CarState.get_cruise_signals()[0]
checks += CarState.get_cruise_signals()[1]
messages += CarState.get_cruise_messages()

return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 2)
return CANParser(DBC[CP.carFingerprint]["pt"], messages, 2)
18 changes: 6 additions & 12 deletions selfdrive/car/chrysler/radar_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,12 @@ def _create_radar_can_parser(car_fingerprint):
# ('LONG_DIST', 1074),
# ('LONG_DIST', 1075),

signals = list(zip(['LONG_DIST'] * msg_n +
['LAT_DIST'] * msg_n +
['REL_SPEED'] * msg_n,
RADAR_MSGS_C * 2 + # LONG_DIST, LAT_DIST
RADAR_MSGS_D)) # REL_SPEED
messages = list(zip(RADAR_MSGS_C +
RADAR_MSGS_D,
[20] * msg_n + # 20Hz (0.05s)
[20] * msg_n)) # 20Hz (0.05s)

checks = list(zip(RADAR_MSGS_C +
RADAR_MSGS_D,
[20] * msg_n + # 20Hz (0.05s)
[20] * msg_n)) # 20Hz (0.05s)

return CANParser(DBC[car_fingerprint]['radar'], signals, checks, 1)
return CANParser(DBC[car_fingerprint]['radar'], messages, 1)

def _address_to_track(address):
if address in RADAR_MSGS_C:
Expand Down Expand Up @@ -89,4 +83,4 @@ def update(self, can_strings):
ret.points = [x for x in self.pts.values() if x.dRel != 0]

self.updated_messages.clear()
return ret
return ret
147 changes: 9 additions & 138 deletions selfdrive/car/ford/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,70 +111,7 @@ def update(self, cp, cp_cam):

@staticmethod
def get_can_parser(CP):
signals = [
# sig_name, sig_address
("TrnAinTq_D_Qf", "VehicleOperatingModes"), # Used to detect hybrid or ICE platform variant

("Veh_V_ActlBrk", "BrakeSysFeatures"), # ABS vehicle speed (kph)
("VehYaw_W_Actl", "Yaw_Data_FD1"), # ABS vehicle yaw rate (rad/s)
("VehStop_D_Stat", "DesiredTorqBrk"), # ABS vehicle stopped
("PrkBrkStatus", "DesiredTorqBrk"), # ABS park brake status
("ApedPos_Pc_ActlArb", "EngVehicleSpThrottle"), # PCM throttle (pct)
("BrkTot_Tq_Actl", "BrakeSnData_4"), # ABS brake torque (Nm)
("BpedDrvAppl_D_Actl", "EngBrakeData"), # PCM driver brake pedal pressed
("Veh_V_DsplyCcSet", "EngBrakeData"), # PCM ACC set speed (mph)
# The units might change with IPC settings?
("CcStat_D_Actl", "EngBrakeData"), # PCM ACC status
("AccStopMde_D_Rq", "EngBrakeData"), # PCM ACC standstill
("AccEnbl_B_RqDrv", "Cluster_Info1_FD1"), # PCM ACC enable
("StePinComp_An_Est", "SteeringPinion_Data"), # PSCM estimated steering angle (deg)
("StePinCompAnEst_D_Qf", "SteeringPinion_Data"), # PSCM estimated steering angle (quality flag)
# Calculates steering angle (and offset) from pinion
# angle and driving measurements.
# StePinRelInit_An_Sns is the pinion angle, initialised
# to zero at the beginning of the drive.
("SteeringColumnTorque", "EPAS_INFO"), # PSCM steering column torque (Nm)
("EPAS_Failure", "EPAS_INFO"), # PSCM EPAS status
("TurnLghtSwtch_D_Stat", "Steering_Data_FD1"), # SCCM Turn signal switch
("TjaButtnOnOffPress", "Steering_Data_FD1"), # SCCM ACC button, lane-centering/traffic jam assist toggle
("DrStatDrv_B_Actl", "BodyInfo_3_FD1"), # BCM Door open, driver
("DrStatPsngr_B_Actl", "BodyInfo_3_FD1"), # BCM Door open, passenger
("DrStatRl_B_Actl", "BodyInfo_3_FD1"), # BCM Door open, rear left
("DrStatRr_B_Actl", "BodyInfo_3_FD1"), # BCM Door open, rear right
("FirstRowBuckleDriver", "RCMStatusMessage2_FD1"), # RCM Seatbelt status, driver
("HeadLghtHiFlash_D_Stat", "Steering_Data_FD1"), # SCCM Passthrough the remaining buttons
("WiprFront_D_Stat", "Steering_Data_FD1"),
("LghtAmb_D_Sns", "Steering_Data_FD1"),
("AccButtnGapDecPress", "Steering_Data_FD1"),
("AccButtnGapIncPress", "Steering_Data_FD1"),
("AslButtnOnOffCnclPress", "Steering_Data_FD1"),
("AslButtnOnOffPress", "Steering_Data_FD1"),
("LaSwtchPos_D_Stat", "Steering_Data_FD1"),
("CcAslButtnCnclResPress", "Steering_Data_FD1"),
("CcAslButtnDeny_B_Actl", "Steering_Data_FD1"),
("CcAslButtnIndxDecPress", "Steering_Data_FD1"),
("CcAslButtnIndxIncPress", "Steering_Data_FD1"),
("CcAslButtnOffCnclPress", "Steering_Data_FD1"),
("CcAslButtnOnOffCncl", "Steering_Data_FD1"),
("CcAslButtnOnPress", "Steering_Data_FD1"),
("CcAslButtnResDecPress", "Steering_Data_FD1"),
("CcAslButtnResIncPress", "Steering_Data_FD1"),
("CcAslButtnSetDecPress", "Steering_Data_FD1"),
("CcAslButtnSetIncPress", "Steering_Data_FD1"),
("CcAslButtnSetPress", "Steering_Data_FD1"),
("CcButtnOffPress", "Steering_Data_FD1"),
("CcButtnOnOffCnclPress", "Steering_Data_FD1"),
("CcButtnOnOffPress", "Steering_Data_FD1"),
("CcButtnOnPress", "Steering_Data_FD1"),
("HeadLghtHiFlash_D_Actl", "Steering_Data_FD1"),
("HeadLghtHiOn_B_StatAhb", "Steering_Data_FD1"),
("AhbStat_B_Dsply", "Steering_Data_FD1"),
("AccButtnGapTogglePress", "Steering_Data_FD1"),
("WiprFrontSwtch_D_Stat", "Steering_Data_FD1"),
("HeadLghtHiCtrl_D_RqAhb", "Steering_Data_FD1"),
]

checks = [
messages = [
# sig_address, frequency
("VehicleOperatingModes", 100),
("BrakeSysFeatures", 50),
Expand All @@ -192,93 +129,31 @@ def get_can_parser(CP):
]

if CP.carFingerprint in CANFD_CAR:
signals += [
("LatCtlSte_D_Stat", "Lane_Assist_Data3_FD1"), # PSCM lateral control status
]
checks += [
messages += [
("Lane_Assist_Data3_FD1", 33),
]

if CP.transmissionType == TransmissionType.automatic:
signals += [
("TrnRng_D_RqGsm", "Gear_Shift_by_Wire_FD1"), # GWM transmission gear position
]
checks += [
messages += [
("Gear_Shift_by_Wire_FD1", 10),
]
elif CP.transmissionType == TransmissionType.manual:
signals += [
("CluPdlPos_Pc_Meas", "Engine_Clutch_Data"), # PCM clutch (pct)
("RvrseLghtOn_B_Stat", "BCM_Lamp_Stat_FD1"), # BCM reverse light
]
checks += [
messages += [
("Engine_Clutch_Data", 33),
("BCM_Lamp_Stat_FD1", 1),
]

if CP.enableBsm and CP.carFingerprint not in CANFD_CAR:
signals += [
("SodDetctLeft_D_Stat", "Side_Detect_L_Stat"), # Blindspot sensor, left
("SodDetctRight_D_Stat", "Side_Detect_R_Stat"), # Blindspot sensor, right
]
checks += [
messages += [
("Side_Detect_L_Stat", 5),
("Side_Detect_R_Stat", 5),
]

return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, CanBus(CP).main)
return CANParser(DBC[CP.carFingerprint]["pt"], messages, CanBus(CP).main)

@staticmethod
def get_cam_can_parser(CP):
signals = [
# sig_name, sig_address
("CmbbDeny_B_Actl", "ACCDATA"), # ACC/AEB unavailable/lockout

("CmbbBrkDecel_B_Rq", "ACCDATA_2"), # AEB actuation request bit

("HaDsply_No_Cs", "ACCDATA_3"),
("HaDsply_No_Cnt", "ACCDATA_3"),
("AccStopStat_D_Dsply", "ACCDATA_3"), # ACC stopped status message
("AccTrgDist2_D_Dsply", "ACCDATA_3"), # ACC target distance
("AccStopRes_B_Dsply", "ACCDATA_3"),
("TjaWarn_D_Rq", "ACCDATA_3"), # TJA warning
("Tja_D_Stat", "ACCDATA_3"), # TJA status
("TjaMsgTxt_D_Dsply", "ACCDATA_3"), # TJA text
("IaccLamp_D_Rq", "ACCDATA_3"), # iACC status icon
("AccMsgTxt_D2_Rq", "ACCDATA_3"), # ACC text
("FcwDeny_B_Dsply", "ACCDATA_3"), # FCW disabled
("FcwMemStat_B_Actl", "ACCDATA_3"), # FCW enabled setting
("AccTGap_B_Dsply", "ACCDATA_3"), # ACC time gap display setting
("CadsAlignIncplt_B_Actl", "ACCDATA_3"),
("AccFllwMde_B_Dsply", "ACCDATA_3"), # ACC lead indicator
("CadsRadrBlck_B_Actl", "ACCDATA_3"),
("CmbbPostEvnt_B_Dsply", "ACCDATA_3"), # AEB event status
("AccStopMde_B_Dsply", "ACCDATA_3"), # ACC stop mode display setting
("FcwMemSens_D_Actl", "ACCDATA_3"), # FCW sensitivity setting
("FcwMsgTxt_D_Rq", "ACCDATA_3"), # FCW text
("AccWarn_D_Dsply", "ACCDATA_3"), # ACC warning
("FcwVisblWarn_B_Rq", "ACCDATA_3"), # FCW visible alert
("FcwAudioWarn_B_Rq", "ACCDATA_3"), # FCW audio alert
("AccTGap_D_Dsply", "ACCDATA_3"), # ACC time gap
("AccMemEnbl_B_RqDrv", "ACCDATA_3"), # ACC adaptive/normal setting
("FdaMem_B_Stat", "ACCDATA_3"), # FDA enabled setting

("FeatConfigIpmaActl", "IPMA_Data"),
("FeatNoIpmaActl", "IPMA_Data"),
("PersIndexIpma_D_Actl", "IPMA_Data"),
("AhbcRampingV_D_Rq", "IPMA_Data"), # AHB ramping
("LaDenyStats_B_Dsply", "IPMA_Data"), # LKAS error
("CamraDefog_B_Req", "IPMA_Data"), # Windshield heater?
("CamraStats_D_Dsply", "IPMA_Data"), # Camera status
("DasAlrtLvl_D_Dsply", "IPMA_Data"), # DAS alert level
("DasStats_D_Dsply", "IPMA_Data"), # DAS status
("DasWarn_D_Dsply", "IPMA_Data"), # DAS warning
("AhbHiBeam_D_Rq", "IPMA_Data"), # AHB status
("Passthru_63", "IPMA_Data"),
("Passthru_48", "IPMA_Data"),
]

checks = [
messages = [
# sig_address, frequency
("ACCDATA", 50),
("ACCDATA_2", 50),
Expand All @@ -287,13 +162,9 @@ def get_cam_can_parser(CP):
]

if CP.enableBsm and CP.carFingerprint in CANFD_CAR:
signals += [
("SodDetctLeft_D_Stat", "Side_Detect_L_Stat"), # Blindspot sensor, left
("SodDetctRight_D_Stat", "Side_Detect_R_Stat"), # Blindspot sensor, right
]
checks += [
messages += [
("Side_Detect_L_Stat", 5),
("Side_Detect_R_Stat", 5),
]

return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, CanBus(CP).camera)
return CANParser(DBC[CP.carFingerprint]["pt"], messages, CanBus(CP).camera)
Loading

0 comments on commit cbfcc40

Please sign in to comment.