mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 20:03:53 +08:00
# Conflicts: # .github/workflows/release.yaml # README.md # RELEASES.md # common/params_keys.h # docs/CARS.md # opendbc_repo # panda # release/build_stripped.sh # selfdrive/controls/lib/longitudinal_planner.py # selfdrive/modeld/modeld.py # selfdrive/ui/feedback/feedbackd.py # selfdrive/ui/translations/main_ar.ts # selfdrive/ui/translations/main_de.ts # selfdrive/ui/translations/main_es.ts # selfdrive/ui/translations/main_fr.ts # selfdrive/ui/translations/main_ja.ts # selfdrive/ui/translations/main_ko.ts # selfdrive/ui/translations/main_pt-BR.ts # selfdrive/ui/translations/main_th.ts # selfdrive/ui/translations/main_tr.ts # selfdrive/ui/translations/main_zh-CHS.ts # selfdrive/ui/translations/main_zh-CHT.ts # system/version.py # uv.lock
55 lines
2.2 KiB
Python
55 lines
2.2 KiB
Python
from parameterized import parameterized
|
|
|
|
from cereal import car, log
|
|
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.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)
|
|
|
|
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)
|
|
assert lac_log.saturated
|
|
|
|
for _ in range(1000):
|
|
_, _, lac_log = controller.update(True, CS, VM, params, False, 0, pose, False)
|
|
assert not lac_log.saturated
|
|
|
|
for _ in range(1000):
|
|
_, _, lac_log = controller.update(True, CS, VM, params, False, 1, pose, False)
|
|
assert lac_log.saturated
|