mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-23 18:43:54 +08:00
* init * more init * keep it alive * fixes * more fixes * more fix * new submodule for nn data * bump submodule * update path to submodule * spacing??? * update submodule path * update submodule path * bump * dump * bump * introduce params * Add Neural Network Lateral Control toggle to developer panel This introduces a new toggle for enabling Neural Network Lateral Control (NNLC), providing detailed descriptions of its functionality and compatibility. It includes UI integration, car compatibility checks, and feedback links for unsupported vehicles. * decouple even more * static * codespell * remove debug * in structs * fix import * convert to capnp * fixes * debug * only initialize if NNLC is enabled or allow to enable * oops * fix initialization * only allow engage if nnlc is off * fix toggle param * fix tests * lint * fix more test * capnp test * try this out * validate if it's not None * make it 33 to match * align * share the same friction input calculation * return stock values if not enabled * unused * split base and child * space * rename * NeuralNetworkFeedForwardModel * less * just use file name * try this * more explicit * rename * move it * child class for additional controllers * rename * time to split out custom lateral acceleration * move around * space * fix * TODO-SP * TODO-SP * split nnlc and custom lat accel * more * not yet * comment * fix --------- Co-authored-by: DevTekVE <devtekve@gmail.com>
30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
import math
|
|
|
|
from cereal import log
|
|
from openpilot.selfdrive.controls.lib.latcontrol import LatControl
|
|
|
|
STEER_ANGLE_SATURATION_THRESHOLD = 2.5 # Degrees
|
|
|
|
|
|
class LatControlAngle(LatControl):
|
|
def __init__(self, CP, CP_SP, CI):
|
|
super().__init__(CP, CP_SP, CI)
|
|
self.sat_check_min_speed = 5.
|
|
|
|
def update(self, active, CS, VM, params, steer_limited_by_controls, desired_curvature, calibrated_pose, curvature_limited):
|
|
angle_log = log.ControlsState.LateralAngleState.new_message()
|
|
|
|
if not active:
|
|
angle_log.active = False
|
|
angle_steers_des = float(CS.steeringAngleDeg)
|
|
else:
|
|
angle_log.active = True
|
|
angle_steers_des = math.degrees(VM.get_steer_from_curvature(-desired_curvature, CS.vEgo, params.roll))
|
|
angle_steers_des += params.angleOffsetDeg
|
|
|
|
angle_control_saturated = abs(angle_steers_des - CS.steeringAngleDeg) > STEER_ANGLE_SATURATION_THRESHOLD
|
|
angle_log.saturated = bool(self._check_saturation(angle_control_saturated, CS, False, curvature_limited))
|
|
angle_log.steeringAngleDeg = float(CS.steeringAngleDeg)
|
|
angle_log.steeringAngleDesiredDeg = angle_steers_des
|
|
return 0, float(angle_steers_des), angle_log
|