Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subaru Pre-Global: Rename ES_CruiseThrottle to ES_Distance #23024

Merged
merged 3 commits into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions selfdrive/car/subaru/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class CarController():
def __init__(self, dbc_name, CP, VM):
self.apply_steer_last = 0
self.es_distance_cnt = -1
self.es_accel_cnt = -1
self.es_lkas_cnt = -1
self.cruise_button_prev = 0
self.steer_rate_limited = False
Expand Down Expand Up @@ -44,7 +43,7 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, le
# *** alerts and pcm cancel ***

if CS.CP.carFingerprint in PREGLOBAL_CARS:
if self.es_accel_cnt != CS.es_accel_msg["Counter"]:
if self.es_distance_cnt != CS.es_distance_msg["Counter"]:
# 1 = main, 2 = set shallow, 3 = set deep, 4 = resume shallow, 5 = resume deep
# disengage ACC when OP is disengaged
if pcm_cancel_cmd:
Expand All @@ -60,8 +59,8 @@ def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, le
cruise_button = 0
self.cruise_button_prev = cruise_button

can_sends.append(subarucan.create_es_throttle_control(self.packer, cruise_button, CS.es_accel_msg))
self.es_accel_cnt = CS.es_accel_msg["Counter"]
can_sends.append(subarucan.create_preglobal_es_distance(self.packer, cruise_button, CS.es_distance_msg))
self.es_distance_cnt = CS.es_distance_msg["Counter"]

else:
if self.es_distance_cnt != CS.es_distance_msg["Counter"]:
Expand Down
41 changes: 20 additions & 21 deletions selfdrive/car/subaru/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,13 @@ def update(self, cp, cp_cam):
ret.steerError = cp.vl["Steering_Torque"]["Steer_Error_1"] == 1

if self.car_fingerprint in PREGLOBAL_CARS:
self.cruise_button = cp_cam.vl["ES_CruiseThrottle"]["Cruise_Button"]
self.cruise_button = cp_cam.vl["ES_Distance"]["Cruise_Button"]
self.ready = not cp_cam.vl["ES_DashStatus"]["Not_Ready_Startup"]
self.es_accel_msg = copy.copy(cp_cam.vl["ES_CruiseThrottle"])
else:
ret.steerWarning = cp.vl["Steering_Torque"]["Steer_Warning"] == 1
ret.cruiseState.nonAdaptive = cp_cam.vl["ES_DashStatus"]["Conventional_Cruise"] == 1
self.es_distance_msg = copy.copy(cp_cam.vl["ES_Distance"])
self.es_lkas_msg = copy.copy(cp_cam.vl["ES_LKAS_State"])
self.es_distance_msg = copy.copy(cp_cam.vl["ES_Distance"])

return ret

Expand Down Expand Up @@ -168,28 +167,28 @@ def get_cam_can_parser(CP):
("Cruise_Set_Speed", "ES_DashStatus", 0),
("Not_Ready_Startup", "ES_DashStatus", 0),

("Throttle_Cruise", "ES_CruiseThrottle", 0),
("Signal1", "ES_CruiseThrottle", 0),
("Cruise_Activated", "ES_CruiseThrottle", 0),
("Signal2", "ES_CruiseThrottle", 0),
("Brake_On", "ES_CruiseThrottle", 0),
("Distance_Swap", "ES_CruiseThrottle", 0),
("Standstill", "ES_CruiseThrottle", 0),
("Signal3", "ES_CruiseThrottle", 0),
("Close_Distance", "ES_CruiseThrottle", 0),
("Signal4", "ES_CruiseThrottle", 0),
("Standstill_2", "ES_CruiseThrottle", 0),
("Cruise_Fault", "ES_CruiseThrottle", 0),
("Signal5", "ES_CruiseThrottle", 0),
("Counter", "ES_CruiseThrottle", 0),
("Signal6", "ES_CruiseThrottle", 0),
("Cruise_Button", "ES_CruiseThrottle", 0),
("Signal7", "ES_CruiseThrottle", 0),
("Cruise_Throttle", "ES_Distance", 0),
("Signal1", "ES_Distance", 0),
("Car_Follow", "ES_Distance", 0),
("Signal2", "ES_Distance", 0),
("Brake_On", "ES_Distance", 0),
("Distance_Swap", "ES_Distance", 0),
("Standstill", "ES_Distance", 0),
("Signal3", "ES_Distance", 0),
("Close_Distance", "ES_Distance", 0),
("Signal4", "ES_Distance", 0),
("Standstill_2", "ES_Distance", 0),
("Cruise_Fault", "ES_Distance", 0),
("Signal5", "ES_Distance", 0),
("Counter", "ES_Distance", 0),
("Signal6", "ES_Distance", 0),
("Cruise_Button", "ES_Distance", 0),
("Signal7", "ES_Distance", 0),
]

checks = [
("ES_DashStatus", 20),
("ES_CruiseThrottle", 20),
("ES_Distance", 20),
]
else:
signals = [
Expand Down
8 changes: 4 additions & 4 deletions selfdrive/car/subaru/subarucan.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ def create_preglobal_steering_control(packer, apply_steer, frame, steer_step):

return packer.make_can_msg("ES_LKAS", 0, values)

def create_es_throttle_control(packer, cruise_button, es_accel_msg):
def create_preglobal_es_distance(packer, cruise_button, es_distance_msg):

values = copy.copy(es_accel_msg)
values = copy.copy(es_distance_msg)
values["Cruise_Button"] = cruise_button

values["Checksum"] = subaru_preglobal_checksum(packer, values, "ES_CruiseThrottle")
values["Checksum"] = subaru_preglobal_checksum(packer, values, "ES_Distance")

return packer.make_can_msg("ES_CruiseThrottle", 0, values)
return packer.make_can_msg("ES_Distance", 0, values)