diff --git a/.importlinter b/.importlinter index 5e96db4469..79f541ccb3 100644 --- a/.importlinter +++ b/.importlinter @@ -28,10 +28,6 @@ forbidden_modules = openpilot.teleoprtc openpilot.tinygrad ignore_imports = - # remove these - openpilot.selfdrive.car.gm.interface -> openpilot.common.basedir - openpilot.selfdrive.car.interfaces -> openpilot.common.basedir - # these are okay openpilot.selfdrive.car.card -> openpilot.common.swaglog openpilot.selfdrive.car.card -> openpilot.common.realtime diff --git a/selfdrive/car/common/basedir.py b/selfdrive/car/common/basedir.py new file mode 100644 index 0000000000..6b4811e53c --- /dev/null +++ b/selfdrive/car/common/basedir.py @@ -0,0 +1,4 @@ +import os + + +BASEDIR = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../")) diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index ae1689fe89..f19ce740ac 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -4,8 +4,8 @@ from typing import cast from math import fabs, exp from panda import Panda -from openpilot.common.basedir import BASEDIR from openpilot.selfdrive.car import get_safety_config, get_friction, structs +from openpilot.selfdrive.car.common.basedir import BASEDIR from openpilot.selfdrive.car.conversions import Conversions as CV from openpilot.selfdrive.car.gm.carstate import CarState from openpilot.selfdrive.car.gm.radar_interface import RADAR_HEADER_MSG @@ -21,7 +21,7 @@ NON_LINEAR_TORQUE_PARAMS = { CAR.CHEVROLET_SILVERADO: [3.29974374, 1.0, 0.25571356, 0.0465122] } -NEURAL_PARAMS_PATH = os.path.join(BASEDIR, 'selfdrive/car/torque_data/neural_ff_weights.json') +NEURAL_PARAMS_PATH = os.path.join(BASEDIR, 'torque_data/neural_ff_weights.json') class CarInterface(CarInterfaceBase): diff --git a/selfdrive/car/interfaces.py b/selfdrive/car/interfaces.py index 05150b0532..90aaec40b4 100644 --- a/selfdrive/car/interfaces.py +++ b/selfdrive/car/interfaces.py @@ -9,10 +9,10 @@ from typing import Any, NamedTuple from collections.abc import Callable from functools import cache -from openpilot.common.basedir import BASEDIR from openpilot.selfdrive.car import DT_CTRL, apply_hysteresis, gen_empty_fingerprint, scale_rot_inertia, scale_tire_stiffness, get_friction, STD_CARGO_KG from openpilot.selfdrive.car import structs from openpilot.selfdrive.car.can_definitions import CanData, CanRecvCallable, CanSendCallable +from openpilot.selfdrive.car.common.basedir import BASEDIR from openpilot.selfdrive.car.conversions import Conversions as CV from openpilot.selfdrive.car.common.simple_kalman import KF1D, get_kalman_gain from openpilot.selfdrive.car.common.numpy_fast import clip @@ -26,9 +26,9 @@ ACCEL_MAX = 2.0 ACCEL_MIN = -3.5 FRICTION_THRESHOLD = 0.3 -TORQUE_PARAMS_PATH = os.path.join(BASEDIR, 'selfdrive/car/torque_data/params.toml') -TORQUE_OVERRIDE_PATH = os.path.join(BASEDIR, 'selfdrive/car/torque_data/override.toml') -TORQUE_SUBSTITUTE_PATH = os.path.join(BASEDIR, 'selfdrive/car/torque_data/substitute.toml') +TORQUE_PARAMS_PATH = os.path.join(BASEDIR, 'torque_data/params.toml') +TORQUE_OVERRIDE_PATH = os.path.join(BASEDIR, 'torque_data/override.toml') +TORQUE_SUBSTITUTE_PATH = os.path.join(BASEDIR, 'torque_data/substitute.toml') GEAR_SHIFTER_MAP: dict[str, structs.CarState.GearShifter] = { 'P': GearShifter.park, 'PARK': GearShifter.park, @@ -400,7 +400,7 @@ def get_interface_attr(attr: str, combine_brands: bool = False, ignore_none: boo # - keys are all the car models or brand names # - values are attr values from all car folders result = {} - for car_folder in sorted([x[0] for x in os.walk(BASEDIR + '/selfdrive/car')]): + for car_folder in sorted([x[0] for x in os.walk(BASEDIR)]): try: brand_name = car_folder.split('/')[-1] brand_values = __import__(f'openpilot.selfdrive.car.{brand_name}.{INTERFACE_ATTR_FILE.get(attr, "values")}', fromlist=[attr]) diff --git a/tools/setup.sh b/tools/setup.sh index 2dc1144900..bc8e41a401 100755 --- a/tools/setup.sh +++ b/tools/setup.sh @@ -89,7 +89,7 @@ function ask_dir() { read if [[ ! -z "$REPLY" ]]; then mkdir -p $REPLY - OPENPILOT_ROOT="$(realpath $REPLY/openpilot)" + OPENPILOT_ROOT="$(realpath $REPLY)/openpilot" fi }