Skip to content

Commit

Permalink
more refactor/cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jyoung8607 committed Sep 27, 2024
1 parent 8fa5d58 commit 59cc222
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 27 deletions.
14 changes: 12 additions & 2 deletions opendbc/car/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from collections import namedtuple
from dataclasses import dataclass
from enum import IntFlag, ReprEnum, EnumType
from dataclasses import replace
from dataclasses import replace, field

from panda import uds
from opendbc.car import structs
from opendbc.car.can_definitions import CanData
from opendbc.car.docs_definitions import CarDocs
from opendbc.car.docs_definitions import CarDocs, OtherCarDocs
from opendbc.car.common.numpy_fast import clip, interp

# set up logging
Expand Down Expand Up @@ -321,3 +321,13 @@ def create_dbc_map(cls) -> dict[str, DbcDict]:
@classmethod
def with_flags(cls, flags: IntFlag) -> set['Platforms']:
return {p for p in cls if p.config.flags & flags}



@dataclass(order=True)
class OtherPlatformConfig(PlatformConfig):
car_docs: list[OtherCarDocs]
specs: CarSpecs | None = None
dbc_dict: DbcDict = field(default_factory=lambda: dbc_dict('unknown', None))
flags = 0
platform_str = "Unknown"
2 changes: 1 addition & 1 deletion opendbc/car/body/values.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from opendbc.car import CarSpecs, PlatformConfig, Platforms, dbc_dict
from opendbc.car.structs import CarParams
from opendbc.car.docs_definitions import CarDocs, SupportType
from opendbc.car.docs_definitions import CarDocs
from opendbc.car.fw_query_definitions import FwQueryConfig, Request, StdQueries

Ecu = CarParams.Ecu
Expand Down
2 changes: 0 additions & 2 deletions opendbc/car/docs_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from dataclasses import dataclass, field
from enum import Enum

from mypy.typeops import supported_self_type

from opendbc.car.common.conversions import Conversions as CV
from opendbc.car.structs import CarParams

Expand Down
27 changes: 5 additions & 22 deletions opendbc/car/other_cars.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,16 @@
from dataclasses import dataclass, field
from dataclasses import dataclass
from enum import Enum

from opendbc.car import dbc_dict, structs, CarSpecs, DbcDict, PlatformConfig, Platforms
from opendbc.car import structs, Platforms, OtherPlatformConfig
from opendbc.car.docs_definitions import CarFootnote, OtherCarDocs, Column, SupportType


@dataclass
class OtherPlatformConfig(PlatformConfig):
dbc_dict: DbcDict = field(default_factory=lambda: dbc_dict('unknown', None))


@dataclass(frozen=True, kw_only=True)
class OtherCarSpecs(CarSpecs):
# FIXME: Need to be able to print these as N/A or Unknown or whatever, try to eliminate entirely
steerRatio: float = 0.


@dataclass
class CommunityCarDocs(OtherCarDocs):
def init_make(self, CP: structs.CarParams):
self.support_type = SupportType.COMMUNITY


@dataclass
class IncompatibleCarDocs(OtherCarDocs):
def init_make(self, CP: structs.CarParams):
self.support_type = SupportType.INCOMPATIBLE


@dataclass
class ToyotaSecurityCarDocs(OtherCarDocs):
def init_make(self, CP: structs.CarParams):
Expand Down Expand Up @@ -57,7 +40,7 @@ class CAR(Platforms):
CommunityCarDocs("Hyundai Palisade 2023-24", package="All", footnotes=[Footnote.UNDER_REVIEW]),
CommunityCarDocs("Kia Telluride 2023-24", package="All", footnotes=[Footnote.UNDER_REVIEW]),
],
OtherCarSpecs(mass=0., wheelbase=0.), # TODO: Don't require CarSpecs for unsupported cars
None,
)

TOYOTA_SECURITY_CARS = OtherPlatformConfig(
Expand All @@ -76,7 +59,7 @@ class CAR(Platforms):
ToyotaSecurityCarDocs("Toyota Tundra 2022-25"),
ToyotaSecurityCarDocs("Toyota Venza 2021-25"),
],
OtherCarSpecs(mass=0., wheelbase=0.), # TODO: Don't require CarSpecs for unsupported cars
None,
)

AUDI_FLEXRAY = OtherPlatformConfig(
Expand All @@ -85,5 +68,5 @@ class CAR(Platforms):
FlexRayCarDocs("Audi A5 2016-24", package="All"),
FlexRayCarDocs("Audi Q5 2017-24", package="All"),
],
OtherCarSpecs(mass=0., wheelbase=0.), # TODO: Don't require CarSpecs for unsupported cars
None,
)

0 comments on commit 59cc222

Please sign in to comment.