Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 6 additions & 13 deletions opendbc/car/docs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python3
import argparse
import os
from typing import get_args

from collections import defaultdict
import jinja2
Expand All @@ -11,20 +10,14 @@
from opendbc.car.common.basedir import BASEDIR
from opendbc.car import gen_empty_fingerprint
from opendbc.car.structs import CarParams
from opendbc.car.docs_definitions import CarDocs, Device, ExtraCarDocs, Column, ExtraCarsColumn, CommonFootnote, PartType
from opendbc.car.docs_definitions import CarDocs, Device, Column, ExtraCarsColumn, CommonFootnote, PartType
from opendbc.car.car_helpers import interfaces, get_interface_attr
from opendbc.car.values import Platform, PLATFORMS
from opendbc.car.values import PLATFORMS
from opendbc.car.mock.values import CAR as MOCK
from opendbc.car.extra_cars import CAR as EXTRA


EXTRA_CARS_MD_OUT = os.path.join(BASEDIR, "../", "../", "docs", "CARS.md")
EXTRA_CARS_MD_TEMPLATE = os.path.join(BASEDIR, "CARS_template.md")

ExtraPlatform = Platform | EXTRA
EXTRA_BRANDS = get_args(ExtraPlatform)
EXTRA_PLATFORMS: dict[str, ExtraPlatform] = {str(platform): platform for brand in EXTRA_BRANDS for platform in brand}


def get_params_for_docs(platform) -> CarParams:
cp_platform = platform if platform in interfaces else MOCK.MOCK
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove this once done

Expand All @@ -42,7 +35,7 @@ def get_all_footnotes() -> dict[Enum, int]:


def build_sorted_car_docs_list(platforms, footnotes=None, include_dashcam=False):
collected_car_docs: list[CarDocs | ExtraCarDocs] = []
collected_car_docs: list[CarDocs] = []
for platform in platforms.values():
car_docs = platform.config.car_docs
CP = get_params_for_docs(platform)
Expand All @@ -69,8 +62,8 @@ def get_all_car_docs() -> list[CarDocs]:
return sorted_list


def get_car_docs_with_extras() -> list[CarDocs | ExtraCarDocs]:
sorted_list: list[CarDocs] = build_sorted_car_docs_list(EXTRA_PLATFORMS, include_dashcam=True)
def get_car_docs_with_extras() -> list[CarDocs]:
sorted_list: list[CarDocs] = build_sorted_car_docs_list(PLATFORMS, include_dashcam=True)
return sorted_list


Expand All @@ -93,7 +86,7 @@ def generate_cars_md(all_car_docs: list[CarDocs], template_fn: str) -> str:
return cars_md


def generate_cars_md_with_extras(car_docs_with_extras: list[CarDocs | ExtraCarDocs], template_fn: str) -> str:
def generate_cars_md_with_extras(car_docs_with_extras: list[CarDocs], template_fn: str) -> str:
with open(template_fn) as f:
template = jinja2.Template(f.read(), trim_blocks=True, lstrip_blocks=True)

Expand Down
3 changes: 3 additions & 0 deletions opendbc/car/docs_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ def init(self, CP: CarParams, all_footnotes=None):
self.brand = CP.brand
self.car_fingerprint = CP.carFingerprint

if self.support_type == SupportType.COMMUNITY:
self.support_link = "#community"

if self.merged and CP.dashcamOnly:
if self.support_type != SupportType.REVIEW:
self.support_type = SupportType.DASHCAM
Expand Down
5 changes: 0 additions & 5 deletions opendbc/car/extra_cars.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ class CAR(Platforms):
ToyotaSecurityCarDocs("Toyota Camry 2025"),
ToyotaSecurityCarDocs("Toyota Corolla Cross 2022-25"),
ToyotaSecurityCarDocs("Toyota Highlander 2025"),
CommunityCarDocs("Toyota RAV4 Prime 2021-23"),
ToyotaSecurityCarDocs("Toyota RAV4 Prime 2024-25"),
ToyotaSecurityCarDocs("Toyota Sequoia 2023-25"),
CommunityCarDocs("Toyota Sienna 2021-23"),
ToyotaSecurityCarDocs("Toyota Sienna 2024-25"),
ToyotaSecurityCarDocs("Toyota Tundra 2022-25"),
ToyotaSecurityCarDocs("Toyota Venza 2021-25"),
],
Expand Down
1 change: 1 addition & 0 deletions opendbc/car/tests/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
SUBARU.SUBARU_FORESTER_HYBRID,
TESLA.TESLA_MODEL_3,
TESLA.TESLA_MODEL_Y,
TOYOTA.TOYOTA_SEQUOIA,
]


Expand Down
3 changes: 3 additions & 0 deletions opendbc/car/torque_data/override.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ legend = ["LAT_ACCEL_FACTOR", "MAX_LAT_ACCEL_MEASURED", "FRICTION"]
"RIVIAN_R1_GEN1" = [2.8, 2.5, 0.07]
"HYUNDAI_NEXO_1ST_GEN" = [2.5, 2.5, 0.1]

# TODO: verify these
"TOYOTA_SEQUOIA" = [2.5, 2.5, 0.1]

# Dashcam or fallback configured as ideal car
"MOCK" = [10.0, 10, 0.0]

Expand Down
31 changes: 25 additions & 6 deletions opendbc/car/toyota/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from opendbc.car import Bus, CarSpecs, PlatformConfig, Platforms, AngleSteeringLimits
from opendbc.car.common.conversions import Conversions as CV
from opendbc.car.structs import CarParams
from opendbc.car.docs_definitions import CarFootnote, CarDocs, Column, CarParts, CarHarness
from opendbc.car.docs_definitions import CarFootnote, CarDocs, Column, CarParts, CarHarness, SupportType
from opendbc.car.fw_query_definitions import FwQueryConfig, Request, StdQueries

Ecu = CarParams.Ecu
Expand Down Expand Up @@ -87,9 +87,18 @@ class ToyotaCarDocs(CarDocs):
package: str = "All"
car_parts: CarParts = field(default_factory=CarParts.common([CarHarness.toyota_a]))


@dataclass
class ToyotaSecurityCarDocs(ToyotaCarDocs):
def init_make(self, CP: CarParams):
self.support_type = SupportType.INCOMPATIBLE
self.support_link = "#can-bus-security"


def dbc_dict(pt, radar):
return {Bus.pt: pt, Bus.radar: radar}


@dataclass
class ToyotaTSS2PlatformConfig(PlatformConfig):
dbc_dict: dict = field(default_factory=lambda: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'))
Expand All @@ -105,9 +114,6 @@ class ToyotaSecOCPlatformConfig(PlatformConfig):
dbc_dict: dict = field(default_factory=lambda: dbc_dict('toyota_secoc_pt_generated', 'toyota_tss2_adas'))

def init(self):
# don't expose car docs until SecOC cars can be suppressed from the comma website
self.car_docs = []

self.flags |= ToyotaFlags.TSS2 | ToyotaFlags.NO_STOP_TIMER | ToyotaFlags.NO_DSU | ToyotaFlags.SECOC

if self.flags & ToyotaFlags.RADAR_ACC:
Expand Down Expand Up @@ -278,7 +284,10 @@ class CAR(Platforms):
flags=ToyotaFlags.RADAR_ACC | ToyotaFlags.ANGLE_CONTROL,
)
TOYOTA_RAV4_PRIME = ToyotaSecOCPlatformConfig(
[ToyotaCarDocs("Toyota RAV4 Prime 2021-23", min_enable_speed=MIN_ACC_SPEED)],
[
ToyotaCarDocs("Toyota RAV4 Prime 2021-23", min_enable_speed=MIN_ACC_SPEED, support_type=SupportType.COMMUNITY),
ToyotaSecurityCarDocs("Toyota RAV4 Prime 2024-25"),
],
CarSpecs(mass=4372. * CV.LB_TO_KG, wheelbase=2.68, steerRatio=16.88, tireStiffnessFactor=0.5533),
)
TOYOTA_MIRAI = ToyotaTSS2PlatformConfig( # TSS 2.5
Expand All @@ -292,7 +301,10 @@ class CAR(Platforms):
flags=ToyotaFlags.NO_STOP_TIMER,
)
TOYOTA_SIENNA_4TH_GEN = ToyotaSecOCPlatformConfig(
[ToyotaCarDocs("Toyota Sienna 2021-23", min_enable_speed=MIN_ACC_SPEED)],
[
ToyotaCarDocs("Toyota Sienna 2021-23", min_enable_speed=MIN_ACC_SPEED, support_type=SupportType.COMMUNITY),
ToyotaSecurityCarDocs("Toyota Sienna 2024-25"),
],
CarSpecs(mass=4625. * CV.LB_TO_KG, wheelbase=3.06, steerRatio=17.8, tireStiffnessFactor=0.444),
)

Expand Down Expand Up @@ -377,6 +389,13 @@ class CAR(Platforms):
flags=ToyotaFlags.UNSUPPORTED_DSU,
)

# Non-upstream car docs
TOYOTA_SEQUOIA = ToyotaSecOCPlatformConfig(
[ToyotaSecurityCarDocs("Toyota Sequoia 2023-25")],
# TODO: set these values
CarSpecs(mass=4034. * CV.LB_TO_KG, wheelbase=2.84988, steerRatio=13.3, tireStiffnessFactor=0.444),
)


# (addr, cars, bus, 1/freq*100, vl)
STATIC_DSU_MSGS = [
Expand Down