mirror of
https://jihulab.com/mr-one/openpilot.git
synced 2026-10-26 20:43:49 +08:00
test: migrate BSM handling to brand flags
This commit is contained in:
@@ -70,7 +70,7 @@ class CarState(CarStateBase, CarStateExt):
|
||||
if self.CP.carFingerprint == CAR.HONDA_CIVIC_2022 and self.CP.flags & HondaFlags.BOSCH_RADARLESS:
|
||||
acc_hud_parser = self._select_hud_parser(cp, cp_cam, "ACC_HUD")
|
||||
lkas_hud_parser = self._select_hud_parser(cp, cp_cam, "LKAS_HUD")
|
||||
if self.CP.enableBsm:
|
||||
if self.CP.flags & HondaFlags.HAS_BSM:
|
||||
cp_body = can_parsers[Bus.body]
|
||||
|
||||
ret = structs.CarState()
|
||||
|
||||
@@ -87,10 +87,9 @@ class CarInterface(CarInterfaceBase):
|
||||
# TODO: Some TSS-P platforms have BSM, but are flipped based on region or driving direction.
|
||||
# Detect flipped signals and enable for C-HR and others
|
||||
from openpilot.common.params import Params
|
||||
if Params().get_bool("ToyotaAftermarketBsm"):
|
||||
ret.enableBsm = False # aftermarket BSM: disable factory BSM enablement
|
||||
else:
|
||||
ret.enableBsm = 0x3F6 in fingerprint[0] and bool(ret.flags & ToyotaFlags.TSS2)
|
||||
aftermarket_bsm = Params().get_bool("ToyotaAftermarketBsm")
|
||||
if not aftermarket_bsm and 0x3F6 in fingerprint[0] and ret.flags & ToyotaFlags.TSS2:
|
||||
ret.flags |= ToyotaFlags.HAS_BSM.value
|
||||
|
||||
# No radar dbc for cars without DSU which are not TSS 2.0
|
||||
# TODO: make an adas dbc file for dsu-less models
|
||||
|
||||
@@ -8,6 +8,7 @@ from opendbc.car.structs import car
|
||||
from enum import IntEnum
|
||||
|
||||
from openpilot.selfdrive.ui.ui_state import ui_state
|
||||
from opendbc.sunnypilot.car.interfaces import has_bsm
|
||||
from openpilot.system.ui.lib.multilang import tr, tr_noop
|
||||
from openpilot.system.ui.sunnypilot.widgets.list_view import toggle_item_sp, simple_button_item_sp, option_item_sp, LineSeparatorSP
|
||||
from openpilot.system.ui.widgets.scroller_tici import Scroller
|
||||
@@ -134,7 +135,7 @@ class SteeringLayout(Widget):
|
||||
|
||||
# inline lane-change toggles (flattened from Customize Lane Change submenu)
|
||||
lc = self._lane_change_settings_layout
|
||||
enable_bsm = ui_state.CP is not None and ui_state.CP.enableBsm
|
||||
enable_bsm = ui_state.CP is not None and has_bsm(ui_state.CP, ui_state.CP_SP)
|
||||
if not enable_bsm and ui_state.params.get_bool("AutoLaneChangeBsmDelay"):
|
||||
ui_state.params.remove("AutoLaneChangeBsmDelay")
|
||||
lc._bsm_delay.action_item.set_enabled(enable_bsm and ui_state.params.get("AutoLaneChangeTimer", return_default=True) > AutoLaneChangeMode.NUDGE)
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@ from collections.abc import Callable
|
||||
import pyray as rl
|
||||
|
||||
from openpilot.selfdrive.ui.ui_state import ui_state
|
||||
from opendbc.sunnypilot.car.interfaces import has_bsm
|
||||
from openpilot.system.ui.lib.multilang import tr
|
||||
from openpilot.system.ui.sunnypilot.widgets.list_view import toggle_item_sp, option_item_sp, LineSeparatorSP
|
||||
from openpilot.system.ui.widgets.network import NavButton
|
||||
@@ -82,7 +83,7 @@ class LaneChangeSettingsLayout(Widget):
|
||||
self._scroller.show_event()
|
||||
|
||||
def _update_toggles(self):
|
||||
enable_bsm = ui_state.CP is not None and ui_state.CP.enableBsm
|
||||
enable_bsm = ui_state.CP is not None and has_bsm(ui_state.CP, ui_state.CP_SP)
|
||||
if not enable_bsm and ui_state.params.get_bool("AutoLaneChangeBsmDelay"):
|
||||
ui_state.params.remove("AutoLaneChangeBsmDelay")
|
||||
self._bsm_delay.action_item.set_enabled(enable_bsm and ui_state.params.get("AutoLaneChangeTimer", return_default=True) > AutoLaneChangeMode.NUDGE)
|
||||
|
||||
@@ -11,6 +11,7 @@ from opendbc.car.structs import car
|
||||
from opendbc.car.hyundai.values import CAR as HYUNDAI_CAR, UNSUPPORTED_LONGITUDINAL_CAR
|
||||
from opendbc.car.subaru.values import CAR as SUBARU_CAR, SubaruFlags
|
||||
from opendbc.sunnypilot.car.tesla.values import TeslaFlagsSP
|
||||
from opendbc.sunnypilot.car.interfaces import has_bsm
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.common.swaglog import cloudlog
|
||||
from openpilot.common.hardware import HARDWARE
|
||||
@@ -142,6 +143,7 @@ def generate_capabilities(params: Params | None = None) -> dict:
|
||||
|
||||
# CarParams-derived capabilities
|
||||
CP = None
|
||||
CP_SP = None
|
||||
CP_bytes = params.get("CarParamsPersistent")
|
||||
if CP_bytes is not None:
|
||||
try:
|
||||
@@ -159,7 +161,6 @@ def generate_capabilities(params: Params | None = None) -> dict:
|
||||
if not caps["brand"] and CP.brand:
|
||||
caps["brand"] = str(CP.brand)
|
||||
caps["pcm_cruise"] = bool(CP.pcmCruise)
|
||||
caps["enable_bsm"] = bool(CP.enableBsm)
|
||||
# Generic SnG fallback. Brand-specific opaque flags below override.
|
||||
caps["has_stop_and_go"] = bool(CP.openpilotLongitudinalControl)
|
||||
except Exception:
|
||||
@@ -177,6 +178,7 @@ def generate_capabilities(params: Params | None = None) -> dict:
|
||||
except Exception:
|
||||
cloudlog.exception("capabilities: failed to deserialize CarParamsSPPersistent")
|
||||
|
||||
caps["enable_bsm"] = has_bsm(CP, CP_SP) if CP is not None else False
|
||||
_resolve_brand_capabilities(caps, bundle_platform, CP)
|
||||
|
||||
return caps
|
||||
|
||||
Reference in New Issue
Block a user