Skip to content

Commit 49c422e

Browse files
authored
Tesla: fix angle control saturation (commaai#35256)
* we shouldn't need this * or this? * stash junk * hmm * comment * cc * sadly we have to maintain behavior * bump
1 parent da67010 commit 49c422e

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

selfdrive/controls/lib/latcontrol_angle.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class LatControlAngle(LatControl):
1010
def __init__(self, CP, CI):
1111
super().__init__(CP, CI)
1212
self.sat_check_min_speed = 5.
13+
self.use_steer_limited_by_controls = CP.brand == "tesla"
1314

1415
def update(self, active, CS, VM, params, steer_limited_by_controls, desired_curvature, calibrated_pose, curvature_limited):
1516
angle_log = log.ControlsState.LateralAngleState.new_message()
@@ -22,7 +23,13 @@ def update(self, active, CS, VM, params, steer_limited_by_controls, desired_curv
2223
angle_steers_des = math.degrees(VM.get_steer_from_curvature(-desired_curvature, CS.vEgo, params.roll))
2324
angle_steers_des += params.angleOffsetDeg
2425

25-
angle_control_saturated = abs(angle_steers_des - CS.steeringAngleDeg) > STEER_ANGLE_SATURATION_THRESHOLD
26+
if self.use_steer_limited_by_controls:
27+
# these cars' carcontrolers calculate max lateral accel and jerk, so we can rely on carOutput for saturation
28+
angle_control_saturated = steer_limited_by_controls
29+
else:
30+
# for cars which use a method of limiting torque such as a torque signal (Nissan and Toyota)
31+
# or relying on EPS (Ford Q3), carOutput does not capture maxing out torque # TODO: this can be improved
32+
angle_control_saturated = abs(angle_steers_des - CS.steeringAngleDeg) > STEER_ANGLE_SATURATION_THRESHOLD
2633
angle_log.saturated = bool(self._check_saturation(angle_control_saturated, CS, False, curvature_limited))
2734
angle_log.steeringAngleDeg = float(CS.steeringAngleDeg)
2835
angle_log.steeringAngleDesiredDeg = angle_steers_des

0 commit comments

Comments
 (0)