mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-02 18:15:35 +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
57 lines
2.3 KiB
Python
57 lines
2.3 KiB
Python
from openpilot.common.parameterized import parameterized
|
|
|
|
from openpilot.cereal import log
|
|
from opendbc.car.structs import car
|
|
from opendbc.car.car_helpers import interfaces
|
|
from opendbc.car.honda.values import CAR as HONDA
|
|
from opendbc.car.toyota.values import CAR as TOYOTA
|
|
from opendbc.car.nissan.values import CAR as NISSAN
|
|
from opendbc.car.gm.values import CAR as GM
|
|
from opendbc.car.vehicle_model import VehicleModel
|
|
from openpilot.common.realtime import DT_CTRL
|
|
from openpilot.selfdrive.car.helpers import convert_to_capnp
|
|
from openpilot.selfdrive.controls.lib.latcontrol_pid import LatControlPID
|
|
from openpilot.selfdrive.controls.lib.latcontrol_torque import LatControlTorque
|
|
from openpilot.selfdrive.controls.lib.latcontrol_angle import LatControlAngle
|
|
from openpilot.selfdrive.locationd.helpers import Pose
|
|
from openpilot.common.mock.generators import generate_livePose
|
|
from openpilot.sunnypilot.selfdrive.car import interfaces as sunnypilot_interfaces
|
|
|
|
|
|
class TestLatControl:
|
|
|
|
@parameterized.expand([(HONDA.HONDA_CIVIC, LatControlPID), (TOYOTA.TOYOTA_RAV4, LatControlTorque),
|
|
(NISSAN.NISSAN_LEAF, LatControlAngle), (GM.CHEVROLET_BOLT_EUV, LatControlTorque)])
|
|
def test_saturation(self, car_name, controller):
|
|
CarInterface = interfaces[car_name]
|
|
CP = CarInterface.get_non_essential_params(car_name)
|
|
CP_SP = CarInterface.get_non_essential_params_sp(CP, car_name)
|
|
CI = CarInterface(CP, CP_SP)
|
|
sunnypilot_interfaces.setup_interfaces(CI)
|
|
CP_SP = convert_to_capnp(CP_SP)
|
|
VM = VehicleModel(CP)
|
|
|
|
controller = controller(CP.as_reader(), CP_SP.as_reader(), CI, DT_CTRL)
|
|
|
|
CS = car.CarState.new_message()
|
|
CS.vEgo = 30
|
|
CS.steeringPressed = False
|
|
|
|
params = log.LiveParametersData.new_message()
|
|
|
|
lp = generate_livePose()
|
|
pose = Pose.from_live_pose(lp.livePose)
|
|
|
|
# Saturate for curvature limited and controller limited
|
|
for _ in range(1000):
|
|
_, _, lac_log = controller.update(True, CS, VM, params, False, 0, pose, True, 0.2)
|
|
assert lac_log.saturated
|
|
|
|
for _ in range(1000):
|
|
_, _, lac_log = controller.update(True, CS, VM, params, False, 0, pose, False, 0.2)
|
|
assert not lac_log.saturated
|
|
|
|
for _ in range(1000):
|
|
_, _, lac_log = controller.update(True, CS, VM, params, False, 1, pose, False, 0.2)
|
|
assert lac_log.saturated
|