From 9a0b4fd155e4fcc52bc4d119b2ba744e08f34495 Mon Sep 17 00:00:00 2001 From: infiniteCable <75014343+infiniteCable@users.noreply.github.com> Date: Sun, 6 Apr 2025 14:48:29 +0200 Subject: [PATCH] Update controlsd.py --- selfdrive/controls/controlsd.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 7820cb94d..6ec39cdae 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -18,6 +18,7 @@ from openpilot.selfdrive.controls.lib.latcontrol_angle import LatControlAngle, S from openpilot.selfdrive.controls.lib.latcontrol_torque import LatControlTorque from openpilot.selfdrive.controls.lib.longcontrol import LongControl from openpilot.selfdrive.locationd.helpers import PoseCalibrator, Pose +from openpilot.selfdrive.controls.lib.longitudinal_mpc_lib.long_mpc import get_T_FOLLOW State = log.SelfdriveState.OpenpilotState LaneChangeState = log.LaneChangeState @@ -48,6 +49,7 @@ class Controls: self.steer_limited_by_controls = False self.curvature = 0.0 self.desired_curvature = 0.0 + self.roll = 0.0 self.pose_calibrator = PoseCalibrator() self.calibrated_pose: Pose | None = None @@ -80,7 +82,7 @@ class Controls: 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) + self.curvature = -self.VM.calc_curvature(steer_angle_without_offset, CS.vEgo, 0) # Update Torque Params if self.CP.lateralTuning.which() == 'torque': @@ -156,6 +158,9 @@ class Controls: def publish(self, CC, CC_SP, lac_log): CS = self.sm['carState'] + CC.currentCurvature = self.curvature + CC.rollDEPRECATED = self.roll + # Orientation and angle rates can be useful for carcontroller # Only calibrated (car) frame is relevant for the carcontroller if self.calibrated_pose is not None: @@ -174,7 +179,9 @@ class Controls: hudControl.speedVisible = CC.enabled hudControl.lanesVisible = CC.enabled hudControl.leadVisible = self.sm['longitudinalPlan'].hasLead + hudControl.leadDistance = self.sm['longitudinalPlan'].leadDistance hudControl.leadDistanceBars = self.sm['selfdriveState'].personality.raw + 1 + hudControl.leadFollowTime = get_T_FOLLOW(hudControl.leadDistanceBars - 1) hudControl.visualAlert = self.sm['selfdriveState'].alertHudVisual hudControl.rightLaneVisible = True