Skip to content

Commit

Permalink
fix: Correct issue of stearing when in external mode even if not enga…
Browse files Browse the repository at this point in the history
…ged and entering in fault
  • Loading branch information
alfhern committed Oct 4, 2024
1 parent 1c21e7e commit d64b398
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions selfdrive/car/toyota/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,25 @@ def update(self, CC, CS, now_nanos):
new_steer = int(round(actuators.steer * 1000))
apply_steer = new_steer
if self.CCP.tuvParams.torqueRateLimiting:
apply_steer = apply_meas_steer_torque_limits(new_steer, self.last_steer, CS.out.steeringTorqueEps, self.CCP)
apply_steer_req = 1
apply_steer = apply_meas_steer_torque_limits(new_steer, self.last_steer, CS.out.steeringTorqueEps, self.CCP)

else:
new_steer = int(round(actuators.steer * self.CCP.STEER_MAX))
apply_steer = apply_meas_steer_torque_limits(new_steer, self.last_steer, CS.out.steeringTorqueEps, self.CCP)

# Count up to MAX_STEER_RATE_FRAMES, at which point we need to cut torque to avoid a steering fault
if lat_active 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 lat_active:
apply_steer = 0
apply_steer_req = 0
elif self.steer_rate_counter > MAX_STEER_RATE_FRAMES:
apply_steer_req = 0
self.steer_rate_counter = 0
# Count up to MAX_STEER_RATE_FRAMES, at which point we need to cut torque to avoid a steering fault
if lat_active 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 lat_active:
apply_steer = 0
apply_steer_req = 0
elif self.steer_rate_counter > MAX_STEER_RATE_FRAMES:
apply_steer_req = 0
self.steer_rate_counter = 0

# Never actuate with LKA on cars that only support LTA
if self.CP.steerControlType == car.CarParams.SteerControlType.angle:
Expand Down

0 comments on commit d64b398

Please sign in to comment.