controls: reset desired curvature while disabled (#34943)

* reset curvature while disabled

* comment

* duplicate line

* fix possible iso violation because it was unlimited while disengaged

* rename so you can't accidentally use

* update refs
pull/34946/head
Shane Smiskol 1 month ago committed by GitHub
parent a6bfb9919d
commit a2859090d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 14
      selfdrive/controls/controlsd.py
  2. 2
      selfdrive/test/process_replay/ref_commit

@ -41,6 +41,7 @@ class Controls:
self.pm = messaging.PubMaster(['carControl', 'controlsState'])
self.steer_limited_by_controls = False
self.curvature = 0.0
self.desired_curvature = 0.0
self.pose_calibrator = PoseCalibrator()
@ -73,6 +74,9 @@ class Controls:
sr = max(lp.steerRatio, 0.1)
self.VM.update_params(x, sr)
steer_angle_without_offset = math.radians(CS.steeringAngleDeg - lp.angleOffsetDeg)
self.curvature = -self.VM.calc_curvature(steer_angle_without_offset, CS.vEgo, lp.roll)
# Update Torque Params
if self.CP.lateralTuning.which() == 'torque':
torque_params = self.sm['liveTorqueParameters']
@ -110,7 +114,10 @@ class Controls:
actuators.accel = float(self.LoC.update(CC.longActive, CS, long_plan.aTarget, long_plan.shouldStop, pid_accel_limits))
# Steering PID loop and lateral MPC
self.desired_curvature, curvature_limited = clip_curvature(CS.vEgo, self.desired_curvature, model_v2.action.desiredCurvature, lp.roll)
# Reset desired curvature to current to avoid violating the limits on engage
new_desired_curvature = model_v2.action.desiredCurvature if CC.latActive else self.curvature
self.desired_curvature, curvature_limited = clip_curvature(CS.vEgo, self.desired_curvature, new_desired_curvature, lp.roll)
actuators.curvature = self.desired_curvature
steer, steeringAngleDeg, lac_log = self.LaC.update(CC.latActive, CS, self.VM, lp,
self.steer_limited_by_controls, self.desired_curvature,
@ -175,10 +182,7 @@ class Controls:
dat.valid = CS.canValid
cs = dat.controlsState
lp = self.sm['liveParameters']
steer_angle_without_offset = math.radians(CS.steeringAngleDeg - lp.angleOffsetDeg)
cs.curvature = -self.VM.calc_curvature(steer_angle_without_offset, CS.vEgo, lp.roll)
cs.curvature = self.curvature
cs.longitudinalPlanMonoTime = self.sm.logMonoTime['longitudinalPlan']
cs.lateralPlanMonoTime = self.sm.logMonoTime['modelV2']
cs.desiredCurvature = self.desired_curvature

@ -1 +1 @@
e239a1683b7f97c9d8dca74c57ebf4ef8bc416cd
1904f49bcc97370a842aeee1f831e9ced5a6cad6
Loading…
Cancel
Save