Skip to content

Commit

Permalink
Subaru: resume from cruise standstill
Browse files Browse the repository at this point in the history
  • Loading branch information
adeebshihadeh authored and budney committed Aug 29, 2022
1 parent 50e54e1 commit 766ee6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 6 additions & 5 deletions selfdrive/car/subaru/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def __init__(self, dbc_name, CP, VM):
def update(self, CC, CS):
actuators = CC.actuators
hud_control = CC.hudControl
pcm_cancel_cmd = CC.cruiseControl.cancel

can_sends = []

Expand Down Expand Up @@ -53,7 +52,7 @@ def update(self, CC, CS):
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:
if CC.cruiseControl.cancel:
cruise_button = 1
# turn main on if off and past start-up state
elif not CS.out.cruiseState.available and CS.ready:
Expand All @@ -70,10 +69,12 @@ def update(self, CC, CS):
self.es_distance_cnt = CS.es_distance_msg["COUNTER"]

else:
if pcm_cancel_cmd and (self.frame - self.last_cancel_frame) > 0.2:
if (self.frame - self.last_cancel_frame) > 0.2:
bus = 1 if self.CP.carFingerprint in GLOBAL_GEN2 else 0
can_sends.append(subarucan.create_es_distance(self.packer, CS.es_distance_msg, bus, pcm_cancel_cmd))
self.last_cancel_frame = self.frame
resume = CC.cruiseControl.resume and not CC.cruiseControl.cancel
if CC.cruiseControl.cancel or resume:
can_sends.append(subarucan.create_es_distance(self.packer, CS.es_distance_msg, bus, CC.cruiseControl.cancel, resume))
self.last_cancel_frame = self.frame

if self.es_dashstatus_cnt != CS.es_dashstatus_msg["COUNTER"]:
can_sends.append(subarucan.create_es_dashstatus(self.packer, CS.es_dashstatus_msg))
Expand Down
6 changes: 4 additions & 2 deletions selfdrive/car/subaru/subarucan.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ def create_steering_control(packer, apply_steer):
def create_steering_status(packer):
return packer.make_can_msg("ES_LKAS_State", 0, {})

def create_es_distance(packer, es_distance_msg, bus, pcm_cancel_cmd):
def create_es_distance(packer, es_distance_msg, bus, cancel, resume):
values = copy.copy(es_distance_msg)
values["COUNTER"] = (values["COUNTER"] + 1) % 0x10
if pcm_cancel_cmd:
if cancel:
values["Cruise_Cancel"] = 1
elif resume:
values["Cruise_Resume"] = 1
return packer.make_can_msg("ES_Distance", bus, values)

def create_es_lkas(packer, es_lkas_msg, enabled, visual_alert, left_line, right_line, left_lane_depart, right_lane_depart):
Expand Down

0 comments on commit 766ee6c

Please sign in to comment.