cut torque for 1 frame

pull/24067/head
Shane Smiskol 3 years ago
parent c25eea1742
commit 18a4c62e7f
  1. 7
      selfdrive/car/toyota/carcontroller.py

@ -24,6 +24,7 @@ class CarController:
self.steer_rate_limited = False self.steer_rate_limited = False
self.frames_above_rate_threshold = 0 self.frames_above_rate_threshold = 0
self.predicted_steering_fault_prev = False
self.packer = CANPacker(dbc_name) self.packer = CANPacker(dbc_name)
self.gas = 0 self.gas = 0
@ -67,7 +68,7 @@ class CarController:
# the value seems to describe how many frames the steering rate was above 100 deg/s, so # the value seems to describe how many frames the steering rate was above 100 deg/s, so
# cut torque with some margin for the lower state # cut torque with some margin for the lower state
# Only cut torque when steering angle and rate have opposite signs # Only cut torque when steering angle and rate have opposite signs
predicted_steering_fault = self.frames_above_rate_threshold > 18 and (CS.steeringRateDeg * CS.steeringAngleDeg) < 0 predicted_steering_fault = self.frames_above_rate_threshold > 18 # and (CS.out.steeringRateDeg * CS.out.steeringAngleDeg) < 0
# Cut steering while we're in a known fault state (2s) or about to be # Cut steering while we're in a known fault state (2s) or about to be
if not CC.latActive or CS.steer_state in (9, 25) or predicted_steering_fault: if not CC.latActive or CS.steer_state in (9, 25) or predicted_steering_fault:
@ -99,6 +100,10 @@ class CarController:
# toyota can trace shows this message at 42Hz, with counter adding alternatively 1 and 2; # toyota can trace shows this message at 42Hz, with counter adding alternatively 1 and 2;
# sending it at 100Hz seem to allow a higher rate limit, as the rate limit seems imposed # sending it at 100Hz seem to allow a higher rate limit, as the rate limit seems imposed
# on consecutive messages # on consecutive messages
if predicted_steering_fault and not self.predicted_steering_fault_prev:
apply_steer = 0
apply_steer_req = 0
self.predicted_steering_fault_prev = predicted_steering_fault
can_sends.append(create_steer_command(self.packer, apply_steer, apply_steer_req, self.frame)) can_sends.append(create_steer_command(self.packer, apply_steer, apply_steer_req, self.frame))
if self.frame % 2 == 0 and self.CP.carFingerprint in TSS2_CAR: if self.frame % 2 == 0 and self.CP.carFingerprint in TSS2_CAR:
can_sends.append(create_lta_steer_command(self.packer, 0, 0, self.frame // 2)) can_sends.append(create_lta_steer_command(self.packer, 0, 0, self.frame // 2))

Loading…
Cancel
Save