Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toyota: use platform config #31607

Merged
merged 39 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b99584a
part 1. Toyota platform config
sshane Feb 27, 2024
02194be
more
sshane Feb 27, 2024
6b94b71
everything works now
sshane Feb 27, 2024
639624e
no more DBC
sshane Feb 27, 2024
abbc4c2
janky but that saves a lot of car lines
sshane Feb 27, 2024
2773d07
need to init inside values or else it won't be reliable
sshane Feb 27, 2024
31ef9e3
no return
sshane Feb 27, 2024
dd25b70
fixes
sshane Feb 27, 2024
b592eb7
Merge remote-tracking branch 'upstream/master' into toyota-pc
sshane Feb 29, 2024
854434d
Merge remote-tracking branch 'upstream/master' into toyota-pc
sshane Feb 29, 2024
4c6d5be
minor update
sshane Feb 29, 2024
726b921
common flags, no dbc grouping
sshane Feb 29, 2024
30ab584
some clean up
sshane Feb 29, 2024
32cc965
some clean up
sshane Feb 29, 2024
2bfd681
rename
sshane Feb 29, 2024
57d237c
copied wrong :(
sshane Feb 29, 2024
b507037
another
sshane Feb 29, 2024
4c6df8e
copied specs for easiest ones first
sshane Feb 29, 2024
32771ba
second easiest
sshane Feb 29, 2024
4ad9492
fix erroneous commas
sshane Feb 29, 2024
bd63bea
more clean up
sshane Feb 29, 2024
1fa4040
do the rest
sshane Feb 29, 2024
2966605
bug
sshane Feb 29, 2024
43886c1
the refactor is so error prone
sshane Feb 29, 2024
0f5840d
huh?!
sshane Feb 29, 2024
2a5bd5b
Merge remote-tracking branch 'upstream/master' into toyota-pc
sshane Mar 1, 2024
c8f5751
static
sshane Mar 1, 2024
d14d2fc
fix stiffness factor
sshane Mar 1, 2024
9b72de6
detect unsupported DSU
sshane Mar 1, 2024
3cb185d
Revert "detect unsupported DSU"
sshane Mar 1, 2024
0052d6c
fix DBC diff
sshane Mar 1, 2024
b029716
test carparams
sshane Mar 1, 2024
62402f9
test sets
sshane Mar 1, 2024
de08daa
scratch
sshane Mar 1, 2024
25c4394
catches this
sshane Mar 1, 2024
e572d4a
Revert "scratch"
sshane Mar 1, 2024
8339251
Revert "test sets"
sshane Mar 1, 2024
e8f66f6
Revert "test carparams"
sshane Mar 1, 2024
361d372
Update ref_commit
sshane Mar 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions selfdrive/car/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,25 +248,29 @@ def update(self, current_value, current_counter):

@dataclass(frozen=True, kw_only=True)
class CarSpecs:
mass: float
wheelbase: float
mass: float # kg
wheelbase: float # m
steerRatio: float
centerToFrontRatio: float = field(default=0.5)
minSteerSpeed: float = field(default=0.)
minEnableSpeed: float = field(default=-1.)
minSteerSpeed: float = field(default=0.) # m/s
minEnableSpeed: float = field(default=-1.) # m/s
tireStiffnessFactor: float = field(default=1.)


@dataclass(frozen=True, order=True)
@dataclass(order=True)
class PlatformConfig:
platform_str: str
car_info: CarInfos
dbc_dict: DbcDict
dbc_dict: DbcDict = None # needs a test

specs: CarSpecs | None = None

def __hash__(self) -> int:
return hash(self.platform_str)

def init_config(self):
pass


class Platforms(str, ReprEnum):
config: PlatformConfig
Expand All @@ -277,6 +281,10 @@ def __new__(cls, platform_config: PlatformConfig):
member._value_ = platform_config.platform_str
return member

@classmethod
def init_configs(cls):
[p.config.init_config() for p in cls]

@classmethod
def create_dbc_map(cls) -> dict[str, DbcDict]:
return {p: p.config.dbc_dict for p in cls}
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/ford/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def init_make(self, CP: car.CarParams):
self.car_parts = CarParts([Device.threex, harness])


@dataclass(frozen=True)
@dataclass(frozen=False)
class FordPlatformConfig(PlatformConfig):
dbc_dict: DbcDict = field(default_factory=lambda: dbc_dict('ford_lincoln_base_pt', RADAR.DELPHI_MRR))

Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/gm/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def init_make(self, CP: car.CarParams):
self.footnotes.append(Footnote.OBD_II)


@dataclass(frozen=True)
@dataclass(frozen=False)
class GMPlatformConfig(PlatformConfig):
dbc_dict: DbcDict = field(default_factory=lambda: dbc_dict('gm_global_a_powertrain_generated', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'))

Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/subaru/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def init_make(self, CP: car.CarParams):
self.footnotes.append(Footnote.EXP_LONG)


@dataclass(frozen=True)
@dataclass(frozen=False)
class SubaruPlatformConfig(PlatformConfig):
dbc_dict: DbcDict = field(default_factory=lambda: dbc_dict('subaru_global_2017_generated', None))

Expand Down
7 changes: 7 additions & 0 deletions selfdrive/car/tests/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from openpilot.selfdrive.car.honda.values import CAR as HONDA
from openpilot.selfdrive.debug.dump_car_info import dump_car_info
from openpilot.selfdrive.debug.print_docs_diff import print_car_info_diff
from openpilot.selfdrive.car.values import PLATFORMS


class TestCarDocs(unittest.TestCase):
Expand All @@ -26,6 +27,12 @@ def test_generator(self):
self.assertEqual(generated_cars_md, current_cars_md,
"Run selfdrive/car/docs.py to update the compatibility documentation")

def test_platforms(self):
sshane marked this conversation as resolved.
Show resolved Hide resolved
for platform in PLATFORMS.values():
if hasattr(platform, "config"):
self.assertIsNotNone(platform.config)
self.assertIsNotNone(platform.config.dbc_dict)

def test_docs_diff(self):
dump_path = os.path.join(BASEDIR, "selfdrive", "car", "tests", "cars_dump")
dump_car_info(dump_path)
Expand Down
Loading
Loading