Skip to content

Commit fdc36cc

Browse files
haraschaxrjsmith1999
authored andcommitted
Torque control: max torque warning (commaai#25018)
* New steer torque warning * typo
1 parent d63e05c commit fdc36cc

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

selfdrive/controls/controlsd.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def update_events(self, CS):
300300
self.events.add(EventName.commIssue)
301301
elif not self.sm.all_freq_ok():
302302
self.events.add(EventName.commIssueAvgFreq)
303-
else: # invalid or can_rcv_error.
303+
else: # invalid or can_rcv_error.
304304
self.events.add(EventName.commIssue)
305305

306306
if not self.logged_comm_issue:
@@ -588,7 +588,14 @@ def state_control(self, CS):
588588
lac_log.saturated = abs(actuators.steer) >= 0.9
589589

590590
# Send a "steering required alert" if saturation count has reached the limit
591-
if lac_log.active and lac_log.saturated and not CS.steeringPressed:
591+
if lac_log.active and not CS.steeringPressed and self.CP.lateralTuning.which() == 'torque':
592+
undershooting = abs(lac_log.desiredLateralAccel) / abs(1e-3 + lac_log.actualLateralAccel) > 1.2
593+
turning = abs(lac_log.desiredLateralAccel) > 1.0
594+
good_speed = CS.vEgo > 5
595+
max_torque = abs(self.last_actuators.steer) > 0.99
596+
if undershooting and turning and good_speed and max_torque:
597+
self.events.add(EventName.steerSaturated)
598+
elif lac_log.active and lac_log.saturated and not CS.steeringPressed:
592599
dpath_points = lat_plan.dPathPoints
593600
if len(dpath_points):
594601
# Check if we deviated from the path

0 commit comments

Comments
 (0)