mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-10-01 01:43:41 +08:00
only initialize if NNLC is enabled or allow to enable
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user