From 989d898a4fd22fba00fed070f5a8b8c952a49a9f Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 13 Aug 2024 23:50:05 -0700 Subject: [PATCH] and these --- selfdrive/car/tests/test_car_interfaces.py | 19 +++++++++---------- selfdrive/car/toyota/values.py | 4 ++-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/selfdrive/car/tests/test_car_interfaces.py b/selfdrive/car/tests/test_car_interfaces.py index 789241a420..0833fe0df6 100644 --- a/selfdrive/car/tests/test_car_interfaces.py +++ b/selfdrive/car/tests/test_car_interfaces.py @@ -83,16 +83,15 @@ class TestCarInterfaces: # Lateral sanity checks if car_params.steerControlType != CarParams.SteerControlType.angle: tune = car_params.lateralTuning - # TODO: we use which again, this is wrong - if isinstance(tune, CarParams.LateralPIDTuning): + if tune.which() == 'pid': if car_name != MOCK.MOCK: - assert not math.isnan(tune.kf) and tune.kf > 0 - assert len(tune.kpV) > 0 and len(tune.kpV) == len(tune.kpBP) - assert len(tune.kiV) > 0 and len(tune.kiV) == len(tune.kiBP) + assert not math.isnan(tune.pid.kf) and tune.pid.kf > 0 + assert len(tune.pid.kpV) > 0 and len(tune.pid.kpV) == len(tune.pid.kpBP) + assert len(tune.pid.kiV) > 0 and len(tune.pid.kiV) == len(tune.pid.kiBP) - elif isinstance(tune, CarParams.LateralTorqueTuning): - assert not math.isnan(tune.kf) and tune.kf > 0 - assert not math.isnan(tune.friction) and tune.friction > 0 + elif tune.which() == 'torque': + assert not math.isnan(tune.torque.kf) and tune.torque.kf > 0 + assert not math.isnan(tune.torque.friction) and tune.torque.friction > 0 cc_msg = FuzzyGenerator.get_random_msg(data.draw, car.CarControl, real_floats=True) # Run car interface @@ -118,9 +117,9 @@ class TestCarInterfaces: LongControl(car_params) if car_params.steerControlType == CarParams.SteerControlType.angle: LatControlAngle(car_params, car_interface) - elif isinstance(car_params.lateralTuning, CarParams.LateralPIDTuning): + elif car_params.lateralTuning.which() == 'pid': LatControlPID(car_params, car_interface) - elif isinstance(car_params.lateralTuning, CarParams.LateralTorqueTuning): + elif car_params.lateralTuning.which() == 'torque': LatControlTorque(car_params, car_interface) # Test radar interface diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index 8ac94fb41c..f032a1ba10 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -31,8 +31,8 @@ class CarControllerParams: ANGLE_RATE_LIMIT_UP = AngleRateLimit(speed_bp=[5, 25], angle_v=[0.3, 0.15]) ANGLE_RATE_LIMIT_DOWN = AngleRateLimit(speed_bp=[5, 25], angle_v=[0.36, 0.26]) - def __init__(self, CP: CarParams): - if isinstance(CP.lateralTuning, CarParams.LateralTorqueTuning): + def __init__(self, CP): + if CP.lateralTuning.which == 'torque': self.STEER_DELTA_UP = 15 # 1.0s time to peak torque self.STEER_DELTA_DOWN = 25 # always lower than 45 otherwise the Rav4 faults (Prius seems ok with 50) else: