only initialize if NNLC is enabled or allow to enable

This commit is contained in:
Jason Wen
2025-03-16 15:46:03 -04:00
parent 914d5af2eb
commit 815afba5f4
2 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -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
+5 -3
View File
@@ -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,