From 815afba5f40cd90a2d7c0540c1cadc355bdb8c3b Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Sun, 16 Mar 2025 15:46:03 -0400 Subject: [PATCH] only initialize if NNLC is enabled or allow to enable --- selfdrive/controls/controlsd.py | 2 +- selfdrive/controls/lib/latcontrol_torque.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 0a8a9d519f..8e7743e684 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -117,7 +117,7 @@ class Controls: self.LoC.reset() # Neural Network Lateral Control - if self.CP_SP.neuralNetworkLateralControl.enabled and self.CP.steerControlType.which() == 'torque': + if self.CP_SP.neuralNetworkLateralControl.enabled: self.LaC.nnlc.update_model_v2(model_v2) # accel PID loop diff --git a/selfdrive/controls/lib/latcontrol_torque.py b/selfdrive/controls/lib/latcontrol_torque.py index 0c350d87a1..ac7168b1e7 100644 --- a/selfdrive/controls/lib/latcontrol_torque.py +++ b/selfdrive/controls/lib/latcontrol_torque.py @@ -34,7 +34,8 @@ class LatControlTorque(LatControl): self.use_steering_angle = self.torque_params.useSteeringAngle self.steering_angle_deadzone_deg = self.torque_params.steeringAngleDeadzoneDeg - self.nnlc = NeuralNetworkLateralControl(self, CP, CP_SP) + if CP_SP.neuralNetworkLateralControl.enabled: + self.nnlc = NeuralNetworkLateralControl(self, CP, CP_SP) def update_live_torque_params(self, latAccelFactor, latAccelOffset, friction): self.torque_params.latAccelFactor = latAccelFactor @@ -79,8 +80,9 @@ class LatControlTorque(LatControl): # Neural Network Lateral Control updates # Override stock ff and pid_log.error - ff, pid_log = self.nnlc.update(CS, VM, params, ff, pid_log, setpoint, measurement, calibrated_pose, roll_compensation, - desired_lateral_accel, actual_lateral_accel, lateral_accel_deadzone, gravity_adjusted_lateral_accel) + if self.nnlc.enabled: + ff, pid_log = self.nnlc.update(CS, VM, params, ff, pid_log, setpoint, measurement, calibrated_pose, roll_compensation, + desired_lateral_accel, actual_lateral_accel, lateral_accel_deadzone, gravity_adjusted_lateral_accel) freeze_integrator = steer_limited_by_controls or CS.steeringPressed or CS.vEgo < 5 output_torque = self.pid.update(pid_log.error,