Skip to content
Draft
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
6 changes: 5 additions & 1 deletion opendbc/car/toyota/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
# EPS allows user torque above threshold for 50 frames before permanently faulting
MAX_USER_TORQUE = 500

CRUISE_CANCEL_DELAY_FRAMES = 10


def get_long_tune(CP, params):
if CP.flags & ToyotaFlags.TSS2:
Expand All @@ -57,6 +59,7 @@ def __init__(self, dbc_names, CP):
self.permit_braking = True
self.steer_rate_counter = 0
self.distance_button = 0
self.cancel_counter = 0

# *** start long control state ***
self.long_pid = get_long_tune(self.CP, self.params)
Expand All @@ -79,7 +82,8 @@ def update(self, CC, CS, now_nanos):
actuators = CC.actuators
stopping = actuators.longControlState == LongCtrlState.stopping
hud_control = CC.hudControl
pcm_cancel_cmd = CC.cruiseControl.cancel
self.cancel_counter = self.cancel_counter + 1 if CC.cruiseControl.cancel else 0
pcm_cancel_cmd = self.cancel_counter > CRUISE_CANCEL_DELAY_FRAMES
lat_active = CC.latActive and abs(CS.out.steeringTorque) < MAX_USER_TORQUE

if len(CC.orientationNED) == 3:
Expand Down
Loading