|
|
|
@ -173,6 +173,7 @@ class Controls: |
|
|
|
|
self.cruise_mismatch_counter = 0 |
|
|
|
|
self.can_rcv_timeout_counter = 0 |
|
|
|
|
self.last_blinker_frame = 0 |
|
|
|
|
self.last_steering_pressed_frame = 0 |
|
|
|
|
self.distance_traveled = 0 |
|
|
|
|
self.last_functional_fan_frame = 0 |
|
|
|
|
self.events_prev = [] |
|
|
|
@ -623,29 +624,34 @@ class Controls: |
|
|
|
|
lac_log.output = actuators.steer |
|
|
|
|
lac_log.saturated = abs(actuators.steer) >= 0.9 |
|
|
|
|
|
|
|
|
|
if CS.steeringPressed: |
|
|
|
|
self.last_steering_pressed_frame = self.sm.frame |
|
|
|
|
recent_steer_pressed = (self.sm.frame - self.last_steering_pressed_frame)*DT_CTRL < 2.0 |
|
|
|
|
|
|
|
|
|
# Send a "steering required alert" if saturation count has reached the limit |
|
|
|
|
if lac_log.active and not CS.steeringPressed and self.CP.lateralTuning.which() == 'torque' and not self.joystick_mode: |
|
|
|
|
undershooting = abs(lac_log.desiredLateralAccel) / abs(1e-3 + lac_log.actualLateralAccel) > 1.2 |
|
|
|
|
turning = abs(lac_log.desiredLateralAccel) > 1.0 |
|
|
|
|
good_speed = CS.vEgo > 5 |
|
|
|
|
max_torque = abs(self.last_actuators.steer) > 0.99 |
|
|
|
|
if undershooting and turning and good_speed and max_torque: |
|
|
|
|
self.events.add(EventName.steerSaturated) |
|
|
|
|
elif lac_log.active and lac_log.saturated: |
|
|
|
|
dpath_points = lat_plan.dPathPoints |
|
|
|
|
if len(dpath_points): |
|
|
|
|
# Check if we deviated from the path |
|
|
|
|
# TODO use desired vs actual curvature |
|
|
|
|
if self.CP.steerControlType == car.CarParams.SteerControlType.angle: |
|
|
|
|
steering_value = actuators.steeringAngleDeg |
|
|
|
|
else: |
|
|
|
|
steering_value = actuators.steer |
|
|
|
|
if lac_log.active and not recent_steer_pressed: |
|
|
|
|
if self.CP.lateralTuning.which() == 'torque' and not self.joystick_mode: |
|
|
|
|
undershooting = abs(lac_log.desiredLateralAccel) / abs(1e-3 + lac_log.actualLateralAccel) > 1.2 |
|
|
|
|
turning = abs(lac_log.desiredLateralAccel) > 1.0 |
|
|
|
|
good_speed = CS.vEgo > 5 |
|
|
|
|
max_torque = abs(self.last_actuators.steer) > 0.99 |
|
|
|
|
if undershooting and turning and good_speed and max_torque: |
|
|
|
|
lac_log.active and self.events.add(EventName.steerSaturated) |
|
|
|
|
elif lac_log.saturated: |
|
|
|
|
dpath_points = lat_plan.dPathPoints |
|
|
|
|
if len(dpath_points): |
|
|
|
|
# Check if we deviated from the path |
|
|
|
|
# TODO use desired vs actual curvature |
|
|
|
|
if self.CP.steerControlType == car.CarParams.SteerControlType.angle: |
|
|
|
|
steering_value = actuators.steeringAngleDeg |
|
|
|
|
else: |
|
|
|
|
steering_value = actuators.steer |
|
|
|
|
|
|
|
|
|
left_deviation = steering_value > 0 and dpath_points[0] < -0.20 |
|
|
|
|
right_deviation = steering_value < 0 and dpath_points[0] > 0.20 |
|
|
|
|
left_deviation = steering_value > 0 and dpath_points[0] < -0.20 |
|
|
|
|
right_deviation = steering_value < 0 and dpath_points[0] > 0.20 |
|
|
|
|
|
|
|
|
|
if left_deviation or right_deviation: |
|
|
|
|
self.events.add(EventName.steerSaturated) |
|
|
|
|
if left_deviation or right_deviation: |
|
|
|
|
self.events.add(EventName.steerSaturated) |
|
|
|
|
|
|
|
|
|
# Ensure no NaNs/Infs |
|
|
|
|
for p in ACTUATOR_FIELDS: |
|
|
|
|