mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-05 21:42:05 +08:00
Toyota: remove 100°/sec steering lockout (#24067)
* try a method to kill those faults * cut torque for 1 frame * sign doesn't seem to matter * clean up * better name * Toyota allows you to keep your apply_steer, better control * the logic was wrong entire time? * cut steer for two frames * Revert "cut steer for two frames" This reverts commit 13a68ecc568fe1c0cd1f6f0b5f7ff6560efaf9e0. * better variable names and comments better variable names and comments * should be good * add safety * actual number of frames * constant * bump panda * bump panda * bump panda * bump panda * bump panda * bump panda * bump panda * fix to use min valid frames * rm line * simplify check * bump panda * bump panda to master old-commit-hash: 50d117ed9a0c75a7374e76ec6e42d1a603bb11b0
This commit is contained in:
+1
-1
Submodule panda updated: 13d64d4cc3...0ca23b6778
@@ -10,6 +10,10 @@ from opendbc.can.packer import CANPacker
|
||||
|
||||
VisualAlert = car.CarControl.HUDControl.VisualAlert
|
||||
|
||||
# constants for fault workaround
|
||||
MAX_STEER_RATE = 100 # deg/s
|
||||
MAX_STEER_RATE_FRAMES = 18 # control frames allowed where steering rate >= MAX_STEER_RATE
|
||||
|
||||
|
||||
class CarController:
|
||||
def __init__(self, dbc_name, CP, VM):
|
||||
@@ -20,6 +24,7 @@ class CarController:
|
||||
self.alert_active = False
|
||||
self.last_standstill = False
|
||||
self.standstill_req = False
|
||||
self.steer_rate_counter = 0
|
||||
|
||||
self.packer = CANPacker(dbc_name)
|
||||
self.gas = 0
|
||||
@@ -52,11 +57,19 @@ class CarController:
|
||||
new_steer = int(round(actuators.steer * CarControllerParams.STEER_MAX))
|
||||
apply_steer = apply_toyota_steer_torque_limits(new_steer, self.last_steer, CS.out.steeringTorqueEps, self.torque_rate_limits)
|
||||
|
||||
# Count up to MAX_STEER_RATE_FRAMES, at which point we need to cut torque to avoid a steering fault
|
||||
if CC.latActive and abs(CS.out.steeringRateDeg) >= MAX_STEER_RATE:
|
||||
self.steer_rate_counter += 1
|
||||
else:
|
||||
self.steer_rate_counter = 0
|
||||
|
||||
apply_steer_req = 1
|
||||
if not CC.latActive:
|
||||
apply_steer = 0
|
||||
apply_steer_req = 0
|
||||
else:
|
||||
apply_steer_req = 1
|
||||
elif self.steer_rate_counter > MAX_STEER_RATE_FRAMES:
|
||||
apply_steer_req = 0
|
||||
self.steer_rate_counter = 0
|
||||
|
||||
# TODO: probably can delete this. CS.pcm_acc_status uses a different signal
|
||||
# than CS.cruiseState.enabled. confirm they're not meaningfully different
|
||||
|
||||
Reference in New Issue
Block a user