mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-24 04:23:47 +08:00
14318d2f09
# Conflicts: # .github/labeler.yaml # .github/workflows/auto_pr_review.yaml # .github/workflows/docs.yaml # .github/workflows/release.yaml # .github/workflows/repo-maintenance.yaml # .github/workflows/tests.yaml # .github/workflows/ui_preview.yaml # README.md # SConstruct # conftest.py # docs/CARS.md # msgq_repo # opendbc_repo # openpilot/cereal/messaging/tests/validate_sp_cereal_upstream.py # openpilot/common/api.py # openpilot/common/hardware/hw.py # openpilot/common/version.py # openpilot/selfdrive/assets/fonts/Audiowide-Regular.ttf # openpilot/selfdrive/assets/sounds/prompt_single_high.wav # openpilot/selfdrive/assets/sounds/prompt_single_low.wav # openpilot/selfdrive/car/card.py # openpilot/selfdrive/car/helpers.py # openpilot/selfdrive/car/tests/test_car_interfaces.py # openpilot/selfdrive/car/tests/test_cruise_speed.py # openpilot/selfdrive/controls/lib/desire_helper.py # openpilot/selfdrive/controls/lib/longcontrol.py # openpilot/selfdrive/controls/plannerd.py # openpilot/selfdrive/controls/radard.py # openpilot/selfdrive/controls/tests/test_longcontrol.py # openpilot/selfdrive/modeld/compile_warp.py # openpilot/selfdrive/modeld/modeld.py # openpilot/selfdrive/monitoring/policy.py # openpilot/selfdrive/monitoring/test_monitoring.py # openpilot/selfdrive/selfdrived/events.py # openpilot/selfdrive/selfdrived/selfdrived.py # openpilot/selfdrive/ui/layouts/onboarding.py # openpilot/selfdrive/ui/mici/layouts/onboarding.py # openpilot/selfdrive/ui/soundd.py # openpilot/selfdrive/ui/tests/diff/replay.py # openpilot/selfdrive/ui/translations/app.pot # openpilot/system/athena/athenad.py # openpilot/system/athena/manage_athenad.py # openpilot/system/hardware/hardwared.py # openpilot/system/loggerd/config.py # openpilot/system/manager/github_runner.sh # openpilot/system/manager/manager.py # openpilot/system/updated/updated.py # panda # pyproject.toml # scripts/lint/lint.sh # system/manager/process_config.py # system/statsd.py # tinygrad_repo # tools/release/build_release.sh # tools/release/build_stripped.sh # uv.lock
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
import numpy as np
|
|
from abc import abstractmethod, ABC
|
|
from openpilot.selfdrive.locationd.helpers import Pose
|
|
|
|
|
|
class LatControl(ABC):
|
|
def __init__(self, CP, CP_SP, CI, dt):
|
|
self.dt = dt
|
|
self.sat_limit = CP.steerLimitTimer
|
|
self.sat_time = 0.
|
|
self.sat_check_min_speed = 10.
|
|
|
|
# we define the steer torque scale as [-1.0...1.0]
|
|
self.steer_max = 1.0
|
|
|
|
@abstractmethod
|
|
def update(self, active: bool, CS, VM, params, steer_limited_by_safety: bool, desired_curvature: float, calibrated_pose: Pose,
|
|
curvature_limited: bool, lat_delay: float):
|
|
pass
|
|
|
|
def reset(self):
|
|
self.sat_time = 0.
|
|
|
|
def _check_saturation(self, saturated, CS, steer_limited_by_safety, curvature_limited):
|
|
# Saturated only if control output is not being limited by car torque/angle rate limits
|
|
if (saturated or curvature_limited) and CS.vEgo > self.sat_check_min_speed and not steer_limited_by_safety and not CS.steeringPressed:
|
|
self.sat_time += self.dt
|
|
else:
|
|
self.sat_time -= self.dt
|
|
self.sat_time = np.clip(self.sat_time, 0.0, self.sat_limit)
|
|
return self.sat_time > (self.sat_limit - 1e-3)
|