Compare commits

..

1 Commits

Author SHA1 Message Date
Jason Wen 7fde95c2e4 NNLC: keep own PID in torque extension 2026-11-29 01:27:31 -05:00
8 changed files with 39 additions and 14 deletions
@@ -194,7 +194,7 @@ jobs:
find . -name '__pycache__' -type d -exec rm -rf {} +
find . -name 'SConstruct' -delete
find . -name 'SConscript' -delete
rm -rf .sconsign.dblite tools/release/ release/
rm -rf .sconsign.dblite Jenkinsfile tools/release/ release/
rm -f openpilot/selfdrive/modeld/models/*.onnx*
rm -f openpilot/sunnypilot/modeld*/models/*.onnx*
find openpilot/third_party/ -name '*x86*' -exec rm -r {} +
@@ -3,6 +3,8 @@ name: Build dev
env:
DEFAULT_SOURCE_BRANCH: "master"
DEFAULT_TARGET_BRANCH: "master-dev"
LFS_URL: 'https://gitlab.com/sunnypilot/public/sunnypilot-new-lfs.git/info/lfs'
LFS_PUSH_URL: 'ssh://git@gitlab.com/sunnypilot/public/sunnypilot-new-lfs.git'
on:
push:
@@ -64,6 +66,15 @@ jobs:
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Set up SSH
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Add GitLab public keys
run: |
ssh-keyscan -H gitlab.com >> ~/.ssh/known_hosts
- name: Set up Python
uses: actions/setup-python@v5
with:
@@ -156,6 +167,13 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update LFS Config
run: |
echo '[lfs]' > .lfsconfig
echo ' url = ${{ env.LFS_URL }}' >> .lfsconfig
echo ' pushurl = ${{ env.LFS_PUSH_URL }}' >> .lfsconfig
echo ' locksverify = false' >> .lfsconfig
- name: Restore workflows from source
run: |
TARGET_BRANCH="${{ inputs.target_branch || env.DEFAULT_TARGET_BRANCH }}"
+4
View File
@@ -0,0 +1,4 @@
[lfs]
url = https://gitlab.com/commaai/openpilot-lfs.git/info/lfs
pushurl = ssh://git@gitlab.com/commaai/openpilot-lfs.git
locksverify = false
+1 -7
View File
@@ -52,13 +52,7 @@ std::vector<std::string> PandaSafety::fetchCarParams() {
if (!params_.getBool("ControlsReady")) {
return {};
}
std::string car_params = params_.get("CarParams");
std::string car_params_sp = params_.get("CarParamsSP");
if (car_params.empty() || car_params_sp.empty()) {
return {};
}
return {car_params, car_params_sp};
return {params_.get("CarParams"), params_.get("CarParamsSP")};
}
// TODO-SP: Use structs instead of vector
@@ -18,7 +18,6 @@ class LatControlTorqueExt(NeuralNetworkLateralControl, LatControlTorqueExtOverri
desired_lateral_accel, actual_lateral_accel, lateral_accel_deadzone, gravity_adjusted_lateral_accel,
desired_curvature, actual_curvature, steer_limited_by_safety, output_torque):
self._ff = ff
self._pid = pid
self._pid_log = pid_log
self._setpoint = setpoint
self._measurement = measurement
@@ -63,7 +63,7 @@ class LatControlTorqueExtBase:
self.torque_params = lac_torque.torque_params
self._ff = 0.0
self._pid = PIDController(KP, KI)
self._pid = PIDController(KP, KI, pos_limit=lac_torque.steer_max, neg_limit=-lac_torque.steer_max, rate=1 / lac_torque.dt)
self._pid_log = log.ControlsState.LateralTorqueState.new_message()
self._setpoint = 0.0
self._measurement = 0.0
@@ -4,6 +4,7 @@ Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
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.
"""
import math
import numpy as np
from openpilot.cereal import log, messaging
@@ -59,9 +60,9 @@ def _make_model_v2():
return model
def _run_update(controller, VM):
def _run_update(controller, VM, v_ego=30, desired_curvature=0.5):
CS = car.CarState.new_message()
CS.vEgo = 30
CS.vEgo = v_ego
CS.steeringPressed = False
lp = generate_deviceMotion()
pose = Pose.from_device_motion(lp.deviceMotion)
@@ -69,7 +70,7 @@ def _run_update(controller, VM):
model_v2 = _make_model_v2().modelV2
controller.extension.update_model_v2(model_v2)
controller.extension.update_lateral_lag(0.2)
return controller.update(True, CS, VM, params, False, 0.5, pose, False, 0.2)
return controller.update(True, CS, VM, params, False, desired_curvature, pose, False, 0.2)
class TestLatControlTorqueExt(OpenpilotTestCase):
@@ -107,3 +108,12 @@ class TestLatControlTorqueExt(OpenpilotTestCase):
controller, VM, _ = _make_controller(enhanced=True, nnlc=True)
output_torque, _, pid_log = _run_update(controller, VM)
assert pid_log.active
def test_low_speed_gain_bounded(self):
for kwargs in ({"nnlc": True}, {"enhanced": True}):
controller, VM, _ = _make_controller(**kwargs)
one_degree = -VM.calc_curvature(math.radians(1.0), 2.0, 0.0)
output_torque, _, _ = _run_update(controller, VM, v_ego=2.0, desired_curvature=one_degree)
assert controller.extension._nnlc_enabled or controller.extension._jerk_aware_enabled
assert controller.extension._pid is not controller.pid
assert abs(output_torque) < 0.3, kwargs
+1 -1
View File
@@ -102,7 +102,7 @@ def generate_model(driving_pkl: Path) -> dict:
artifact_data = {
"file_name": driving_pkl.name,
"download_uri": {
"url": "",
"url": "https://gitlab.com/sunnypilot/public/docs.sunnypilot.ai/-/raw/main/",
"sha256": tinygrad_hash
}
}