From 7d75f4bfc086badfea6009a52a3fdc7946f7a7da Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Thu, 20 Mar 2025 16:11:49 -0400 Subject: [PATCH] update name and expose toggle --- common/params_keys.h | 2 +- selfdrive/controls/controlsd.py | 4 ++++ selfdrive/ui/qt/offroad/developer_panel.cc | 2 ++ sunnypilot/selfdrive/controls/lib/latcontrol_torque_ext.py | 4 ++-- .../selfdrive/controls/lib/latcontrol_torque_lat_accel.py | 4 ++-- system/manager/manager.py | 2 +- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/common/params_keys.h b/common/params_keys.h index ba42469981..fb248e68b6 100644 --- a/common/params_keys.h +++ b/common/params_keys.h @@ -125,7 +125,7 @@ inline static std::unordered_map keys = { {"CarParamsSPPersistent", PERSISTENT}, {"CarPlatformBundle", PERSISTENT}, {"EnableGithubRunner", PERSISTENT | BACKUP}, - {"LateralTorqueControlLateralJerk", PERSISTENT | BACKUP}, + {"LateralTorqueControlEnhancedLateralAccel", PERSISTENT | BACKUP}, {"ModelRunnerTypeCache", CLEAR_ON_ONROAD_TRANSITION}, {"OffroadMode", CLEAR_ON_MANAGER_START}, {"OffroadMode_Status", CLEAR_ON_MANAGER_START}, diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 294722c06a..5d917bc27e 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -118,6 +118,10 @@ class Controls: if not CC.longActive: self.LoC.reset() + # Neural Network Lateral Control + if self.CP_SP.neuralNetworkLateralControl.enabled or self.params.get_bool("LateralTorqueControlEnhancedLateralAccel"): + self.LaC.extension.update_model_v2(model_v2) + # accel PID loop pid_accel_limits = self.CI.get_pid_accel_limits(self.CP, CS.vEgo, CS.vCruise * CV.KPH_TO_MS) actuators.accel = float(self.LoC.update(CC.longActive, CS, long_plan.aTarget, long_plan.shouldStop, pid_accel_limits)) diff --git a/selfdrive/ui/qt/offroad/developer_panel.cc b/selfdrive/ui/qt/offroad/developer_panel.cc index 746ef5961c..d1a3250205 100644 --- a/selfdrive/ui/qt/offroad/developer_panel.cc +++ b/selfdrive/ui/qt/offroad/developer_panel.cc @@ -60,6 +60,8 @@ DeveloperPanel::DeveloperPanel(SettingsWindow *parent) : ListWidget(parent) { #if SUNNYPILOT neuralNetworkLateralControlToggle = neuralNetworkLateralControl.toggle; addItem(neuralNetworkLateralControlToggle); + auto latControlTorqueCustomLatAccel = new ParamControl("LateralTorqueControlEnhancedLateralAccel", tr("Enhanced Lateral Acceleration"), "", ""); + addItem(latControlTorqueCustomLatAccel); #endif enableGithubRunner = new ParamControl("EnableGithubRunner", tr("Enable GitHub runner service"), tr("Enables or disables the github runner service."), ""); diff --git a/sunnypilot/selfdrive/controls/lib/latcontrol_torque_ext.py b/sunnypilot/selfdrive/controls/lib/latcontrol_torque_ext.py index 409e1f09a4..c19ea54404 100644 --- a/sunnypilot/selfdrive/controls/lib/latcontrol_torque_ext.py +++ b/sunnypilot/selfdrive/controls/lib/latcontrol_torque_ext.py @@ -5,11 +5,11 @@ This file is part of sunnypilot and is licensed under the MIT License. See the LICENSE.md file in the root directory for more details. """ -from openpilot.sunnypilot.selfdrive.controls.lib.latcontrol_torque_lat_accel import LatControlTorqueCustomLateralAccel +from openpilot.sunnypilot.selfdrive.controls.lib.latcontrol_torque_lat_accel import LatControlTorqueEnhancedLateralAccel from openpilot.sunnypilot.selfdrive.controls.lib.nnlc.nnlc import NeuralNetworkLateralControl -class LatControlTorqueExt(NeuralNetworkLateralControl, LatControlTorqueCustomLateralAccel): +class LatControlTorqueExt(NeuralNetworkLateralControl, LatControlTorqueEnhancedLateralAccel): def __init__(self, lac_torque, CP, CP_SP): super().__init__(lac_torque, CP, CP_SP) diff --git a/sunnypilot/selfdrive/controls/lib/latcontrol_torque_lat_accel.py b/sunnypilot/selfdrive/controls/lib/latcontrol_torque_lat_accel.py index 9b8a0a12c5..35c243dab7 100644 --- a/sunnypilot/selfdrive/controls/lib/latcontrol_torque_lat_accel.py +++ b/sunnypilot/selfdrive/controls/lib/latcontrol_torque_lat_accel.py @@ -10,11 +10,11 @@ from openpilot.common.params import Params from openpilot.sunnypilot.selfdrive.controls.lib.latcontrol_torque_ext_base import LatControlTorqueExtBase -class LatControlTorqueCustomLateralAccel(LatControlTorqueExtBase): +class LatControlTorqueEnhancedLateralAccel(LatControlTorqueExtBase): def __init__(self, lac_torque, CP, CP_SP): super().__init__(lac_torque, CP, CP_SP) self.params = Params() # TODO-SP: unused after moving the param to cereal - self.use_lateral_jerk: bool = self.params.get_bool("LateralTorqueControlLateralJerk") # TODO-SP: move this to cereal + self.use_lateral_jerk: bool = self.params.get_bool("LateralTorqueControlEnhancedLateralAccel") # TODO-SP: move this to cereal def update_custom_lateral_acceleration(self, CS, roll_compensation, gravity_adjusted_lateral_accel): if not self.use_lateral_jerk: diff --git a/system/manager/manager.py b/system/manager/manager.py index 785eb50bcb..11fe552c2b 100755 --- a/system/manager/manager.py +++ b/system/manager/manager.py @@ -44,7 +44,7 @@ def manager_init() -> None: sunnypilot_default_params: list[tuple[str, str | bytes]] = [ ("DynamicExperimentalControl", "0"), - ("LateralTorqueControlLateralJerk", "0"), + ("LateralTorqueControlEnhancedLateralAccel", "0"), ("Mads", "1"), ("MadsMainCruiseAllowed", "1"), ("MadsSteeringMode", "0"),