all brands can be done like this

pull/31550/head
Justin Newberry 1 year ago
parent 27031ef91b
commit f96d08f11c
  1. 12
      selfdrive/car/interfaces.py
  2. 6
      selfdrive/car/subaru/interface.py

@ -4,7 +4,7 @@ import numpy as np
import tomllib import tomllib
from abc import abstractmethod, ABC from abc import abstractmethod, ABC
from enum import StrEnum from enum import StrEnum
from typing import Any, Dict, Optional, Tuple, List, Callable, NamedTuple from typing import Any, Dict, Optional, Tuple, List, Callable, NamedTuple, cast
from cereal import car from cereal import car
from openpilot.common.basedir import BASEDIR from openpilot.common.basedir import BASEDIR
@ -12,7 +12,7 @@ from openpilot.common.conversions import Conversions as CV
from openpilot.common.simple_kalman import KF1D, get_kalman_gain from openpilot.common.simple_kalman import KF1D, get_kalman_gain
from openpilot.common.numpy_fast import clip from openpilot.common.numpy_fast import clip
from openpilot.common.realtime import DT_CTRL from openpilot.common.realtime import DT_CTRL
from openpilot.selfdrive.car import apply_hysteresis, gen_empty_fingerprint, scale_rot_inertia, scale_tire_stiffness, STD_CARGO_KG from openpilot.selfdrive.car import PlatformConfig, apply_hysteresis, gen_empty_fingerprint, scale_rot_inertia, scale_tire_stiffness, STD_CARGO_KG
from openpilot.selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX, get_friction from openpilot.selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX, get_friction
from openpilot.selfdrive.controls.lib.events import Events from openpilot.selfdrive.controls.lib.events import Events
from openpilot.selfdrive.controls.lib.vehicle_model import VehicleModel from openpilot.selfdrive.controls.lib.vehicle_model import VehicleModel
@ -111,6 +111,14 @@ class CarInterfaceBase(ABC):
ret = CarInterfaceBase.get_std_params(candidate) ret = CarInterfaceBase.get_std_params(candidate)
ret = cls._get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs) ret = cls._get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs)
if hasattr(candidate, "config"):
platform_config = cast(PlatformConfig, candidate.config)
if platform_config.specs is not None:
ret.mass = platform_config.specs.mass
ret.wheelbase = platform_config.specs.wheelbase
ret.steerRatio = platform_config.specs.steerRatio
ret.centerToFront = ret.wheelbase * 0.5
# Vehicle mass is published curb weight plus assumed payload such as a human driver; notCars have no assumed payload # Vehicle mass is published curb weight plus assumed payload such as a human driver; notCars have no assumed payload
if not ret.notCar: if not ret.notCar:
ret.mass = ret.mass + STD_CARGO_KG ret.mass = ret.mass + STD_CARGO_KG

@ -40,12 +40,6 @@ class CarInterface(CarInterfaceBase):
else: else:
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
platform_config = CAR(candidate).config
ret.mass = platform_config.specs.mass
ret.wheelbase = platform_config.specs.wheelbase
ret.steerRatio = platform_config.specs.steerRatio
ret.centerToFront = ret.wheelbase * 0.5
if candidate in (CAR.ASCENT, CAR.ASCENT_2023): if candidate in (CAR.ASCENT, CAR.ASCENT_2023):
ret.steerActuatorDelay = 0.3 # end-to-end angle controller ret.steerActuatorDelay = 0.3 # end-to-end angle controller
ret.lateralTuning.init('pid') ret.lateralTuning.init('pid')

Loading…
Cancel
Save