Skip to content

Commit

Permalink
Chrysler: carState signals update (#24760)
Browse files Browse the repository at this point in the history
* carstate update

* update refs

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
  • Loading branch information
realfast and adeebshihadeh authored Jul 1, 2022
1 parent d2c2154 commit 38ff298
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 38 deletions.
2 changes: 1 addition & 1 deletion opendbc
4 changes: 2 additions & 2 deletions selfdrive/car/chrysler/carcontroller.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from cereal import car
from opendbc.can.packer import CANPacker
from selfdrive.car import apply_toyota_steer_torque_limits
from selfdrive.car.chrysler.chryslercan import create_lkas_hud, create_lkas_command, create_wheel_buttons
from selfdrive.car.chrysler.chryslercan import create_lkas_hud, create_lkas_command, create_cruise_buttons
from selfdrive.car.chrysler.values import CAR, CarControllerParams


Expand Down Expand Up @@ -49,7 +49,7 @@ def update(self, CC, CS):
# *** control msgs ***

if CC.cruiseControl.cancel:
can_sends.append(create_wheel_buttons(self.packer, CS.button_counter + 1, cancel=True))
can_sends.append(create_cruise_buttons(self.packer, CS.button_counter + 1, cancel=True))

# LKAS_HEARTBIT is forwarded by Panda so no need to send it here.
# frame is 100Hz (0.01s period)
Expand Down
58 changes: 29 additions & 29 deletions selfdrive/car/chrysler/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ def update(self, cp, cp_cam):

ret = car.CarState.new_message()

self.frame = int(cp.vl["EPS_STATUS"]["COUNTER"])
self.frame = int(cp.vl["EPS_2"]["COUNTER"])

ret.doorOpen = any([cp.vl["BCM_1"]["DOOR_OPEN_FL"],
cp.vl["BCM_1"]["DOOR_OPEN_FR"],
cp.vl["BCM_1"]["DOOR_OPEN_RL"],
cp.vl["BCM_1"]["DOOR_OPEN_RR"]])
ret.seatbeltUnlatched = cp.vl["SEATBELT_STATUS"]["SEATBELT_DRIVER_UNLATCHED"] == 1
ret.seatbeltUnlatched = cp.vl["ORC_1"]["SEATBELT_DRIVER_UNLATCHED"] == 1

# brake pedal
ret.brake = 0
Expand All @@ -35,10 +35,10 @@ def update(self, cp, cp_cam):
ret.espDisabled = (cp.vl["TRACTION_BUTTON"]["TRACTION_OFF"] == 1)

ret.wheelSpeeds = self.get_wheel_speeds(
cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_FL"],
cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_FR"],
cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_RL"],
cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_RR"],
cp.vl["ESP_6"]["WHEEL_SPEED_FL"],
cp.vl["ESP_6"]["WHEEL_SPEED_FR"],
cp.vl["ESP_6"]["WHEEL_SPEED_RL"],
cp.vl["ESP_6"]["WHEEL_SPEED_RR"],
unit=1,
)
ret.vEgoRaw = (cp.vl["SPEED_1"]["SPEED_LEFT"] + cp.vl["SPEED_1"]["SPEED_RIGHT"]) / 2.
Expand All @@ -51,17 +51,17 @@ def update(self, cp, cp_cam):

ret.cruiseState.available = cp.vl["DAS_3"]["ACC_AVAILABLE"] == 1 # ACC is white
ret.cruiseState.enabled = cp.vl["DAS_3"]["ACC_ACTIVE"] == 1 # ACC is green
ret.cruiseState.speed = cp.vl["DASHBOARD"]["ACC_SPEED_CONFIG_KPH"] * CV.KPH_TO_MS
ret.cruiseState.speed = cp.vl["DAS_4"]["ACC_SPEED_CONFIG_KPH"] * CV.KPH_TO_MS
# CRUISE_STATE is a three bit msg, 0 is off, 1 and 2 are Non-ACC mode, 3 and 4 are ACC mode, find if there are other states too
ret.cruiseState.nonAdaptive = cp.vl["DASHBOARD"]["CRUISE_STATE"] in (1, 2)
ret.cruiseState.nonAdaptive = cp.vl["DAS_4"]["CRUISE_STATE"] in (1, 2)
ret.accFaulted = cp.vl["DAS_3"]["ACC_FAULTED"] != 0

ret.steeringAngleDeg = cp.vl["STEERING"]["STEER_ANGLE"]
ret.steeringRateDeg = cp.vl["STEERING"]["STEERING_RATE"]
ret.steeringTorque = cp.vl["EPS_STATUS"]["TORQUE_DRIVER"]
ret.steeringTorqueEps = cp.vl["EPS_STATUS"]["TORQUE_MOTOR"]
ret.steeringTorque = cp.vl["EPS_2"]["COLUMN_TORQUE"]
ret.steeringTorqueEps = cp.vl["EPS_2"]["EPS_TORQUE_MOTOR"]
ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD
steer_state = cp.vl["EPS_STATUS"]["LKAS_STATE"]
steer_state = cp.vl["EPS_2"]["LKAS_STATE"]
ret.steerFaultPermanent = steer_state == 4 or (steer_state == 0 and ret.vEgo > self.CP.minSteerSpeed)

ret.genericToggle = bool(cp.vl["STEERING_LEVERS"]["HIGH_BEAM_FLASH"])
Expand All @@ -73,7 +73,7 @@ def update(self, cp, cp_cam):
self.lkas_counter = cp_cam.vl["LKAS_COMMAND"]["COUNTER"]
self.lkas_car_model = cp_cam.vl["LKAS_HUD"]["CAR_MODEL"]
self.lkas_status_ok = cp_cam.vl["LKAS_HEARTBIT"]["LKAS_STATUS_OK"]
self.button_counter = cp.vl["WHEEL_BUTTONS"]["COUNTER"]
self.button_counter = cp.vl["CRUISE_BUTTONS"]["COUNTER"]

return ret

Expand All @@ -90,42 +90,42 @@ def get_can_parser(CP):
("Accelerator_Position", "ECM_5"),
("SPEED_LEFT", "SPEED_1"),
("SPEED_RIGHT", "SPEED_1"),
("WHEEL_SPEED_FL", "WHEEL_SPEEDS"),
("WHEEL_SPEED_RR", "WHEEL_SPEEDS"),
("WHEEL_SPEED_RL", "WHEEL_SPEEDS"),
("WHEEL_SPEED_FR", "WHEEL_SPEEDS"),
("WHEEL_SPEED_FL", "ESP_6"),
("WHEEL_SPEED_RR", "ESP_6"),
("WHEEL_SPEED_RL", "ESP_6"),
("WHEEL_SPEED_FR", "ESP_6"),
("STEER_ANGLE", "STEERING"),
("STEERING_RATE", "STEERING"),
("TURN_SIGNALS", "STEERING_LEVERS"),
("ACC_AVAILABLE", "DAS_3"),
("ACC_ACTIVE", "DAS_3"),
("ACC_FAULTED", "DAS_3"),
("HIGH_BEAM_FLASH", "STEERING_LEVERS"),
("ACC_SPEED_CONFIG_KPH", "DASHBOARD"),
("CRUISE_STATE", "DASHBOARD"),
("TORQUE_DRIVER", "EPS_STATUS"),
("TORQUE_MOTOR", "EPS_STATUS"),
("LKAS_STATE", "EPS_STATUS"),
("COUNTER", "EPS_STATUS",),
("ACC_SPEED_CONFIG_KPH", "DAS_4"),
("CRUISE_STATE", "DAS_4"),
("COLUMN_TORQUE", "EPS_2"),
("EPS_TORQUE_MOTOR", "EPS_2"),
("LKAS_STATE", "EPS_2"),
("COUNTER", "EPS_2",),
("TRACTION_OFF", "TRACTION_BUTTON"),
("SEATBELT_DRIVER_UNLATCHED", "SEATBELT_STATUS"),
("COUNTER", "WHEEL_BUTTONS"),
("SEATBELT_DRIVER_UNLATCHED", "ORC_1"),
("COUNTER", "CRUISE_BUTTONS"),
]

checks = [
# sig_address, frequency
("ESP_1", 50),
("EPS_STATUS", 100),
("EPS_2", 100),
("SPEED_1", 100),
("WHEEL_SPEEDS", 50),
("ESP_6", 50),
("STEERING", 100),
("DAS_3", 50),
("GEAR", 50),
("ECM_5", 50),
("WHEEL_BUTTONS", 50),
("DASHBOARD", 15),
("CRUISE_BUTTONS", 50),
("DAS_4", 15),
("STEERING_LEVERS", 10),
("SEATBELT_STATUS", 2),
("ORC_1", 2),
("BCM_1", 1),
("TRACTION_BUTTON", 1),
]
Expand Down
9 changes: 4 additions & 5 deletions selfdrive/car/chrysler/chryslercan.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ def create_lkas_command(packer, apply_steer, moving_fast, frame):
return packer.make_can_msg("LKAS_COMMAND", 0, values)


def create_wheel_buttons(packer, frame, cancel=False):
# WHEEL_BUTTONS (571) Message sent to cancel ACC.
def create_cruise_buttons(packer, frame, cancel=False):
values = {
"ACC_CANCEL": cancel,
"COUNTER": frame % 0x10
"ACC_Cancel": cancel,
"COUNTER": frame % 0x10,
}
return packer.make_can_msg("WHEEL_BUTTONS", 0, values)
return packer.make_can_msg("CRUISE_BUTTONS", 0, values)
2 changes: 1 addition & 1 deletion selfdrive/test/process_replay/ref_commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d7c610172f3ff10b68403abc19b260c91c848ebb
806984d4206056fb132625c5dad6c0ca1835a2d6

0 comments on commit 38ff298

Please sign in to comment.